/* Shared tokens and components: student app + admin panel. */
:root {
  --paper: #FBFBF9; --paper-2: #F3F3EF; --card: #FFFFFF;
  --ink: #15171C; --graphite: #5B5F68; --muted: #6B6F77;
  --line: #E3E3DF; --line-2: #D2D2CC;
  --accent: #2B3FF5; --accent-2: #1F31D9; --on-accent: #FFFFFF; --accent-soft: #EDEFFE;
  --wrong: #B4321F; --wrong-soft: #FBEEEB; --on-wrong: #FFFFFF;
  --shadow: 0 1px 2px rgba(21, 23, 28, .05), 0 12px 32px -14px rgba(21, 23, 28, .16);
  --r: 16px;
  --f-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --f-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(.65, 0, .25, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101114; --paper-2: #17191D; --card: #1A1C21;
    --ink: #EDEDEA; --graphite: #A6AAB2; --muted: #8A8E97;
    --line: #272A31; --line-2: #383C45;
    --accent: #7D8BFF; --accent-2: #98A3FF; --on-accent: #0C0E1C; --accent-soft: #1C2042;
    --wrong: #FF8A75; --wrong-soft: #351D19; --on-wrong: #2A0F0A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101114; --paper-2: #17191D; --card: #1A1C21;
  --ink: #EDEDEA; --graphite: #A6AAB2; --muted: #8A8E97;
  --line: #272A31; --line-2: #383C45;
  --accent: #7D8BFF; --accent-2: #98A3FF; --on-accent: #0C0E1C; --accent-soft: #1C2042;
  --wrong: #FF8A75; --wrong-soft: #351D19; --on-wrong: #2A0F0A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 500 16px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
/* No double-tap zoom delay; pinch zoom still works. */
* { touch-action: manipulation; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.ic { flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.meta { font-size: 14.5px; font-weight: 600; color: var(--graphite); font-variant-numeric: tabular-nums; }
.display { font-family: var(--f-display); font-weight: 600; letter-spacing: -.01em; line-height: 1.02; }
.muted { color: var(--graphite); }
.small { font-size: 14px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px; border-radius: 999px;
  font-weight: 700; font-size: 15.5px; letter-spacing: .005em; white-space: nowrap;
  background: var(--ink); color: var(--paper);
  transition: transform .15s var(--ease-out), background-color .2s, opacity .2s, box-shadow .2s;
  user-select: none; -webkit-user-select: none; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.accent:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--graphite); }
.btn.soft { background: var(--paper-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--wrong); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.danger-fill { background: var(--wrong); color: var(--on-wrong); }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 15px; font-size: 14px; }
.btn:disabled { opacity: .38; cursor: default; transform: none; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; flex: none;
  border-radius: 999px; color: var(--ink); transition: background-color .15s;
}
.icon-btn:hover { background: var(--paper-2); }
.icon-btn.sm { width: 36px; height: 36px; }

/* forms */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 700; color: var(--graphite); }
.input {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 16px; font-weight: 600; outline: 2px solid transparent; outline-offset: 2px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); font-weight: 500; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea.input { padding: 12px 16px; min-height: 140px; resize: vertical; line-height: 1.55; }
.pw { position: relative; }
.pw .input { padding-right: 52px; }
.pw .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--graphite); }
.form-error { color: var(--wrong); font-size: 14px; font-weight: 600; min-height: 1.5em; }

.switch {
  position: relative; width: 48px; height: 28px; border-radius: 999px; flex: none;
  background: var(--line-2); transition: background-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .25s var(--ease);
}
.switch::before { content: ""; position: absolute; inset: -8px -4px; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--paper-2); gap: 2px; }
.seg button { min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--graphite); transition: background-color .2s, color .2s; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 15px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 14px; transition: border-color .15s, background-color .15s, color .15s;
}
.chip small { font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .7; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }

/* word pictures and avatars */
.pic {
  display: inline-grid; place-items: center; overflow: hidden; flex: none;
  width: 48px; height: 48px; border-radius: 12px; background: var(--paper-2);
  font-size: 28px; line-height: 1;
}
.pic img { width: 100%; height: 100%; object-fit: cover; }
.pic-empty { font-family: var(--f-display); font-weight: 600; color: var(--graphite); font-size: 24px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-weight: 800; font-size: 14px; color: #fff; letter-spacing: .02em;
}

.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } }

/* toasts */
.toasts {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 90; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow); animation: riseIn .3s var(--ease-out);
  transition: opacity .3s, transform .3s;
}
.toast.bad { background: var(--wrong); color: var(--on-wrong); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* confirmation sheet */
.dlg-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(10, 11, 14, .45);
  display: grid; place-items: end center; animation: fadeIn .2s; transition: opacity .2s;
}
.dlg-back.out { opacity: 0; }
.dlg {
  width: min(100%, 460px); background: var(--card); border-radius: 22px 22px 0 0;
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px;
  animation: sheetUp .32s var(--ease-out);
}
.dlg-title { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.dlg-actions { display: grid; gap: 8px; margin-top: 6px; }
@keyframes sheetUp { from { transform: translateY(100%); } }
@media (min-width: 600px) {
  .dlg-back { place-items: center; }
  .dlg { border-radius: 22px; padding: 28px; animation: riseIn .25s var(--ease-out); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spin { animation: none; border-top-color: var(--line-2); border-right-color: var(--accent); }
}
/* Keyboard users jump past the header straight to the content. */
.skip {
  position: fixed; left: 12px; top: -80px; z-index: 100; padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-weight: 700; text-decoration: none;
}
.skip:focus { top: calc(10px + env(safe-area-inset-top)); }
/* Figures that sit side by side or change in place keep their width. */
.stat b, .week-val, .px-count, .done-stat b, .score, .board-row, .u-num, .l-mark, .s-row .num, .g-count { font-variant-numeric: tabular-nums; }

/* Touch screens: every target at least 44 x 44 (Apple HIG, WCAG 2.5.5). */
@media (any-pointer: coarse) {
  .icon-btn.sm { width: 44px; height: 44px; }
  .btn.sm, .seg button { min-height: 44px; }
}
