/* Theophi — cathedral at night (dark, default) / vellum (light).
   Gold = theology, verdigris = philosophy, amethyst = the edges, garnet = doubt. */
:root {
  --bg: #0e1220; --bg2: #141929; --card: #181e30; --card2: #1f2639; --line: #2a3147;
  --fg: #ece6d6; --fg2: #a9a596; --fg3: #7d7a70;
  --theo: #d9a84a; --theo-soft: rgba(217,168,74,.14);
  --phil: #5fbdb5; --phil-soft: rgba(95,189,181,.14);
  --edge: #b09ad8; --edge-soft: rgba(176,154,216,.14);
  --doubt: #d98181; --doubt-soft: rgba(217,129,129,.14);
  --ok: #7fc89a;
  --hdr: rgba(14,18,32,.88); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.35);
  --display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) {
  --bg: #f3eee2; --bg2: #ebe4d3; --card: #faf7ef; --card2: #f0e9d8; --line: #d9d0ba;
  --fg: #1e2230; --fg2: #5b5f6d; --fg3: #8a8c94;
  --theo: #a3721c; --theo-soft: rgba(163,114,28,.12);
  --phil: #1f7d76; --phil-soft: rgba(31,125,118,.12);
  --edge: #6a5a9a; --edge-soft: rgba(106,90,154,.12);
  --doubt: #a33d3d; --doubt-soft: rgba(163,61,61,.12);
  --ok: #2f7d4f;
  --hdr: rgba(243,238,226,.9); --shadow: 0 1px 2px rgba(30,30,40,.06), 0 8px 24px rgba(30,30,40,.08);
  color-scheme: light; } }
:root[data-theme="light"] {
  --bg: #f3eee2; --bg2: #ebe4d3; --card: #faf7ef; --card2: #f0e9d8; --line: #d9d0ba;
  --fg: #1e2230; --fg2: #5b5f6d; --fg3: #8a8c94;
  --theo: #a3721c; --theo-soft: rgba(163,114,28,.12);
  --phil: #1f7d76; --phil-soft: rgba(31,125,118,.12);
  --edge: #6a5a9a; --edge-soft: rgba(106,90,154,.12);
  --doubt: #a33d3d; --doubt-soft: rgba(163,61,61,.12);
  --ok: #2f7d4f;
  --hdr: rgba(243,238,226,.9); --shadow: 0 1px 2px rgba(30,30,40,.06), 0 8px 24px rgba(30,30,40,.08);
  color-scheme: light; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.5;
  padding-bottom: calc(72px + env(safe-area-inset-bottom)); min-height: 100%; }
b { font-weight: 600; }
button { font-family: inherit; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--c, var(--theo)); outline-offset: 2px; }

/* header */
header { position: sticky; top: 0; z-index: 10; background: var(--hdr); backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; min-height: 52px; }
header h1 { font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: .01em; line-height: 1; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbtn { background: none; border: 1px solid transparent; color: var(--fg2); width: 36px; height: 36px; border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.hbtn:hover { border-color: var(--line); color: var(--fg); }
#back { font-size: 30px; padding-bottom: 4px; }
.hdr-right { display: flex; gap: 4px; }

main { max-width: 720px; margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left)); }

/* bottom tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--hdr); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { flex: 1; background: none; border: none; color: var(--fg3); padding: 8px 0 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button i { font-style: normal; font-size: 19px; line-height: 1; font-family: var(--display); font-weight: 600; }
.tabs button span { font-size: 10px; font-weight: 600; letter-spacing: .02em; }
.tabs button.active { color: var(--fg); }
.tabs button[data-tab="start"].active { color: var(--ok); }
.tabs button[data-tab="theo"].active { color: var(--theo); }
.t-start { --c: var(--ok); --soft: rgba(127,200,154,.14); }
.rec { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; cursor: pointer; text-align: left; color: var(--fg); width: 100%; border-left: 4px solid var(--c); }
.rec .n { font-family: var(--display); font-size: 30px; font-weight: 600; color: var(--c); line-height: 1; }
.rec .top { display: flex; gap: 12px; align-items: flex-start; }
.rec .top .body { flex: 1; min-width: 0; }
.rec h3 { font-size: 21px; }
.rec .by { font-size: 13.5px; color: var(--fg2); }
.rec .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--fg2); }
.rec .kind { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--c); color: var(--c); }
.rec .path { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--theo); }
.covers { display: flex; gap: 6px; flex-wrap: wrap; }
.covers .pill { font-size: 12px; }
.tabs button[data-tab="phil"].active { color: var(--phil); }
.tabs button[data-tab="edges"].active { color: var(--edge); }
.tabs button[data-tab="doubt"].active { color: var(--doubt); }

/* type */
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--fg3); }
h2.big { font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1.05; margin: 2px 0 6px; text-wrap: balance; }
h3 { font-family: var(--display); font-weight: 600; font-size: 22px; line-height: 1.15; }
.lede { color: var(--fg2); font-size: 15px; line-height: 1.5; }
.q { font-family: var(--display); font-style: italic; font-size: 21px; line-height: 1.25; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--fg2); }
.small { font-size: 13px; }

/* tone per section: sets --c and --soft */
.t-theo { --c: var(--theo); --soft: var(--theo-soft); }
.t-phil { --c: var(--phil); --soft: var(--phil-soft); }
.t-ov   { --c: var(--edge); --soft: var(--edge-soft); }
.t-edge { --c: var(--edge); --soft: var(--edge-soft); }
.t-doubt{ --c: var(--doubt); --soft: var(--doubt-soft); }
.t-lens { --c: var(--fg2); --soft: var(--card2); }

/* home */
.hero { padding: 10px 2px 18px; display: grid; gap: 8px; }
.hero h2.big { font-size: 44px; }
.search { position: relative; margin: 2px 0 14px; }
.search input { width: 100%; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px 12px 40px; font-size: 16px; font-family: inherit; }
.search::before { content: "⌕"; position: absolute; left: 14px; top: 9px; font-size: 20px; color: var(--fg3); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; text-align: left;
  color: var(--fg); display: grid; gap: 6px; align-content: start; position: relative; overflow: hidden; min-height: 118px; border-top: 3px solid var(--c); }
.tile.wide { grid-column: 1 / -1; min-height: 0; }
.tile .glyph { font-family: var(--display); font-size: 30px; line-height: 1; color: var(--c); font-weight: 600; }
.tile h3 { font-size: 20px; }
.tile p { color: var(--fg2); font-size: 13px; line-height: 1.4; }
.tile .prog { font-family: var(--mono); font-size: 10.5px; color: var(--fg3); letter-spacing: .06em; }
.tile .bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.tile .bar i { display: block; height: 100%; background: var(--c); }

/* controls */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--bg2); }
.seg button { background: none; border: none; cursor: pointer; padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--fg2); }
.seg button.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.pills { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill { font-size: 12.5px; padding: 6px 11px; border-radius: 999px; white-space: nowrap; cursor: pointer; flex-shrink: 0;
  background: var(--card); color: var(--fg2); border: 1px solid var(--line); font-weight: 500; }
.pill.active { background: var(--soft); color: var(--c); border-color: var(--c); }
.pill.dash { border-style: dashed; }
.note { background: var(--soft); border-left: 3px solid var(--c); padding: 12px 14px; border-radius: 0 12px 12px 0; font-size: 14px; display: grid; gap: 8px; }

/* lists */
.sec { margin-top: 18px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; padding: 0 2px 8px; }
.sec-head h3 { color: var(--c); }
.sec-head .why { font-size: 12.5px; color: var(--fg2); flex: 1; min-width: 0; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; background: none; border-left: none; border-right: none; border-bottom: none; width: 100%; text-align: left; color: var(--fg); }
.item:first-child { border-top: none; }
.item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; box-shadow: 0 0 0 3px var(--soft); }
.item .body { flex: 1; min-width: 0; }
.item .t { font-size: 15.5px; font-weight: 500; line-height: 1.3; }
.item .m { font-size: 12px; color: var(--fg2); margin-top: 2px; line-height: 1.35; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .lvl { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); }
.item .chev { color: var(--fg3); font-size: 20px; flex-shrink: 0; }
.item.dim { opacity: .38; }
.item.core .dot { box-shadow: 0 0 0 3px var(--c); }
.item.read .t { color: var(--fg2); }
.item .rd { color: var(--ok); font-size: 14px; flex-shrink: 0; }
.item .bk { color: var(--theo); font-size: 14px; flex-shrink: 0; }

/* detail */
.detail { display: grid; gap: 16px; min-width: 0; }
.detail > * { min-width: 0; }
.pager { min-width: 0; overflow: hidden; }
.detail .crumbs { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--c); }
.detail h2.big { font-size: 32px; }
.detail .body p { font-size: 16.5px; line-height: 1.55; }
.detail .names { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.5; }
.detail .names .lbl, .detail .diff .lbl { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); margin-bottom: 4px; }
.detail .diff { border-top: 1px dashed var(--line); padding-top: 12px; font-size: 14.5px; color: var(--fg2); line-height: 1.5; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { background: var(--card); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 10px 14px; font-size: 14px; cursor: pointer; font-weight: 500; }
.btn.on { background: var(--soft); border-color: var(--c); color: var(--c); }
.btn.ghost { background: none; }
.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.pager .btn { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }

/* ladder */
.track-note { font-size: 14px; color: var(--fg2); margin: 6px 0 12px; }
.rung { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; border-left: 4px solid var(--c); }
.rung .who { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rung .who b { font-family: var(--display); font-size: 24px; font-weight: 600; color: var(--c); }
.rung .who span { font-size: 12.5px; color: var(--fg2); }
.rung ul { padding-left: 18px; display: grid; gap: 5px; font-size: 14.5px; line-height: 1.45; }
.rung .can { font-size: 13.5px; padding: 9px 12px; background: var(--soft); border-radius: 10px; line-height: 1.45; }

/* lenses */
figure { margin: 0; }
figure svg { max-width: 100%; height: auto; display: block; }
figcaption { font-size: 12.5px; color: var(--fg2); margin: 8px 2px 0; line-height: 1.4; }
.vregion { cursor: pointer; }
.lens { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; border-top: 3px solid var(--c); }
.lens dl { display: grid; gap: 8px; }
.lens dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); }
.lens dd { font-size: 14.5px; line-height: 1.5; }

/* edges */
.weight { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg3); display: inline-flex; align-items: center; gap: 3px; }
.weight i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c); opacity: .25; }
.weight i.on { opacity: 1; }
.status { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--fg2); white-space: nowrap; }
.status.real { border-color: var(--ok); color: var(--ok); }
.status.myth { border-color: var(--doubt); color: var(--doubt); }
.status.mixed { border-color: var(--theo); color: var(--theo); }
.timeline { display: grid; border-left: 2px solid var(--line); margin-left: 8px; }
.tl { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 9px 0 9px 14px; position: relative; cursor: pointer; }
.tl::before { content: ""; position: absolute; left: -6px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.tl .yr { font-family: var(--mono); font-size: 11.5px; color: var(--fg2); padding-top: 3px; }
.tl .t { font-size: 15px; font-weight: 500; line-height: 1.3; }
.tl .t small { display: block; color: var(--fg2); font-size: 12.5px; font-weight: 400; margin-top: 2px; }

/* doubt */
.arg { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 6px; border-left: 4px solid var(--c); }
.arg b { font-size: 17px; font-family: var(--display); font-weight: 600; line-height: 1.2; }
.arg .what { font-size: 14.5px; line-height: 1.5; }
.arg .sw { font-size: 13.5px; color: var(--fg2); line-height: 1.45; border-top: 1px dashed var(--line); padding-top: 6px; }
.reading ol { padding-left: 22px; display: grid; gap: 10px; }
.reading li { font-size: 15px; line-height: 1.4; }
.reading li small { display: block; color: var(--fg2); font-size: 13px; }
.coda { background: var(--soft); border-radius: 16px; padding: 18px; display: grid; gap: 10px; }
.coda .q { color: var(--c); }
.coda p { font-size: 15px; line-height: 1.5; }

.empty { text-align: center; color: var(--fg2); padding: 40px 16px; font-size: 14px; line-height: 1.5; }
.foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--fg3); line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
