:root {
  --bg: #0b1d2a;
  --panel: #12293b;
  --text: #eaf4fb;
  --muted: #8aa5b8;
  --btn: #1d4560;
  --good: #1f7a4d;
  --danger: #b3261e;
  --go: #c27a00;
  --on: #35d07f;
  --off: #ff5a4e;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.3 -apple-system, system-ui, sans-serif; }
body { padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom); }

header { display: flex; align-items: center; gap: 8px; padding: 10px 0 4px; }
.students { flex: 1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.students::-webkit-scrollbar { display: none; }
.student { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 6px 14px;
  border: 2px solid transparent; border-radius: 24px; background: var(--panel); color: var(--text);
  font: inherit; font-size: 17px; font-weight: 600; }
.student.selected { border-color: var(--text); background: var(--btn); }
.student .time { font-size: 13px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.student.flash-film { background: var(--go); animation: blink .6s 8 alternate; }
.add { flex: 0 0 auto; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--panel);
  color: var(--text); font-size: 24px; }
.add[hidden] { display: none; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 13px; min-height: 1.3em; }
body.no-student .grid, body.no-student .compose { opacity: .35; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--on); }
.dot.off { background: var(--off); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px), (orientation: landscape) { .grid { grid-template-columns: repeat(4, 1fr); } }

.preset { min-height: 72px; border: 0; border-radius: 14px; background: var(--btn); color: var(--text);
  font-size: 19px; font-weight: 700; padding: 8px; touch-action: manipulation; user-select: none; }
.preset.good { background: var(--good); }
.preset.danger { background: var(--danger); grid-column: span 2; min-height: 84px; font-size: 22px; }
.preset.go { background: var(--go); }
.preset:active { transform: scale(.97); filter: brightness(1.2); }
.preset.flash { animation: flash .5s; }
@keyframes flash { from { box-shadow: 0 0 0 4px #fff; } to { box-shadow: 0 0 0 0 transparent; } }

.goals { margin-top: 10px; grid-template-columns: repeat(2, 1fr) !important; }
.goals .preset { font-size: 17px; }
.goals.editing .preset { outline: 2px dashed var(--muted); outline-offset: -4px; }
.goal-tools { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.goal-tools[hidden], .goal-edit[hidden], #copyFrom[hidden] { display: none; }
.goal-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.goal-edit p { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 13px; }
.goal-tools button, .goal-tools select { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit;
  font-size: 15px; font-weight: 600; color: var(--text); }
.goal-tools select { background: var(--panel); }
.edit-goals { align-self: flex-start; color: var(--muted) !important; }
.edit-goals.send { color: var(--text) !important; background: var(--good); }
dialog select { display: block; width: 100%; margin-top: 4px; font-size: 17px; padding: 10px;
  border-radius: 10px; border: 0; background: var(--bg); color: var(--text); }
.compose { margin-top: 14px; display: flex; gap: 8px; align-items: stretch; }
textarea { flex: 1; resize: none; border: 0; border-radius: 12px; padding: 10px; background: var(--panel);
  color: var(--text); font: inherit; font-size: 17px; }
.compose-actions { display: flex; flex-direction: column; gap: 6px; }
.mic, .send { border: 0; border-radius: 12px; font-size: 18px; font-weight: 700; padding: 8px 14px; color: var(--text); }
.mic { background: var(--panel); }
.mic.rec { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.send { background: var(--good); }

.log { list-style: none; margin: 14px 0; padding: 0; font-size: 14px; }
.log li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 6px 2px; border-bottom: 1px solid #ffffff12; }
.log .txt b { color: var(--muted); font-weight: 600; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .st { font-weight: 700; color: var(--muted); }
.log li[data-state="ack"] .st { color: var(--on); }
.log li[data-state="queued"] .st, .log li[data-state="error"] .st { color: var(--off); }

dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 16px; width: min(90vw, 360px); }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
dialog input { display: block; width: 100%; margin-top: 4px; font-size: 20px; padding: 10px;
  border-radius: 10px; border: 0; background: var(--bg); color: var(--text); }
dialog .code-input { font-size: 28px; text-align: center; letter-spacing: .2em; text-transform: uppercase; }
dialog menu { padding: 0; margin: 12px 0 0; display: flex; flex-direction: row-reverse; gap: 8px; }
dialog menu button { border: 0; border-radius: 10px; padding: 10px 14px; font-size: 16px; font-weight: 600; color: var(--text); }
.plain-btn { background: transparent; }
.danger-btn { background: transparent; color: var(--off) !important; margin-right: auto; }
.danger-btn[hidden] { display: none; }

.alert { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: var(--go); color: #fff; font-size: 34px; font-weight: 800; animation: blink .6s 6 alternate;
  white-space: pre-line; }
.alert[hidden] { display: none; }
.alert small { font-size: 14px; font-weight: 400; opacity: .8; }
@keyframes blink { to { background: var(--danger); } }
.log li[data-state="in"] { background: #c27a0022; }
