:root {
  --bg: #111214; --fg: #e8e8e8; --muted: #9a9a9a; --card: #1b1c1f; --line: #2c2d31;
  --accent: #4c8dff; --anchor: #ff3b30; --mark: #55575c;
  --word-size: 56px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
[data-theme="light"] { --bg: #fafafa; --fg: #141414; --muted: #666; --card: #fff; --line: #ddd; --mark: #b5b5b5; }
[data-theme="contrast"] { --bg: #000; --fg: #fff; --muted: #ccc; --card: #0a0a0a; --line: #444; --mark: #fff; --anchor: #ffd400; }
[data-theme="sepia"] { --bg: #f1e7d0; --fg: #3b2f1e; --muted: #7a6a52; --card: #f8f1e0; --line: #d9ccb0; --mark: #9c8c6a; --anchor: #b3261e; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
body { padding-top: var(--safe-top); }
h1 { font-size: 20px; margin: 0; } h2 { font-size: 16px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
p { margin: 6px 0; } .muted { color: var(--muted); } .small { font-size: 13px; }
button, select, input, textarea { font: inherit; color: inherit; }
.view { display: none; min-height: 100%; } .view.active { display: block; }
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.bar h1, .bar h2 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad { padding: 16px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.file input { display: none; }
.icon { background: none; border: 0; font-size: 20px; padding: 6px 10px; cursor: pointer; color: var(--fg); }
textarea, input[type=text] { width: 100%; margin: 8px 0; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
details summary { cursor: pointer; margin: 10px 0 4px; }
.list .item { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); margin-bottom: 8px; }
.list.compact .item { padding: 8px 10px; margin-bottom: 4px; }
.list .item .grow { flex: 1; min-width: 0; } .list .item .title { font-weight: 600; } .list .item .sub { color: var(--muted); font-size: 13px; }
.list .item.dim { opacity: .5; }
.group { margin: 10px 0; } .group h4 { margin: 8px 0 4px; font-size: 14px; }
.group .blk { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-left: 3px solid var(--line); margin: 4px 0; font-size: 14px; }
.group .blk.hidden-blk { opacity: .55; border-left-color: var(--anchor); }
.group .blk .txt { flex: 1; } .group .blk button { font-size: 12px; padding: 4px 8px; }
.warn { background: #5a3b00; color: #ffe2b0; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 14px; }

/* ===== leitor ===== */
#view-reader { position: fixed; inset: 0; display: none; flex-direction: column; }
#view-reader.active { display: flex; }
.stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.redicle { position: relative; width: 100%; height: calc(var(--word-size) * 2.2); display: flex; align-items: center; overflow: visible; }
.redicle::before, .redicle::after { content: ""; position: absolute; left: 50%; width: 2px; height: calc(var(--word-size) * 0.45); background: var(--mark); transform: translateX(-1px); }
.redicle::before { top: 0; } .redicle::after { bottom: 0; }
.word { position: absolute; left: 0; white-space: nowrap; font-size: var(--word-size); font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif; line-height: 1; will-change: transform; }
.word .anc { color: var(--anchor); }
.word.title { position: static; white-space: normal; text-align: center; width: 100%; font-size: calc(var(--word-size) * 0.55); line-height: 1.2; padding: 0 20px; font-style: italic; }
.word.overflow { outline: 1px dashed var(--anchor); }
.progress { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--line); }
#progress-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); width: 0; }
#progress-max { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); opacity: .3; width: 0; }
.label { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--muted); pointer-events: none; }
.pill { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; pointer-events: none; }
.controls { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.ctl { min-width: 52px; height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 22px; cursor: pointer; }
.ctl.big { min-width: 76px; font-size: 26px; background: var(--accent); color: #fff; border-color: var(--accent); }
.ppm { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; font-size: 18px; }
.sentence-panel { position: absolute; left: 0; right: 0; bottom: calc(72px + var(--safe-bottom)); max-height: 45%; overflow: auto; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line); font-size: 17px; line-height: 1.5; z-index: 1; }
.sentence-panel .prev, .sentence-panel .next { color: var(--muted); font-size: 15px; }
.sentence-panel .cur .w.on { background: var(--anchor); color: #fff; border-radius: 3px; padding: 0 2px; }
.sentence-panel .w.has-note { text-decoration: underline dotted; cursor: pointer; }
.sentence-panel sup { color: var(--accent); font-size: 11px; }
.note-box { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: var(--card); }
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--bg); border-left: 1px solid var(--line); overflow: auto; z-index: 3; }
.panel label { display: block; margin: 10px 0; } .panel select, .panel input[type=range] { width: 100%; margin-top: 4px; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; z-index: 9; max-width: 90%; }
@media (orientation: landscape) and (max-height: 500px) { .controls { padding-top: 6px; padding-bottom: calc(6px + var(--safe-bottom)); } .ctl { height: 42px; } }
