/* 檢討點題：共用樣式 */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
[hidden] { display: none !important; }
/* Layout: one phone-width column. Two tabs on top (student / teacher). Student side is a bubble-sheet number grid; teacher side is a ranked bar list. */
:root {
  --bg: #F5F6FB;
  --surface: #FFFFFF;
  --ink: #151A2E;
  --ink-2: #484F6B;
  --muted: #5E6583;
  --line: #DADFEE;
  --line-strong: #B4BBD6;
  --track: #E9ECF6;
  --hover: #F0F2FA;
  --accent: #2B4BD8;
  --on-accent: #FFFFFF;
  --accent-soft: #E7ECFF;
  --bar-lo: #7F95EE;
  --shadow: rgba(20, 26, 46, 0.14);
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1120;
    --surface: #171B2E;
    --ink: #EDF0FB;
    --ink-2: #B6BCD8;
    --muted: #9AA1BF;
    --line: #2B3050;
    --line-strong: #4A5280;
    --track: #222741;
    --hover: #1E2340;
    --accent: #8CA2FF;
    --on-accent: #0E1120;
    --accent-soft: #222B55;
    --bar-lo: #5568B8;
    --shadow: rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1120;
  --surface: #171B2E;
  --ink: #EDF0FB;
  --ink-2: #B6BCD8;
  --muted: #9AA1BF;
  --line: #2B3050;
  --line-strong: #4A5280;
  --track: #222741;
  --hover: #1E2340;
  --accent: #8CA2FF;
  --on-accent: #0E1120;
  --accent-soft: #222B55;
  --bar-lo: #5568B8;
  --shadow: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
*, *::before, *::after { box-sizing: border-box; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding-block: 20px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; text-wrap: balance; }
h2 { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 700; text-wrap: balance; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }
p { margin: 0; }
.sub { margin-top: 4px; color: var(--ink-2); }
.meta { font-size: 13px; color: var(--muted); }



.card {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.panel { display: grid; gap: 14px; }
.card-head { display: grid; gap: 2px; }

/* student: bubble sheet */
.allgood {
  min-height: 48px;
  padding: 8px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: 500 15px var(--font-body);
  cursor: pointer;
}
.allgood[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}
.allgood[aria-pressed="true"]::before { content: "✓ "; color: var(--accent); }
.groups { display: grid; gap: 20px; }
.group { display: grid; gap: 10px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bubbles { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 10px; }
.bubble {
  width: 100%;
  max-width: 60px;
  aspect-ratio: 1;
  justify-self: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font: 600 17px/1 var(--font-num);
  cursor: pointer;
  transition: background-color 0.12s;
}
.bubble[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.anon { padding: 0 4px; font-size: 13px; color: var(--muted); }

.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-top: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.submit-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}
.submit-info { min-width: 0; display: grid; }
.submit-info strong { font-size: 17px; }
.primary {
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: 700 16px var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}
.primary:disabled { background: var(--track); color: var(--muted); cursor: default; }
.ghost {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 500 14px var(--font-body);
  cursor: pointer;
}

/* teacher */
.summary { gap: 12px; }
.big { display: flex; align-items: baseline; gap: 8px; }
#n-resp { font: 600 44px/1 var(--font-num); font-variant-numeric: tabular-nums; }
.big .unit { color: var(--ink-2); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.seg { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 12px; background: var(--track); }
.seg button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: 500 14px var(--font-body);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px var(--shadow); }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 1fr) 5rem;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--hover); }
.q { display: flex; align-items: baseline; gap: 6px; }
.q-g { font-size: 12px; color: var(--muted); }
.q-n { font: 600 17px var(--font-num); }
.track { height: 10px; border-radius: 2px; background: var(--track); overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--bar-lo); }
.fill.hi { background: var(--accent); }
.cnt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cnt b { font: 600 17px var(--font-num); }
.cnt small { font-size: 12px; color: var(--muted); }
.row.done { opacity: 0.55; }
.row.done .q-n { text-decoration: line-through; }
.row.done .q::before { content: "✓"; color: var(--accent); font-weight: 700; }
.empty { padding: 20px 8px; text-align: center; color: var(--muted); }
.zero { margin-top: 4px; padding: 12px 6px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* setup */
.setup { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.setup > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 8px 16px;
  list-style: none;
  font-weight: 700;
  cursor: pointer;
}
.setup > summary::-webkit-details-marker { display: none; }
.setup > summary .meta { margin-left: auto; font-weight: 400; }
.setup > summary > span:first-child { white-space: nowrap; }
.setup > summary .meta { min-width: 0; text-align: right; }
.setup > summary::after { content: "▾"; color: var(--muted); }
.setup[open] > summary::after { content: "▴"; }
.setup-body { display: grid; gap: 14px; padding: 4px 16px 16px; }
.grow { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.grow-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.hint { min-height: 1.2em; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 500 14px var(--font-body);
  cursor: pointer;
}
.bubble.long { font-size: 13px; }
.nl { display: grid; gap: 8px; }
.nl label { font-weight: 700; }
.nl textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  resize: vertical;
}
.manual { border-top: 1px solid var(--line); padding-top: 4px; }
.manual > summary { display: flex; align-items: center; min-height: 44px; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.manual-body { display: grid; gap: 14px; padding-top: 6px; }
.end-session { display: grid; gap: 6px; justify-items: start; padding: 4px 2px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 400 16px var(--font-body);
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: 400 22px/1 var(--font-body);
  cursor: pointer;
}
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.gate { max-width: 420px; margin: 8vh auto 0; }
.gate input { width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); font: 400 16px var(--font-body); }
.err { min-height: 1.4em; font-size: 14px; color: var(--ink); }
.net { font-size: 13px; color: var(--muted); min-height: 1.4em; }
