/* Dyson Nestbox styles. System fonts only (no font downloads). WCAG 2.1 AA colours.
   SPDX-License-Identifier: EUPL-1.2 */
:root {
  --cream: #FFF4DE; --cream-2: #F6E7C8; --paper: #FFFFFF; --wood: #7E4828; --wood-dark: #5C3219; --wood-light: #B8743F;
  --ink: #3B2414; --muted: #6E5644; --line: #E7D6B5; --comb: #C21F35; --beak: #F4A300; --straw: #E9BE4F;
  --ok: #2E7D32; --ok-bg: #E7F4E8; --warn-bg: #FFF1C9; --err: #B3261E; --err-bg: #FCE8E6; --focus: #1D5FD1;
  --radius: 14px; --shadow: 0 1px 2px rgba(59,36,20,.08), 0 2px 8px rgba(59,36,20,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, sans-serif;
  --dys: Verdana, Tahoma, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.5; background: var(--cream); color: var(--ink); }
a { color: var(--wood-dark); }
img, video { max-width: 100%; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: .2em 0 .5em; }
h2 { font-size: 1.25rem; margin: 0 0 .4em; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .88rem; } .center { text-align: center; } .pre { white-space: pre-wrap; }
.big-text { font-size: 1.25rem; } .grow { flex: 1; min-width: 0; } .danger-text { color: var(--err) !important; }
.boot { font-size: 1.4rem; text-align: center; margin-top: 30vh; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* Layout */
main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 60px; }
main:focus { outline: none; }
.stack { display: flex; flex-direction: column; gap: 14px; } .small-gap { gap: 6px; }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.narrow { max-width: 480px; margin: 0 auto; }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } h1 { font-size: 1.45rem; } }

/* Header */
header.top { background: var(--wood); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; position: sticky; top: 0; z-index: 20; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand img { background: var(--cream); border-radius: 9px; }
.school-name { opacity: .85; font-size: .9rem; }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.lang-select { background: var(--wood-dark); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 6px 8px; font-size: .9rem; }
.main-nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.nav-link { color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: .95rem; }
.nav-link:hover, .nav-link.on { background: rgba(255,255,255,.18); }
.menu-btn { display: none; color: #fff; }
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .main-nav { display: none; flex-direction: column; }
  .main-nav.open { display: flex; }
  .school-name { display: none; }
}
footer.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px; }
.demo-banner { background: var(--straw); color: var(--ink); padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; font-size: .95rem; }

/* Cards and lists */
.card { background: var(--paper); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); color: inherit; text-decoration: none; display: block; }
.card.stack, .card.row { display: flex; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; gap: 12px; align-items: center; background: var(--paper); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; border: 0; text-align: left; font: inherit; width: 100%; cursor: pointer; }
.list-item.unread { border-left: 5px solid var(--beak); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: rgba(255,255,255,.5); border-radius: var(--radius); }
.notice { background: var(--warn-bg); border-radius: 12px; padding: 12px 14px; display: block; }
.notice.error { background: var(--err-bg); color: var(--err); }
.link-notice { text-decoration: none; color: var(--ink); margin: 10px auto; max-width: 1040px; }
.loading { text-align: center; padding: 40px; color: var(--muted); }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--cream-2); color: var(--ink); white-space: nowrap; }
.tag.st-pending { background: var(--warn-bg); } .tag.st-approved { background: var(--ok-bg); color: var(--ok); } .tag.st-returned { background: var(--err-bg); color: var(--err); }
.badge { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 999px; background: var(--comb); color: #fff; font-size: .8rem; font-weight: 700; margin-left: 6px; }
.avatar { font-size: 1.5rem; line-height: 1; } .avatar.big { font-size: 2.4rem; }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; } .table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 2px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--wood); color: #fff; } .btn.primary:hover { background: var(--wood-dark); }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line); } .btn.ghost:hover { border-color: var(--wood-light); }
.btn.danger { background: var(--err); color: #fff; }
.btn.big { font-size: 1.1rem; padding: 14px 22px; min-height: 54px; }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: .9rem; }
.btn:disabled, .btn.busy { opacity: .6; cursor: progress; }
.icon-btn { background: none; border: 0; font-size: 1.2rem; cursor: pointer; padding: 6px 8px; border-radius: 8px; min-width: 40px; min-height: 40px; color: inherit; }
.icon-btn:disabled { opacity: .3; }
.linklike { background: none; border: 0; color: var(--wood-dark); text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); font: inherit; cursor: pointer; color: inherit; }
.chip.on { border-color: var(--wood); background: var(--cream-2); font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: .95rem; }
.hint { font-size: .85rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-height: 44px; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--wood); }
input:focus, select:focus, textarea:focus { border-color: var(--wood-light); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; }
.or { text-align: center; color: var(--muted); font-size: .9rem; }
.lang-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 18px; }
.scroll-box { max-height: 220px; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 4px; }
.tab { white-space: nowrap; padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--ink); background: rgba(255,255,255,.6); }
.tab.on { background: var(--wood); color: #fff; }

/* Landing */
.hero { display: flex; gap: 20px; align-items: center; margin: 10px 0; }
.hero-logo { flex-shrink: 0; }
.lead { font-size: 1.15rem; color: var(--muted); }
.pupil-card { background: linear-gradient(160deg, #fff 60%, var(--cream-2)); }
@media (max-width: 560px) { .hero { flex-direction: column; text-align: center; } .hero-logo { width: 90px; height: 90px; } }

/* Pupil mode: big, friendly, few words */
.pupil-top { background: var(--wood); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
.pupil-home { font-size: 2rem; text-decoration: none; background: var(--cream); border-radius: 14px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
.pupil-me { font-size: 1.25rem; font-weight: 700; flex: 1; }
.btn.finish { background: var(--straw); color: var(--ink); font-size: 1.05rem; }
.pupil-main { font-size: 1.1rem; }
.pupil-hello { font-size: 2rem; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.tile { position: relative; background: var(--paper); border-radius: 22px; box-shadow: var(--shadow); padding: 24px 12px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 160px; justify-content: center; border: 3px solid transparent; }
.tile:hover { border-color: var(--straw); }
.tile-main { grid-column: 1 / -1; background: var(--straw); min-height: 130px; flex-direction: row; gap: 18px; }
.tile-icon { font-size: 3.4rem; line-height: 1; } .tile-label { font-size: 1.35rem; font-weight: 700; }
.tile .badge { position: absolute; top: 12px; right: 12px; font-size: 1rem; min-width: 30px; height: 30px; }
.task-card { display: flex; gap: 14px; align-items: center; } .task-card.done { opacity: .75; } .task-icon { font-size: 2.2rem; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; }
.kind-btn { background: var(--paper); border: 3px solid var(--line); border-radius: 20px; padding: 22px 8px; font: inherit; font-size: 1.2rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; color: var(--ink); }
.kind-btn:hover { border-color: var(--wood-light); } .kind-icon { font-size: 3rem; }
.big-emoji { font-size: 4.5rem; }
.big-input { font-size: 1.4rem; padding: 14px; }
.big-select { font-size: 1.1rem; }
.celebrate { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(255,244,222,.92); z-index: 60; font-size: 1.5rem; font-weight: 700; text-align: center; padding: 20px; }
.egg { font-size: 6rem; animation: wobble .6s ease-in-out 3; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@media (prefers-reduced-motion: reduce) { .egg { animation: none; } * { scroll-behavior: auto !important; } }

/* Pupil sign-in */
.name-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.name-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--paper); border: 3px solid var(--line); border-radius: 18px; padding: 16px 8px; font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.name-btn .avatar { font-size: 2.6rem; } .name-btn:hover { border-color: var(--wood-light); }
.name-btn .badge { position: absolute; top: 8px; right: 8px; }
.pic-wrap, .pin-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pic-dots { display: flex; gap: 12px; } .pic-dot { width: 64px; height: 64px; border-radius: 16px; border: 3px dashed var(--wood-light); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; background: #fff; }
.pic-dot.on { border-style: solid; }
.pic-grid { display: grid; grid-template-columns: repeat(3, 96px); gap: 12px; }
.pic { width: 96px; height: 96px; font-size: 3.2rem; border-radius: 20px; border: 3px solid var(--line); background: #fff; cursor: pointer; }
.pic:active { transform: scale(.95); border-color: var(--wood); }
.pin-show { font-size: 2.2rem; letter-spacing: 10px; }
.pin-grid { display: grid; grid-template-columns: repeat(3, 84px); gap: 10px; }
.pin-key { height: 72px; font-size: 1.8rem; border-radius: 16px; border: 3px solid var(--line); background: #fff; cursor: pointer; }

/* Posts */
.post { display: flex; flex-direction: column; gap: 8px; }
.post.status-pending { border-left: 6px solid var(--beak); } .post.status-returned { border-left: 6px solid var(--err); }
.post-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .who { font-weight: 700; }
.post-body { white-space: pre-wrap; font-size: 1.05rem; }
.post-media { display: flex; flex-direction: column; gap: 8px; } .post-img { border-radius: 12px; max-height: 520px; object-fit: contain; background: #fafafa; }
.post-media audio, .feedback audio { width: 100%; }
.feedback { display: flex; gap: 10px; background: var(--cream); border-radius: 12px; padding: 10px 12px; } .sticker { font-size: 2rem; }
.task-label { color: var(--muted); }
.staff-actions { border-top: 1px solid var(--line); padding-top: 8px; }
.sticker-btn { font-size: 1.8rem; background: #fff; border: 2px solid var(--line); border-radius: 12px; width: 52px; height: 52px; cursor: pointer; }
.sticker-btn.on { border-color: var(--wood); background: var(--cream-2); }

/* Media capture */
.draw-wrap { display: flex; flex-direction: column; gap: 8px; }
.draw-canvas { width: 100%; aspect-ratio: 900 / 640; background: #fff; border-radius: 14px; border: 3px solid var(--line); touch-action: none; cursor: crosshair; }
.draw-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--wood); }
.size-btn { width: 40px; height: 40px; border-radius: 10px; border: 2px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.size-btn.on { border-color: var(--wood); } .size-btn .dot { background: var(--ink); border-radius: 50%; display: block; }
.sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.recorder { display: flex; flex-direction: column; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 16px; }
.rec-btn { width: 84px; height: 84px; border-radius: 50%; border: 4px solid var(--line); background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.rec-dot { width: 44px; height: 44px; border-radius: 50%; background: var(--comb); transition: border-radius .2s; }
.rec-btn.on .rec-dot { border-radius: 8px; width: 34px; height: 34px; }
.recorder audio { width: 100%; }
.progress { height: 12px; background: var(--cream-2); border-radius: 999px; overflow: hidden; } .progress-fill { height: 100%; width: 0; background: var(--wood); transition: width .2s; }

/* Video */
.video-wrap { position: relative; } .safe-video { width: 100%; border-radius: 14px; background: #000; display: block; }
.video-end { position: absolute; inset: 0; background: rgba(255,244,222,.96); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 16px; font-size: 1.15rem; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.video-card { display: flex; gap: 10px; align-items: center; }

/* Quiz */
.quiz-top { display: flex; justify-content: space-between; } .quiz-prompt { font-size: 1.4rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.choice { padding: 18px; font: inherit; font-size: 1.2rem; border-radius: 16px; border: 3px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.choice.on { border-color: var(--wood); background: var(--cream-2); font-weight: 700; }
.order-list { padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; }
.order-list li { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 1.15rem; }
.match-row { display: flex; align-items: center; gap: 8px; } .match-row select { flex: 1; }

/* Messages */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow: auto; padding: 6px; }
.bubble { background: #fff; border-radius: 14px 14px 14px 4px; padding: 10px 14px; max-width: 80%; box-shadow: var(--shadow); }
.bubble.mine { align-self: flex-end; background: var(--cream-2); border-radius: 14px 14px 4px 14px; }
.bubble p { white-space: pre-wrap; margin: 4px 0 0; }

/* Admin */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; } .stat strong { font-size: 1.8rem; }
.class-card { display: flex; flex-direction: column; gap: 4px; position: relative; } .class-icon { font-size: 2rem; }
.class-card .badge { position: absolute; top: 12px; right: 12px; }
.open-concern { border-left: 6px solid var(--comb); }

/* QR and sign-in cards */
.qr-box { background: #fff; padding: 8px; border-radius: 12px; display: inline-flex; }
.qr-box.big { padding: 14px; } .qr-box.small { padding: 4px; }
.class-qr { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; background: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.card-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.signin-card { background: #fff; border: 2px dashed var(--wood-light); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; break-inside: avoid; }
.pic-print { font-size: 2.2rem; margin-right: 6px; } .pin-print { font-size: 2rem; letter-spacing: 6px; font-weight: 700; }

/* Dialogs and toasts */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, 94vw); max-height: 90vh; box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--ink); }
dialog.modal.wide { width: min(900px, 96vw); }
dialog::backdrop { background: rgba(59,36,20,.45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 0; } .modal-head h2 { margin: 0; }
.modal-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(520px, 92vw); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: var(--err); }

/* Print: class QR poster and sign-in cards */
@media print {
  body { background: #fff; font-size: 12pt; }
  header, footer, .no-print, .demo-banner, .tabs, .link-notice, .skip { display: none !important; }
  main { max-width: none; padding: 0; }
  .class-qr { page-break-after: always; box-shadow: none; }
  .card-sheet { grid-template-columns: 1fr 1fr; }
  .signin-card { box-shadow: none; }
}
.page > * + * { margin-top: 14px; }
.card.stack > .btn:not(.big) { align-self: flex-start; }
body.dys { font-family: var(--dys); letter-spacing: .02em; word-spacing: .12em; line-height: 1.7; }
body.dys input, body.dys textarea, body.dys select, body.dys button { font-family: var(--dys); }
body.contrast { --ink: #000; --muted: #333; --line: #8a6a4a; --cream: #fff; }
