/* Lore Forge – night-sky reading room. Entity type colours (set per type) are the main accent in content. */
:root {
  color-scheme: light dark;
  --bg: #f1f2f6;
  --surface: #ffffff;
  --surface2: #e9ebf2;
  --line: #d6d9e3;
  --text: #191d2a;
  --muted: #646c80;
  --accent: #5a3fd0;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --ok: #1f7a46;
  --warn: #9a6200;
  --mark: #ffe58a;
  --tc: var(--accent);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --side: 16.5rem;
  --shadow: 0 1px 0 rgba(20, 24, 40, 0.04), 0 8px 24px -12px rgba(20, 24, 40, 0.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f16; --surface: #141925; --surface2: #1b2231; --line: #273046; --text: #e3e7f0; --muted: #8b95ab;
    --accent: #a897ff; --accent-ink: #12102a; --danger: #ff8a80; --ok: #6fd39a; --warn: #f0be5a; --mark: #5b4d12;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f16; --surface: #141925; --surface2: #1b2231; --line: #273046; --text: #e3e7f0; --muted: #8b95ab;
  --accent: #a897ff; --accent-ink: #12102a; --danger: #ff8a80; --ok: #6fd39a; --warn: #f0be5a; --mark: #5b4d12;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 650; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 0.8em; }
small, .small { font-size: 0.85em; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.right { text-align: right; white-space: nowrap; }
.bad, .danger-text { color: var(--danger); }
.icon { flex: none; vertical-align: -0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 1rem; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.01em; }
.brand-wrap { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.app-ver { font-size: 0.62rem; color: var(--muted); padding-left: 1.7rem; letter-spacing: 0.02em; }
.brand-mark { width: 1.15rem; height: 1.15rem; border-radius: 50%; background: radial-gradient(circle at 70% 35%, transparent 0 46%, var(--accent) 47%); box-shadow: inset 0 0 0 1.5px var(--accent); }
.crumb-world { color: var(--muted); text-decoration: none; padding-left: 0.7rem; border-left: 1px solid var(--line); }
.topsearch { display: flex; align-items: center; gap: 0.4rem; margin-left: 0.8rem; padding: 0 0.6rem; background: var(--surface2); border-radius: 999px; color: var(--muted); min-width: 0; flex: 0 1 22rem; }
.topsearch input { all: unset; flex: 1; min-width: 0; padding: 0.4rem 0; color: var(--text); }
.body { display: flex; flex: 1; min-width: 0; }
.side { width: var(--side); flex: none; padding: 1rem 0.8rem 3rem; border-right: 1px solid var(--line); position: sticky; top: 3.1rem; align-self: flex-start; height: calc(100vh - 3.1rem); height: calc(100dvh - 3.1rem); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.no-side .side { display: none; }
.side-world { display: flex; flex-direction: column; margin-bottom: 0.8rem; padding: 0 0.3rem; }
.navgroup { margin-top: 1.1rem; display: flex; flex-direction: column; }
.navgroup h4 { margin: 0 0 0.25rem 0.5rem; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.navgroup.foot { border-top: 1px solid var(--line); padding-top: 0.6rem; }
.navlink { display: flex; align-items: center; gap: 0.55rem; padding: 0.3rem 0.5rem; border-radius: var(--radius); color: var(--text); text-decoration: none; }
.navlink:hover { background: var(--surface2); }
.navlink.on { background: var(--surface2); font-weight: 600; }
.navlink small { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.navlink .dot { width: 0.55rem; height: 0.55rem; border-radius: 2px; background: var(--tc); flex: none; }
.main { flex: 1; min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 5rem; outline: none; }
.page { max-width: 120rem; margin: 0 auto; }
.page.narrow { max-width: 42rem; } .page.wide { max-width: 140rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.lede { color: var(--muted); max-width: 50rem; margin: 0.4rem 0 0; }

/* ---------- controls ---------- */
.btn.burger { display: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.42rem 0.85rem; font: inherit; font-weight: 550; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-decoration: none; line-height: 1.25; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.sm { padding: 0.22rem 0.55rem; font-size: 0.85rem; }
.btn.icon-only { padding: 0.42rem; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.42rem 0.6rem; max-width: 100%; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; padding: 0; }
input[type="color"] { padding: 0.1rem; height: 2.2rem; width: 4rem; }
input[readonly], textarea[readonly] { opacity: 0.65; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.9rem; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.field small { color: var(--muted); }
.check { display: flex; align-items: center; gap: 0.5rem; margin: 0.4rem 0; }
.form-err { color: var(--danger); margin: 0.4rem 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.sec-head { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0 0.6rem; flex-wrap: wrap; }
.sec-head h2, .sec-head h3 { margin: 0; }
.row-actions { display: flex; gap: 0.4rem; margin: 0.5rem 0; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { all: unset; cursor: pointer; padding: 0.3rem 0.8rem; font-size: 0.9rem; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--line); margin-bottom: 0.8rem; overflow-x: auto; }
.tabs button { all: unset; cursor: pointer; padding: 0.55rem 0.9rem; border-bottom: 2px solid transparent; white-space: nowrap; color: var(--muted); }
.tabs button.on { color: var(--text); border-color: var(--accent); font-weight: 600; }
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { max-width: calc(100vw - 1.5rem); position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 13rem; display: flex; flex-direction: column; padding: 0.3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu-pop.right { left: auto; right: 0; }
.menu-pop a, .menu-pop button { all: unset; display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border-radius: 4px; cursor: pointer; color: var(--text); }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface2); }
.menu-pop .danger-text { color: var(--danger); }

/* chips, pills, badges */
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.12rem 0.55rem 0.12rem 0.45rem; border-radius: 4px; font-size: 0.85rem; font-weight: 600; color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); }
.chip.sm { font-size: 0.78rem; padding: 0.05rem 0.4rem; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--surface2); font-size: 0.85rem; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.pill button { all: unset; cursor: pointer; display: inline-flex; color: var(--muted); }
.pill button:hover { color: var(--danger); }
a.pill:hover { border-color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.08rem 0.5rem; border-radius: 4px; font-size: 0.78rem; background: var(--surface2); color: var(--muted); }
.badge.st-canon { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.st-draft { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.st-discarded { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.badge.vis.pub { color: var(--accent); }
.alink { color: var(--text); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--tc, var(--accent)) 55%, transparent); }
.alink:hover { color: var(--tc, var(--accent)); }
.alink .chip { margin-right: 0.4rem; border-bottom: 0; }
.vocab { display: inline-flex; align-items: center; gap: 0.35rem; }
.vocab[style*="--vc"]::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--vc); }
.avatar { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--ac, var(--accent)); color: #fff; font-size: 0.8rem; font-weight: 700; margin-left: -0.35rem; border: 2px solid var(--surface); }
.people { display: inline-flex; padding-left: 0.35rem; }

/* dialogs / toasts */
.dlg { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); padding: 1.3rem 1.4rem; width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(5, 8, 14, 0.55); }
.dlg h3 { font-size: 1.15rem; margin-bottom: 1rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.toasts { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(26rem, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: 0.6rem 0.9rem; border-radius: var(--radius); box-shadow: var(--shadow); animation: toast-in 0.18s ease-out; }
.toast.bad { background: var(--danger); color: var(--surface); }
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.spin { width: 1.6rem; height: 1.6rem; margin: 3rem auto; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty h2, .empty h3 { color: var(--text); }

/* tables & lists */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.tbl th, .tbl td { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.inherited td { color: var(--muted); background: var(--surface2); }
.tbl tr.inactive { opacity: 0.55; }
.tbl .btn + .btn { margin-left: 0.3rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; }
.linklist, ul.plain, .results, .tree, .tree ul { list-style: none; padding: 0; margin: 0; }
.linklist li { padding: 0.25rem 0; }
ul.plain li { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0; flex-wrap: wrap; }
.tree ul { padding-left: 1.2rem; border-left: 1px solid var(--line); margin-left: 0.4rem; }
.tree summary, .tree .leaf { padding: 0.2rem 0; }
.tree .leaf { padding-left: 1.05rem; }
.results li { padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.snippet { color: var(--muted); margin: 0.2rem 0 0; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.bigsearch { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; } .bigsearch input { flex: 1; font-size: 1.1rem; padding: 0.6rem 0.8rem; }

/* worlds, dashboard */
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.world-card { display: block; padding: 1.2rem 1.3rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.world-card:hover { box-shadow: var(--shadow); }
.world-card h2 { margin-bottom: 0.3rem; } .world-card p { color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; align-items: start; }
.big { font-size: 2.4rem; font-weight: 700; margin: 0 0 0.6rem; font-variant-numeric: tabular-nums; line-height: 1; }
.bars { list-style: none; padding: 0; margin: 0 0 0.8rem; display: grid; gap: 0.35rem; }
.bars li { display: grid; grid-template-columns: 9rem 1fr 2.5rem; gap: 0.6rem; align-items: center; }
.bars a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar { height: 0.5rem; background: var(--surface2); border-radius: 3px; overflow: hidden; } .bars .bar i { display: block; height: 100%; background: var(--accent); }
.bars b { text-align: right; font-variant-numeric: tabular-nums; }
.wl.missing { color: var(--danger); }
.auth { max-width: 24rem; margin: 6vh auto; } .auth h1 { margin-bottom: 1.2rem; }
.boot-error { max-width: 30rem; margin: 20vh auto; text-align: center; }

/* new article */
.type-grid h3 { margin: 0.8rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.type-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.type-opt { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.7rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.type-opt .dot { width: 0.6rem; height: 0.6rem; border-radius: 2px; background: var(--tc); }
.type-opt.on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 16%, var(--surface)); font-weight: 600; }

/* ---------- article ---------- */
.article { --tc: var(--accent); max-width: 120rem; margin: 0 auto; }
.a-head { border-left: 4px solid var(--tc); padding-left: 1.1rem; margin-bottom: 1.4rem; }
.crumbs { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.5rem; }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--text); }
.crumbs .chip { color: var(--tc); }
.a-titlebar { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.a-title { font: 700 clamp(1.9rem, 4vw, 2.7rem)/1.1 var(--serif); letter-spacing: -0.01em; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
.a-abbr { color: var(--muted, var(--mut)); font-weight: 500; }
.alink .abbr { opacity: .65; font-size: .92em; }
.abbr-input { max-width: 12rem; }
.a-title-input { flex: 1 1 18rem; min-width: 0; font: 700 clamp(1.6rem, 3.5vw, 2.3rem)/1.15 var(--serif); padding: 0.1rem 0.4rem; margin-bottom: 0.5rem; }
.a-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.badges { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.sync { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.sync.offline { color: var(--danger); }
.a-grid { display: grid; justify-content: start; grid-template-columns: minmax(0, 74rem) clamp(21rem, 24vw, 30rem); gap: 2rem; align-items: start; }
.a-main { min-width: 0; }
.a-aside { position: sticky; top: 4rem; display: flex; flex-direction: column; gap: 1rem; max-height: calc(100vh - 5rem); overflow-y: auto; padding-bottom: 1rem; }
.a-aside .panel { margin: 0; }
.infobox { border-top: 3px solid var(--tc); padding-top: 0.8rem; }
.ib-group + .ib-group { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.ib-group h3 { font-size: 0.85rem; color: var(--muted); font-weight: 600; margin-bottom: 0.4rem; }
.infobox dl { margin: 0; display: grid; gap: 0.5rem; }
.ib-row { display: grid; grid-template-columns: 7.2rem 1fr; gap: 0.6rem; align-items: baseline; }
.writing .ib-row { grid-template-columns: 1fr; gap: 0.15rem; }
.ib-row dt { color: var(--muted); font-size: 0.85rem; display: flex; gap: 0.3rem; align-items: baseline; }
.ib-row dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ib-row dd input:not([type="checkbox"]), .ib-row dd select { width: 100%; }
.ib-row .lock { color: var(--muted); }
.ib-row .refs { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.unit { color: var(--muted); } .with-unit { display: flex; align-items: center; gap: 0.4rem; } .with-unit input { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
.field-img { max-width: 100%; border-radius: var(--radius); display: block; margin-bottom: 0.4rem; }
.img-edit { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; }
.date-edit { display: grid; grid-template-columns: 4rem 1fr 5.5rem; gap: 0.3rem; } .date-edit small { grid-column: 1 / -1; }
.checks { display: grid; gap: 0.1rem; }
.props .prop { display: grid; gap: 0.15rem; margin-bottom: 0.7rem; } .props .prop > label { font-size: 0.85rem; color: var(--muted); } .props select { width: 100%; }
.taginput { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; padding: 0.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.taginput input { all: unset; flex: 1; min-width: 6rem; padding: 0.15rem 0.3rem; }
.picker { position: relative; } .picker-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.3rem; } .picker-input { width: 100%; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0.2rem; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 16rem; overflow-y: auto; }
.picker-list li { padding: 0.35rem 0.5rem; border-radius: 4px; cursor: pointer; display: flex; gap: 0.5rem; align-items: center; } .picker-list li:hover { background: var(--surface2); } .picker-list li.none { color: var(--muted); cursor: default; }

/* prose */
.md { font: 1.07rem/1.72 var(--serif); max-width: 64rem; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--sans); margin: 1.8em 0 0.5em; }
.md h2 { font-size: 1.35rem; padding-bottom: 0.25em; border-bottom: 1px solid var(--line); } .md h3 { font-size: 1.1rem; }
.md p { margin: 0 0 1em; }
.md blockquote { margin: 1.2em 0; padding: 0.1em 1.1em; border-left: 3px solid var(--tc); color: var(--muted); font-style: italic; }
.md code { font: 0.88em var(--mono); background: var(--surface2); padding: 0.1em 0.35em; border-radius: 3px; }
.md pre { background: var(--surface2); padding: 0.8rem 1rem; border-radius: var(--radius); overflow-x: auto; } .md pre code { background: none; padding: 0; }
.md img { max-width: 100%; border-radius: var(--radius); }
.md table { border-collapse: collapse; font: 0.95rem var(--sans); } .md th, .md td { border: 1px solid var(--line); padding: 0.35rem 0.7rem; } .md th { background: var(--surface2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.md a.wl { text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.md a.wl.missing { color: var(--danger); border-bottom-style: dashed; }
.md aside.secret { position: relative; margin: 1.2em 0; padding: 0.7em 1em 0.2em; border: 1px dashed var(--warn); border-radius: var(--radius); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.md aside.secret::before { content: attr(data-label); display: block; font: 600 0.75rem var(--sans); color: var(--warn); margin-bottom: 0.4em; }
.long-field { margin-top: 2rem; }
.a-below { margin-top: 2.5rem; display: grid; gap: 1.8rem; }
.a-below h2 { font-size: 1.05rem; }
.rel-group { margin-bottom: 0.8rem; } .rel-group h3 { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.2rem; }
.rel-group ul { list-style: none; padding: 0; margin: 0; } .rel-group li { padding: 0.25rem 0; }
.rel-group li .btn { margin-left: 0.4rem; }

/* editor */
.split { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 1250px) { .writing .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .writing .a-grid { grid-template-columns: minmax(0, 1fr) clamp(20rem, 22vw, 28rem); } .writing .a-main { max-width: none; } }
.preview { display: none; border-left: 1px solid var(--line); padding-left: 1.5rem; max-width: none; }
@media (min-width: 1250px) { .preview { display: block; } }
.editor-wrap { position: relative; }
.editor { font: 0.95rem/1.6 var(--mono); min-height: 14rem; padding: 0.8rem 1rem; border-radius: 0 0 var(--radius) var(--radius); tab-size: 2; resize: none; overflow: hidden; }
.toolbar { display: flex; gap: 0.2rem; padding: 0.3rem; background: var(--surface2); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.tb { all: unset; cursor: pointer; display: inline-grid; place-items: center; min-width: 1.9rem; height: 1.9rem; border-radius: 4px; padding: 0 0.3rem; } .tb:hover { background: var(--surface); }
.wiki-suggest { position: fixed; z-index: 70; left: 0; top: 0; margin: 0; padding: 0.2rem; list-style: none; min-width: 14rem; max-width: min(34rem, calc(100vw - 1rem)); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow); }
.wiki-suggest li { padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer; } .wiki-suggest li.on, .wiki-suggest li:hover { background: var(--surface2); }

/* history drawer */
.drawer { position: fixed; z-index: 60; top: 0; right: 0; bottom: 0; width: min(46rem, 100vw); display: grid; grid-template-columns: 15rem 1fr; grid-template-rows: auto 1fr; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); animation: drawer-in 0.18s ease-out; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); } .drawer-head h2 { margin: 0; }
.versions { list-style: none; margin: 0; padding: 0.4rem; overflow-y: auto; border-right: 1px solid var(--line); }
.ver { all: unset; box-sizing: border-box; display: flex; flex-direction: column; width: 100%; padding: 0.5rem 0.6rem; border-radius: var(--radius); cursor: pointer; } .ver:hover, .ver.on { background: var(--surface2); }
.ver-detail { padding: 1rem; overflow: auto; }
.ver-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.diff { font: 0.82rem/1.5 var(--mono); background: var(--surface2); padding: 0.6rem; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap; }
.dl.add { background: color-mix(in srgb, var(--ok) 20%, transparent); } .dl.del { background: color-mix(in srgb, var(--danger) 18%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 50%, transparent); }

/* schema editor */
.types-tab { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.type-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 75vh; overflow-y: auto; }
.tl { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.3rem 0.6rem; cursor: pointer; } .tl:hover, .tl.on { background: var(--surface2); } .tl.on { font-weight: 600; box-shadow: inset 3px 0 0 var(--tc, var(--accent)); }
.tl .dot { width: 0.55rem; height: 0.55rem; border-radius: 2px; background: var(--tc, var(--muted)); }
.vocab-panel summary { cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .a-grid { grid-template-columns: 1fr; } .a-aside { position: static; max-height: none; order: -1; }
  .types-tab { grid-template-columns: 1fr; }
  .drawer { grid-template-columns: 1fr; grid-template-rows: auto 12rem 1fr; } .versions { border-right: 0; border-bottom: 1px solid var(--line); }
}
.side-close, .side-backdrop { display: none; }
@media (max-width: 800px) {
  .btn.burger { display: inline-flex; }
  .side { position: fixed; z-index: 50; top: 3.1rem; left: 0; bottom: auto; height: calc(100vh - 3.1rem); height: calc(100dvh - 3.1rem); padding-bottom: 5rem; background: var(--bg); transform: translateX(-102%); transition: transform 0.18s; width: min(var(--side), 86vw); box-shadow: var(--shadow); }
  .side-open .side { transform: none; top: 0; z-index: 70; height: 100vh; height: 100dvh; width: min(var(--side), 86vw); padding-top: 0.6rem; }
  body.side-open { overflow: hidden; }
  .side-backdrop { display: none; }
  .side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); }
  .side-close { display: flex; width: 100%; justify-content: center; margin-bottom: 0.6rem; }
  .no-side .btn.burger { display: none; }
  .crumb-world { display: none; } .topsearch { flex-basis: 8rem; margin-left: 0; }
  .brand span:last-child { display: none; }
  .main { padding: 1rem 1rem 4rem; }
  .tabs { margin-right: -1rem; }
  .main { overflow-x: clip; }
  .tbl { display: block; overflow-x: auto; }
  .bars li { grid-template-columns: 6rem 1fr 2rem; }
  .ib-row { grid-template-columns: 1fr; gap: 0.1rem; }
}

.review-btn.on { background: var(--warn-bg, #fff3d6); border-color: var(--warn, #d9a21b); color: var(--warn-fg, #8a5d00); }
:root[data-theme="dark"] .review-btn.on { background: #3a2f12; color: #f1c65a; border-color: #8a6a1d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .review-btn.on { background: #3a2f12; color: #f1c65a; border-color: #8a6a1d; } }
.notes h3 { display: flex; align-items: center; gap: 0.3rem; }
.note-list { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.note { border-left: 3px solid var(--line); padding: 0.1rem 0 0.1rem 0.6rem; }
.note.from-ai { border-left-color: var(--accent); }
.note-meta { display: flex; align-items: center; gap: 0.3rem; } .note-check { margin: 0 0.2rem 0 0; cursor: pointer; }
.note.done { opacity: 0.7; } .note.done summary { cursor: pointer; list-style-position: outside; }
.notes-done { margin: 0 0 0.6rem; } .notes-done > summary { cursor: pointer; margin-bottom: 0.4rem; }
.note-body.md { font: 0.92rem/1.5 var(--sans, system-ui); max-width: none; }
.note-body.md > :first-child { margin-top: 0.2rem; } .note-body.md > :last-child { margin-bottom: 0; }
.note-form { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; } .note-form textarea { width: 100%; resize: vertical; }
.review-list { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.review-last { margin-top: 0.1rem; overflow-wrap: anywhere; }
.filters .chk { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.tok-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.tok-list li { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; align-items: flex-start; }
.tok-list .badge { margin-left: 0.5rem; }
.tok-form { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.url-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; } .url-row code { overflow-wrap: anywhere; }
.tok-secret { white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.api-panel .chk { display: flex; align-items: center; gap: 0.4rem; }
.linkbtn { background: none; border: 0; padding: 0 0.2rem; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline dotted; }
.linkbtn:hover { text-decoration: underline; }
.wanted-from { margin: 0.2rem 0 0.4rem 1rem; } .wanted-from[hidden] { display: none; }
.status-sel { font: inherit; font-size: 0.8rem; padding: 0.15rem 0.4rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.status-sel.st-canon { color: var(--ok); } .status-sel.st-draft { color: var(--warn); } .status-sel.st-discarded { color: var(--danger); }
.status-link { color: inherit; text-decoration: none; border-bottom: 1px dotted currentColor; } .status-link:hover { color: var(--accent); border-bottom-style: solid; }

/* link assistant */
.badge-n { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 0.45rem; font-size: 0.7rem; line-height: 1.3; }
.link-btn { text-decoration: none; }
.links-settings, .links-rules { margin-top: 1rem; } .links-settings summary, .links-rules summary { cursor: pointer; }
.links-settings form { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; margin-top: 0.6rem; } .row-fields { display: flex; gap: 1rem; flex-wrap: wrap; } .field.inline input { width: 5rem; }
.la-bar { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin: 0.8rem 0; }
.la-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 1100px) { .la-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: start; } .la-grid > .panel:first-child { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); overflow: auto; } }
.la-preview { font-size: 0.95rem; max-width: none; }
.chg { border-radius: 3px; padding: 0 0.12rem; cursor: pointer; color: inherit; }
.chg.k-add { background: color-mix(in srgb, var(--ok) 25%, transparent); } .chg.k-dedupe { background: color-mix(in srgb, var(--warn) 28%, transparent); } .chg.k-abbr { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.chg.hot, .chg.sel { outline: 2px solid var(--accent); }
.la-tbl td { vertical-align: top; } .la-place { font-size: 0.85rem; line-height: 1.5; word-break: break-word; }
.la-place del { background: color-mix(in srgb, var(--danger) 16%, transparent); text-decoration: line-through; padding: 0 0.1rem; border-radius: 3px; }
.la-place ins { background: color-mix(in srgb, var(--ok) 20%, transparent); text-decoration: none; padding: 0 0.1rem; border-radius: 3px; }
.la-kind { white-space: nowrap; font-weight: 600; font-size: 0.8rem; } .la-kind.k-add { color: var(--ok); } .la-kind.k-dedupe { color: var(--warn); } .la-kind.k-abbr { color: var(--accent); }
.la-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: flex-start; } .la-ignore { position: relative; }
.la-ignore .menu-pop { left: 0; right: auto; min-width: 10rem; z-index: 40; }
tr.flash { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.la-tbl .la-place { min-width: 14rem; } .la-tbl .la-actions { min-width: 7.5rem; flex-direction: column; } .la-tbl .la-actions .btn { white-space: nowrap; }
