:root {
  --bg: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --ok: #22c55e;
  --ok-dark: #15803d;
  --danger: #ef4444;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { min-height: 100dvh; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: .5rem 0 0; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */

input {
  width: 100%;
  font: inherit;
  padding: .75rem .9rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font: inherit;
  font-weight: 600;
  padding: .7rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.small { padding: .4rem .7rem; font-size: .875rem; }
.btn.danger { color: #fca5a5; }
.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.card.center { text-align: center; align-items: center; }

/* ---------- home ---------- */

.home {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.home h1 { font-size: 2.25rem; text-align: center; margin: 0; }
.lead { text-align: center; color: var(--muted); margin: 0; }
.code-input {
  font-size: 2rem;
  text-align: center;
  letter-spacing: .4em;
  text-transform: uppercase;
  font-family: ui-monospace, monospace;
  padding-left: 1.3rem;
}
.my-rooms { list-style: none; margin: 0 0 .25rem; padding: 0; display: grid; gap: .5rem; }
.my-rooms li { display: flex; align-items: center; gap: .75rem; }
.my-rooms .btn { flex: 1; }

/* ---------- student ---------- */

.student {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}
.room-tag { color: var(--muted); margin: 0; }
.room-tag b { color: var(--text); font-family: ui-monospace, monospace; letter-spacing: .1em; }
.task { font-size: 1.25rem; font-weight: 600; margin: 0; }
.big-btn {
  aspect-ratio: 1;
  width: min(80vw, 360px);
  align-self: center;
  border-radius: 50%;
  border: 6px solid var(--accent);
  background: radial-gradient(circle at 50% 35%, #1d4ed8, #1e3a8a);
  color: white;
  font: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  cursor: pointer;
  box-shadow: 0 10px 40px rgb(59 130 246 / .35);
  transition: transform .1s, background .2s, border-color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.big-btn:active:not(:disabled) { transform: scale(.96); }
.big-btn:disabled { opacity: .5; cursor: default; }
.big-btn.done {
  border-color: var(--ok);
  background: radial-gradient(circle at 50% 35%, var(--ok), var(--ok-dark));
  box-shadow: 0 10px 40px rgb(34 197 94 / .4);
}
.big-icon { font-size: 4.5rem; line-height: 1; }
.hint { color: var(--muted); margin: 0; min-height: 1.5em; }
.status { color: #fbbf24; margin: 0; min-height: 1.5em; font-size: .9rem; }

/* ---------- teacher ---------- */

.teacher { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.t-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.25rem;
}
.t-code { display: flex; flex-direction: column; align-items: flex-start; }
.code-big {
  font: 700 2.5rem ui-monospace, monospace;
  letter-spacing: .15em;
  background: none;
  border: 0;
  color: var(--text);
  padding: 0;
  cursor: pointer;
}
.code-big:hover { color: var(--accent); }
.t-count { font-size: 1.1rem; }
.t-count b { font-size: 2.5rem; color: var(--ok); }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: .35rem 0; }
.bar-fill { height: 100%; width: 0; background: var(--ok); transition: width .3s; }
.t-actions { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.task-form { display: flex; gap: .5rem; }
.task-form input { min-width: 14rem; }
.row { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); cursor: pointer; margin-right: auto; }
.toggle input { width: auto; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1rem; }
.cols h3 { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; }
.pill { font-size: .85rem; background: var(--line); border-radius: 99px; padding: .05rem .55rem; }
.pill.ok { background: var(--ok-dark); }
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .5rem;
}
.list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
}
#list-done { counter-reset: n; }
#list-done li { background: rgb(34 197 94 / .15); border-color: var(--ok-dark); counter-increment: n; }
#list-done li::before { content: counter(n); font-weight: 700; color: var(--ok); min-width: 1.4em; }
.list li.offline { opacity: .45; }
.list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list .time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.list .remove {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  padding: 0 .1rem;
}
.list li:hover .remove, .list .remove:focus-visible { opacity: 1; }
@media (hover: none) { .list .remove { opacity: .6; } }
.empty { color: var(--muted); text-align: center; margin: 3rem 0; }

dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: white;
  color: #0f172a;
  max-width: 95vw;
  max-height: 95vh;
}
dialog::backdrop { background: rgb(0 0 0 / .8); }
.projector { padding: 2rem 3rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.projector p { font-size: 1.75rem; margin: 0; }
.code-huge { font: 800 min(22vw, 11rem)/1 ui-monospace, monospace; letter-spacing: .1em; }
.qr { width: min(40vh, 320px); }
.qr svg { width: 100%; height: auto; display: block; }
.projector .btn { background: #e2e8f0; color: #0f172a; border-color: #cbd5e1; }

@media (max-width: 900px) {
  .t-head { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .task-form input { min-width: 0; }
}
