/* ==========================================================
   Teacher tools — shared layout + each tool's styles.
   Every control is at least 48px tall so it's easy to hit on a
   smartboard or tablet. Each tool page sets --tool to its colour.
   ========================================================== */

.tool-page { --tool: var(--accent); }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; min-width: 0; }
.topbar-title strong { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-eyebrow { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--tool); }
#muteBtn .ico-off { display: none; }
#muteBtn.muted .ico-on { display: none; }
#muteBtn.muted .ico-off { display: block; }

.tool-main { width: min(1400px, 100% - 32px); margin: 0 auto; padding: 8px 0 40px; }

/* ---------- Layout ---------- */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
}
.panel h2 { font-size: 1rem; margin: 0 0 12px; }
@media (max-width: 960px) {
  .tool-layout { grid-template-columns: 1fr; }
  /* No names yet: put the name box first so it's the first thing you see */
  .tool-layout:has(.roster.starts-empty) > aside { order: -1; }
}

/* ---------- Big, colourful controls ---------- */

.btn-tool {
  background: var(--tool);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 28px -12px var(--tool);
}
.btn-tool:hover { filter: brightness(1.06); }
.btn-xl { min-height: 60px; padding: 14px 28px; font-size: 1.15rem; border-radius: 18px; }
.btn-sm { padding: 8px 14px; font-size: .88rem; border-radius: 12px; min-height: 40px; }
.btn-ghost { background: transparent; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.seg button {
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--tool); color: #fff; }

.stepper {
  display: inline-flex;
  align-items: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.stepper button {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}
.stepper button:active { background: var(--surface-2); }
.stepper output { min-width: 64px; text-align: center; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stepper-label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; margin-bottom: 4px; }

.toggle { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; min-height: 44px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--tool); }

.tool-note { color: var(--muted); font-size: .88rem; }

/* ---------- Class list ---------- */

.roster-class { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.roster-select { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.roster-select select {
  min-height: 48px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}
.roster-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* The "add a name" box is the first thing you see */
.roster-add { margin-top: 14px; }
.roster-add-label { display: block; font-weight: 800; font-size: 1.05rem; margin-bottom: 8px; }
.roster-add-row { display: flex; gap: 8px; }
.roster-add-row input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid color-mix(in srgb, var(--tool) 55%, var(--border-strong));
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
}
.roster-add-row input:focus { outline: none; border-color: var(--tool); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tool) 22%, transparent); }
.roster-add-row input::placeholder { color: var(--muted); font-weight: 500; }
.roster-add-row .btn { min-height: 52px; padding: 0 20px; }
.roster.is-empty .roster-add-row input { animation: nudge 2.2s ease-in-out 1s 2; }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tool) 25%, transparent); } }
.roster-help { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }

.roster-summary { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; font-weight: 700; font-size: .9rem; color: var(--muted); }

/* One row per student: name · here/absent · remove */
.roster-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; display: grid; gap: 4px; }
.roster-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 4px 4px 4px 14px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
}
.roster-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-row.away .roster-name { color: var(--muted); text-decoration: line-through; }
.here-toggle {
  min-width: 78px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--c-green) 50%, transparent);
  background: color-mix(in srgb, var(--c-green) 14%, transparent);
  color: var(--c-green);
  font-weight: 800;
  font-size: .8rem;
  cursor: pointer;
}
.roster-row.away .here-toggle {
  border-color: var(--border-strong);
  background: transparent;
  color: var(--muted);
}
.remove-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.remove-btn:hover { background: color-mix(in srgb, var(--missed) 14%, transparent); color: var(--missed); }

.roster-empty {
  margin-top: 14px;
  padding: 18px;
  border-radius: 14px;
  border: 2px dashed var(--border-strong);
  text-align: center;
  color: var(--muted);
}
.roster-empty p { margin: 0 0 10px; }
.roster-note { font-size: .8rem; color: var(--muted); margin: 12px 0 0; }

/* Chips (used for the seating chart's "not seated yet" list) */
.roster-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 280px; overflow-y: auto; }
.name-chip {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--tool) 45%, transparent);
  background: color-mix(in srgb, var(--tool) 12%, transparent);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
}
.name-chip.absent {
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
  text-decoration: line-through;
}

/* ---------- Pop-up result (winner, time's up) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.overlay-card {
  width: min(720px, 100%);
  padding: clamp(24px, 4vw, 48px);
  border-radius: 32px;
  background: var(--surface-solid);
  border: 3px solid var(--tool);
  box-shadow: var(--shadow);
  text-align: center;
  animation: popIn .45s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes popIn { from { opacity: 0; transform: scale(.85); } }
.overlay-card .big {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 9vw, 7rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 10px 0 24px;
  word-break: break-word;
}
.overlay-card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================
   Name picker wheel
   ========================================================== */

.picker-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.wheel-wrap {
  position: relative;
  width: min(100%, 72vh, 680px);
  aspect-ratio: 1;
}
.wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .35)); }
.wheel text { font-family: var(--font); font-weight: 800; fill: #fff; dominant-baseline: central; pointer-events: none; }
.wheel .seg-path { stroke: var(--bg); stroke-width: 2; }
.wheel-hub { fill: var(--surface-solid); stroke: var(--bg); stroke-width: 4; }
.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 40px solid var(--text);
  z-index: 2;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .4));
}
.spin-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--bg);
  background: var(--tool);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1rem, 2.6vw, 1.8rem);
  cursor: pointer;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, .5);
  z-index: 3;
}
.spin-btn:active { transform: translate(-50%, -50%) scale(.95); }
.spin-btn:disabled { opacity: .7; cursor: default; }
.picker-controls { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.picked { width: 100%; text-align: center; }
.picked h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.picked-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.picked-list span { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: .85rem; }
.wheel-empty {
  text-align: center;
  font-size: 1.05rem;
  padding: 12px 18px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--tool) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tool) 35%, transparent);
}
.wheel-empty b { color: var(--tool); }

/* ==========================================================
   Group maker
   ========================================================== */

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.group-card {
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: popIn .35s cubic-bezier(.2, .9, .3, 1.2) both;
}
.group-card header {
  padding: 12px 16px;
  background: var(--gc);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.group-card header small { font-family: var(--font); font-size: .8rem; opacity: .85; }
.group-card ul { list-style: none; margin: 0; padding: 10px 16px 16px; display: grid; gap: 4px; }
.group-card li { font-size: clamp(1rem, 1.3vw, 1.35rem); font-weight: 700; padding: 4px 0; border-bottom: 1px solid var(--border); }
.group-card li:last-child { border-bottom: 0; }
.groups-empty { padding: 40px 16px; text-align: center; color: var(--muted); border: 2px dashed var(--border-strong); border-radius: 20px; }

/* ==========================================================
   Seating chart
   ========================================================== */

.room {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 16px;
  overflow-x: auto;
}
.room-front {
  margin: 0 auto 16px;
  width: min(60%, 420px);
  padding: 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tool) 20%, var(--surface-solid));
  border: 1px solid color-mix(in srgb, var(--tool) 50%, transparent);
  text-align: center;
  font-weight: 800;
  font-size: .8rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.desks {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(90px, 1fr));
  gap: 10px;
  min-width: calc(var(--cols) * 100px);
}
.desk {
  min-height: 64px;
  padding: 8px;
  border-radius: 12px;
  border: 2px solid var(--border-strong);
  background: var(--surface-solid);
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 800;
  font-size: clamp(.85rem, 1.1vw, 1.15rem);
  line-height: 1.1;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  word-break: break-word;
  transition: border-color .15s, background .15s, transform .15s;
}
.desk.filled { border-color: color-mix(in srgb, var(--tool) 60%, transparent); background: color-mix(in srgb, var(--tool) 14%, var(--surface-solid)); }
.desk.empty { color: var(--muted); font-weight: 600; font-size: .8rem; border-style: dashed; }
.desk.off { visibility: hidden; }
.editing .desk.off { visibility: visible; opacity: .35; background: transparent; border-style: dotted; }
.desk.absent { opacity: .45; text-decoration: line-through; }
.desk.selected, .unseated .name-chip.selected { outline: 3px solid var(--tool); outline-offset: 2px; }
.desk.drop-target { transform: scale(1.04); border-color: var(--tool); }
.unseated { margin-top: 16px; }
.unseated h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.unseated .roster-chips { max-height: none; }
.unseated .name-chip { touch-action: none; }
.drag-ghost {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--tool);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%) rotate(-3deg);
}

/* ==========================================================
   Classroom timer
   ========================================================== */

.timer {
  --p: 1;            /* fraction of time left, set by script */
  --tc: var(--c-green);
  position: relative;
  border-radius: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  padding: clamp(16px, 3vw, 40px);
  text-align: center;
}
.timer::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--p) * 100%);
  background: color-mix(in srgb, var(--tc) 16%, transparent);
  transition: height .25s linear, background .5s;
  z-index: 0;
}
.timer > * { position: relative; z-index: 1; }
.timer-display {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(5rem, 22vw, 26rem);
  line-height: .95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--tc);
  margin: 8px 0 16px;
  transition: color .5s;
}
.timer.running.last10 .timer-display { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.timer.done { animation: flash .6s steps(1) 6; }
@keyframes flash { 50% { background: color-mix(in srgb, var(--missed) 35%, transparent); } }
.timer-set { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.timer.running .timer-set, .timer.running .presets { display: none; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.preset {
  min-height: 48px;
  min-width: 72px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}
.preset:hover { border-color: var(--tool); }
.timer-controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.timer-controls .btn-xl { min-width: 180px; }
.timer-options { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.timer-options select {
  min-height: 44px; padding: 0 10px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text); font: inherit; font-weight: 700;
}
.laps { list-style: none; padding: 0; margin: 16px auto 0; max-width: 360px; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.laps li { display: flex; justify-content: space-between; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; }
:root.is-fullscreen .tool-page .learn,
:root.is-fullscreen .tool-page .site-footer { display: none; }

/* ==========================================================
   Scoreboard
   ========================================================== */

.teams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.team {
  --team: var(--c-blue);
  border-radius: 28px;
  border: 3px solid var(--team);
  background: color-mix(in srgb, var(--team) 10%, var(--surface-solid));
  padding: 18px;
  text-align: center;
  position: relative;
}
.team.leader::after {
  content: "👑";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
}
.team-name {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font: inherit;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.2rem, 2vw, 2rem);
  padding: 6px;
  border-radius: 10px;
}
.team-name:focus { outline: 2px solid var(--team); }
.team-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(4rem, 11vw, 11rem);
  line-height: 1;
  color: var(--team);
  font-variant-numeric: tabular-nums;
  margin: 8px 0 14px;
}
.team-score.bump { animation: bump .3s ease; }
@keyframes bump { 50% { transform: scale(1.15); } }
.team-buttons { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.team-buttons button {
  min-height: 60px;
  border-radius: 16px;
  border: 0;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: var(--team);
}
.team-buttons .minus { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }

/* ==========================================================
   Noise meter
   ========================================================== */

.noise {
  --lvl: 0;
  --nc: var(--c-green);
  text-align: center;
  border-radius: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: clamp(18px, 3vw, 40px);
  transition: background .3s;
}
.noise.loud { background: color-mix(in srgb, var(--missed) 22%, var(--surface)); }
.noise-face { font-size: clamp(5rem, 16vw, 12rem); line-height: 1; }
.noise-label { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.6rem, 4vw, 3.4rem); color: var(--nc); margin: 10px 0 24px; }
.meter {
  position: relative;
  height: clamp(40px, 7vw, 80px);
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  margin: 0 auto 20px;
  max-width: 1000px;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--lvl) * 1%);
  background: linear-gradient(90deg, var(--c-green), var(--c-yellow) 60%, var(--missed));
  background-size: 1000px 100%;
  transition: width .1s linear;
}
.meter-limit {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 4px;
  left: calc(var(--limit) * 1%);
  background: var(--text);
  border-radius: 2px;
}
.noise-controls { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; align-items: center; }
.noise-controls label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .85rem; min-width: 220px; }
.noise-controls input[type="range"] { width: 100%; accent-color: var(--tool); height: 32px; }
.noise-stat { font-weight: 800; font-size: 1.2rem; }

/* ==========================================================
   Large screens (smartboards, projectors): scale up controls
   ========================================================== */

@media (min-width: 1600px) {
  .tool-main { width: min(1800px, 100% - 64px); }
  .btn-xl { min-height: 72px; font-size: 1.35rem; }
  .preset, .stepper button { min-height: 56px; }
  .stepper button { width: 56px; height: 56px; }
}

/* ==========================================================
   Printing (seating chart, groups)
   ========================================================== */

@media print {
  .topbar, .toolbar, .tool-layout > aside, .learn, .site-footer, .install-card, .unseated, .tool-note { display: none !important; }
  body { background: #fff; color: #000; }
  .tool-layout { display: block; }
  .room, .group-card { border-color: #999; background: #fff; }
  .desk { border-color: #666 !important; background: #fff !important; color: #000; }
  .desk.off { visibility: hidden !important; }
}
