/* 班級期待文字雲 — 簡潔、低彩度、以留白與字級建立層次 */

:root {
  --ink:      #14181d;
  --ink-2:    #4a5560;
  --ink-3:    #838d97;
  --line:     #e3e6ea;
  --line-2:   #eef0f3;
  --bg:       #fbfbfa;
  --surface:  #ffffff;
  --accent:   #1f3d5c;
  --accent-w: #eef2f6;
  --ok:       #3f7a5c;
  --warn:     #9a5b2a;
  --radius:   10px;
  --shadow:   0 1px 2px rgba(20, 24, 29, .04), 0 8px 24px -16px rgba(20, 24, 29, .18);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { line-height: 1.6; }

.wrap { max-width: 900px; margin: 0 auto; padding: 40px 24px 80px; }
.wrap-wide { max-width: 1180px; }

/* ---------- 標題 ---------- */
.eyebrow {
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 10px;
  font-weight: 600;
}
h1 { font-size: 30px; line-height: 1.3; margin: 0 0 8px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 700; letter-spacing: .01em; }
.lede { color: var(--ink-2); margin: 0 0 32px; font-size: 15px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card + .card { margin-top: 0; }
.card-title {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-title h2 { margin: 0; }

/* ---------- 按鈕 ---------- */
button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--line-2); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:disabled:hover { background: var(--surface); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #16304a; border-color: #16304a; }
.btn-lg { font-size: 16px; padding: 14px 28px; border-radius: 9px; }
.btn-danger { color: #9b3b3b; border-color: #e8d9d9; }
.btn-danger:hover { background: #fbf3f3; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 表單 ---------- */
input:not([type="checkbox"]):not([type="radio"]), select {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, button:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label.row { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.field { margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }

.code-input {
  font-size: 30px !important;
  font-weight: 700;
  letter-spacing: .38em;
  text-align: center;
  padding: 14px 12px !important;
  font-variant-numeric: tabular-nums;
}

/* ---------- 選項 chips ---------- */
.cat { margin-bottom: 22px; }
.cat-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .1em;
  color: var(--ink-3); margin-bottom: 10px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.chip[disabled] { opacity: .35; cursor: not-allowed; }
.chip[disabled]:hover { border-color: var(--line); }

/* ---------- 狀態列 ---------- */
.bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 -24px -80px;
}
.bar-inner { max-width: 900px; margin: 0 auto; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.pill.live { color: var(--ok); border-color: #cfe2d7; background: #f4f9f6; }
.pill.hold { color: var(--warn); border-color: #ecdcc9; background: #fbf6f0; }

/* ---------- 大數字 ---------- */
.stat-row { display: flex; gap: 32px; flex-wrap: wrap; }
.stat { min-width: 96px; }
.stat b { display: block; font-size: 30px; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--ink-3); letter-spacing: .06em; }

.roomcode {
  font-size: 46px; font-weight: 800; letter-spacing: .16em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; letter-spacing: .1em; color: var(--ink-3);
  font-weight: 700; padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; width: 56px; }
.wordcell { display: flex; align-items: center; gap: 9px; }
.scroll { max-height: 380px; overflow-y: auto; margin: 0 -10px; }

/* 類別長條 */
.barrow { display: grid; grid-template-columns: 118px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12.5px; }
.barrow > span:first-child { line-height: 1.35; }
.barrow .track { height: 7px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.barrow .fill { height: 100%; border-radius: 999px; }
.barrow .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- 文字雲 ---------- */
.cloud-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
canvas.cloud { display: block; width: 100%; height: 520px; max-width: 100%; }

/* ---------- 投影模式 ---------- */
body.display { background: #fff; }
.display-wrap { height: 100vh; display: flex; flex-direction: column; padding: 28px 36px 22px; overflow: hidden; }
.display-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.display-head h1 { font-size: 24px; margin: 0; }
.display-wrap canvas.cloud { flex: 1 1 0; min-height: 0; height: 0; width: 100%; }
.display-foot { display: flex; align-items: center; justify-content: space-between; color: var(--ink-3); font-size: 14px; padding-top: 12px; }
.joinbig { text-align: center; margin: auto; padding: 0 24px; max-width: 100%; }
.joinbig .roomcode { font-size: 120px; }
.joinbig .url { font-size: 22px; color: var(--ink-2); margin: 12px 0 0; }
.joinurl {
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.15;
  white-space: nowrap;      /* 字級由 JS 量測後縮到剛好一行 */
  font-size: 48px;
}
.display .joinbig .eyebrow { font-size: 17px; letter-spacing: .12em; margin-bottom: 18px; }

/* 教師控制台上的學生網址 */
.urlchip {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent-w);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
}

/* ---------- 雜項 ---------- */
.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 8px;
  padding: 14px 16px; font-size: 14px; color: var(--ink-2); margin-bottom: 18px;
}
.notice.err { border-left-color: #9b3b3b; color: #7e3232; background: #fcf7f7; }
.center { text-align: center; }
.hide { display: none !important; }
.spacer { flex: 1; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

.done-mark {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--accent-w); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; margin: 0 auto 18px;
}

.choice-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.choice-list span {
  font-size: 14px; padding: 7px 14px; border-radius: 999px;
  background: var(--accent-w); color: var(--accent); font-weight: 600;
}

@media (max-width: 620px) {
  .wrap { padding: 28px 18px 80px; }
  h1 { font-size: 24px; }
  .bar { margin: 0 -18px -80px; padding: 12px 18px; }
  .roomcode { font-size: 40px; }
  .stat-row { gap: 22px; }
}

/* ---------- 動畫 ---------- */
@keyframes pop {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}
.pop { animation: pop .42s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes popIn {
  0%   { transform: scale(.4) rotate(-12deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.pop-in { animation: popIn .55s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes riseIn {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
/* 刻意不用 fill-mode 也不加 delay：分頁在背景時 CSS 動畫不會前進，
   一旦用了 both / backwards，內容就會卡在 opacity:0 消失不見。
   投影幕上讓班規消失是不能接受的，寧可少一點層次感。 */
.rise-in > * { animation: riseIn .38s ease; }

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .45; transform: scale(.7); }
}
.pill.live::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; animation: pulseDot 1.4s ease-in-out infinite;
}

.chip { transition: transform .14s cubic-bezier(.34,1.56,.64,1), background .12s ease, border-color .12s ease, color .12s ease; }
.chip:active { transform: scale(.94); }
.barrow .fill { transition: width .55s cubic-bezier(.22,.9,.25,1); }
.stat b { transition: color .2s ease; }

@media (prefers-reduced-motion: reduce) {
  .pop, .pop-in, .rise-in > *, .pill.live::before { animation: none !important; }
  .chip, .barrow .fill { transition: none; }
}

/* 首頁最下方的老師入口：看得到，但不搶戲 */
.teacher-entry { text-align: center; margin: 52px 0 0; }
.teacher-entry a {
  font-size: 12px;
  color: var(--ink-3);
  text-decoration: none;
  letter-spacing: .06em;
  padding: 6px 10px;
  border-radius: 6px;
}
.teacher-entry a:hover { color: var(--ink-2); background: var(--line-2); }

/* ---------- 第二幕：寫作為 ---------- */
.seed-card { transition: opacity .15s ease; }
.seed-card.dimmed { opacity: .42; }
.seed-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; color: var(--ink-2); margin-bottom: 12px;
}
.seed-head b { color: var(--ink); font-weight: 800; font-size: 17px; }

/* ---------- 第二幕：票選提案 ---------- */
.rulerow {
  display: block; width: 100%; text-align: left;
  font-family: inherit; font-size: 15px; font-weight: 500; line-height: 1.5;
  padding: 13px 16px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: normal;
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), background .12s ease, border-color .12s ease, color .12s ease;
}
.rulerow:hover { border-color: var(--ink-3); }
.rulerow:active { transform: scale(.985); }
.rulerow[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.rulerow[disabled] { opacity: .35; cursor: not-allowed; }
.rulerow:last-child { margin-bottom: 0; }

/* ---------- 第二幕：我的提案 ---------- */
.myact {
  display: flex; align-items: baseline; gap: 10px; justify-content: center;
  flex-wrap: wrap; font-size: 15px; margin-bottom: 8px;
}
.myact-word {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-w); color: var(--accent); flex: none;
}

/* ---------- 第二幕：班規 ---------- */
.rulelist { list-style: none; counter-reset: rule; margin: 0; padding: 0; }
.rulelist li {
  counter-increment: rule;
  position: relative;
  padding: 14px 0 14px 46px;
  font-size: 17px; font-weight: 600; line-height: 1.6;
  border-bottom: 1px solid var(--line-2);
}
.rulelist li:last-child { border-bottom: 0; }
.rulelist li::before {
  content: counter(rule);
  position: absolute; left: 0; top: 13px;
  width: 30px; text-align: center;
  font-size: 20px; font-weight: 800;
  color: var(--mark, var(--accent));
}

/* ---------- 教師控制台：分幕流程 ---------- */
.flowrow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.flowlabel {
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
  color: var(--ink-2); line-height: 1.4; flex: none; min-width: 54px;
}
.flowlabel .muted { font-weight: 600; font-size: 11px; letter-spacing: 0; }

/* ---------- 教師控制台：提案清單 ---------- */
.actrow {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid var(--line-2);
  font-size: 14px;
}
.actrow:last-child { border-bottom: 0; }
.actrow.off { opacity: .4; text-decoration: line-through; }
.actrow .actvotes {
  flex: none; width: 26px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent);
}
.actrow .acttext { flex: 1; line-height: 1.5; }
.actrow button { padding: 3px 8px; font-size: 12px; flex: none; }

/* ---------- 投影：第二幕 ---------- */
.seedwords {
  display: flex; flex-wrap: wrap; gap: 16px 40px; justify-content: center;
  font-size: clamp(30px, 7vh, 78px); font-weight: 800; letter-spacing: -.01em;
}
.ruleboard {
  flex: 1 1 0; min-height: 0; display: flex; align-items: center;
  padding: 0 6vw; overflow: hidden;
}
.ruleboard .rulelist { width: 100%; }
.rulelist.big li {
  padding: .45em 0 .45em 1.7em;
  font-size: 1em; font-weight: 700;
}
.rulelist.big li::before { width: 1.2em; top: .45em; font-size: 1.05em; }

/* 內容一模一樣的提案：票數會被拆開，老師要一眼看得到 */
.actrow.dup .acttext::after {
  content: '重複';
  font-size: 11px; font-weight: 700; color: var(--warn);
  border: 1px solid #ecdcc9; background: #fbf6f0;
  border-radius: 999px; padding: 1px 7px; margin-left: 8px;
  vertical-align: 1px;
}

/* 票選時每一群的完成狀態 */
#voteList .cat-head { font-size: 13px; }
#voteList .cat-head.done { color: var(--ok); }
.pickstate { font-weight: 600; letter-spacing: 0; text-transform: none; }

/* 投影模式：遮住學生此刻還不該看到的東西 */
.veiled { display: none !important; }
.veil {
  margin: 0; padding: 22px 16px; text-align: center;
  font-size: 13px; color: var(--warn);
  background: #fbf6f0; border: 1px dashed #e6d5c2; border-radius: 9px;
}

/* 班規：可當場微調的清單 */
.rulerow-edit {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-bottom: 1px solid var(--line-2); font-size: 15px;
}
.rulerow-edit:last-child { border-bottom: 0; }
.rulerow-edit .rulenum { flex: none; width: 22px; font-weight: 800; font-size: 17px; }
.rulerow-edit .ruletext { flex: 1; font-weight: 600; line-height: 1.5; }
.rulerow-edit button { padding: 3px 8px; font-size: 12px; flex: none; }

.projtoggle {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
  background: var(--surface);
}

/* 預覽模式的提示條 */
.previewbar {
  position: sticky; top: 0; z-index: 20;
  background: #fbf6f0; color: var(--warn);
  border-bottom: 1px solid #ecdcc9;
  font-size: 13px; font-weight: 600;
  padding: 9px 18px; text-align: center;
}
body.has-previewbar .wrap { padding-top: 26px; }

/* 浮動錯誤提示：控制台很長，訊息不能只放在最上面 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  max-width: min(520px, calc(100vw - 32px));
  background: #7e3232; color: #fff;
  font-size: 14px; font-weight: 600; line-height: 1.5;
  padding: 12px 18px; border-radius: 9px;
  box-shadow: 0 8px 28px -10px rgba(20, 24, 29, .5);
  opacity: 0; pointer-events: none; z-index: 50;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- 教師控制台：導引卡 ---------- */
.nowcard { border-color: #d6dce3; box-shadow: var(--shadow); }

.stepper {
  display: flex; flex-wrap: wrap; gap: 4px 6px;
  list-style: none; margin: 0 0 22px; padding: 0;
}
.stepper li {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  padding: 5px 12px 5px 6px; border-radius: 999px;
  background: var(--line-2);
}
.stepper .dotnum {
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; color: var(--ink-3);
  font-size: 11px; font-weight: 800; flex: none;
}
.stepper li.done { color: var(--ok); background: #f1f7f4; }
.stepper li.done .dotnum { background: var(--ok); color: #fff; }
.stepper li.at { color: #fff; background: var(--accent); }
.stepper li.at .dotnum { background: #fff; color: var(--accent); }

.nowbody { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.nowmain { flex: 1 1 340px; }
.nowmain h2 { font-size: 22px; line-height: 1.35; margin: 0 0 10px; }
.nowtodo { font-size: 15px; color: var(--ink-2); line-height: 1.7; margin: 0; }

.nowside { flex: 0 0 210px; display: flex; flex-direction: column; gap: 10px; }
.sidebox {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 13px;
  font-size: 13px; color: var(--ink); line-height: 1.5;
}
.sidelabel {
  display: block; font-size: 10px; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 700; margin-bottom: 3px;
}

.manual { margin-top: 18px; border-top: 1px solid var(--line-2); padding-top: 14px; }
.manual > summary {
  cursor: pointer; font-size: 12px; color: var(--ink-3);
  font-weight: 600; list-style: none;
}
.manual > summary::-webkit-details-marker { display: none; }
.manual > summary::before { content: '▸ '; }
.manual[open] > summary::before { content: '▾ '; }

/* 第一次使用的三件事 */
.firstrun { border-left: 3px solid var(--accent); }
.checklist { margin: 0; padding-left: 22px; font-size: 14px; color: var(--ink-2); line-height: 1.75; }
.checklist li { margin-bottom: 8px; }
.checklist li:last-child { margin-bottom: 0; }
.checklist b { color: var(--ink); }

details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '＋'; color: var(--ink-3); font-size: 15px; }
details.card[open] > summary::after { content: '－'; }

@media (max-width: 720px) {
  .nowside { flex: 1 1 100%; flex-direction: row; }
  .sidebox { flex: 1; }
}

/* 學生要抄的網址 —— 白板上要看得清楚 */
.bigurl {
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--accent);
  line-height: 1.25;
  word-break: break-all;
}

/* 還沒寫的提案卡 */
.seed-todo {
  font-size: 11px; font-weight: 700; color: var(--warn);
  border: 1px solid #ecdcc9; background: #fbf6f0;
  border-radius: 999px; padding: 2px 9px; flex: none;
}
@keyframes flashCard {
  0%   { box-shadow: 0 0 0 0 rgba(154, 91, 42, .45); }
  100% { box-shadow: 0 0 0 10px rgba(154, 91, 42, 0); }
}
.flash { animation: flashCard .7s ease-out; border-color: #e0c9ae; }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* 學生頁底部有固定工具列，提示要浮在它上面 */
.toast.above-bar { bottom: 88px; }
