/* Kitah Gems — styles. Phone first, then iPad, then projector / classboard. */

/* ---------- Tokens ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #14111d;
  --bg-dot: rgba(255, 255, 255, 0.035);
  --surface: #1f1a2c;
  --surface-2: #292238;
  --surface-3: #342b47;
  --border: #3a3150;
  --text: #f5f1fc;
  --muted: #a99fc0;
  --accent: #9b6dff;
  --accent-strong: #b794ff;
  --accent-ink: #140d24;
  --accent-soft: rgba(155, 109, 255, 0.16);
  --danger: #f2555a;
  --danger-soft: rgba(242, 85, 90, 0.14);
  --gold: #f2b84b;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  --backdrop: rgba(8, 6, 14, 0.66);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f3fb;
  --bg-dot: rgba(60, 30, 120, 0.05);
  --surface: #ffffff;
  --surface-2: #f1ecf8;
  --surface-3: #e5ddf2;
  --border: #ddd4ec;
  --text: #1d1730;
  --muted: #6a6184;
  --accent: #7442e8;
  --accent-strong: #5b2fd0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(116, 66, 232, 0.12);
  --danger: #d93036;
  --danger-soft: rgba(217, 48, 54, 0.1);
  --gold: #b9861c;
  --shadow: 0 12px 30px rgba(40, 20, 80, 0.16);
  --backdrop: rgba(30, 20, 50, 0.45);
  color-scheme: light;
}
:root {
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 16px;
  --r-sm: 10px;
  --gutter: 16px;
  --card-min: 150px;
  --bar-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
body[data-size="s"] { --card-min: 132px; }
body[data-size="m"] { --card-min: 150px; }
body[data-size="l"] { --card-min: 190px; }
body[data-size="xl"] { --card-min: 240px; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
a { color: var(--accent-strong); }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ico { width: 1.25em; height: 1.25em; display: block; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.86rem; }
.center { text-align: center; }
.pad { padding: 22px 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row2.labels { margin-bottom: -6px; }
.section-h { font-size: 1.05rem; font-weight: 600; }
.label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--muted); margin: 4px 0 -4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-weight: 500; text-decoration: none; text-align: center;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger-outline { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; border-radius: 10px; }
.btn.lg { min-height: 52px; font-size: 1.05rem; }
.btn.block { width: 100%; }
label.btn { cursor: pointer; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  border: 1px solid var(--border); background: var(--surface-2);
}
.icon-btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn.danger-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn.danger-ghost:hover { color: var(--danger); background: var(--danger-soft); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-strong); font-weight: 500; padding: 4px 0; }

.round-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 46px; height: 46px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
}
.round-btn:hover { border-color: var(--accent); }
.round-btn.lg { width: 60px; height: 60px; }
.round-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Fields ---------- */
.field {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.lg { min-height: 54px; font-size: 1.1rem; }
.field.num { max-width: 92px; }
textarea.field { resize: vertical; min-height: 96px; }
select.field { appearance: auto; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.color-in { width: 46px; height: 46px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); flex: none; }

.switch { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none; transition: background 0.15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(18px); }

/* ---------- Chips, pills, tabs ---------- */
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 500; }
.chip:hover { border-color: var(--accent); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row.center { justify-content: center; }
.pill-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--surface-3); font-size: 0.9rem; }
button.pill:hover { background: var(--accent-soft); }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); margin-bottom: 14px; }
.tabs.scroll { overflow-x: auto; scrollbar-width: none; }
.tabs.scroll::-webkit-scrollbar { display: none; }
.tab { flex: 1; min-height: 40px; padding: 6px 12px; border-radius: 10px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab.active { background: var(--surface-3); color: var(--text); }
.tab.add { flex: none; width: 44px; }

/* ---------- Progress ---------- */
.progress { display: block; flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.35s ease; }
.progress.big { height: 10px; }

/* ================= Board ================= */
.board-app { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--bar-h) + var(--safe-b) + 24px); }
.bar-btn {
  display: flex; align-items: center; justify-content: center; gap: 18px; width: 100%;
  height: var(--bar-h); color: var(--accent-strong);
  font-weight: 600; letter-spacing: 0.18em; font-size: 0.95rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar-btn .ico { width: 1.4em; height: 1.4em; }
.menu-bar { padding-top: var(--safe-t); height: calc(var(--bar-h) + var(--safe-t)); }
.wb-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--bar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  border-bottom: 0; border-top: 1px solid var(--border);
}

.board { max-width: 1400px; margin: 0 auto; padding: 16px var(--gutter) 0; display: flex; flex-direction: column; gap: 14px; }
.greeting { font-size: 1.3rem; font-weight: 600; line-height: 1.25; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-pill, .tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 50px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.tool-pill { padding: 0 16px; font-weight: 600; }
.tool-pill.hot { background: var(--gold); border-color: var(--gold); color: #24170a; }
.tool-btn { width: 50px; }
.tool-btn .ico, .tool-pill .ico { width: 1.4em; height: 1.4em; }
.tool-btn:hover, .tool-pill:hover { border-color: var(--accent); }
.tool-btn:active, .tool-pill:active { transform: scale(0.95); }
.tool-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.chip-scroll { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; min-width: 0; flex: 1; }
.chip-scroll::-webkit-scrollbar { display: none; }
.class-chip, .subject-chip {
  display: inline-flex; align-items: center; flex: none; height: 46px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.class-chip.active, .subject-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-main { height: 100%; padding: 0 16px; font-weight: 600; white-space: nowrap; }
.class-chip.active .chip-main, .subject-chip.active .chip-main { padding-right: 6px; }
.chip-edit { height: 100%; padding: 0 12px 0 4px; display: inline-flex; align-items: center; opacity: 0.85; }
.class-row { display: flex; }
.subject-row {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 20px; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.subject-empty { color: var(--muted); padding: 0 8px; text-align: left; white-space: nowrap; }
.class-point { flex: none; min-height: 46px; padding: 6px 14px; line-height: 1.15; max-width: 120px; }

.goal-bar {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.goal-bar .ico { color: var(--gold); }
.goal-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.goal-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.goal-bar .progress i { background: var(--gold); }
.goal-bar.done { border-color: var(--gold); }

.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-weight: 500; max-width: 100%;
}
.link-chip:hover { border-color: var(--accent); }
.link-chip .ico { color: var(--accent-strong); }

.empty-box {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 34px 18px; border-radius: var(--r); border: 2px dashed var(--border); color: var(--muted);
}
.empty-box h3 { color: var(--text); font-size: 1.15rem; }
.empty-box .btn { margin-top: 8px; }
.empty-box.sm { padding: 20px 14px; }
.empty-ic .ico { width: 40px; height: 40px; }

/* Student cards */
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: 10px; }
.student {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; border-radius: var(--r); background: var(--surface);
  border: 1px solid var(--border); box-shadow: inset 0 3px 0 var(--zone);
  transition: opacity 0.2s;
}
.student { container-type: inline-size; }
.student.zoned { border-color: color-mix(in srgb, var(--zone) 55%, var(--border)); }
.student.absent { opacity: 0.5; }
.st-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); font-weight: 700; font-size: 0.85rem;
}
.st-name { flex: 1; min-width: 0; font-weight: 600; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-btn { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.mini-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-btn .ico { width: 1.1em; height: 1.1em; }
.absent-btn { color: var(--accent-strong); }
.absent-btn.on { color: var(--danger); background: var(--danger-soft); }
.pts-row { display: grid; grid-template-columns: 1fr 1.25fr 1fr auto; gap: 5px; align-items: stretch; }
.pts-btn, .pts-num {
  min-height: 52px; border-radius: 12px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s, background 0.15s;
}
.pts-btn .ico { width: 1.4em; height: 1.4em; }
.pts-btn:active, .pts-num:active { transform: scale(0.93); }
.pts-btn:hover, .pts-num:hover { background: var(--surface-3); }
.pts-num { background: var(--bg); font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 0; }
.pts-num.bump-up { animation: bumpUp 0.45s ease; }
.pts-num.bump-down { animation: bumpDown 0.35s ease; }
@keyframes bumpUp { 0% { transform: scale(1); } 35% { transform: scale(1.18); color: var(--accent-strong); } 100% { transform: scale(1); } }
@keyframes bumpDown { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-3px); } 60% { transform: translateX(3px); } }
.step-chip {
  align-self: center; width: 26px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); font-size: 0.8rem; font-weight: 600; color: var(--muted);
}
.no-subject .pts-row { opacity: 0.5; }
.st-foot { display: flex; align-items: center; gap: 8px; }
.zone-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.add-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 140px; border-radius: var(--r); border: 2px dashed var(--border); color: var(--muted); font-weight: 500;
}
.add-card:hover { border-color: var(--accent); color: var(--text); }
.add-card .ico { width: 1.6em; height: 1.6em; }
/* Narrow cards (phones): give the name the room */
@container (max-width: 190px) {
  .student .avatar { display: none; }
  .student .st-head { gap: 2px; }
  .student .mini-btn { width: 26px; }
  .student .pts-row { gap: 4px; }
  .student .step-chip { width: 22px; }
}
@container (max-width: 400px) {
  .student .pts-num { font-size: clamp(1.25rem, 13cqi, 2.6rem); }
}

.zone-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 10px 0 4px; }
.zone-chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.zone-chip.sm { font-size: 0.75rem; padding: 2px 8px; }

/* ================= Floating mini-players ================= */
#floats {
  position: fixed; left: var(--gutter); bottom: calc(var(--bar-h) + var(--safe-b) + 12px); z-index: 30;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none;
}
#floats > * { pointer-events: auto; }
body.wb-open #floats { bottom: auto; top: calc(var(--bar-h) + var(--safe-t) + 70px); left: auto; right: var(--gutter); align-items: flex-end; z-index: 60; }
.float-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 16px;
  border-radius: 14px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: var(--shadow);
}
.float-pill.paused { background: var(--surface-3); color: var(--text); }
.float-pill.done { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
.float-pill.music { padding: 0; gap: 0; overflow: hidden; }
.mp-open { display: inline-flex; align-items: center; gap: 8px; height: 100%; padding: 0 12px 0 16px; color: inherit; }
.mp-name { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-btn { width: 46px; height: 100%; display: inline-flex; align-items: center; justify-content: center; color: inherit; border-left: 1px solid rgba(0, 0, 0, 0.18); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 4px; background: currentColor; border-radius: 1px; }
.float-pill.playing .eq i, .eq.on i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: 0.2s !important; }
.eq i:nth-child(3) { animation-delay: 0.4s !important; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
@keyframes pulse { 50% { opacity: 0.65; } }

/* ================= Modals ================= */
#overlay-root { position: relative; z-index: 80; }
.backdrop {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  padding: max(12px, var(--safe-t)) 12px max(12px, var(--safe-b));
  background: var(--backdrop); opacity: 0; transition: opacity 0.16s ease;
}
.backdrop.in { opacity: 1; }
.modal {
  width: min(100%, 520px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow);
  transform: translateY(10px) scale(0.98); transition: transform 0.16s ease;
}
.backdrop.in .modal { transform: none; }
.modal-sm { width: min(100%, 420px); }
.modal-lg { width: min(100%, 720px); }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 14px 10px 18px; }
.modal-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-strong); }
.modal-titles { flex: 1; min-width: 0; padding-top: 4px; }
.modal-title { font-size: 1.2rem; font-weight: 600; }
.modal-sub { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.modal-body { padding: 6px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 18px; border-top: 1px solid var(--border); }
.modal-foot .btn { min-width: 110px; }
.modal.flash { border-color: var(--danger); animation: flashBorder 0.8s ease-in-out 4; }
@keyframes flashBorder { 50% { box-shadow: 0 0 0 6px var(--danger-soft), var(--shadow); } }
.danger-zone { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Lists used in modals */
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { min-height: 50px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 500; }
.preset:hover { border-color: var(--accent); }
.edit-list { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: flex; gap: 8px; align-items: center; }
.order-list { display: flex; flex-direction: column; gap: 6px; }
.order-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--surface-2); }
.order-n { width: 24px; color: var(--muted); font-variant-numeric: tabular-nums; }
.order-name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg-col { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 500; text-align: left; }
.choice.active { border-color: var(--accent); background: var(--accent-soft); }
.choice.active .ico { color: var(--accent-strong); }
.goal-edit { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.goal-edit-h { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.goal-edit .row2 { grid-template-columns: 1fr 110px; }
.zone-edit-list { display: flex; flex-direction: column; gap: 8px; }
.zone-edit { display: flex; gap: 8px; align-items: center; }
.leader { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.leader-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.leader-row.top { background: var(--accent-soft); }
.leader-n { width: 26px; font-weight: 700; color: var(--muted); }
.leader-row.top .leader-n { color: var(--gold); }
.leader-name { flex: 1; font-weight: 500; min-width: 0; }
.leader-pts { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.award-list { display: flex; flex-direction: column; gap: 6px; }
.award-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.award-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.award-name { font-weight: 600; }
.award-meta { font-size: 0.85rem; width: 100%; padding-left: 30px; }
.inline-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.inline-form .field { background: var(--surface); }

/* ================= Toasts ================= */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 120;
  bottom: calc(var(--bar-h) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(calc(100% - 24px), 520px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 500;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: auto; max-width: 100%;
}
.toast.in { opacity: 1; transform: none; }
.toast.award { background: var(--gold); color: #24170a; }
.toast.danger { background: var(--danger); color: #fff; }
.toast-msg { flex: 1; }
.toast-btn { padding: 6px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.14); font-weight: 600; white-space: nowrap; }

.confetti {
  position: fixed; z-index: 130; width: 8px; height: 12px; border-radius: 2px; pointer-events: none;
  animation: confetti 1.2s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
@keyframes confetti {
  to { transform: translate(var(--dx), calc(var(--dy) + 160px)) rotate(var(--r)); opacity: 0; }
}

/* ================= MENU drawer ================= */
.drawer-back { position: fixed; inset: 0; z-index: 70; background: var(--backdrop); opacity: 0; transition: opacity 0.2s; }
.drawer-back.in { opacity: 1; }
.drawer {
  position: absolute; left: 0; right: 0; top: 0; max-height: 88dvh; overflow-y: auto;
  padding: calc(var(--safe-t) + 14px) var(--gutter) 18px;
  background: var(--surface); border-bottom: 1px solid var(--border); border-radius: 0 0 24px 24px; box-shadow: var(--shadow);
  transform: translateY(-100%); transition: transform 0.22s ease;
}
.drawer-back.in .drawer { transform: none; }
.drawer > * { max-width: 620px; margin-left: auto; margin-right: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.3rem; }
.brand-ic { color: var(--accent-strong); }
.brand-ic .ico { width: 1.3em; height: 1.3em; }
.brand.lg { font-size: 1.6rem; }
.acc { border-radius: 14px; }
.acc.open { background: var(--surface-2); }
.acc-head {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 0 12px;
  color: var(--muted); font-weight: 600; letter-spacing: 0.08em; font-size: 0.92rem; text-align: left;
}
.acc-head > span:not(.ic) { flex: 1; }
.acc.open .acc-head { color: var(--text); }
.acc .trail { transition: transform 0.2s; }
.acc.open > .acc-head .trail { transform: rotate(180deg); }
.acc-body { display: flex; flex-direction: column; gap: 2px; padding: 0 6px 8px; }
.menu-item { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 12px; border-radius: 12px; text-align: left; font-weight: 500; width: 100%; }
.menu-item > span:not(.ic) { flex: 1; }
.menu-item:hover { background: var(--surface-3); }
.menu-item .ico { color: var(--accent-strong); }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.tool-toggle { display: flex; align-items: center; gap: 4px; }
.tool-check { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 12px; text-align: left; font-weight: 500; color: var(--muted); }
.tool-check:hover { background: var(--surface-3); }
.tool-check.on { color: var(--text); }
.tool-check .ic:first-child { color: var(--muted); }
.tool-check.on .ic:first-child { color: var(--accent-strong); }
.tool-info { padding: 0 16px 10px 50px; color: var(--muted); font-size: 0.88rem; }

/* ================= Tools ================= */
.wp-row { display: flex; gap: 10px; justify-content: center; }
.wp { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wp-label { font-size: 0.75rem; letter-spacing: 0.12em; color: var(--muted); font-weight: 600; }
.wp-window { position: relative; width: 100%; height: 200px; border-radius: 14px; background: var(--bg); overflow: hidden; }
.wp-list { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; position: relative; z-index: 1; }
.wp-list::-webkit-scrollbar { display: none; }
.wp-spacer { height: 80px; }
.wp-item { height: 40px; display: flex; align-items: center; justify-content: center; scroll-snap-align: center; color: var(--muted); font-size: 1.1rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.wp-item.sel { color: var(--text); font-weight: 600; font-size: 1.3rem; }
.wp-hl { position: absolute; left: 6px; right: 6px; top: 80px; height: 40px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); pointer-events: none; }
.wp-window::before, .wp-window::after { content: ''; position: absolute; left: 0; right: 0; height: 60px; z-index: 2; pointer-events: none; }
.wp-window::before { top: 0; background: linear-gradient(var(--bg), transparent); }
.wp-window::after { bottom: 0; background: linear-gradient(transparent, var(--bg)); }
.big-time {
  text-align: center; font-size: clamp(3.2rem, 16vw, 6rem); font-weight: 700; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums; color: var(--gold); line-height: 1.1; padding: 8px 0;
}
.big-time.done { color: var(--danger); }
.big-time.sw { font-size: clamp(2.6rem, 13vw, 5rem); }
.day-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { min-height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; font-size: 0.85rem; }
.day.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.alarm-list { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.alarm-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--surface-2); }
.alarm-row.off { opacity: 0.55; }
.alarm-time { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.alarm-meta { flex: 1; display: flex; flex-direction: column; min-width: 0; font-size: 0.85rem; }

.wheel-wrap { position: relative; width: min(100%, 440px); margin: 0 auto; }
.wheel-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.wheel-pointer {
  position: absolute; left: 50%; top: -4px; transform: translateX(-50%);
  width: 0; height: 0; border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 28px solid var(--text);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}
.wheel-result { text-align: center; font-size: clamp(1.6rem, 7vw, 2.6rem); font-weight: 700; min-height: 1.3em; color: var(--gold); opacity: 0; transform: scale(0.8); transition: 0.25s; }
.wheel-result.show { opacity: 1; transform: none; }
.wheel-controls { display: flex; flex-direction: column; gap: 8px; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.team { border-radius: 14px; background: var(--surface-2); border-top: 4px solid var(--t); padding: 10px 12px; }
.team-h { font-weight: 700; color: var(--t); margin-bottom: 6px; }
.team ul { margin: 0; padding-left: 18px; }
.team li { padding: 2px 0; }
.rating-list { display: flex; flex-direction: column; gap: 6px; }
.rating-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--surface-2); }
.rating-seg { display: flex; gap: 4px; }
.rate { width: 34px; height: 34px; border-radius: 9px; background: var(--bg); font-weight: 600; color: var(--muted); }
.rate.on { background: var(--accent); color: var(--accent-ink); }

.setup-list { display: flex; flex-direction: column; gap: 6px; }
.setup-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 0; border-radius: 12px; background: var(--surface-2); }
.setup-open { flex: 1; display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; text-align: left; }
.center-names { display: flex; flex-direction: column; gap: 6px; }
.center-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.center-cell { border-radius: 14px; background: var(--surface-2); border-left: 4px solid var(--t); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.center-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.group-tag { font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--t); color: #fff; }

.key-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.key-list li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 1.1rem; font-weight: 500; }
.key-pts { min-width: 54px; text-align: center; padding: 4px 8px; border-radius: 10px; background: var(--gold); color: #24170a; font-weight: 700; }

.player { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.player-now { display: flex; align-items: center; gap: 10px; color: var(--accent-strong); }
.player-now strong { color: var(--text); }
.player-ctrls { display: flex; align-items: center; gap: 12px; }
.vol { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.vol input { flex: 1; accent-color: var(--accent); }
.track-list { display: flex; flex-direction: column; gap: 4px; }
.track { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.track.cur { background: var(--accent-soft); }
.track-play { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; text-align: left; min-width: 0; }
.track-play span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-play .ico { color: var(--accent-strong); }

.study { display: flex; flex-direction: column; gap: 12px; }
.study-note { white-space: pre-wrap; font-size: 1.05rem; line-height: 1.55; padding: 14px; border-radius: 14px; background: var(--surface-2); }

.link-list { display: flex; flex-direction: column; gap: 6px; }
.link-item { display: flex; align-items: center; gap: 4px; padding-right: 4px; border-radius: 12px; background: var(--surface-2); }
.link-item a { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--text); text-decoration: none; min-width: 0; }
.link-item a > span { display: flex; flex-direction: column; min-width: 0; }
.link-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item .ico { color: var(--accent-strong); }

/* ================= Whiteboard ================= */
.wb { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #2a2735; color: #f5f1fc; }
:root[data-theme="light"] .wb { background: #d9d5e2; color: var(--text); }
.wb-return { flex: none; padding-top: var(--safe-t); height: calc(var(--bar-h) + var(--safe-t)); }
.wb-top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 10px var(--gutter) 0; padding: 6px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.wb-group { display: flex; align-items: center; gap: 2px; }
.wb-mode { padding: 3px; border-radius: 12px; background: var(--bg); }
.wb-btn {
  width: 42px; height: 42px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: inherit;
}
.wb-btn:hover:not(:disabled) { background: var(--surface-2); }
.wb-btn.active { background: var(--accent); color: var(--accent-ink); }
.wb-mode .wb-btn { width: 40px; height: 36px; }
.wb-page { min-width: 40px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.wb-stage { flex: 1; position: relative; min-height: 0; }
.wb-canvas { position: absolute; inset: 0; touch-action: none; display: block; }
.wb-tools {
  flex: none; align-self: center; display: flex; align-items: center; gap: 2px; max-width: calc(100% - 2 * var(--gutter));
  margin: 0 0 calc(12px + var(--safe-b)); padding: 5px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow);
}
.wb-tools-inner { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.wb-tools-inner::-webkit-scrollbar { display: none; }
.wb.collapsed .wb-tools-inner { display: none; }
.wb-grip { color: var(--muted); width: 32px; }
.wb-sep { width: 1px; height: 26px; background: var(--border); margin: 0 4px; flex: none; }
.wb-swatch { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.wb-swatch::after { content: ''; width: 24px; height: 24px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.wb-swatch.active { box-shadow: 0 0 0 2px var(--accent-strong); }
.wb-custom { cursor: pointer; color: var(--sw, inherit); }
.wb-size i { display: block; width: 22px; border-radius: 999px; background: currentColor; }
.wb-size[data-size="0"] i { height: 3px; }
.wb-size[data-size="1"] i { height: 6px; }
.wb-size[data-size="2"] i { height: 11px; }
.wb.presenting .wb-tools { display: none; }
@media (max-width: 480px) {
  .wb-top { margin: 8px 8px 0; padding: 4px; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .wb-top::-webkit-scrollbar { display: none; }
  .wb-btn { width: 34px; height: 38px; border-radius: 9px; }
  .wb-mode .wb-btn { width: 34px; height: 32px; }
  .wb-page { min-width: 30px; font-size: 0.8rem; }
  .wb-tools { max-width: calc(100% - 16px); }
  .wb-tools-inner { flex-wrap: wrap; justify-content: center; overflow: visible; row-gap: 4px; }
  .wb-sep { display: none; }
  .wb-swatch { width: 30px; height: 30px; }
  .wb-swatch::after { width: 20px; height: 20px; }
}
.wb.presenting .wb-stage { margin-bottom: var(--safe-b); }

/* ================= Tours ================= */
.tour-layer { position: fixed; inset: 0; z-index: 200; }
.tour-layer.dim { background: var(--backdrop); }
.tour-hl {
  position: fixed; border-radius: 16px; pointer-events: none;
  box-shadow: 0 0 0 9999px var(--backdrop), 0 0 0 3px var(--accent-strong);
  transition: all 0.25s ease;
}
.tour-card {
  position: fixed; width: min(calc(100% - 24px), 380px); padding: 18px;
  background: var(--surface); color: var(--text); border: 1px solid var(--accent); border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; transition: top 0.25s ease, left 0.25s ease;
}
.tour-card h3 { font-size: 1.15rem; }
.tour-card p { color: var(--muted); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.tour-count { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.tour-btns { display: flex; gap: 6px; }

/* ================= Onboarding ================= */
.onboard-app { min-height: 100vh; min-height: 100dvh; display: flex; }
.onboard { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: calc(var(--safe-t) + 32px) var(--gutter) calc(var(--safe-b) + 32px); }
.onboard-card {
  width: min(100%, 520px); display: flex; flex-direction: column; gap: 14px; padding: 24px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow);
}
.onboard-card h1 { font-size: 1.6rem; line-height: 1.2; }
.step-label { color: var(--accent-strong); font-weight: 600; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.tool-checklist { display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: 16px; background: var(--surface-2); }

/* ================= Printing ================= */
#print-root { display: none; }
@media print {
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body.printing { background: #fff; color: #000; }
}
.cert {
  page-break-after: always; break-after: page; height: 180mm; display: flex; padding: 6mm;
  font-family: var(--font); color: #1d1730; -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cert:last-child { page-break-after: auto; break-after: auto; }
.cert-inner {
  flex: 1; border: 3mm solid var(--z); border-radius: 6mm; outline: 0.6mm solid #c9bfe0; outline-offset: -6mm;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 3mm; padding: 10mm;
}
.cert-brand { display: flex; align-items: center; gap: 2mm; font-weight: 700; letter-spacing: 0.3em; color: #7442e8; font-size: 11pt; }
.cert-brand .ico { width: 6mm; height: 6mm; }
.cert-title { font-size: 30pt; font-weight: 700; }
.cert-small { font-size: 13pt; color: #5a5270; }
.cert-name { font-size: 38pt; font-weight: 700; color: #1d1730; border-bottom: 0.5mm solid #c9bfe0; padding: 0 12mm 2mm; margin: 2mm 0; }
.cert-zone { font-size: 22pt; font-weight: 700; padding: 2mm 10mm; border-radius: 999px; background: var(--z); color: var(--zi); }
.cert-foot { display: flex; justify-content: space-between; width: 100%; margin-top: 8mm; padding: 0 10mm; }
.cert-line { min-width: 60mm; border-bottom: 0.4mm solid #9a90b5; padding-bottom: 1mm; font-size: 13pt; font-weight: 500; }
.cert-cap { font-size: 10pt; color: #5a5270; margin-top: 1mm; }
.report { font-family: var(--font); color: #000; }
.report h1 { font-size: 18pt; margin-bottom: 2mm; }
.report p { margin-bottom: 6mm; color: #444; }
.report table { width: 100%; border-collapse: collapse; font-size: 11pt; }
.report th, .report td { border: 0.3mm solid #bbb; padding: 2mm 3mm; text-align: left; }
.report th { background: #f0ecf8; }
.report small { color: #666; }

/* ================= Larger screens ================= */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .greeting { font-size: 1.6rem; }
  .student-grid { gap: 12px; }
  .class-point { max-width: none; white-space: nowrap; }
}
/* iPad */
@media (min-width: 768px) {
  body[data-size="s"] { --card-min: 150px; }
  body[data-size="m"] { --card-min: 180px; }
  body[data-size="l"] { --card-min: 230px; }
  body[data-size="xl"] { --card-min: 290px; }
  .pts-btn, .pts-num { min-height: 60px; }
  .pts-num { font-size: 2rem; }
  .modal-body { padding: 6px 22px 22px; }
}
/* Projector / classboard */
@media (min-width: 1200px) {
  html { font-size: 18px; }
  body { font-size: 18px; }
  body[data-size="s"] { --card-min: 180px; }
  body[data-size="m"] { --card-min: 220px; }
  body[data-size="l"] { --card-min: 280px; }
  body[data-size="xl"] { --card-min: 340px; }
  :root { --bar-h: 60px; }
  .board { gap: 18px; padding-top: 22px; }
  .greeting { font-size: 2rem; }
  .tool-pill, .tool-btn { height: 58px; }
  .tool-btn { width: 58px; }
  .class-chip, .subject-chip, .round-btn { height: 52px; }
  .round-btn { width: 52px; }
  .pts-btn, .pts-num { min-height: 70px; }
  .pts-num { font-size: 2.5rem; }
  .st-name { font-size: 1.25rem; }
  .avatar { width: 34px; height: 34px; font-size: 1rem; }
  .zone-chip { font-size: 1rem; padding: 6px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
