/* Mobile first. Colors keep >= 4.5:1 text contrast on their backgrounds. */
:root {
  --fg: #172033;
  --muted: #4a5568;
  --bg: #f5f6fa;
  --line: #d5d9e2;
  --input: #6b7280;
  --pri: #2b4acb;
  --danger: #b42318;
  --ok: #0f6b47;
  --ok-bg: #e3f6ec;
  --wait: #7a4100;
  --wait-bg: #fff1d6;
  --night: #101828;
  --focus: #2b4acb;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; }
input, select, button, textarea { font: inherit; } /* 16px inputs: no iOS zoom on focus */
h1 { font-size: 1.375rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.125rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0; }
p { margin: .25rem 0; }
a { color: var(--pri); }
:focus-visible, .file:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .hint { color: var(--muted); }
.hint, .err, .errors { overflow-wrap: anywhere; }
.hint { font-size: .875rem; }

/* header */
.top { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; max-width: 60rem; margin: 0 auto; }
.brand { font-weight: 700; }
.site { flex: 1; color: var(--muted); }
nav { display: flex; gap: .25rem; overflow-x: auto; padding: 0 .5rem; max-width: 60rem; margin: 0 auto; }
nav a { flex: none; padding: .625rem .75rem; color: var(--fg); text-decoration: none; border-bottom: 3px solid transparent; }
nav a[aria-current="page"] { color: var(--pri); border-bottom-color: var(--pri); font-weight: 700; }

main { max-width: 60rem; margin: 0 auto; padding: 1rem 1rem 6rem; }
.center { max-width: 26rem; margin: 15vh auto 0; text-align: center; background: #fff; padding: 2rem 1.5rem; border-radius: .75rem; }
.center > .btn { margin-top: 1rem; }
.back { margin: -.5rem 0 .75rem; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  min-height: 44px; padding: .5rem 1rem; border: 1px solid var(--input); border-radius: .5rem;
  background: #fff; color: var(--fg); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 36px; padding: .25rem .75rem; }
.btn:disabled { opacity: .55; cursor: default; }
.actions, .row, .toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar { margin-bottom: .75rem; justify-content: space-between; }
.row.end { align-items: flex-end; }
.row.end .field { margin-bottom: 0; }

/* lists */
.list { list-style: none; margin: 0 0 1rem; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: .75rem; }
.list > li { border-top: 1px solid var(--line); padding: .75rem 1rem; }
.list > li:first-child { border-top: none; }
.list > li:has(> .row-link) { padding: 0; }
.list > li.row { justify-content: space-between; }
.row-link { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: .875rem 1rem; color: var(--fg); text-decoration: none; }
.row-link:hover { background: #eff6ff; }
.group h2 { margin-top: 1rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; margin: 1rem 0; }
.panel .list { border: none; }

/* person cards */
.cards { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.card { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; display: grid; grid-template-columns: 4.5rem 1fr; gap: .5rem .75rem; margin-bottom: 1rem; }
.cards .card { margin: 0; }
.card .info { min-width: 0; }
.card .actions { grid-column: 1 / -1; }
.card .actions .btn { flex: 1 1 auto; }
.thumb { width: 4.5rem; height: 4.5rem; border-radius: .5rem; object-fit: cover; background: #e5e7eb; }
.thumb.none { display: grid; place-items: center; text-align: center; font-size: .8125rem; color: #374151; }
.badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; }
.badge { font-size: .8125rem; padding: .0625rem .5rem; border-radius: 999px; background: #e5e7eb; color: #1f2937; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #14532d; }
.badge.no { background: #fee2e2; color: #7f1d1d; }
.badge.wait { background: #fef3c7; color: #78350f; }
.badge.info { background: #dbeafe; color: #1e3a8a; }

/* forms */
.form { background: #fff; border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; margin-bottom: 1rem; }
.panel .form, details .form { border: none; padding: 0; }
.field { margin: 0 0 1rem; }
fieldset.field { border: none; padding: 0; }
.field > label:not(.check), legend { display: block; font-weight: 600; margin-bottom: .25rem; padding: 0; }
input[type="text"], input[type="date"], input[type="time"], input[type="datetime-local"], select {
  width: 100%; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--input); border-radius: .5rem; background: #fff; color: var(--fg);
}
input[type="file"]:not(.sr-only) { max-width: 100%; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; font-weight: 400; }
.check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--pri); flex: none; }
.err { color: var(--danger); font-size: .9375rem; }
.err:empty { display: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.preview { display: block; max-width: 100%; max-height: 45vh; margin-top: .75rem; border-radius: .5rem; }
progress { width: 100%; height: .75rem; margin-top: .5rem; }
details { margin-top: 1rem; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--pri); }
details[open] summary { margin-bottom: .75rem; }
.result { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .75rem; }
.errors { color: var(--danger); padding-left: 1.25rem; }

/* dialog */
dialog { width: min(32rem, calc(100% - 2rem)); max-height: calc(100% - 2rem); border: none; border-radius: .75rem; padding: 1rem; color: var(--fg); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog .actions { margin-top: 1rem; justify-content: flex-end; }

/* check-ins */
.daystate { margin-bottom: .75rem; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: .75rem; margin-top: 1rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .875rem; color: var(--muted); }
.face { width: 3rem; height: 3rem; object-fit: cover; border-radius: .375rem; display: block; }

/* toasts: fixed at the top, seen at any scroll position and never covering the sticky primary button */
.toast {
  position: fixed; left: 1rem; right: 1rem; top: .75rem; z-index: 10; max-width: 34rem; margin: 0 auto;
  padding: .75rem 1rem; border-radius: .5rem; background: #111827; color: #fff;
  display: flex; gap: .75rem; align-items: center; justify-content: space-between;
}
.toast.error { background: #7f1d1d; }
.toast:empty { display: none; }

/* ---------- teacher flows: start screen, class screen, shooting, bulk upload, new child ---------- */
.empty { color: var(--muted); padding: .75rem 0; }
.ok { color: var(--ok); font-weight: 600; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.0625rem; font-weight: 700; border-radius: .875rem; }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.light { background: #fff; color: var(--night); border-color: #fff; }
.btn.ghost-light { background: transparent; color: #fff; border-color: rgb(255 255 255 / .6); }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .5rem; border: 0; background: none; color: var(--pri); text-decoration: underline; font: inherit; cursor: pointer; }
.link.light { color: #dbe2f0; }
.link:focus-within { outline: 3px solid var(--focus); }
.sticky { position: sticky; bottom: 0; z-index: 1; padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom)); background: var(--bg); }
.form .sticky { background: #fff; }
.photo-bar { display: grid; gap: .5rem; }
/* Fields that get focus or are scrolled into view stay clear of the sticky bar (bar height + air). */
html:has(.sticky) { scroll-padding-bottom: 6rem; }
html:has(.photo-bar) { scroll-padding-bottom: 10rem; }
.all-done { display: grid; place-items: center; min-height: 56px; margin: 0; padding: .5rem; border-radius: .875rem; background: var(--ok-bg); color: var(--ok); font-weight: 700; text-align: center; }
.more-actions { display: grid; gap: .5rem; margin-bottom: 1rem; }

.class-list { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: .625rem; }
.class-card { display: grid; grid-template-columns: 1fr auto; gap: .125rem .75rem; padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: .875rem; color: var(--fg); text-decoration: none; }
.class-card:hover { border-color: var(--pri); }
.class-name { font-size: 1.125rem; font-weight: 700; }
.class-time { grid-row: 2; color: var(--muted); }
.class-photos { grid-row: 1 / 3; grid-column: 2; align-self: center; font-weight: 700; color: var(--wait); font-variant-numeric: tabular-nums; }
.class-photos.done { color: var(--ok); }
.meter { grid-column: 1 / -1; height: 6px; margin-top: .5rem; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--pri); }

.search { width: 100%; min-height: 48px; margin-bottom: .75rem; padding: .5rem .875rem; border: 1px solid var(--input); border-radius: .75rem; background: #fff; }
.kids { list-style: none; margin: 0 0 1rem; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: .875rem; }
.kids li + li { border-top: 1px solid var(--line); }
.kid { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 64px; padding: .5rem 1rem; border: 0; background: none; color: var(--fg); text-align: left; cursor: pointer; }
.kid-name { flex: 1; font-size: 1.0625rem; font-weight: 600; }
.kid-status { font-size: .875rem; color: var(--muted); }
.kid-status.warn { color: var(--wait); font-weight: 600; }
.avatar { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #e6e9f2; color: #3b4660; font-weight: 700; }
.dropzone { display: none; }

dialog.sheet { width: 100%; max-width: 30rem; margin: auto auto 0; padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom)); border-radius: 1.25rem 1.25rem 0 0; text-align: center; }
.sheet-photo { display: grid; place-items: center; width: min(70vw, 16rem); aspect-ratio: 1; margin: 0 auto .75rem; border-radius: 1rem; object-fit: cover; background: #e6e9f2; color: #3b4660; font-size: 4rem; font-weight: 800; }
.stack { display: grid; gap: .5rem; margin-top: 1rem; }

/* Continuous shooting: a dark, camera-like screen where the child's name is the one big thing. */
dialog.shoot { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border-radius: 0; background: var(--night); color: #fff; }
dialog.shoot[open] { display: flex; flex-direction: column; }
.shoot :focus-visible, .shoot .link:focus-within { outline-color: #8fb1ff; }
body:has(dialog[open]) { overflow: hidden; }
.shoot-top { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; }
.shoot-bar { flex: 1; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .2); overflow: hidden; }
.shoot-bar span { display: block; width: 0; height: 100%; background: #fff; transition: width .3s; }
.shoot-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .375rem; padding: 1rem 1.25rem; overflow-y: auto; text-align: center; }
.shoot-count { color: #c3cad8; font-variant-numeric: tabular-nums; }
.shoot-face { display: grid; place-items: center; width: 6.5rem; height: 6.5rem; border-radius: 50%; object-fit: cover; background: #24304a; font-size: 2.75rem; font-weight: 800; }
.shoot-name { margin: .5rem 0 0; font-size: clamp(2.25rem, 12vw, 3.75rem); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.shoot-name.small { font-size: 1.5rem; }
.shoot-meta { color: #c3cad8; font-size: 1.0625rem; }
.shutter { display: grid; place-items: center; width: 88px; height: 88px; margin-top: 1.75rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 5px var(--night), 0 0 0 9px #fff; cursor: pointer; }
.shutter:focus-within { outline: 3px solid #8fb1ff; outline-offset: 12px; }
.shutter-label { color: var(--night); font-size: 1.0625rem; font-weight: 800; }
.shoot-links { display: flex; gap: 1.5rem; margin-top: 1rem; }
.shoot-preview { max-width: 100%; max-height: 52vh; border-radius: 1rem; }
.shoot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; width: 100%; max-width: 26rem; margin-top: 1rem; }
.shoot-body > .btn.big { max-width: 26rem; margin-top: 1rem; }
.shoot-failed { width: 100%; max-width: 26rem; margin: .5rem 0 0; padding: 0; list-style: none; text-align: left; }
.shoot-failed li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .625rem 0; border-top: 1px solid rgb(255 255 255 / .15); }
.shoot-failed small { display: block; color: #fecaca; }
.tally { min-height: 2.75rem; margin: 0; padding: .5rem 1rem calc(.75rem + env(safe-area-inset-bottom)); color: #c3cad8; text-align: center; }

dialog.bulk { width: 100%; height: 100%; max-width: 48rem; max-height: none; margin: 0 auto; padding: 0 1rem; border-radius: 0; background: var(--bg); }
.bulk-top { display: flex; align-items: center; justify-content: space-between; padding-top: .75rem; }
.bulk-top h2 { margin: 0; }
.bulk-head { margin-bottom: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.bulk-list { display: grid; gap: .625rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.bulk-card { display: grid; grid-template-columns: 4.5rem 1fr; gap: .75rem; padding: .75rem; background: #fff; border: 1px solid var(--line); border-radius: .875rem; }
.bulk-thumb { width: 4.5rem; height: 4.5rem; border-radius: .625rem; object-fit: cover; }
.bulk-info { min-width: 0; }
.bulk-file { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.bulk-kid { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: 1.0625rem; }
.bulk-who { color: var(--wait); font-weight: 700; }
.tag { padding: .0625rem .5rem; border-radius: 999px; background: var(--wait-bg); color: var(--wait); font-size: .8125rem; }
.chips { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .375rem; }
.chip { min-height: 44px; padding: .25rem .875rem; border: 1px solid var(--input); border-radius: 999px; background: #fff; color: var(--fg); cursor: pointer; }
.chip:disabled { opacity: .45; text-decoration: line-through; cursor: default; }
.chip-search { width: 100%; min-height: 44px; margin-top: .5rem; padding: .375rem .75rem; border: 1px solid var(--input); border-radius: .5rem; }

.snap { display: grid; place-items: center; width: min(100%, 15rem); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border: 2px dashed var(--pri); border-radius: 1.25rem; background: #eef1fc; color: var(--pri); text-align: center; cursor: pointer; }
.snap:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.snap-view { display: grid; place-content: center; gap: .25rem; width: 100%; height: 100%; }
.snap-view strong { font-size: 1.25rem; }
.snap-view small { padding: 0 1rem; color: var(--muted); }
.snap-view img { width: 100%; height: 100%; object-fit: cover; }
.alt-pick { margin: .25rem 0 1rem; text-align: center; }
.seg .row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.seg .check, .chipset .check { position: relative; justify-content: center; min-height: 52px; border: 1px solid var(--input); border-radius: .75rem; background: #fff; font-weight: 600; cursor: pointer; }
.seg .check input, .chipset .check input { position: absolute; opacity: 0; }
.seg .check:has(input:checked), .chipset .check:has(input:checked) { background: var(--pri); border-color: var(--pri); color: #fff; }
.seg .check:has(input:focus-visible), .chipset .check:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
fieldset.chipset { display: flex; flex-wrap: wrap; gap: .5rem; }
.chipset legend { width: 100%; }
.chipset .check { min-height: 44px; padding: 0 1rem; border-radius: 999px; font-weight: 500; }
.consent { align-items: flex-start; padding: .5rem 0; }
.consent input { margin-top: .2rem; }
.consent strong, .consent small { display: block; }
.consent small { color: var(--muted); font-size: .9375rem; }
.more { margin-top: .25rem; }
.more summary { color: var(--muted); font-weight: 500; }
.dup:not(:empty) { margin-bottom: .75rem; padding: .875rem; border-radius: .75rem; background: var(--wait-bg); color: var(--wait); }
.dup .row { margin-top: .5rem; }
.registered { margin-bottom: 1rem; text-align: center; }

@media (prefers-reduced-motion: reduce) { .shoot-bar span { transition: none; } }
@media (pointer: fine) and (min-width: 40rem) {
  .dropzone { display: block; padding: 1.25rem; border: 2px dashed var(--input); border-radius: .875rem; color: var(--muted); text-align: center; }
  .dropzone.over { border-color: var(--pri); background: #eef1fc; }
}
@media (min-width: 40rem) {
  h1 { font-size: 1.625rem; }
  .card .actions .btn { flex: none; }
}
