/* ABS Book Developer — parchment (light) / candlelight (dark) */
:root {
  --bg: #f5f1e8; --surface: #fffdf8; --surface-2: #f0ebdf; --border: #e2d9c6;
  --text: #241d14; --muted: #6a5f4e; --faint: #9a8f7c;
  --brand: #8a5a12; --brand-2: #a66d16; --brand-soft: #f3e4c4; --on-brand: #fff;
  --danger: #b4231a; --danger-soft: #fbe3df; --ok: #2f7a3a;
  --epic: #7c3aed; --epic-soft: #ede4ff; --leg: #b7791f; --leg-soft: #fff1cc;
  --lv-low: #9a8f7c; --lv-mid: #2f7a8a; --lv-high: #2f7a3a;
  --radius: 12px; --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 4px 18px rgba(60, 40, 10, .05);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --nav-w: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110f; --surface: #1b1916; --surface-2: #24211d; --border: #36312a;
    --text: #ece6da; --muted: #b0a692; --faint: #7d7465;
    --brand: #d6a24a; --brand-2: #e4b663; --brand-soft: #3a2e19; --on-brand: #1b1307;
    --danger: #f07167; --danger-soft: #3d1d1a; --ok: #6fcf7f;
    --epic: #a78bfa; --epic-soft: #2c2147; --leg: #f2c14e; --leg-soft: #3b2f12;
    --lv-low: #8b8170; --lv-mid: #5fb3c4; --lv-high: #6fcf7f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12110f; --surface: #1b1916; --surface-2: #24211d; --border: #36312a;
  --text: #ece6da; --muted: #b0a692; --faint: #7d7465;
  --brand: #d6a24a; --brand-2: #e4b663; --brand-soft: #3a2e19; --on-brand: #1b1307;
  --danger: #f07167; --danger-soft: #3d1d1a; --ok: #6fcf7f;
  --epic: #a78bfa; --epic-soft: #2c2147; --leg: #f2c14e; --leg-soft: #3b2f12;
  --lv-low: #8b8170; --lv-mid: #5fb3c4; --lv-high: #6fcf7f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; margin: 0; letter-spacing: .2px; }
h1 { font-size: 28px; } h2 { font-size: 19px; } h3 { font-size: 18px; } h4 { font-size: 14px; color: var(--muted); margin: 14px 0 4px; }
p { margin: 6px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; }
.nowrap { white-space: nowrap; } .w1 { width: 1%; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .wrap { flex-wrap: wrap; }
.warn { background: var(--leg-soft); padding: 10px 12px; border-radius: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 3px 0; }

/* ---------- Buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none !important; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: none; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { padding: 2px 8px; font-size: 12px; border-radius: 7px; min-width: 26px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; }
.link.danger { color: var(--danger); }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }
input:not([type=checkbox]):not([type=range]):not([type=color]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=color] { width: 60px; height: 36px; border: 1px solid var(--border); border-radius: 9px; padding: 2px; background: var(--surface); }
textarea { resize: vertical; line-height: 1.5; }
select:disabled { opacity: .55; }
.form { display: flex; flex-direction: column; gap: 14px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld-l { font-size: 13px; font-weight: 600; color: var(--muted); }
.req { color: var(--danger); font-style: normal; }
.fgroup { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; background: var(--surface); }
.fgroup legend { font-family: var(--serif); font-weight: 700; font-size: 16px; padding: 0 6px; }

/* Level input: slider + number + Epic / Legendary */
.lvl-in { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lvl-in input[type=range] { flex: 1; min-width: 140px; accent-color: var(--brand); }
.lvl-in input[type=range].dim { opacity: .35; }
.lvl-in input[type=number].num { width: 78px !important; flex: none; }
.tier { border: 1px solid var(--border); background: var(--surface); padding: 6px 10px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13px; }
.tier.epic.on { background: var(--epic); border-color: var(--epic); color: #fff; }
.tier.legendary.on { background: linear-gradient(135deg, #f6d365, #d4a017 60%, #b7791f); border-color: #b7791f; color: #2a1b00; }
.date-in { display: grid; grid-template-columns: 110px 90px minmax(120px, 200px) 90px; gap: 6px; }

/* Level badges + bars */
.lvl { display: inline-block; min-width: 34px; text-align: center; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }
.lvl-none { opacity: .6; }
.lvl-mid { color: var(--lv-mid); } .lvl-high { color: var(--lv-high); }
.lvl-epic { background: var(--epic-soft); color: var(--epic); border-color: var(--epic); }
.lvl-legendary { background: linear-gradient(135deg, #f6d365, #d4a017 60%, #b7791f); color: #2a1b00; border-color: #b7791f; box-shadow: 0 0 10px rgba(242, 193, 78, .35); }
.bar { display: inline-block; width: 110px; height: 7px; border-radius: 9px; background: var(--surface-2); overflow: hidden; vertical-align: middle; border: 1px solid var(--border); }
.bar-in { display: block; height: 100%; background: var(--lv-low); border-radius: 9px; }
.bar-in.lvl-mid { background: var(--lv-mid); } .bar-in.lvl-high { background: var(--lv-high); }
.bar-in.lvl-epic { background: var(--epic); } .bar-in.lvl-legendary { background: linear-gradient(90deg, #f6d365, #d4a017); }
.spark { stroke: var(--brand); fill: none; stroke-width: 1.6; vertical-align: middle; }
.spark circle { fill: var(--brand); stroke: none; }
.spark.big { width: 100%; height: 80px; margin-bottom: 8px; }
.delta { font-size: 11px; font-weight: 700; } .delta.up { color: var(--ok); } .delta.down { color: var(--danger); }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.nav { width: var(--nav-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav a svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.nav-brand { padding: 6px 8px 16px; color: var(--text); }
.nav-brand > span { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.nav-brand b { font-family: var(--serif); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 32px; height: 32px; flex: none; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.main { flex: 1; min-width: 0; padding: 22px 28px 80px; max-width: 1280px; }
.page { padding: 28px 20px; } .page.narrow { max-width: 960px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.crumbs { font-size: 13px; color: var(--faint); margin-bottom: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { flex: 1 1 260px; } .filters select { width: auto; flex: 0 1 auto; }
.asof { display: inline-flex; align-items: center; gap: 6px; }
.asof select { width: auto; max-width: 260px; padding: 5px 8px; font-size: 13px; }

/* ---------- Login / series ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.brand-big { display: flex; align-items: center; gap: 14px; }
.brand-big .logo { width: 44px; height: 44px; }
.brand-big p { margin: 0; }
.home-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.series-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.series-card { padding: 18px; color: var(--text); text-decoration: none !important; display: flex; flex-direction: column; gap: 4px; min-height: 120px; }
.series-card:hover { border-color: var(--brand); }
.series-card.new { align-items: center; justify-content: center; cursor: pointer; color: var(--muted); border-style: dashed; font-weight: 600; }
.plus { font-size: 30px; line-height: 1; color: var(--brand); }

/* ---------- Avatars ---------- */
.av { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; background: var(--brand-soft); color: var(--brand); font-family: var(--serif); font-weight: 700; flex: none; }
.av-xs { width: 22px; height: 22px; font-size: 10px; }
.av-sm { width: 30px; height: 30px; font-size: 12px; }
.av-md { width: 40px; height: 40px; font-size: 15px; }
.av-card { width: 100%; height: 100%; border-radius: 0; font-size: 42px; }
.av-hero { width: 180px; height: 220px; border-radius: 12px; font-size: 64px; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* ---------- Character list ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.char-card { overflow: hidden; color: var(--text); text-decoration: none !important; display: flex; flex-direction: column; transition: transform .12s, border-color .12s; }
.char-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.cc-img { aspect-ratio: 4 / 5; position: relative; background: var(--surface-2); }
.cc-img .av { display: grid; }
.cc-img img.av { display: block; }
.cc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 1px; }
.cc-body b { font-family: var(--serif); font-size: 16px; }
.status { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.cc-img .status { position: absolute; top: 8px; left: 8px; }
.st-alive { background: #dff3e2; color: #24692f; }
.st-dead { background: #3b3330; color: #f1e6dc; }
.st-missing { background: var(--leg-soft); color: var(--leg); }

/* ---------- Character view ---------- */
.hero { display: flex; gap: 22px; padding: 18px; margin-bottom: 16px; }
.hero-img { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 12px; flex: none; }
.hero-img .av { display: grid; }
.hero-main { flex: 1; min-width: 0; }
.hero-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.hero h1 { font-size: 32px; line-height: 1.15; }
.titles { font-family: var(--serif); font-style: italic; color: var(--brand); margin: 2px 0; font-size: 16px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin-top: 16px; }
.fact { display: flex; flex-direction: column; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sec { padding: 16px 18px; }
.sec.drop { outline: 2px dashed var(--brand); }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.sec-head h2 .dot { margin-right: 8px; }
.para p { white-space: normal; }
blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--brand); font-family: var(--serif); font-style: italic; }
table.kv { border-collapse: collapse; width: 100%; }
.kv th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 4px 12px 4px 0; width: 38%; vertical-align: top; }
.kv td { padding: 4px 0; }
.tree-g { padding: 6px 0 8px; border-top: 1px solid var(--border); }
.tree-g:first-of-type { border-top: 0; }
.tree-h { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--sc, var(--brand)); }
.skill { display: grid; grid-template-columns: minmax(110px, 1fr) auto auto; gap: 10px; align-items: center; padding: 5px 0 5px 18px; }
.skill-head { padding-left: 0; }
.skill-head .sk-name b { font-family: var(--serif); font-size: 16px; }
.sk-name { display: flex; flex-direction: column; min-width: 0; }
.sk-lvl { display: flex; align-items: center; gap: 8px; }
.sk-x { display: flex; align-items: center; gap: 4px; }
.inv { display: flex; flex-direction: column; gap: 6px; }
.inv-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; }
.inv-item:hover { border-color: var(--brand); }
.inv-item img, .inv-ph, .ti img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: none; }
.inv-ph { display: grid; place-items: center; background: var(--surface-2); color: var(--brand); }
.inv-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rels { display: flex; flex-direction: column; }
.rel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--border); }
.rel:first-child { border-top: 0; }
.rel-type { color: var(--muted); font-size: 13px; min-width: 90px; }
.rel .btn { margin-left: auto; }
.rel-d { flex-basis: 100%; margin: 0; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.chip.first { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--faint); padding: 0 0 0 2px; }
.app-book { margin-bottom: 8px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.g-item { display: flex; flex-direction: column; gap: 4px; }
.g-img { padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: zoom-in; aspect-ratio: 1; background: var(--surface-2); }
.g-item.portrait .g-img { border: 2px solid var(--brand); }
.g-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.g-cap { margin: 0; }
.known { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.known-c { display: inline-flex; align-items: center; gap: 3px; text-decoration: none !important; }
.char-ref { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Catalog pages ---------- */
.school, .art, .book { padding: 16px 18px; margin-bottom: 14px; border-top: 4px solid var(--sc, var(--brand)); }
.art, .book { border-top-color: var(--border); border-top-width: 1px; }
.spells { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.spell { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.spell:hover { border-color: var(--brand); }
.sp-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.k-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.k-card { padding: 16px 18px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:first-child td { border-top: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl tr.future td { opacity: .45; }
.items-tbl .ti { width: 54px; }
.item-top { display: flex; gap: 16px; margin-bottom: 8px; }
.item-img { padding: 0; border: 0; background: none; cursor: zoom-in; }
.item-img img { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; }
.danger-zone { border-color: var(--danger-soft); }
.months { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.month-row { display: grid; grid-template-columns: 26px 1fr 90px auto auto; gap: 8px; align-items: center; }
.seg { display: flex; gap: 8px; }

/* ---------- Chapter multi-select ---------- */
.ch-multi { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ch-book-h { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.ch-book-h .link { font-size: 12px; }
.ch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 10px; }
.ch-opt { display: flex; gap: 6px; align-items: center; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* ---------- Modal / picker ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 14, 6, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border: 1px solid var(--border); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.modal-foot .left { margin-right: auto; }
.picker { display: flex; flex-direction: column; gap: 10px; }
.picker-bar { display: flex; gap: 8px; } .picker-bar select { width: auto; min-width: 150px; flex: none; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; max-height: 50vh; overflow-y: auto; padding: 2px; }
.pk-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; }
.pk-item:hover { border-color: var(--brand); }
.pk-item.on { border-color: var(--brand); background: var(--brand-soft); }
.pk-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pk-txt b, .pk-txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-check { color: var(--brand); font-weight: 800; visibility: hidden; }
.pk-item.on .pk-check { visibility: visible; }
.picker-new { display: flex; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.save-bar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); margin-top: 10px; }
.main > .form { gap: 16px; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 80; display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox img { max-width: 90vw; max-height: 82vh; object-fit: contain; border-radius: 6px; }
.lightbox figcaption { color: #ddd; font-size: 14px; white-space: pre; }
.lightbox button { position: absolute; background: rgba(255, 255, 255, .1); border: 0; color: #fff; font-size: 30px; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; }
.lb-x { top: 16px; right: 16px; font-size: 20px !important; } .lb-p { left: 16px; } .lb-n { right: 16px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 30px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0;
  transition: .2s; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .nav { width: 100%; height: auto; position: sticky; z-index: 20; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav a { padding: 7px 10px; flex: none; }
  .nav a span { white-space: nowrap; }
  .nav a.nav-brand { padding: 4px 8px; }
  .nav-brand > span { display: none; }
  .main { padding: 16px 16px 80px; }
  .hero { flex-direction: column; align-items: center; text-align: center; }
  .hero-top { justify-content: center; }
  .facts { text-align: left; width: 100%; }
  .av-hero { width: 150px; height: 180px; }
  .date-in { grid-template-columns: 1fr 1fr; }
  .skill { grid-template-columns: 1fr; gap: 4px; }
  .modal { max-height: calc(100vh - 16px); }
  .modal-back { padding: 8px; }
}

/* ---------- Kingdoms & places ---------- */
a.k-card { color: var(--text); text-decoration: none !important; display: flex; flex-direction: column; gap: 4px; transition: border-color .12s; }
a.k-card:hover { border-color: var(--brand); }
.royal-sec { margin-bottom: 16px; }
.royal-grid { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-bottom: 6px; }
.royal { display: flex; flex-direction: column; gap: 4px; }
.ptree { display: flex; flex-direction: column; }
.pnode { border-top: 1px solid var(--border); }
.ptree > .pnode:first-child { border-top: 0; }
.pkids { margin-left: 14px; padding-left: 12px; border-left: 2px solid var(--border); }
.pkids .pnode { border-top: 0; }
.prow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.picon { font-size: 17px; width: 22px; text-align: center; }
.pname { font-weight: 700; color: var(--text); font-size: 15px; }
.pname:hover { color: var(--brand); }
.ptype { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; }
.cap { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--leg-soft); color: var(--leg); }
.plord { display: inline-flex; align-items: center; gap: 5px; }
.pbtns { margin-left: auto; display: inline-flex; gap: 4px; opacity: .55; }
.prow:hover .pbtns { opacity: 1; }
.ev-count { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.picon-big { margin-right: 8px; }
/* Tabs (Places page, place picker) */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 14px; font: 600 14px system-ui, sans-serif; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.page-tabs { margin-bottom: 12px; }
.pl-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.pl-group-h { font: 700 11px system-ui, sans-serif; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); padding: 2px 10px 4px; }
.pl-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.pl-item:hover { background: var(--surface-2); }
.pl-item.on { border-color: var(--brand); background: var(--brand-soft); }
.pdesc { margin: -2px 0 6px 30px; }
.people { display: flex; flex-direction: column; gap: 4px; }
.person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: var(--text); text-decoration: none !important; }
.person:hover { background: var(--surface-2); }

/* App switcher button (public/apps.js) sits in the nav's top-right corner */
.nav-brand { padding-right: 40px !important; }
.nav > .absapps-btn { position: absolute; top: 18px; right: 12px; margin: 0; }
@media (max-width: 760px) {
  .nav-brand { padding-right: 8px !important; }
  .nav > .absapps-btn { position: static; align-self: center; margin: 0 4px; }
}

/* Power & battles */
.tier-badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.tier-badge.none { background: var(--surface-2); color: var(--faint); font-weight: 400; }
.pow { color: var(--muted); }
.pow b, .bt-tbl b { color: var(--text); }
.sec-foot { margin-top: 10px; }
.bt-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--border); }
.bt-cmp { display: grid; gap: 10px; margin: 6px 0 10px; }
.bt-row { display: grid; grid-template-columns: minmax(80px, 160px) 1fr auto; gap: 12px; align-items: center; }
.bt-name { font-weight: 600; overflow-wrap: anywhere; }
.bt-bars { display: grid; gap: 4px; }
.bt-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bt-fill { display: block; height: 100%; border-radius: 999px; }
.bt-fill.pp { background: var(--brand); }
.bt-fill.mp { background: var(--epic); }
.bt-val { text-align: right; font-size: 13px; white-space: nowrap; }
.bt-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.tbl-wrap { overflow-x: auto; }
.num-r, .tbl th.num-r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.squad td { background: var(--surface-2); font-weight: 600; font-size: 13px; }
.tbl tfoot td { border-top: 2px solid var(--border); font-weight: 600; }
.mage-t { color: var(--epic); }
.warn-t { color: var(--danger); }
.pw-tbl td, .pw-tbl th { font-size: 13px; }
@media (max-width: 760px) {
  .bt-sides { grid-template-columns: 1fr; }
  .bt-row { grid-template-columns: 1fr auto; }
  .bt-bars { grid-column: 1 / -1; grid-row: 2; }
}
.ev-type { display: inline-block; padding: 1px 8px; border-radius: 999px; font: 600 11px/1.6 system-ui, sans-serif; letter-spacing: .3px; text-transform: uppercase; background: var(--surface-2); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.ev-type[style] { background: color-mix(in srgb, var(--tc) 16%, transparent); color: color-mix(in srgb, var(--tc) 70%, var(--text)); }
.ev-ic { margin-right: 4px; }
.et-list { display: flex; flex-wrap: wrap; gap: 8px; }
.et { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.et:hover { border-color: var(--brand); }
.tl-g { position: relative; margin: 0 0 18px; padding-left: 18px; border-left: 2px solid var(--border); }
.tl-h { font-size: 15px; color: var(--muted); margin: 0 0 8px; }
.tl-h::before { content: ""; position: absolute; left: -7px; margin-top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.tl-ev { display: block; color: inherit; text-decoration: none; margin-bottom: 8px; padding: 12px 14px; }
.tl-ev:hover { border-color: var(--brand); }
.tl-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-ev .known { margin-top: 8px; }
.ev-list li { padding: 3px 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.lib-card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; padding: 14px 16px; }
.lib-card:hover { border-color: var(--brand); }
.lib-card p { margin: 0; }
.lib-title { font-family: var(--serif); font-size: 16px; }
.lib-peek { white-space: pre-line; color: var(--muted); font-family: var(--serif); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.lib-text { white-space: pre-wrap; font-family: var(--serif); font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.lib-text.poem { font-style: italic; padding-left: 12px; border-left: 3px solid var(--brand-soft); }

/* Timeline (graphic) */
.tl-bar { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.tl-bar .filters { margin: 0; }
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.src { display: inline-flex; align-items: center; padding: 3px 11px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.src.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.src input { display: none; }
.tl2 { position: relative; padding-left: 40px; }
.tl2::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.tl2-book { position: relative; font-size: 20px; margin: 22px 0 6px -40px; padding: 4px 0 4px 40px; background: var(--bg); }
.tl2 > .tl2-book:first-child { margin-top: 0; }
.tl2-chh { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 16px 0 8px; }
.tl2-chh::before { content: ""; position: absolute; left: -31px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--bg); }
.tl2-chl { color: var(--text); font-size: 15px; }
.tl2-acts { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.tl2-item { position: relative; margin-bottom: 8px; }
.tl2-dot { position: absolute; left: -40px; top: 9px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--tc, var(--border)); font-size: 15px; line-height: 1; }
.tl2-dot.sm { width: 24px; height: 24px; left: -36px; top: 1px; font-size: 12px; border-width: 1px; border-color: var(--border); }
.tl2-card { padding: 10px 14px; border-left: 3px solid var(--tc, var(--brand)); }
.tl2-item.planned .tl2-card { border-style: dashed; border-left-style: solid; background: var(--surface-2); }
.tl2-name { font-weight: 700; color: var(--text); }
.tl2-name:hover { color: var(--brand); }
.tl2-ppl { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.tl2-p { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); text-decoration: none !important; }
.tl2-p .faint { font-size: 11px; }
.tl2-sides { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tl2-mini { padding: 3px 0; font-size: 14px; }
.tl2-item.mini { margin-bottom: 4px; }
.tl2-skip { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 4px 0 10px; padding: 3px 4px 3px 12px; border: 1px dashed var(--border); border-radius: 999px; font-size: 13px; width: fit-content; max-width: 100%; }
.tl2-skip .tl2-dot { left: -37px; top: 3px; }
.tl2-year { position: relative; font: 700 14px var(--serif); color: var(--brand); margin: 18px 0 8px; }
.tl2-year::before { content: ""; position: absolute; left: -30px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--bg); }
.tl2-gap { margin: 4px 0; font-size: 12px; color: var(--faint); font-style: italic; }
.tl2-era { margin: 20px 0 10px -40px; padding: 6px 0 0 40px; border-top: 2px solid var(--brand); color: var(--brand); font-weight: 700; font-size: 13px; }
.tl2-now { margin: 16px 0 16px -40px; padding: 4px 0 0 40px; border-top: 2px dashed var(--danger); color: var(--danger); font: 700 12px system-ui, sans-serif; letter-spacing: .6px; }
.tag { display: inline-block; font: 700 11px/1.6 system-ui, sans-serif; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.tag.plan { background: var(--leg-soft); color: var(--leg); }
.tag.fb { background: var(--epic-soft); color: var(--epic); }
.warn-l { color: var(--danger); font-size: 12px; margin-top: 4px; }
/* Deadlines (planned events) */
.dl-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.dl { display: flex; gap: 10px; align-items: center; padding: 8px 14px 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none !important; }
.dl > span:last-child { display: flex; flex-direction: column; line-height: 1.35; }
.dl-ic { font-size: 22px; }
.dl.soon { border-color: var(--leg); background: var(--leg-soft); }
.dl.over { border-color: var(--danger); background: var(--danger-soft); }
.tl2-pn { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Maps */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.map-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: inherit; text-decoration: none !important; }
.map-card img, .map-ph { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); }
.map-card-b { display: flex; flex-direction: column; padding: 10px 14px; }
.mv-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 12px; }
.mv { position: relative; height: calc(100vh - 230px); min-height: 380px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: #cfd8d6; touch-action: none; cursor: grab; outline: none; user-select: none; }
.mv:active { cursor: grabbing; }
.mv-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.mv-img { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }
.mv-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.rg-fill { opacity: .4; }
.rg-fill path { cursor: pointer; }
.rg-fill path:hover { fill-opacity: 1; filter: brightness(1.15); }
.rg-line path { fill: none; stroke-width: calc(1.6px * var(--k, 1)); pointer-events: none; } .rg-line path.free { stroke-dasharray: calc(6px * var(--k, 1)) calc(5px * var(--k, 1)); }
.rg-sel { fill: none; stroke: #fff; stroke-width: calc(3px * var(--k, 1)); stroke-dasharray: calc(8px * var(--k, 1)) calc(5px * var(--k, 1)); pointer-events: none; filter: drop-shadow(0 0 2px #000); }
.draft { fill: none; stroke: var(--danger); stroke-width: calc(2.5px * var(--k, 1)); pointer-events: none; }
.hd { fill: #fff; stroke: #222; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: move; }
.hd.mid { fill: #fff8; stroke: #2228; cursor: copy; }
.hd.first { fill: var(--danger); cursor: pointer; }
.pin { cursor: pointer; }
.pin circle { fill: #fffdf6; stroke: #3b2a14; stroke-width: 2; }
.pin.on circle { fill: #ffd76a; stroke-width: 3; }
.pin-ic { font-size: 14px; text-anchor: middle; pointer-events: none; }
.pin-l { font: 700 13px system-ui, sans-serif; fill: #24190c; paint-order: stroke; stroke: #fffdf6; stroke-width: 3.5px; stroke-linejoin: round; pointer-events: none; }
.mv-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; }
.mv-zoom .btn { width: 34px; padding: 4px 0; justify-content: center; background: var(--surface); }
.mv-hint { position: absolute; left: 10px; bottom: 10px; right: 60px; padding: 6px 10px; border-radius: 10px; background: rgba(20, 16, 10, .78); color: #f3ead8; font-size: 13px; pointer-events: none; }
.mv-panel { padding: 14px; max-height: calc(100vh - 230px); overflow-y: auto; }
.mv-panel h3 { font-size: 17px; margin-bottom: 6px; }
.mv-panel .grow { flex: 1; }
.legend { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; }
.lg { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.lg:hover { background: var(--surface-2); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0003; vertical-align: -1px; margin-right: 5px; flex: none; }
.pl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.pl-row.on { background: var(--brand-soft); }
.mv-time { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 14px; }
.mv-time input[type=range] { flex: 1; min-width: 160px; accent-color: var(--brand); }
.tc-ic { font-size: 20px; }
.tc-l { min-width: 150px; font-family: var(--serif); }
.tc-ch { width: auto; }
.seg-btns { display: inline-flex; gap: 4px; }
@media (max-width: 900px) {
  .mv-wrap { grid-template-columns: 1fr; }
  .mv { height: 62vh; }
  .mv-panel { max-height: none; }
}

/* Bestiary */
.mon-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: inherit; text-decoration: none !important; }
.mon-card:hover { border-color: var(--brand); }
.mon-img { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center; font-size: 54px; overflow: hidden; }
.mon-img img { width: 100%; height: 100%; object-fit: cover; }
.mon-img .cls-badge { position: absolute; left: 8px; top: 8px; }
/* Class badge: warmer and darker as the class rises */
.cls-badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font: 700 12px/1.6 system-ui, sans-serif; vertical-align: middle; white-space: nowrap;
  color: #fff; background: hsl(calc(50 - var(--cl) * 6) 70% calc(52% - var(--cl) * 2.2%)); box-shadow: 0 1px 2px #0003; }
.plain-b { margin: 4px 0; padding-left: 18px; }
.plain-b li { margin: 2px 0; }
.ladder { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.ld-col { flex: 0 0 160px; display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ld-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.ld-m { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; color: var(--text); text-decoration: none !important; font-size: 14px; }
.ld-m:hover { background: var(--surface-2); }
.ld-m img, .ld-m > span { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.rp-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.rp-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.rp-row:hover { background: var(--surface-2); }
.mon-prev { margin: 8px 0 0; }

/* Relations graph + family tree */
.gr-time { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 12px; }
.gr-time input { flex: 1; accent-color: var(--brand); }
.gr-time b { min-width: 180px; font-family: var(--serif); }
.gr-box { position: relative; height: calc(100vh - 250px); min-height: 400px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.gr-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.g-edge { fill: none; stroke-width: 2.2; transition: opacity .15s; }
.g-edge:hover { stroke-width: 4; }
.g-edge.on-path { stroke-width: 5; }
.g-imp { stroke: var(--faint); opacity: .35; }
.gn { cursor: pointer; transition: opacity .15s; }
.g-ring { fill: var(--surface); stroke-width: 4; }
.gn.focus .g-ring, .gn.on-path .g-ring { stroke-width: 6; filter: drop-shadow(0 0 6px var(--brand)); }
.gn.dead image, .gn.dead .g-ini { filter: grayscale(1); opacity: .6; }
.g-ini { fill: var(--brand-soft); }
.g-ini-t { fill: var(--brand); font: 700 13px var(--serif); text-anchor: middle; pointer-events: none; }
.g-lbl { fill: var(--text); font: 600 12px system-ui, sans-serif; text-anchor: middle; paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; pointer-events: none; }
.dim { opacity: .12; }
.g-rels li { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 14px; flex-wrap: wrap; }
.g-path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.g-cats { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.g-cats .src { gap: 4px; }
.g-sel { margin: 4px 0 8px; }
.g-opt { margin: 4px 0; }
.rel-past { margin-top: 8px; }
.rel-past summary { cursor: pointer; }
.rel-past .rel { opacity: .75; }
.rt-row { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--border); }
.rt-row:first-of-type { border-top: 0; }
.rt-cat { min-width: 110px; font-weight: 600; font-size: 14px; padding-top: 6px; }
.ft-card { cursor: pointer; }
.ft-card rect { fill: var(--surface); stroke-width: 2.5; }
.ft-card:hover rect { fill: var(--brand-soft); }
.ft-card.dead rect { stroke-dasharray: 4 3; }
.ft-card.dead image { filter: grayscale(1); }
.ft-name { fill: var(--text); font: 700 13px var(--serif); }
.ft-yrs { fill: var(--muted); font: 11px system-ui, sans-serif; }
.ft-line { fill: none; stroke: #9a6a32; stroke-width: 2; }
.ft-spouse { stroke: #d0508a; stroke-width: 3; }
.ft-sib { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 3 4; }
.ft-far { stroke: #9a6a32; stroke-width: 1.5; stroke-dasharray: 8 6; opacity: .7; }
.ft-legend { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.ft-legend i { display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid #9a6a32; }
.ft-legend .ft-l2 { border-top: 3px solid #d0508a; } .ft-legend .ft-l3 { border-top: 2px dotted var(--faint); } .ft-legend .ft-l4 { border-top: 2px dashed #9a6a32; }
@media (max-width: 900px) { .gr-box { height: 60vh; } }

/* Timeline: parallel lanes */
.lanes-wrap { padding: 0; }
.lane-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.lanes { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.lane-row { display: grid; gap: 0; min-width: max-content; }
.lane-row > * { padding: 6px 10px; border-left: 1px solid var(--border); min-height: 34px; }
.lane-row > :first-child { border-left: 0; }
.lane-top { position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 2px solid var(--border); }
.lane-who { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none !important; border-top: 4px solid var(--rc); }
.lane-group { display: grid; padding: 8px 10px; background: var(--surface-2); border-top: 1px solid var(--border); font-family: var(--serif); min-width: max-content; }
.lane-group b { grid-column: 1 / -1; }
.lane-when { display: flex; align-items: center; }
.lane-cell { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.lane-cell::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--border); z-index: 0; }
.lane-cell.on::before { display: none; }
.lane-cell.dead { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 8px); }
.lane-cell.dead::before { display: none; }
.lane-at { position: relative; z-index: 1; align-self: center; background: var(--surface); padding: 0 6px; }
.lane-cell.ev { margin: 3px 6px; padding: 6px 9px; border-radius: 8px; border-left: 3px solid var(--tc); background: var(--bg); color: var(--text); text-decoration: none !important; }
.lane-cell.ev:hover { background: var(--brand-soft); }
.lane-cell.mini { font-size: 13px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 6px; }
.lane-ev { display: flex; gap: 6px; align-items: baseline; font-size: 14px; }
.lane-row.together { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }
.map-link { cursor: pointer; }
.map-link circle { fill: #fffdf6; stroke: #2f6fb0; stroke-width: 2.5; }
.map-link text { font-size: 14px; text-anchor: middle; pointer-events: none; }
.block-btn { display: flex; justify-content: center; margin: 4px 0 8px; }

/* Roads & routes on maps */
.rd-e { stroke-width: calc(3px * var(--k, 1)); stroke-linecap: round; cursor: pointer; } .rd-e.sea { stroke-dasharray: calc(10px * var(--k, 1)) calc(7px * var(--k, 1)); } .rd-e.portal { stroke-dasharray: calc(2px * var(--k, 1)) calc(6px * var(--k, 1)); }
.rd-e.sel { stroke-width: calc(6px * var(--k, 1)); filter: drop-shadow(0 0 3px #fff); }
.rd-e.shown { stroke-width: calc(2.5px * var(--k, 1)); opacity: .85; pointer-events: none; }
.rd-n { fill: #fff; stroke: #222; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: move; }
.rd-n.pl { fill: #ffd76a; }
.rd-n.chain { fill: var(--danger); }
.rt-glow { fill: none; stroke: #fff; stroke-width: calc(10px * var(--k, 1)); stroke-opacity: .75; stroke-linejoin: round; pointer-events: none; }
.rt-leg { stroke-width: calc(5px * var(--k, 1)); stroke-linecap: round; pointer-events: none; }
.rt-end { stroke: #fff; stroke-width: 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.rt-end.from { fill: #2f8f3c; } .rt-end.to { fill: var(--danger); }
.rd-types { display: flex; flex-direction: column; gap: 3px; }
.rd-type { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit; font-size: 14px; }
.rd-type .faint { margin-left: auto; }
.rd-type.on { border-color: var(--brand); background: var(--brand-soft); }
.rd-sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; flex: none; vertical-align: middle; margin-right: 4px; }
.rd-sel { padding: 10px; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.rt-res, .rt-sug { padding: 12px; margin: 10px 0; }
.rt-big { font-size: 16px; margin-bottom: 4px; }
.rd-all { filter: drop-shadow(0 0 calc(1.5px * var(--k, 1)) rgba(255, 255, 255, .9)); }

/* ---------- Overview ---------- */
.ov-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
a.ov-stat { display: flex; flex-direction: column; padding: 12px 14px; color: var(--text); text-decoration: none !important; transition: border-color .12s; min-width: 0; }
a.ov-stat:hover { border-color: var(--brand); }
.ov-n { font: 700 26px/1.1 var(--serif); }
.ov-l { font-weight: 600; color: var(--muted); font-size: 13px; }
.ov-sub { font-size: 12px; color: var(--faint); min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-new { color: var(--ok); font-weight: 600; }
.ov-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.ov-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ov-journal select { width: auto; padding: 5px 8px; font-size: 13px; }
.ov-filt { background: var(--brand-soft); padding: 6px 10px; border-radius: 8px; }
.ov-heat { margin-bottom: 12px; }
.hm-wrap { overflow-x: auto; }
.hm { display: inline-flex; flex-direction: column; gap: 3px; }
.hm-m { display: grid; grid-template-columns: repeat(27, 13px); gap: 3px; font-size: 10px; color: var(--faint); height: 14px; }
.hm-m span { white-space: nowrap; overflow: visible; }
.hm-g { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px; }
.hm-g > *, .hm-key i { width: 13px; height: 13px; border-radius: 3px; border: 0; padding: 0; display: inline-block; }
.hm-g button { cursor: pointer; }
.hm-g button.on { outline: 2px solid var(--text); outline-offset: 1px; }
.hm-key i { width: 10px; height: 10px; vertical-align: middle; }
.h-x { background: transparent; }
.h-0 { background: var(--surface-2); } .h-1 { background: color-mix(in srgb, var(--brand) 28%, var(--surface-2)); }
.h-2 { background: color-mix(in srgb, var(--brand) 52%, var(--surface-2)); } .h-3 { background: color-mix(in srgb, var(--brand) 76%, var(--surface-2)); } .h-4 { background: var(--brand); }
.hm-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.hm-key { display: inline-flex; align-items: center; gap: 3px; }
.jd { margin-bottom: 12px; }
.jd-h { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--border); padding: 4px 0; margin-bottom: 2px; font-family: var(--serif); }
.jl { display: grid; grid-template-columns: 22px auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 4px 2px; border-radius: 6px; }
.jl:hover { background: var(--surface-2); }
.jl-ic { font-weight: 700; text-align: center; color: var(--muted); }
.jl-add .jl-ic { color: var(--ok); } .jl-delete .jl-ic { color: var(--danger); }
.jl-k { font: 600 11px/1.6 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .3px; color: var(--faint); white-space: nowrap; }
.jl-n { min-width: 0; overflow-wrap: anywhere; }
.jl-del { text-decoration: line-through; color: var(--muted); }
.jl-run > summary { list-style: none; cursor: pointer; }
.jl-run > summary::-webkit-details-marker { display: none; }
.jl-run[open] > summary .faint { display: none; }
.jl-run > .jl { margin-left: 22px; }
.ov-chk { border-top: 1px solid var(--border); padding: 6px 0; }
.ov-chk:first-child { border-top: 0; }
.ov-chk summary { display: flex; gap: 8px; cursor: pointer; list-style: none; }
.ov-chk summary::-webkit-details-marker { display: none; }
.ov-warn { color: var(--leg); }
.ov-chk-list { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 4px 0 4px 22px; font-size: 13px; }
.ov-chk p { margin: 2px 0 0 22px; }
.ov-ok { color: var(--ok); }
.ov-ch th.num, .ov-ch td.num { text-align: center; }
.ov-ch td.w-bar { width: 90px; padding-left: 0; }
.ov-bar { display: block; height: 7px; border-radius: 9px; background: var(--brand); opacity: .7; min-width: 0; }
@media (max-width: 980px) { .ov-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .ov-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jl { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .jl-k { display: none; }
  .ov-ch th:nth-child(n+5), .ov-ch td:nth-child(n+5) { display: none; }
}

/* ---------- Story planner ---------- */
.pg-wrap { overflow: auto; max-height: calc(100vh - 150px); padding: 0; }
.pg { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.pg th, .pg td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: top; }
.pg thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); text-align: left; padding: 8px 10px; font-weight: 600; }
.pg thead tr.pg-acts + tr th { top: 30px; }
.pg-acts th { height: 30px; padding: 4px 10px !important; font: 700 12px/1.6 var(--serif) !important; color: var(--brand); background: var(--brand-soft) !important; cursor: pointer; letter-spacing: .4px; }
.pg-acts th:empty { background: var(--surface) !important; cursor: default; }
.pg-ch { min-width: 180px; cursor: pointer; }
.pg-ch b, .pg-ch span { display: block; }
.pg-ch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; font-weight: 400; }
.pg-un { background: var(--surface-2); }
.pg thead th.pg-un { background: var(--surface-2); cursor: default; }
.act-start { border-left: 2px solid var(--brand) !important; }
.pg-corner, .pg-arc { position: sticky; left: 0; z-index: 1; background: var(--surface); width: 200px; min-width: 170px; max-width: 220px; }
.pg-corner { z-index: 3 !important; font-family: var(--serif); }
.pg-arc { padding: 10px 12px 10px 14px; text-align: left; font-weight: 400; cursor: pointer; box-shadow: inset 4px 0 0 var(--ac, transparent); }
.pg-arc:hover { background: var(--surface-2); }
.pg-arc > * { display: block; }
.pg-an { font: 700 15px/1.3 var(--serif); }
.pg-prog { display: block; height: 5px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); margin: 6px 0 4px; overflow: hidden; width: 100%; max-width: 160px; }
.pg-prog span { display: block; height: 100%; background: var(--ok); }
.pg-cell { padding: 6px; min-width: 180px; height: 70px; position: relative; }
.pg-cell.over { background: var(--brand-soft); outline: 2px dashed var(--brand); outline-offset: -3px; }
.pg-add { display: block; width: 100%; border: 1px dashed transparent; background: none; color: var(--faint); border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; }
.pg-cell:hover .pg-add { border-color: var(--border); }
.pg-add:hover { color: var(--brand); border-color: var(--brand) !important; }
.bt { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px 6px 10px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  box-shadow: inset 3px 0 0 var(--ac); cursor: grab; font-size: 13px; transition: opacity .12s, box-shadow .12s; }
.bt:hover { border-color: var(--ac); }
.bt.drag { opacity: .4; }
.bt.dim { opacity: .3; }
.bt.lnk { box-shadow: inset 3px 0 0 var(--ac), 0 0 0 2px var(--leg); }
.bt-t { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.bt-m { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 11px; color: var(--muted); }
.bt-m a { text-decoration: none; }
.bt-c { display: flex; gap: 2px; margin-top: 2px; }
.bs { display: inline-block; font: 700 10px/1.6 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .3px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.bs-idea { background: transparent; border: 1px dashed var(--faint); color: var(--faint); }
.bs-planned { background: var(--surface-2); color: var(--text); }
.bs-drafted { background: var(--brand-soft); color: var(--brand); }
.bs-written { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.bt:has(.bs-idea) { border-style: dashed; }
.warn-t { color: var(--leg); font-weight: 600; }
.arc-list { display: flex; flex-direction: column; gap: 8px; }
.arc-row { display: flex; flex-direction: column; padding: 4px 0 4px 12px; box-shadow: inset 3px 0 0 var(--ac); }

.filters label.chk { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.filters label.chk input { flex: none; }
@media (max-width: 760px) { .pg-corner, .pg-arc { width: 120px; min-width: 120px; } .pg-ch, .pg-cell { min-width: 150px; } .pg-arc .small { display: none; } }

/* ---------- Knowledge ---------- */
.kn-wrap { overflow-x: auto; }
.kn-tbl th.kn-h a { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 600; color: var(--text); white-space: nowrap; }
.kn-tbl th.kn-h { text-align: center; }
.kn-sec { cursor: pointer; min-width: 180px; } .kn-sec:hover { background: var(--surface-2); }
.kn-sec b, .kn-sec span { display: block; }
.kn-cell { text-align: center; cursor: pointer; white-space: nowrap; } .kn-cell:hover { background: var(--surface-2); }
.kn-cell .small { margin-left: 3px; }
.kn { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 6px; font: 700 13px/1 system-ui, sans-serif; background: var(--surface-2); color: var(--muted); }
.kn-k { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.kn.kn-s { background: var(--leg-soft); color: var(--leg); }
.kn-l { background: var(--danger-soft); color: var(--danger); }
.kn-next { display: block; font-size: 11px; color: var(--faint); }
.kn-key { margin-top: 8px; }
.kn-tl { list-style: none; margin: 0; padding: 0; }
.kn-tl li { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; padding: 8px 6px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.kn-tl li:first-child { border-top: 0; }
.kn-tl li:hover { background: var(--surface-2); }
.kn-tl li.future { opacity: .5; }
.kn-when { color: var(--muted); font-weight: 600; }
@media (max-width: 760px) { .kn-tl li { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Continuity ---------- */
.ct { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ct:first-of-type { border-top: 0; }
.ct-ic { text-align: center; }
.ct-t { overflow-wrap: anywhere; }
.ct.off { opacity: .6; }
.ct .link { white-space: nowrap; }
.tag.ct-n { background: var(--danger-soft); color: var(--danger); font-family: system-ui, sans-serif; }
.ct-box { background: var(--leg-soft); border: 1px solid var(--leg); border-radius: var(--radius); padding: 4px 14px; margin: 0 0 16px; }
.ct-box .ct { border-top-color: color-mix(in srgb, var(--leg) 30%, transparent); }
.ct-off summary { cursor: pointer; margin-top: 8px; }
@media (max-width: 760px) { .ct { grid-template-columns: 22px minmax(0, 1fr); } .ct .link { grid-column: 2; justify-self: start; } }

/* ---------- Planner: outline & POV ---------- */
.ol { max-width: 860px; }
.ol-act { font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--brand); border-bottom: 2px solid var(--brand); padding-bottom: 4px; margin: 26px 0 6px; }
.ol-act:first-child { margin-top: 0; }
.ol-ch { margin: 18px 0; }
.ol-ch:first-child { margin-top: 0; }
.ol-ch h3 { cursor: pointer; }
.ol-ch > .small { margin: 2px 0 8px; }
.ol-sum { font-style: italic; color: var(--muted); }
.ol-b, .ol-e { padding: 6px 10px 6px 14px; margin: 6px 0; border-radius: 8px; }
.ol-b { box-shadow: inset 3px 0 0 var(--ac); cursor: pointer; }
.ol-b:hover { background: var(--surface-2); }
.ol-b p, .ol-e p { margin: 4px 0 0; }
.ol-e { color: var(--muted); }
.ol-skip { text-align: center; font-style: italic; color: var(--faint); margin: 10px 0; font-family: var(--serif); }
.ol-tools { margin-bottom: 10px; }
.pov-c { text-align: center; vertical-align: middle !important; font: 700 11px/1 system-ui, sans-serif; color: var(--muted); min-width: 70px; }
.pov-c.pov { background: color-mix(in srgb, var(--brand) 28%, transparent); color: var(--brand); letter-spacing: .5px; }
.pg-ch.pov-ch { min-width: 90px; }
.pg.pov .pg-arc a { font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.pov-share { min-width: 120px; vertical-align: middle !important; padding: 0 10px; white-space: nowrap; }
.pov-share .ov-bar { display: inline-block; vertical-align: middle; margin-right: 6px; max-width: 70px; }
@media print {
  .nav, .tl-bar, .page-head .row, .ol-tools, #toast { display: none !important; }
  .main { padding: 0; max-width: none; } .card { box-shadow: none; border: 0; }
  .ol-b { box-shadow: none; border-left: 3px solid var(--ac); }
}

/* ---------- Writing (2026-10-11) ---------- */
.w-run { text-align: center; padding: 22px 16px; margin-bottom: 16px; border-color: var(--brand); }
.w-clock { font: 700 54px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.w-done { color: var(--ok); font-weight: 600; }
.w-start { margin-bottom: 16px; }
.w-note { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.w-note-t { font-size: 16px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.w-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.w-stats .ov-stat { display: flex; flex-direction: column; padding: 12px 14px; min-width: 0; }
.w-bar { height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.w-bar i { display: block; height: 100%; background: var(--ok); }
.w-h { font-size: 16px; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; }
.w-chart { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 120px; border-bottom: 1px solid var(--border); }
.w-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.w-col i { display: block; width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; opacity: .8; }
.w-col.today i { opacity: 1; background: var(--ok); }
.w-col i.neg { background: var(--danger); }
.w-goal { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--ok); pointer-events: none; }
.w-axis { display: flex; justify-content: space-between; margin-top: 4px; }
.w-list { display: flex; flex-direction: column; }
.w-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); }
.w-row:first-child { border-top: 0; }
.w-d { flex: none; width: 110px; font-weight: 600; font-size: 13px; }
.w-m { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .w-clock { font-size: 42px; } .w-d { width: 80px; } }
