*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-body); line-height: 1.5; color: var(--text); background: var(--bg); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-2xl); line-height: 1.2; }
h2 { font-size: var(--fs-xl); line-height: 1.25; }
h3 { font-size: var(--fs-lg); line-height: 1.3; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 8px; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.meta { font-size: var(--fs-meta); color: var(--muted); }
.ic { flex: none; display: inline-block; vertical-align: middle; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.shell__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--sp-3); min-height: 60px; padding: max(10px, env(safe-area-inset-top)) var(--sp-4) 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title .meta { display: block; line-height: 1.2; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--tap); min-height: var(--tap); padding: 0 10px; border: 0; background: transparent; border-radius: var(--r-md); font-weight: 700; text-decoration: none; }
.icon-btn:active { background: var(--surface-2); }
.page { width: 100%; max-width: 640px; margin: 0 auto; padding: var(--sp-4) var(--sp-4) calc(var(--pad-bottom, 0px) + var(--sp-6)); display: flex; flex-direction: column; gap: var(--sp-4); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.tabbar__in { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 640px; margin: 0 auto; height: var(--tabbar-h); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 0.8125rem; font-weight: 700; min-height: 48px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .ic { stroke-width: 2.1; }

.actionbar { position: fixed; left: 0; right: 0; bottom: var(--nav-h, 0px); z-index: 25; background: var(--bg); border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-extra, 0px)); }
.actionbar__in { max-width: 640px; margin: 0 auto; display: flex; gap: var(--sp-3); align-items: stretch; flex-direction: column; }
.actionbar__in .row { gap: var(--sp-3); }
.actionbar .btn { flex: 1; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: var(--sp-3); }
.card--flat { box-shadow: none; }
.card--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-soft-ink); }
.card--accent .card__title { color: var(--accent-soft-ink); }
.card--ok { background: var(--ok-soft); color: var(--ok-ink); border-color: transparent; }
.card--warn { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.card__title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); font-weight: 800; }
.card__big { font-size: var(--fs-xl); font-weight: 800; line-height: 1.3; }
.badge-ic { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); flex: none; }
.kv { display: grid; grid-template-columns: 1fr; gap: 2px; }
.kv + .kv { margin-top: var(--sp-2); }
.kv dt { font-size: var(--fs-meta); color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; }
dl { margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 52px; padding: 0 var(--sp-5); border-radius: var(--r-md); border: 2px solid transparent; font-weight: 800; font-size: var(--fs-body); text-decoration: none; background: var(--accent); color: var(--accent-ink); transition: transform .08s ease, background .15s; }
.btn:active { transform: scale(.98); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--danger { background: var(--warn-soft); color: var(--warn-ink); }
.btn--block { width: 100%; }
.btn--sm { min-height: var(--tap); padding: 0 var(--sp-4); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn--done { background: var(--ok-soft); color: var(--ok-ink); opacity: 1 !important; }

/* ---------- chips, pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--fs-meta); font-weight: 800; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.pill--ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill--warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill--accent { background: var(--accent-soft); color: var(--accent-soft-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 14px; border-radius: var(--r-pill); border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: var(--fs-body); }
.chip[aria-pressed="true"], .chip[aria-checked="true"], .chip.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); }
.chip:disabled { opacity: .5; }

.gchip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); font-weight: 800; font-size: 0.9375rem; background: var(--surface-2); }
.gchip--t0, .gchip--t1 { background: var(--ok-soft); color: var(--ok-ink); }
.gchip--t2 { background: var(--surface-2); color: var(--text); }
.gchip--t3 { background: var(--accent-soft); color: var(--accent-soft-ink); }
.gchip--t4 { background: var(--warn-soft); color: var(--warn-ink); }
.gchip--none { background: transparent; border: 1px dashed var(--border); color: var(--muted); }

.gbtn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; padding: 6px 8px; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface); font-weight: 800; font-size: 0.9375rem; text-align: center; line-height: 1.15; }
.gbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); }
.gbtn[aria-pressed="true"]::after { content: ''; }
.ggrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--sp-2); }
.stars { display: inline-flex; gap: 1px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-weight: 800; }
.input, .select, .textarea { width: 100%; min-height: 52px; padding: 10px 14px; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface); }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.hint { font-size: var(--fs-meta); color: var(--muted); }
.error { display: flex; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn-ink); font-weight: 700; }
.src-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); font-weight: 800; padding: 3px 10px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-soft-ink); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); }
.segmented button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; font-weight: 800; color: var(--muted); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.datechips { display: flex; gap: var(--sp-2); overflow-x: auto; padding: 2px 0 6px; scroll-snap-type: x proximity; }
.datechips { scrollbar-width: none; }
.datechips::-webkit-scrollbar { display: none; }
.datechip { flex: 1 0 60px; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface); font-weight: 800; scroll-snap-align: start; padding: 4px; }
.datechip small { font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.datechip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-ink); }
.datechip[aria-pressed="true"] small { color: inherit; }
.datechip:disabled { opacity: .45; cursor: not-allowed; }

/* class cards */
.classcards { display: grid; gap: var(--sp-3); }
.classcard { display: flex; align-items: center; gap: var(--sp-3); text-align: left; width: 100%; padding: var(--sp-4); border-radius: var(--r-lg); border: 2px solid var(--border); background: var(--surface); }
.classcard[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.classcard h3 { color: var(--text); }
.classcard[aria-checked="true"] h3, .classcard[aria-checked="true"] .meta { color: var(--accent-soft-ink); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 800; flex: none; }

/* lists */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }
.item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); min-height: 60px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); text-decoration: none; text-align: left; width: 100%; }
a.item:active, button.item:active { background: var(--surface-2); }
.timeline { display: flex; flex-direction: column; gap: var(--sp-3); position: relative; }
.tl-row { display: grid; grid-template-columns: 64px 1fr; gap: var(--sp-3); text-decoration: none; }
.tl-date { text-align: center; padding-top: var(--sp-3); }
.tl-date b { display: block; font-size: var(--fs-xl); line-height: 1; }
.tl-date span { font-size: var(--fs-meta); color: var(--muted); font-weight: 700; }
.tl-card { padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); display: flex; flex-direction: column; gap: 6px; }
.tl-card p { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }

details.acc { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
details.acc > summary { list-style: none; display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-3) var(--sp-4); font-weight: 800; cursor: pointer; border-radius: var(--r-md); }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .chev { margin-left: auto; transition: transform .2s; }
details.acc[open] > summary .chev { transform: rotate(180deg); }
details.acc > .acc__body { padding: 0 var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
details[open] > summary .sum { display: none; }
.sum { display: block; font-weight: 600; color: var(--muted); font-size: var(--fs-meta); }

.progress { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.savebadge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); font-weight: 800; color: var(--ok-ink); }
.rowgrade { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-3); border-top: 1px dashed var(--border); }
.rowgrade:first-child { border-top: 0; padding-top: 0; }
.rowgrade > .lbl { font-weight: 700; }
.pager-slide { animation: slidein .22s ease; }

.empty { text-align: center; padding: var(--sp-8) var(--sp-4); display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.empty .badge-ic { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-soft-ink); }

/* day cards (preschool) */
.daycard { border-left: 6px solid var(--accent); }
.areas { display: grid; gap: var(--sp-2); }
.area { display: flex; gap: var(--sp-3); align-items: flex-start; }
.area .badge-ic { background: var(--accent-soft); color: var(--accent-soft-ink); width: 36px; height: 36px; }
.area b { display: block; font-size: var(--fs-meta); color: var(--muted); }

/* sheet / toast */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--sp-5) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--sp-4); animation: rise .24s ease; }
.sheet--left { align-self: stretch; margin-right: auto; max-width: 300px; border-radius: 0 var(--r-lg) var(--r-lg) 0; animation: slideleft .22s ease; }
.overlay--left { justify-content: flex-start; }
.sheet__grab { width: 44px; height: 5px; border-radius: 9px; background: var(--border); align-self: center; }
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h, 0px) + var(--act-h, 0px) + 16px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 var(--sp-4); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--r-md); font-weight: 700; box-shadow: var(--shadow); animation: rise .2s ease; max-width: 520px; }
.toast button { background: none; border: 0; color: inherit; font-weight: 800; text-decoration: underline; min-height: 44px; padding: 0 8px; }

/* skeleton */
.sk { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--r-md); }
.sk--card { height: 140px; border-radius: var(--r-lg); }
.sk--line { height: 18px; }

/* login */
.login { width: 100%; max-width: 440px; margin: 0 auto; padding: var(--sp-6) var(--sp-4) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-5); }
.logo { display: flex; align-items: center; gap: var(--sp-3); }
.logo .badge-ic { width: 52px; height: 52px; border-radius: 16px; }
.demo { border: 2px dashed var(--border); border-radius: var(--r-lg); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }

/* admin */
.admin-grid { display: grid; gap: var(--sp-3); }
.sidenav { display: none; }

@media (min-width: 768px) {
  .page { max-width: 760px; padding-top: var(--sp-6); }
  .classcards { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .shell--admin { display: grid; grid-template-columns: 264px 1fr; }
  .shell--admin .sidenav { display: flex; flex-direction: column; gap: var(--sp-1); position: sticky; top: 0; height: 100dvh; padding: var(--sp-5) var(--sp-3); border-right: 1px solid var(--border); background: var(--surface); }
  .shell--admin .menu-btn { display: none; }
  .shell--admin .page { max-width: 1040px; }
  .admin-grid { grid-template-columns: repeat(3, 1fr); }
  .page--wide { max-width: 1040px; }
}
.sidenav a, .drawer-link { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); padding: 0 var(--sp-3); border-radius: var(--r-md); text-decoration: none; font-weight: 700; }
.sidenav a[aria-current="page"], .drawer-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-soft-ink); }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideleft { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ================= Brand layer (WHZ Kids): flat, no decoration ================= */
.card--accent { background: var(--hl); color: var(--hl-ink); border-color: transparent; box-shadow: none; }
.card--accent .card__title { color: var(--hl-ink); }
.card--accent .badge-ic { background: var(--c-yellow); color: #3B2A00; }
.badge-ic { box-shadow: none; border-radius: 12px; }
.tone-blue { background: var(--c-blue) !important; color: #fff !important; }
.tone-red { background: var(--c-red) !important; color: #fff !important; }
.tone-yellow { background: var(--c-yellow) !important; color: #3B2A00 !important; }
.tone-green { background: var(--c-green) !important; color: #14290A !important; }
.area:nth-child(4n+1) .badge-ic { background: var(--c-blue); color: #fff; }
.area:nth-child(4n+2) .badge-ic { background: var(--c-red); color: #fff; }
.area:nth-child(4n+3) .badge-ic { background: var(--c-green); color: #14290A; }
.area:nth-child(4n+4) .badge-ic { background: var(--c-yellow); color: #3B2A00; }
.avatar { background: var(--accent-soft); color: var(--accent-soft-ink); }
.btn { box-shadow: none; }
.logo-img { display: block; width: 100%; max-width: 260px; height: auto; background: #fff; border-radius: 12px; padding: 6px 10px; }
.brandmark { flex: none; display: inline-block; width: 71px; height: 36px; border-radius: 6px; background: #fff url('../logo.png') -24.6px -2.9px / 125px auto no-repeat; }
.login-brand { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill--warn .dot { animation: none; }

.topbar__title .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .icon-btn { padding: 0 6px; }
.savebadge { flex: none; }

/* grade buttons: five equal columns, smaller type so all five labels fit */
.ggrid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gbtn { font-size: 0.75rem; padding: 6px 2px; min-height: 56px; gap: 4px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.gbtn .ic { width: 14px; height: 14px; }
.gbtn .stars { gap: 0; }
.ggrid { gap: 4px; }
.gbtn { font-size: 0.6875rem; padding: 6px 1px; overflow-wrap: normal; word-break: keep-all; }
@media (min-width: 400px) { .gbtn { font-size: 0.75rem; } }

.profile-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1.5px solid #1B2433; border-radius: 50%; color: #1B2433; text-decoration: none; background: transparent; flex: none; }
.profile-btn:active { background: var(--surface-2); }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); padding: 0; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__x { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(27, 36, 51, .8); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
