/* SF10 Maker — Tekhx palette: off-white paper (#f5f0e8), ink cyan (#007583),
   pastel cyan (#a2e2e2); dark is the deep teal night (#0d1a20).
   One page, no page scroll: the shell is exactly the viewport and only the
   learner list scrolls inside its own panel. */

@font-face {
  font-family: "Josefin Sans";
  src: url("../assets/fonts/JosefinSans-Variable.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "Sora";
  src: url("../assets/fonts/Sora-Variable.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --paper: #f5f0e8;
  --canvas: #ebe4d7;
  --card: #fbf8f3;
  --card-2: #f1ebe0;
  --ink: #18303a;
  --ink-2: #3c5862;
  --ink-3: #6b7f86;
  --line: #ddd4c4;
  --line-strong: #c9bea9;
  --primary: #007583;
  --primary-hover: #00606c;
  --on-primary: #f8f5ef;
  --pastel: #a2e2e2;
  --pastel-ink: #0c4a53;
  --teal-deep: #32606c;
  --danger: #b4412f;
  --danger-face: #f6e3dc;
  --on-danger: #fff7f3;
  --warn-face: #f7ebcf;
  --warn-ink: #7a5410;
  --heart: #e0245e;
  --shadow: 0 1px 2px rgba(24, 48, 58, 0.06), 0 10px 30px rgba(24, 48, 58, 0.08);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --control-h: 44px;
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #0d1a20;
  --canvas: #0a1519;
  --card: #15262d;
  --card-2: #1b2f37;
  --ink: #f1ece3;
  --ink-2: #c3d0d2;
  --ink-3: #8ea2a7;
  --line: rgba(134, 216, 218, 0.14);
  --line-strong: rgba(134, 216, 218, 0.26);
  --primary: #86d8da;
  --primary-hover: #a6e5e6;
  --on-primary: #0d1a20;
  --pastel: #2b5a63;
  --pastel-ink: #c9f1f1;
  --teal-deep: #86d8da;
  --danger: #f08a74;
  --danger-face: rgba(240, 138, 116, 0.12);
  --on-danger: #2a120c;
  --warn-face: rgba(232, 184, 92, 0.12);
  --warn-ink: #f0cd85;
  --heart: #ff4d7d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font: 400 16px/1.45 "Josefin Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---- Shell ---------------------------------------------------------------- */
.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0 clamp(16px, 3vw, 40px);
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--pastel) 45%, transparent), transparent 70%),
    var(--paper);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand-name { font: 700 21px/1 "Sora", sans-serif; letter-spacing: -0.02em; }
.brand-tag {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px 2px;
  border-radius: 999px;
  background: var(--pastel);
  color: var(--pastel-ink);
}
.top-right { display: flex; align-items: center; gap: 10px; }
.safe-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}
.safe-pill svg { width: 17px; height: 17px; color: var(--primary); margin-top: -2px; }
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  color: var(--ink-2);
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 19px; height: 19px; }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }

.main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(20px, 3.2vw, 48px);
  align-items: stretch;
  padding: clamp(4px, 2vh, 24px) 0 clamp(8px, 2vh, 20px);
}

/* ---- Intro + upload --------------------------------------------------------- */
.intro {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.eyebrow {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}
h1 {
  margin: 0;
  font: 700 clamp(30px, 3.6vw, 50px)/1.05 "Sora", sans-serif;
  letter-spacing: -0.035em;
}
h1 span { color: var(--primary); }
.lede {
  margin: 14px 0 0;
  max-width: 34em;
  font-size: clamp(16px, 1.25vw, 18.5px);
  color: var(--ink-2);
}
.steps {
  list-style: none;
  padding: 0;
  margin: clamp(14px, 2.6vh, 26px) 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.steps li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 14.5px;
  line-height: 1.3;
  color: var(--ink-2);
}
.steps b {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding-top: 3px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font: 700 13px/1 "Sora", sans-serif;
}
.steps span { padding-top: 4px; }

.drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: clamp(16px, 3vh, 28px) 22px;
  border-radius: var(--r-lg);
  border: 2px dashed var(--line-strong);
  background: var(--card);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, background-color 0.15s;
}
.drop:hover, .drop.is-over { border-color: var(--primary); }
.drop.is-over { transform: scale(1.01); background: var(--card-2); }
.drop:focus-within { border-color: var(--primary); border-style: solid; }
.drop input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.drop-art svg { width: 56px; height: 56px; display: block; }
.drop-text { display: grid; gap: 3px; }
.drop-text strong { font: 700 clamp(18px, 1.5vw, 21px)/1.2 "Sora", sans-serif; letter-spacing: -0.015em; }
.drop-text span { color: var(--ink-3); font-size: 15px; }
.drop-text u { color: var(--primary); text-underline-offset: 3px; }
.drop-help {
  margin: 12px 2px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 15px;
  color: var(--ink-3);
}
.drop-help a, .link {
  color: var(--primary);
  font-weight: 600;
  text-underline-offset: 3px;
}
.link {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline;
}

/* ---- Stage (right panel) ---------------------------------------------------- */
.stage {
  position: relative;
  min-height: 0;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
}
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0; /* a flex item otherwise grows to its longest line (a long school name) */
  padding: clamp(18px, 2.6vw, 30px);
  animation: rise 0.28s ease-out both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* idle: SF1 → SF10 */
.view-idle { justify-content: center; gap: clamp(16px, 3vh, 30px); }
.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 4%;
}
.sheet {
  border-radius: var(--r-md);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 12px;
  aspect-ratio: 0.8;
  max-height: 26vh;
  margin-inline: auto;
  width: 100%;
}
.sheet-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; }
.sheet-head span { font: 800 15px/1 "Sora", sans-serif; color: var(--primary); }
.sheet-head small { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.sheet-rows { display: grid; gap: 6px; }
.sheet-rows i {
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--teal-deep) 0 24%, transparent 24% 28%, var(--pastel) 28% 78%, transparent 78% 82%, var(--line-strong) 82%);
  opacity: 0.75;
}
.sheet-rows i:nth-child(odd) { opacity: 0.5; }
/* One learner row at a time lights up and is "copied" across: the register is read row by row. */
.sheet-rows i { animation: read-row 6.4s ease-in-out infinite; }
.sheet-rows i:nth-child(2) { animation-delay: 0.8s; }
.sheet-rows i:nth-child(3) { animation-delay: 1.6s; }
.sheet-rows i:nth-child(4) { animation-delay: 2.4s; }
.sheet-rows i:nth-child(5) { animation-delay: 3.2s; }
.sheet-rows i:nth-child(6) { animation-delay: 4s; }
.sheet-rows i:nth-child(7) { animation-delay: 4.8s; }
.sheet-rows i:nth-child(8) { animation-delay: 5.6s; }
@keyframes read-row {
  0%, 16%, 100% { box-shadow: none; transform: none; }
  6% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); transform: translateX(4px); opacity: 1; }
}
.flow-arrow path:first-child { animation: march 0.8s linear infinite; }
@keyframes march { to { stroke-dashoffset: -8; } }
.sf10-lines i { transform-origin: left; animation: write 3.2s ease-out infinite; }
.sf10-lines i:nth-child(2) { animation-delay: 0.25s; }
.sf10-box i:nth-child(1) { animation-delay: 0.5s; }
.sf10-box i:nth-child(2) { animation-delay: 0.75s; }
.sf10-box i:nth-child(3) { animation-delay: 1s; }
@keyframes write { 0% { transform: scaleX(0); } 30%, 88% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0.85; } }
.flow-arrow { color: var(--primary); width: 64px; }
.flow-arrow svg { width: 100%; display: block; }
.sheet-stack { position: relative; display: grid; }
.sheet-stack .sheet { grid-area: 1 / 1; }
/* The tilted copies are transformed, so they paint as layers; the front sheet must be a layer above them. */
.sheet-stack > .sheet:last-child { position: relative; z-index: 2; }
.sheet-sf10 { background: var(--card); box-shadow: var(--shadow); }
.sheet-stack .back1 { transform: translate(8px, -8px) rotate(3deg); opacity: 0.8; }
.sheet-stack .back2 { transform: translate(15px, -15px) rotate(6deg); opacity: 0.55; }
.sf10-lines { display: grid; gap: 7px; }
.sf10-lines i { display: block; height: 7px; border-radius: 4px; background: var(--primary); opacity: 0.85; }
.sf10-box { margin-top: 6px; padding: 8px; border: 1.5px solid var(--line-strong); border-radius: 6px; display: grid; gap: 6px; }
.sf10-box i { background: var(--pastel); opacity: 1; }
.w80 { width: 80%; } .w70 { width: 70%; } .w60 { width: 60%; } .w50 { width: 50%; } .w40 { width: 40%; }

.fills h2 { margin: 0 0 12px; font: 700 18px/1.2 "Sora", sans-serif; letter-spacing: -0.015em; }
.fill-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fill-cols > div { padding: 14px 16px; border-radius: var(--r-md); background: var(--card-2); }
.fills h3 { margin: 0 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--primary); }
.fills ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 15px; color: var(--ink-2); }
.fills li::before { content: "✓"; color: var(--primary); font-weight: 700; margin-right: 8px; }
.fills-note { margin: 12px 0 0; font-size: 14.5px; color: var(--ink-3); }

/* busy */
.view-busy { align-items: center; justify-content: center; gap: 14px; color: var(--ink-2); font-weight: 600; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--pastel);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* error */
.view-error { gap: 16px; overflow: auto; }
.err-head { display: flex; gap: 14px; align-items: flex-start; }
.err-icon { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--danger-face); color: var(--danger); }
.err-icon svg { width: 26px; height: 26px; }
.err-head h2 { margin: 2px 0 4px; font: 700 clamp(19px, 1.6vw, 23px)/1.2 "Sora", sans-serif; letter-spacing: -0.02em; }
.err-file { margin: 0; color: var(--ink-3); font-size: 15px; word-break: break-all; }
.err-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.err-list li {
  padding: 12px 14px 10px;
  border-radius: var(--r-md);
  background: var(--danger-face);
  border-left: 4px solid var(--danger);
}
.err-list b { display: block; color: var(--ink); }
.err-list span { color: var(--ink-2); font-size: 15px; }
.err-fix { padding: 16px; border-radius: var(--r-md); background: var(--card-2); display: grid; gap: 12px; justify-items: start; }
.err-fix p { margin: 0; color: var(--ink-2); }
.view-error > .btn-ghost { align-self: flex-start; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-h);
  padding: 2px 18px 0;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 15.5px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 19px; height: 19px; margin-top: -2px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--card); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { height: 50px; padding: 2px 22px 0; font-size: 16.5px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* result */
.view-ok { gap: 12px; }
.class-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
}
.class-main { min-width: 0; }
.class-school { margin: 0; font-size: 14.5px; opacity: 0.85; font-weight: 600; }
.class-school, .class-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-card h2 { margin: 3px 0; font: 700 clamp(19px, 1.7vw, 24px)/1.15 "Sora", sans-serif; letter-spacing: -0.02em; }
.class-meta { margin: 0; font-size: 14px; opacity: 0.85; }
.class-counts { display: flex; gap: 6px; align-self: center; }
.class-counts div {
  min-width: 62px;
  padding: 8px 8px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--on-primary) 14%, transparent);
  text-align: center;
}
.class-counts b { display: block; font: 700 22px/1 "Sora", sans-serif; }
.class-counts span { font-size: 12.5px; opacity: 0.85; }
.placed { margin: 0; font-size: 15px; color: var(--ink-2); }
.placed b { color: var(--ink); }
.warns { border-radius: var(--r-md); background: var(--warn-face); color: var(--warn-ink); font-size: 14.5px; }
.warns summary { cursor: pointer; padding: 10px 14px 8px; font-weight: 700; }
.warns ul { margin: 0; padding: 0 14px 10px 32px; max-height: 18vh; overflow: auto; }

.list-head, .learners li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 92px 40px;
  gap: 10px;
  align-items: center;
}
.list-head {
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.learners {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.learners li { padding: 7px 8px 6px 12px; border-bottom: 1px solid var(--line); font-size: 15px; }
.learners li:last-child { border-bottom: 0; }
.learners .sex-head {
  display: block;
  padding: 8px 12px 6px;
  background: var(--card-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  position: sticky;
  top: 0;
  z-index: 1;
}
.l-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.l-name small { font-weight: 400; color: var(--ink-3); }
.l-flag { display: inline-block; margin-left: 6px; padding: 2px 6px 0; border-radius: 6px; background: var(--warn-face); color: var(--warn-ink); font-size: 12px; font-weight: 700; vertical-align: 1px; }
.l-lrn, .l-bd { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14.5px; }
.l-dl {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: none;
  color: var(--primary);
  cursor: pointer;
}
.l-dl:hover { background: var(--card-2); border-color: var(--line); }
.l-dl svg { width: 19px; height: 19px; }
.ok-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ok-actions .short { display: none; }

/* ---- Footer ----------------------------------------------------------------- */
.foot > span:first-child { white-space: nowrap; }
.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
  font-size: 14.5px;
  color: var(--ink-3);
}
.foot a { color: var(--ink); font-weight: 700; text-decoration: none; }
.foot a:hover { color: var(--primary); }
.heart { color: var(--heart); display: inline-block; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(1.22); } }
.foot-links { display: flex; gap: 16px; }
.foot-links .link { color: var(--ink-3); font-weight: 600; }
.foot-links .link:hover { color: var(--primary); }

/* ---- Dialogs ------------------------------------------------------------------ */
.sheet-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 26px 26px 22px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.sheet-dialog::backdrop { background: rgba(10, 21, 25, 0.45); }
.sheet-dialog h2 { margin: 0 0 10px; font: 700 22px/1.2 "Sora", sans-serif; }
.sheet-dialog p { margin: 0 0 10px; color: var(--ink-2); }
.sheet-dialog form { margin-top: 16px; display: flex; justify-content: flex-end; }

/* ---- Smaller screens: still one screen, the list scrolls inside ----------------- */
@media (max-height: 760px) and (min-width: 901px) {
  .steps { display: none; }
  .lede { margin-bottom: 18px; }
  .sheet { max-height: 20vh; }
}
@media (max-width: 900px) {
  .shell { padding: 0 14px; }
  .top { padding: 10px 0; }
  .safe-pill span { display: none; }
  .safe-pill { padding: 8px; }
  .brand-tag { display: none; }
  .main { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 12px; padding: 0 0 8px; }
  .eyebrow, .steps { display: none; }
  h1 { font-size: clamp(25px, 6.4vw, 34px); }
  h1 br { display: none; }
  .lede { margin: 6px 0 12px; font-size: 15px; }
  .drop { padding: 14px 16px; gap: 14px; }
  .drop-art svg { width: 42px; height: 42px; }
  .drop-help { margin-top: 8px; font-size: 14px; }
  .view { padding: 16px; }
  .flow { display: none; }
  .view-idle { justify-content: flex-start; }
  .fill-cols { grid-template-columns: 1fr; gap: 8px; }
  .fill-cols > div { padding: 10px 12px; }
  .fills ul { font-size: 14px; }
  .class-card { flex-direction: column; gap: 10px; padding: 12px 14px; }
  .class-counts { align-self: stretch; }
  .class-counts div { flex: 1; }
  .list-head { display: none; }
  .learners li { grid-template-columns: minmax(0, 1fr) 40px; }
  .l-lrn, .l-bd { display: none; }
  .placed { font-size: 14px; }
  .ok-actions .btn-ghost { padding: 2px 12px 0; }
  .ok-actions .long { display: none; }
  .ok-actions .short { display: inline; }
  .ok-actions .btn-primary { flex: 1; min-width: 0; }
  .btn-lg { height: 46px; padding: 2px 14px 0; font-size: 15px; }
  .foot { padding: 6px 0 10px; font-size: 13.5px; }
}
@media (max-width: 900px) {
  .view-idle, .view-error { overflow: auto; }
  .class-card { gap: 8px; }
  .class-counts div { display: flex; align-items: baseline; justify-content: center; gap: 5px; padding: 6px 6px 4px; min-width: 0; }
  .class-counts b { font-size: 18px; }
  .learners { min-height: 120px; }
}
@media (max-width: 900px) and (max-height: 700px) {
  .lede, .fills-note, .placed { display: none; }
  h1 { font-size: 24px; margin-bottom: 10px; }
  .drop { padding: 10px 14px; }
  .drop-art svg { width: 36px; height: 36px; }
  .drop-help { font-size: 13px; gap: 6px; }
  .class-card h2 { font-size: 18px; }
  .class-meta { display: none; }
  .foot { font-size: 12.5px; }
  .foot-links { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
