/* 題目牆：跟入門課簡報同一套風格。米白紙底、墨色字、朱紅重點、方角面板。 */
:root {
  --paper: #F7F3EA;
  --white: #FFFFFF;
  --sand: #EDE6D8;
  --rule: #D8D0C0;
  --ink: #1D1B18;
  --body: #2B2823;
  --mute: #5E574C;
  --red: #D9432A;
  --red-dk: #B8341F;
  --coral: #F2836B;
  --dark2: #2A2722;
  --dark-rule: #3D3832;
  --on-dark: #F7F3EA;
  --on-dark-soft: #E6DFD2;
  --on-dark-mute: #CFC7B8;
  --font: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", system-ui, sans-serif;
  --num: "Times New Roman", Times, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--body); background: var(--paper); line-height: 1.6; }
button, input, textarea { font: inherit; color: inherit; border-radius: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

/* ---------- 共用元件 ---------- */
.topbar { height: 6px; background: var(--red); }
.eyebrow { display: flex; align-items: center; gap: .55rem; font-size: .85rem; font-weight: 700; letter-spacing: .08em; color: var(--mute); }
.eyebrow .sq { width: .7rem; height: .7rem; background: var(--red); flex: none; }

.btn { border: 1px solid var(--ink); background: var(--ink); color: var(--paper); padding: .7rem 1.2rem; font-weight: 700; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dk); border-color: var(--red-dk); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red-dk); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { display: block; width: 100%; padding: .9rem 1rem; font-size: 1.1rem; }

.field { display: block; margin-top: 1.4rem; }
.field > .label { display: block; font-weight: 700; color: var(--ink); margin-bottom: .45rem; }
.field > .label small { font-weight: 400; color: var(--mute); margin-left: .4rem; }
input[type="text"], input[type="password"], textarea {
  display: block; width: 100%; padding: .7rem .8rem; font-size: 1rem;
  border: 1px solid var(--rule); background: var(--white); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.counter { text-align: right; font-size: .85rem; color: var(--mute); margin-top: .25rem; }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { border: 1px solid var(--rule); background: var(--sand); color: var(--ink); padding: .5rem .85rem; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.notice { border-left: .3rem solid var(--red); padding: .15rem 0 .15rem .8rem; margin-top: 1.6rem; color: var(--ink); font-size: .95rem; }
.error { color: var(--red-dk); font-weight: 700; min-height: 1.6em; margin: .6rem 0 0; }

/* ---------- 手機填寫頁、管理頁 ---------- */
.sheet { max-width: 36rem; margin: 0 auto; padding: 1.4rem 1.25rem 3rem; }
.sheet.wide { max-width: 54rem; }
.sheet h1 { font-size: 1.55rem; line-height: 1.4; color: var(--ink); margin: .7rem 0 .3rem; font-weight: 800; text-wrap: balance; word-break: auto-phrase; }
.sheet .hint { color: var(--mute); margin: 0; }
.sheet .submit { margin-top: .4rem; }
.dept-other { margin-top: .5rem; }
.done { margin-top: 2rem; border-top: .35rem solid var(--red); background: var(--white); border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 1.4rem 1.2rem; }
.done h2 { margin: 0 0 .3rem; color: var(--ink); font-size: 1.4rem; }
.done p { margin: 0 0 1.1rem; }

.walls { list-style: none; margin: 1.2rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.walls li { background: var(--white); border: 1px solid var(--rule); border-top: .3rem solid var(--red); padding: .9rem 1rem; }
.walls .w-title { font-weight: 800; color: var(--ink); font-size: 1.1rem; }
.walls .w-meta { color: var(--mute); font-size: .9rem; }
.walls .w-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .4rem; }
.walls a, .sheet a { color: var(--red-dk); font-weight: 700; }
.new-wall { margin-top: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.new-wall h2 { margin: 0; font-size: 1.15rem; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

/* ---------- 主持人代碼 ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; background: var(--ink); color: var(--on-dark); padding: 1.5rem; }
.gate form { width: min(24rem, 100%); display: flex; flex-direction: column; gap: .8rem; }
.gate h1 { margin: 0; font-size: 1.8rem; }
.gate p { margin: 0; color: var(--on-dark-mute); }
.gate .error { color: var(--coral); }
.gate .eyebrow { color: var(--on-dark-mute); }

/* ---------- 投影牆面 ---------- */
/* 字級跟著螢幕的寬和高一起縮放，左欄在 16:9 的投影畫面上剛好放得下七、八個分類 */
.wall-page { font-size: clamp(14px, min(1.12vw, 1.95vh), 26px); }
.board { display: grid; grid-template-columns: minmax(19rem, 27%) 1fr; height: 100vh; }

.rail { background: var(--ink); color: var(--on-dark); padding: 1.6rem 1.7rem 1.2rem; display: flex; flex-direction: column; gap: 1rem; overflow: auto; }
.rail .eyebrow { color: var(--on-dark-mute); }
.rail h1 { font-size: 1.5rem; line-height: 1.42; margin: 0; font-weight: 800; text-wrap: balance; word-break: auto-phrase; }
.qr-row { display: flex; gap: 1rem; align-items: center; }
.qr-btn { border: 0; padding: .3rem; background: #fff; flex: none; line-height: 0; }
.qr-btn img { width: 7.8rem; height: 7.8rem; display: block; }
.qr-text { min-width: 0; }
.qr-text .how { font-weight: 800; color: var(--coral); font-size: 1.05rem; }
.qr-text .url { color: var(--on-dark-soft); font-size: .9rem; overflow-wrap: anywhere; margin-top: .2rem; }
.count { display: flex; align-items: baseline; gap: .5rem; border-top: 1px solid var(--dark-rule); padding-top: .8rem; }
.count b { font-family: var(--num); font-size: 3.2rem; line-height: 1; color: var(--coral); }
.count span { color: var(--on-dark-soft); font-weight: 700; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .1rem; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; color: var(--on-dark-soft); padding: .24rem .5rem .36rem; }
.bar:hover { background: var(--dark2); }
.bar.active { background: var(--dark2); border-color: var(--coral); color: var(--on-dark); }
.bar-name { font-weight: 700; }
.bar-n { font-family: var(--num); font-weight: 700; font-size: 1.15rem; line-height: 1.3; color: var(--on-dark); }
.bar .track { grid-column: 1 / -1; height: .34rem; background: var(--dark-rule); display: block; }
.bar .fill { display: block; height: 100%; background: var(--red); }
.bar.none .bar-name { font-weight: 400; color: var(--on-dark-mute); }
.bar.none .fill { background: var(--on-dark-mute); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.8rem .8rem; border-bottom: 1px solid var(--rule); }
.toolbar h2 { margin: 0; font-size: 1.35rem; color: var(--ink); display: flex; align-items: baseline; gap: .7rem; }
.toolbar h2 small { font-size: .9rem; font-weight: 400; color: var(--mute); }
.tools { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; align-items: center; }
.tool { font-size: .8rem; padding: .35rem .7rem; border: 1px solid var(--rule); background: transparent; color: var(--mute); }
.tool:hover { border-color: var(--ink); color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tool.closed { border-color: var(--red); color: var(--red-dk); }
.offline { font-size: .8rem; color: var(--red-dk); font-weight: 700; }

.cards { flex: 1; overflow: auto; padding: 1.3rem 1.8rem 2rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; align-content: start; }
.card { background: var(--white); border: 1px solid var(--rule); border-top: .32rem solid var(--red); padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .7rem; }
.card .text { font-size: 1.22rem; line-height: 1.5; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; text-wrap: balance; }
.card .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }
.tag { font-size: .8rem; font-weight: 700; padding: .12rem .5rem; background: var(--sand); color: var(--ink); }
.tag.cat { background: var(--ink); color: var(--paper); }
.tag.none { background: transparent; outline: 1px dashed var(--rule); color: var(--mute); font-weight: 400; }
.tag.hid { background: var(--red); color: #fff; }
.card.is-hidden { opacity: .45; }
.card.is-new { animation: pop 1.2s ease-out; }
@keyframes pop { from { transform: translateY(-.6rem); background: #FBE3DD; } to { transform: none; background: var(--white); } }
.editing .card { cursor: pointer; }
.editing .card:hover { border-color: var(--ink); }
.empty { padding: 3rem 1.8rem; color: var(--mute); font-size: 1.2rem; }

/* ---------- 對話框 ---------- */
dialog { border: 0; padding: 0; background: var(--paper); color: var(--body); width: min(46rem, 92vw); max-height: 92vh; box-shadow: 0 1rem 3rem rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(29, 27, 24, .62); }
.dlg { padding: 1.5rem 1.8rem 1.6rem; border-top: .4rem solid var(--red); }
#pick-body:focus { outline: none; }
.dlg h3 { margin: 0 0 .2rem; color: var(--ink); font-size: 1.25rem; }
.dlg-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.3rem; align-items: center; }
.dlg-actions .spacer { flex: 1; }
.dlg .small { font-size: .85rem; color: var(--mute); }
.pick-text { font-size: 1.55rem; font-weight: 800; color: var(--ink); line-height: 1.45; margin: .5rem 0 .3rem; overflow-wrap: anywhere; text-wrap: balance; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: .5rem; margin: 1.1rem 0 0; }
.cat-btn { display: flex; gap: .6rem; align-items: center; padding: .65rem .8rem; border: 1px solid var(--rule); background: var(--white); font-size: 1.05rem; font-weight: 700; text-align: left; color: var(--ink); }
.cat-btn:hover { border-color: var(--ink); }
.cat-btn kbd { font-family: var(--num); font-weight: 700; color: var(--red); font-size: 1.25rem; min-width: 1ch; }
.cat-btn.current { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cat-btn.current kbd { color: var(--coral); }
.qr-big { padding: 1.5rem; text-align: center; background: #fff; }
.qr-big img { width: min(70vh, 80vw); height: auto; display: block; margin: 0 auto; }
.qr-big p { margin: .6rem 0 0; font-size: 1.3rem; font-weight: 800; color: var(--ink); overflow-wrap: anywhere; }
.danger-zone { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--rule); display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* 小螢幕（主持人用筆電視窗或手機看牆面時） */
@media (max-width: 820px) {
  .board { grid-template-columns: 1fr; height: auto; }
  .main { height: auto; }
  .rail { overflow: visible; }
  .cards { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) { .card.is-new { animation: none; } }
