:root {
  --bg: #faf7f0;
  --panel: #ffffff;
  --ink: #2b2722;
  --muted: #8a8175;
  --line: #e3dccd;
  --accent: #7a5230;
  --accent-soft: #f0e6d6;
  --hi: #c8442b;
  --serif: "Noto Serif CJK TC", "Noto Serif TC", "Songti SC", "宋体", Georgia, serif;
  --sans: "Noto Sans CJK TC", "PingFang TC", "Helvetica Neue", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
}
header {
  padding: 1.4rem 2rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-family: var(--serif); font-size: 1.5rem; letter-spacing: 0.04em; }
header .sub { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.82rem; }
header code { background: var(--accent-soft); padding: 0 0.3em; border-radius: 3px; }

.caveat {
  margin: 0.8rem 2rem 0;
  padding: 0.6rem 0.9rem;
  background: #fff6e9;
  border: 1px solid #e8d4ad;
  border-radius: 7px;
  font-size: 0.78rem;
  color: #6b5840;
}

main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.2rem;
  padding: 1.2rem 2rem;
  align-items: start;
}
@media (max-width: 860px) { main { grid-template-columns: 1fr; } }

.toolbar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.toolbar .lbl { color: var(--muted); font-size: 0.8rem; }
.toolbar button, #renderBtn {
  font-family: var(--sans);
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
}
.toolbar button:hover { background: var(--accent-soft); }
.toolbar .ghost { color: var(--muted); }

textarea {
  width: 100%;
  min-height: 90px;
  font-family: var(--serif);
  font-size: 1.15rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  resize: vertical;
}
#renderBtn {
  margin: 0.6rem 0 1rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  padding: 0.4rem 1.2rem;
  font-size: 0.9rem;
}

.reader {
  font-family: var(--serif);
  font-size: 1.9rem;
  line-height: 2.6;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  min-height: 80px;
}
.han {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
  transition: background 0.12s;
  position: relative;
}
.han:hover { background: var(--accent-soft); }
.han.active { background: var(--hi); color: #fff; }
.han.nohit { color: var(--muted); cursor: default; }
.han.nohit:hover { background: transparent; }
.punct { color: var(--muted); }

.detail {
  position: sticky;
  top: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.detail .hint { color: var(--muted); font-size: 0.85rem; }
.detail .bigchar {
  font-family: var(--serif);
  font-size: 3.2rem;
  line-height: 1;
  color: var(--accent);
}
.detail .gloss { font-size: 0.78rem; color: var(--muted); margin: 0.3rem 0 0.8rem; }

.pron-block { border-top: 1px dashed var(--line); padding-top: 0.7rem; margin-top: 0.7rem; }
.pron-block:first-of-type { border-top: none; }
.pos-desc {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--hi);
  margin-bottom: 0.3rem;
}
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.tag {
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}
.tag b { font-weight: 700; }

.era-group { margin-bottom: 0.5rem; }
.era-label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.15rem; }
.recon-row { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.1rem 0; }
.recon-name { font-size: 0.78rem; color: var(--muted); width: 88px; flex-shrink: 0; }
.recon-val { font-family: var(--serif); font-size: 1.1rem; }
.recon-row.extrap .recon-val { color: #4a6b8a; }
.extrap-badge { font-size: 0.62rem; color: #4a6b8a; border: 1px solid #b8cee0; border-radius: 3px; padding: 0 0.25rem; }

/* ───── 音頻按鈕 ───── */
.audiobar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.vstatus { font-size: 0.72rem; color: var(--muted); }
button.play {
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  font-family: var(--sans);
}
button.play:hover { filter: brightness(1.08); }
button.play.sm { padding: 0.15rem 0.55rem; font-size: 0.74rem; background: #5d7a52; border-color: #5d7a52; }
button.play.playing { animation: pulse 0.8s infinite; }
button.play.err, button.rowplay.err { background: #b34; border-color: #b34; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.livebar { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; margin: 0.2rem 0 0.7rem; padding-bottom: 0.6rem; border-bottom: 1px dashed var(--line); }
.livelbl { font-size: 0.74rem; color: var(--muted); }

.rowplay {
  cursor: pointer;
  margin-left: 0.4rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 0.35rem;
  font-size: 0.7rem;
  line-height: 1.4;
}
.rowplay:hover { background: var(--accent-soft); }
.rowplay.playing { animation: pulse 0.8s infinite; }
.rowplay.recon { color: #3a6b8f; border-color: #bcd4e6; }
.rowplay.recon:hover { background: #e8f1f8; }

footer { padding: 0.6rem 2rem 1.4rem; color: var(--muted); font-size: 0.75rem; }
