:root {
  --paper: #f4efe3;
  --paper-2: #fbf8f1;
  --paper-3: #ebe3d1;
  --ink: #1f2226;
  --ink-2: #4a4d52;
  --ink-3: #7a7468;
  --rule: #d8ccb2;
  --navy: #1d3557;
  --navy-ink: #f4efe3;
  --seal: #b8312f;
  --seal-soft: rgba(184, 49, 47, 0.1);
  --gold: #a87b1f;
  --focus: #2f6fd6;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.08), 0 6px 18px rgba(60, 45, 20, 0.06);
  --radius: 6px;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181f;
    --paper-2: #1b2029;
    --paper-3: #232a35;
    --ink: #ebe5d8;
    --ink-2: #c3bcae;
    --ink-3: #8f897d;
    --rule: #333b48;
    --navy: #8fb0e0;
    --navy-ink: #10141a;
    --seal: #e0605a;
    --seal-soft: rgba(224, 96, 90, 0.14);
    --gold: #d6aa4e;
    --focus: #7fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.75 var(--sans);
  overflow-x: hidden;
}

a { color: var(--navy); }
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 頂部免責 ─────────────────────────── */
.disclaimer {
  background: var(--seal);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 16px;
  text-align: center;
}
.disclaimer strong {
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 0 6px;
  margin-right: 4px;
  font-weight: 700;
}

/* ── 刊頭 ─────────────────────────────── */
.masthead { border-bottom: 3px double var(--rule); background: var(--paper-2); }
.masthead-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font: 900 30px/1.1 var(--serif); letter-spacing: 0.12em; }
.brand-sub { font-size: 13px; color: var(--ink-3); }

.seal {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 3px solid var(--seal);
  border-radius: 4px;
  color: var(--seal);
  font: 900 15px/1.05 var(--serif);
  text-align: center;
  transform: rotate(-6deg);
  box-shadow: inset 0 0 0 2px var(--paper-2), inset 0 0 0 3px var(--seal);
}
.seal-lg { width: 84px; height: 84px; font-size: 22px; }

.timer {
  flex: none;
  text-align: right;
  background: var(--navy);
  color: var(--navy-ink);
  border-radius: var(--radius);
  padding: 6px 14px;
  line-height: 1.3;
}
.timer-label { display: block; font-size: 12px; opacity: 0.85; }
.timer-value { font: 700 24px/1.2 var(--serif); font-variant-numeric: tabular-nums; }
.timer-value small { font: 500 13px var(--sans); opacity: 0.85; }

/* ── 廣告 ─────────────────────────────── */
.ad-wrap {
  position: relative;
  max-width: 1160px;
  margin: 16px auto;
  padding: 18px 16px 8px;
  min-height: 110px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--paper-2);
}
.ad-top, .ad-bottom { width: calc(100% - 32px); }
.ad-label {
  position: absolute;
  top: 2px;
  left: 10px;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}
.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
}
.ad-side { margin: 0 0 16px; min-height: 280px; }

/* ── 版面 ─────────────────────────────── */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

.minutes { min-width: 0; }
.minutes-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.minutes-title { margin: 0; font: 900 22px/1.3 var(--serif); letter-spacing: 0.08em; }
.minutes-meta { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }

/* ── 空狀態 ───────────────────────────── */
.empty {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.empty-lead { margin: 0; font: 700 20px/1.4 var(--serif); }
.empty-sub { margin: 4px 0 14px; color: var(--ink-2); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font: 14px/1.4 var(--sans);
  cursor: pointer;
  text-align: left;
}
.preset:hover { border-color: var(--navy); color: var(--navy); }

/* ── 紀錄 ─────────────────────────────── */
.records { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.record { display: flex; flex-direction: column; gap: 8px; }
.speaker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 13px/1.4 var(--sans);
  color: var(--ink-3);
  letter-spacing: 0.06em;
}
.record-q {
  align-self: flex-end;
  max-width: 88%;
  text-align: right;
}
.record-q p {
  margin: 4px 0 0;
  background: var(--navy);
  color: var(--navy-ink);
  border-radius: 14px 14px 2px 14px;
  padding: 10px 14px;
  text-align: left;
  overflow-wrap: anywhere;
}
.record-a {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--seal);
  border-radius: 2px var(--radius) var(--radius) var(--radius);
  padding: 12px 16px 12px;
  box-shadow: var(--shadow);
}
.record-a p {
  margin: 6px 0 0;
  font: 17px/1.85 var(--serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--seal);
  border: 1px solid var(--seal);
  border-radius: 3px;
  padding: 0 4px;
  letter-spacing: 0;
}
.mode-tag:not(:empty)::before { content: "・"; }
.record.is-error .record-a { border-left-color: var(--ink-3); }
.record.is-error .a-text { color: var(--seal); font-family: var(--sans); font-size: 15px; }

.typing::after {
  content: "";
  display: inline-block;
  width: 1.5em;
  text-align: left;
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "．"; } 50% { content: "．．"; } 75% { content: "．．．"; }
}
.typing { color: var(--ink-3); font-family: var(--sans); font-size: 15px; }

.a-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.stamp {
  display: inline-block;
  border: 2px solid var(--seal);
  color: var(--seal);
  font: 900 13px/1.2 var(--serif);
  padding: 2px 6px;
  border-radius: 3px;
  transform: rotate(-4deg);
  letter-spacing: 0.1em;
}
.meter { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.meter-bar { width: 80px; height: 8px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--seal)); transition: width 0.6s ease; }
.meter-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--seal); }
.actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── 分享卡 ───────────────────────────── */
.shared {
  margin-bottom: 24px;
  padding: 12px 14px 14px;
  border: 1px dashed var(--seal);
  border-radius: var(--radius);
  background: var(--seal-soft);
}
.shared-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px; font: 700 14px var(--sans); color: var(--seal);
}
.shared .record { display: flex; flex-direction: column; gap: 8px; }

/* ── 輸入區 ───────────────────────────── */
.composer {
  margin-top: 20px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  box-shadow: var(--shadow);
}
.modes { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.modes legend { font: 700 13px var(--sans); color: var(--ink-3); padding: 0; margin-bottom: 6px; }
.mode-list { display: flex; flex-wrap: wrap; gap: 6px; }
.mode-chip { position: relative; }
.mode-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-chip span {
  display: inline-block;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink-2);
}
.mode-chip input:checked + span { background: var(--seal); border-color: var(--seal); color: #fff; font-weight: 700; }
.mode-chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

textarea {
  width: 100%;
  resize: vertical;
  min-height: 84px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  padding: 10px 12px;
}
textarea[aria-invalid="true"] { border-color: var(--seal); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.hint { font-size: 13px; color: var(--ink-3); }
.hint.over { color: var(--seal); font-weight: 700; }
.form-error {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--seal-soft);
  color: var(--seal);
  font-size: 14px;
}
.turnstile:empty { display: none; }
.turnstile { margin-top: 10px; }

/* ── 按鈕 ─────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 700 15px/1 var(--sans);
  padding: 11px 18px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--seal); color: #fff; }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--rule); font-size: 14px; padding: 8px 12px; }
.btn-ghost:hover { border-color: var(--navy); }
.btn-small { background: var(--paper); color: var(--ink-2); border-color: var(--rule); font-size: 13px; padding: 6px 10px; }
.btn-small:hover { color: var(--navy); border-color: var(--navy); }

/* ── 側欄 ─────────────────────────────── */
.rail { min-width: 0; }
.rail-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.rail-card h2 { margin: 0 0 8px; font: 900 16px/1.4 var(--serif); letter-spacing: 0.06em; }
.mode-help { margin: 0; font-size: 14px; }
.mode-help dt { font-weight: 700; color: var(--seal); }
.mode-help dd { margin: 0 0 6px; color: var(--ink-2); }
.rules { margin: 0; padding-left: 1.2em; font-size: 14px; color: var(--ink-2); }

/* ── 頁尾 ─────────────────────────────── */
.site-foot {
  max-width: 1160px;
  margin: 24px auto 0;
  padding: 18px 16px 40px;
  border-top: 3px double var(--rule);
  font-size: 13px;
  color: var(--ink-3);
}
.site-foot p { margin: 0 0 6px; }

/* ── 文件頁（隱私、關於、404）────────── */
.doc { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.doc h1 { font: 900 28px/1.4 var(--serif); letter-spacing: 0.06em; margin: 12px 0 4px; }
.doc h2 { font: 900 19px/1.4 var(--serif); margin: 28px 0 8px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.doc li { margin-bottom: 6px; }
.doc-meta { color: var(--ink-3); font-size: 14px; margin: 0; }
.doc-center { text-align: center; padding-top: 72px; }
.doc-center .seal { margin-bottom: 12px; }
.doc .btn { display: inline-block; text-decoration: none; margin-top: 12px; }

/* ── 封鎖畫面 ─────────────────────────── */
.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 16, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lock[hidden] { display: none; }
.lock-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--paper-2);
  border: 2px solid var(--seal);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  text-align: center;
}
.lock-card h2 { margin: 14px 0 6px; font: 900 22px/1.4 var(--serif); }
.lock-card p { margin: 0 0 10px; color: var(--ink-2); }
.lock-reasons { font-size: 13px; color: var(--seal) !important; }
.lock-help { text-align: left; margin: 10px 0 16px; font-size: 14px; }
.lock-help summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.lock-help ul { padding-left: 1.2em; margin: 8px 0 0; }
.lock-help li { margin-bottom: 6px; }

/* ── 提示 ─────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
}

/* ── 窄螢幕 ───────────────────────────── */
@media (max-width: 640px) {
  .masthead-inner { padding: 12px 16px; }
  .brand-title { font-size: 24px; }
  .brand-sub { font-size: 12px; }
  .seal { width: 44px; height: 44px; font-size: 12px; }
  .timer { padding: 4px 10px; }
  .timer-value { font-size: 20px; }
  .record-q { max-width: 94%; }
  .record-a p { font-size: 16px; }
  .actions { margin-left: 0; }
  .composer-foot { flex-direction: column; align-items: stretch; }
  .composer-foot .btn { width: 100%; }
  .minutes-title { font-size: 19px; }
}
@media (max-width: 420px) {
  .brand-sub { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .typing::after { animation: none; content: "．．．"; }
  .meter-fill { transition: none; }
}
