:root {
  --bg: #070b14; --bg2: #0d1424; --card: #121b30; --card2: #182440; --line: #22304f;
  --text: #e8eefc; --muted: #93a2c4; --accent: #2dd4bf; --accent2: #22d3ee; --coral: #fb7185;
  --on-accent: #04201d; --danger: #f43f5e; --ok: #34d399;
  --hl-yellow: rgba(250, 204, 21, .30); --hl-green: rgba(52, 211, 153, .30); --hl-blue: rgba(56, 189, 248, .30);
  --hl-pink: rgba(244, 114, 182, .32); --hl-orange: rgba(251, 146, 60, .32);
  --read-size: 19px; --read-font: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --ui-font: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 62px;
}
:root[data-theme="light"] {
  --bg: #f6f8fc; --bg2: #ffffff; --card: #ffffff; --card2: #eef2fa; --line: #d9e1f0;
  --text: #0f1a30; --muted: #5a6a8a; --accent: #0d9488; --accent2: #0891b2; --coral: #e11d48;
  --on-accent: #ffffff;
  --hl-yellow: rgba(250, 204, 21, .45); --hl-green: rgba(16, 185, 129, .30); --hl-blue: rgba(14, 165, 233, .28);
  --hl-pink: rgba(236, 72, 153, .26); --hl-orange: rgba(249, 115, 22, .30);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui-font); }
body { overscroll-behavior: none; }
body.noscroll { overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; background: var(--bg); position: relative; }
#view { flex: 1; overflow-y: auto; overflow-x: hidden; padding: calc(var(--safe-t) + 0px) 0 24px; outline: none; -webkit-overflow-scrolling: touch; }
a { color: var(--accent2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.noscript { padding: 24px; }

/* tab bar */
#tabs { display: flex; border-top: 1px solid var(--line); background: var(--bg2); padding-bottom: var(--safe-b); height: calc(var(--tab-h) + var(--safe-b)); flex: none; }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; min-height: 48px; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.active { color: var(--accent); }
#tabs a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* generic */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(var(--safe-t) + 10px) 14px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.top h1 { font-size: 19px; flex: 1; }
.pad { padding: 14px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.gap { gap: 10px; margin-top: 14px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pre-wrap { white-space: pre-wrap; }
.btn { border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 10px 14px; cursor: pointer; min-height: 44px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--on-accent); border: 0; font-weight: 650; }
.btn.danger { background: var(--danger); color: #fff; border: 0; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 6px 11px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; width: 44px; height: 44px; border-radius: 12px; cursor: pointer; color: var(--text); font-size: 18px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:active, .btn:active { transform: scale(.97); }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 14px; }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin: 10px 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--muted); min-height: 40px; }
.seg button.on { background: var(--card2); color: var(--text); font-weight: 650; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.err { color: var(--coral); }
.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; }

/* reader */
.reader-head { display: flex; gap: 6px; align-items: center; }
.pill { flex: 1; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; cursor: pointer; font-weight: 650; min-height: 44px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill.ver { flex: none; width: 76px; text-align: center; color: var(--accent); text-transform: uppercase; font-size: 14px; }
.plan-banner { margin: 10px 14px 0; padding: 10px 12px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; font-size: 14px; }
.chapter { padding: 8px 18px 120px; font-family: var(--read-font); font-size: var(--read-size); line-height: 1.75; }
.chapter[dir=rtl] { text-align: right; }
.chapter h2 { font-family: var(--ui-font); font-size: 22px; margin: 14px 0 8px; }
.verse { display: inline; border-radius: 4px; cursor: pointer; padding: 1px 0; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.verse sup { font-family: var(--ui-font); font-size: .56em; color: var(--accent); font-weight: 700; margin: 0 .25em 0 .15em; vertical-align: .55em; }
.verse.sel { background: var(--card2); outline: 1px dashed var(--accent); }
.verse.hl-yellow { background: var(--hl-yellow); } .verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); } .verse.hl-pink { background: var(--hl-pink); } .verse.hl-orange { background: var(--hl-orange); }
.verse.has-note::after { content: '✎'; font-family: var(--ui-font); font-size: .6em; color: var(--coral); margin-left: 3px; vertical-align: .3em; }
.verse.flash { animation: flash 2.2s ease-out; }
@keyframes flash { 0%, 55% { background: var(--accent); color: var(--on-accent); } 100% { } }
.chap-nav { display: flex; gap: 10px; margin: 18px 0 0; font-family: var(--ui-font); }
.chap-nav .btn { flex: 1; }
.selbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 10px); width: min(740px, calc(100% - 20px)); background: var(--card2); border: 1px solid var(--line); border-radius: 18px; padding: 10px; z-index: 20; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.selbar .lbl { font-size: 13px; color: var(--muted); margin: 0 4px 8px; }
.selbar .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.selbar .acts .btn { flex: 1; min-width: 70px; padding: 8px 6px; min-height: 40px; font-size: 14px; }
.swatches { display: flex; gap: 10px; margin: 2px 4px 10px; align-items: center; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.sw.yellow { background: #facc15; } .sw.green { background: #34d399; } .sw.blue { background: #38bdf8; } .sw.pink { background: #f472b6; } .sw.orange { background: #fb923c; }
.sw.none { background: transparent; color: var(--muted); font-size: 14px; }

/* lists */
.list { padding: 4px 0; }
.item { margin: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.item .ref { font-weight: 700; color: var(--accent); font-size: 14px; }
.item .txt { font-family: var(--read-font); line-height: 1.55; margin: 6px 0; font-size: 16.5px; }
.item .why { color: var(--muted); font-size: 13px; font-style: italic; margin: 2px 0 8px; }
.item .note { background: var(--card2); border-left: 3px solid var(--coral); padding: 8px 10px; border-radius: 8px; margin: 8px 0; white-space: pre-wrap; font-size: 15px; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.hl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.hl-dot.yellow { background: #facc15; } .hl-dot.green { background: #34d399; } .hl-dot.blue { background: #38bdf8; } .hl-dot.pink { background: #f472b6; } .hl-dot.orange { background: #fb923c; }
mark { background: var(--hl-yellow); color: inherit; border-radius: 3px; padding: 0 1px; }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes sp { to { transform: rotate(360deg); } }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 16px 4px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border: 0; }
.link-list a { display: block; padding: 11px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.link-list a:last-child { border: 0; }

/* sheets */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 14, .66); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(760px, 100%); max-height: 88vh; background: var(--bg2); border: 1px solid var(--line); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .2s ease-out; padding-bottom: var(--safe-b); }
.sheet.tall { height: 88vh; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 18px; }
.sheet-head h2 { font-size: 17px; }
.sheet-body { overflow-y: auto; padding: 6px 18px 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.grid .btn { padding: 8px 0; text-align: center; min-height: 42px; }
.book-btn { text-align: left !important; padding: 10px 12px !important; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 88%; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.ai-answer { background: var(--card2); border-radius: 12px; padding: 12px; white-space: pre-wrap; line-height: 1.5; font-size: 15px; margin-top: 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check label { margin: 0; font-size: 15px; color: var(--text); }
.lock-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
@media (min-width: 761px) { #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* policy pages */
body.doc { height: auto; }
.doc-wrap { max-width: 760px; margin: 0 auto; padding: 22px 18px 60px; line-height: 1.65; }
.doc-wrap h1 { font-size: 26px; margin: 8px 0 4px; }
.doc-wrap h2 { font-size: 18px; margin: 26px 0 6px; color: var(--accent); }
.doc-wrap p, .doc-wrap li { color: var(--text); }
.doc-wrap .meta { color: var(--muted); font-size: 14px; }
.doc-wrap nav { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 18px; font-size: 14px; }
.doc-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.doc-wrap td, .doc-wrap th { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.doc-logo { width: 56px; height: 56px; }
