/* ============ Tokens ============ */
:root {
  --bg: #f3efe6; --bg-2: #ebe5d8; --panel: #fbf9f4; --panel-2: #f2ede3; --panel-3: #e9e2d5;
  --ink: #1d1b16; --ink-2: #514c40; --ink-3: #8a8473; --line: #e0d8c7; --line-2: #cec4ae;
  --accent: #a4561b; --accent-2: #c46a26; --accent-ink: #fff; --accent-soft: #f3e1ca;
  --danger: #b04848; --mark: #ffe28a; --mark-ink: #2a2000;
  --shadow-sm: 0 1px 2px rgba(40, 30, 10, .06);
  --shadow-md: 0 2px 6px rgba(40, 30, 10, .06), 0 10px 28px rgba(40, 30, 10, .08);
  --shadow-lg: 0 20px 60px rgba(30, 20, 5, .22);
  --radius: 12px; --side-w: 300px; --panel-w: 500px;
  --serif: Fraunces, Georgia, serif; --sans: Inter, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015; --bg-2: #12151c; --panel: #151922; --panel-2: #1b202a; --panel-3: #232936;
    --ink: #ece8df; --ink-2: #b3ad9f; --ink-3: #7b766b; --line: #252a35; --line-2: #333a48;
    --accent: #e9a85a; --accent-2: #f2bb75; --accent-ink: #1b1306; --accent-soft: #3a2d1b;
    --danger: #e27b7b; --mark: #6e5520; --mark-ink: #fff3d0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow-md: 0 2px 8px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.3); --shadow-lg: 0 24px 70px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1015; --bg-2: #12151c; --panel: #151922; --panel-2: #1b202a; --panel-3: #232936;
  --ink: #ece8df; --ink-2: #b3ad9f; --ink-3: #7b766b; --line: #252a35; --line-2: #333a48;
  --accent: #e9a85a; --accent-2: #f2bb75; --accent-ink: #1b1306; --accent-soft: #3a2d1b;
  --danger: #e27b7b; --mark: #6e5520; --mark-ink: #fff3d0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow-md: 0 2px 8px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.3); --shadow-lg: 0 24px 70px rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--sans); display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 1px; }
kbd { font: 600 11px/1 var(--sans); padding: 3px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--panel); color: var(--ink-2); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.small svg.i, .xs svg.i { width: 15px; height: 15px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s, color .12s; }
button:hover { border-color: var(--line-2); background: var(--panel-2); }
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.small { padding: 4px 9px; font-size: 12px; }
button.danger { color: var(--danger); }
.icon-btn { padding: 0; width: 34px; height: 34px; justify-content: center; background: transparent; border-color: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
.icon-btn.wide { width: auto; padding: 0 6px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; }
.icon-btn.on { color: var(--accent); }

/* ============ Topbar ============ */
.topbar { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; margin-right: 4px; }
.brand-mark { color: var(--accent); display: flex; }
.brand-mark svg.i { width: 24px; height: 24px; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.search-wrap { flex: 1; min-width: 140px; max-width: 640px; position: relative; display: flex; align-items: center; }
.search-wrap .search-icon { position: absolute; left: 11px; color: var(--ink-3); display: flex; pointer-events: none; }
.search-wrap kbd { position: absolute; right: 9px; pointer-events: none; }
#search { width: 100%; padding: 8px 36px 8px 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); transition: border-color .12s, box-shadow .12s; }
#search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search:focus + kbd, #search:not(:placeholder-shown) + kbd { display: none; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 5px 10px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.seg button:hover { background: var(--panel-2); color: var(--ink); }
.seg button.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button.active svg.i { color: var(--accent); }
.seg.small button { padding: 3px 9px; font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

/* ============ Layout ============ */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--side-w) minmax(0,1fr) var(--panel-w); }
.layout.no-detail { grid-template-columns: var(--side-w) minmax(0,1fr); }
.layout.no-detail .detail { display: none; }
.layout.detail-collapsed { grid-template-columns: var(--side-w) minmax(0,1fr) 46px; }
.layout.no-sidebar { --side-w: 0px; }
.layout.no-sidebar .sidebar { display: none; }

/* ============ Sidebar ============ */
.sidebar { border-right: 1px solid var(--line); overflow: auto; padding: 6px 10px 0; background: var(--panel); display: flex; flex-direction: column; }
.side-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); margin: 12px 0 4px; padding: 0 2px; font-weight: 700; cursor: pointer; user-select: none; }
.side-head:hover { color: var(--ink); }
.side-head .caret { display: inline-block; width: 16px; }
.tree { margin-bottom: 4px; }
.tree-item { display: flex; align-items: flex-start; gap: 4px; padding: 4px 6px; border-radius: 7px; cursor: pointer; color: var(--ink-2); min-width: 0; line-height: 1.35; position: relative; }
.tree-item:hover { background: var(--panel-2); color: var(--ink); }
.tree-item.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.tree-item.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--accent); }
.tree-item.group { color: var(--ink); font-weight: 500; }
.tree-item.muted { opacity: .5; }
.tree-item .caret { width: 16px; height: 19px; flex: none; color: var(--ink-3); display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.tree-item .caret[data-toggle]:hover { color: var(--accent); background: var(--panel-3); }
.caret.has::before { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: rotate(-45deg); transition: transform .14s; }
.caret.has.open::before { transform: rotate(45deg) translate(-2px, -1px); }
.side-head .caret.has::before { margin-right: 6px; }
.tree-item .label { min-width: 0; overflow-wrap: anywhere; }
.tree-item .sub { font-size: 11px; color: var(--ink-3); flex: none; margin-top: 1px; }
.tree-item .count { margin-left: auto; padding-left: 6px; font-size: 11px; color: var(--ink-3); flex: none; font-weight: 500; font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; background: var(--dc, var(--ink-3)); }
.tree-item .dot { margin-top: 5px; }
.domain-form { display: grid; gap: 6px; margin: 4px 0 8px; }
.domain-form input, .domain-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.side-foot { margin-top: auto; position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 4px; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--ink-3); }

/* ============ Main ============ */
.main { min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; min-height: 54px; }
.toolbar .count-label { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.toolbar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12px; font-weight: 600; max-width: 360px; }
.pill .pill-kind { color: var(--ink-3); font-weight: 500; }
.pill .pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill button { width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; justify-content: center; background: transparent; }
.pill button:hover { background: rgba(0,0,0,.1); }
.pill button svg.i { width: 12px; height: 12px; }
.toolbar select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 13px; }
.filter-btn.on { border-color: var(--accent); color: var(--accent); }
.filter-btn .badge-n { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 10px; padding: 0 6px; font-weight: 700; }
.filter-panel { padding: 14px 22px 6px; border-bottom: 1px solid var(--line); background: var(--panel); display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 24px; }
.facet-name { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-bottom: 6px; font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; margin: 0 4px 6px 0; cursor: pointer; background: var(--panel); color: var(--ink-2); text-decoration: none; transition: all .12s; }
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.content { flex: 1; overflow: auto; padding: 0 22px 60px; scroll-behavior: smooth; }

/* Hero / Header */
.hero { padding: 28px 0 8px; }
.hero h1 { font-family: var(--serif); font-weight: 700; font-size: 34px; letter-spacing: -.02em; margin: 0 0 4px; line-height: 1.15; }
.hero .lead { color: var(--ink-2); font-size: 15px; max-width: 720px; margin: 0 0 18px; }
.hero .crumbs { margin-bottom: 6px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 104px; }
.stat b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; margin: 22px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile { text-align: left; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 14px 14px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); position: relative; overflow: hidden; min-height: 112px; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--dc); }
.tile:hover { border-color: var(--dc); box-shadow: var(--shadow-md); transform: translateY(-1px); background: var(--panel); }
.tile h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.25; padding-right: 34px; }
.tile p { margin: 0; font-size: 12.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .tile-count { position: absolute; top: 12px; right: 12px; font-weight: 700; font-size: 13px; color: var(--dc); font-variant-numeric: tabular-nums; }
.tile .tile-subs { margin-top: auto; padding-top: 6px; font-size: 11.5px; color: var(--ink-3); }
.tile.empty-tile { opacity: .55; }
.tile.empty-tile:hover { opacity: .9; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }

/* Group heads */
.cgroup { margin-top: 26px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 8px 0; }
.group-head h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: -.01em; cursor: pointer; }
.group-head h2:hover { color: var(--dc); }
.group-head .count { color: var(--ink-3); font-size: 12px; font-weight: 600; background: var(--panel-2); border-radius: 999px; padding: 1px 8px; }
.group-head .line { flex: 1; height: 1px; background: var(--line); }
.group-head .dot { width: 11px; height: 11px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px 12px; cursor: pointer; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s, border-color .12s; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--dc); opacity: .85; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-md); }
.card-top { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.card-top .card-domain { display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-top .dot { width: 7px; height: 7px; }
.card h3 { font-family: var(--serif); font-weight: 600; margin: 2px 0 0; font-size: 17px; line-height: 1.25; letter-spacing: -.005em; }
.card .card-alias { font-size: 12px; color: var(--ink-3); font-style: italic; margin-top: -2px; }
.card p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; gap: 12px; margin-top: auto; padding-top: 8px; font-size: 11.5px; color: var(--ink-3); align-items: center; }
.card-foot span { display: inline-flex; align-items: center; gap: 4px; }
.card-foot svg.i { width: 13px; height: 13px; }
.card-foot .stub { margin-left: auto; border: 1px dashed var(--line-2); border-radius: 999px; padding: 0 7px; }

/* List rows */
table.rows { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.rows th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
table.rows td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
table.rows tr:last-child td { border-bottom: 0; }
table.rows tbody tr { cursor: pointer; }
table.rows tbody tr:hover td { background: var(--panel-2); }
table.rows tr.active td { background: var(--accent-soft); }
table.rows td.name b { font-weight: 600; }
table.rows td.name .alias { font-size: 12px; color: var(--ink-3); font-style: italic; }
table.rows td.def { color: var(--ink-2); max-width: 460px; }
table.rows td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); white-space: nowrap; }
table.rows td.dom { white-space: nowrap; color: var(--ink-2); }
table.rows td.dom .dot { width: 8px; height: 8px; margin-right: 6px; }

/* Timeline */
.timeline { position: relative; margin: 26px 0 0 8px; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 0; width: 2px; background: linear-gradient(var(--line-2), var(--line)); border-radius: 2px; }
.tl-bucket { margin-bottom: 18px; }
.tl-label { font-family: var(--serif); font-weight: 700; font-size: 20px; margin: 0 0 10px -28px; display: flex; align-items: center; gap: 12px; }
.tl-label::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); }
.tl-label .count { font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-weight: 600; }
.tl-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.tl-item { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--dc); border-radius: 10px; padding: 9px 12px; cursor: pointer; transition: box-shadow .12s, transform .12s; }
.tl-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tl-item.active { border-color: var(--accent); }
.tl-year { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--dc); min-width: 40px; font-size: 13px; padding-top: 1px; }
.tl-body b { display: block; font-weight: 600; line-height: 1.3; }
.tl-body span { font-size: 12.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.empty { color: var(--ink-3); padding: 50px 20px; text-align: center; }
.login { display: grid; gap: 10px; max-width: 320px; margin: 60px auto; padding: 0 16px; }
.login b { font-family: var(--serif); font-size: 20px; color: var(--ink); }
.login input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font-size: 16px; }
.login button { padding: 10px 12px; }
.login-msg { color: var(--accent); font-size: 13px; min-height: 1em; }
.empty b { display: block; font-family: var(--serif); font-size: 18px; color: var(--ink-2); margin-bottom: 4px; }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: skel 1.2s infinite; border-radius: var(--radius); border: 1px solid var(--line); height: 130px; }
@keyframes skel { to { background-position: -200% 0; } }

/* ============ Detail ============ */
.detail { border-left: 1px solid var(--line); overflow: auto; background: var(--panel); position: relative; }
.resizer { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 4; }
.resizer:hover, .resizer.drag { background: var(--accent); opacity: .5; }
.detail-bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 6px 10px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); min-height: 47px; }
.detail-bar .spacer { flex: 1; }
.detail-bar .pos { font-size: 12px; color: var(--ink-3); margin: 0 6px; font-variant-numeric: tabular-nums; }
.detail-bar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
#detail-body { padding: 0 0 50px; }
.detail-expand { display: none; }
.layout.detail-collapsed .detail { overflow: hidden; }
.layout.detail-collapsed .detail-bar, .layout.detail-collapsed #detail-body, .layout.detail-collapsed .resizer { display: none; }
.layout.detail-collapsed .detail-expand { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; height: 100%; border: 0; border-radius: 0; background: transparent; padding: 14px 0; color: var(--ink-2); }
.layout.detail-collapsed .detail-expand:hover { background: var(--panel-2); color: var(--ink); }
#detail-expand-label { writing-mode: vertical-rl; font-family: var(--serif); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; max-height: calc(100% - 60px); }

.d-hero { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--dc, var(--accent)) 12%, var(--panel)) 0%, var(--panel) 100%); position: relative; }
.d-hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--dc, var(--accent)); }
.d-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.d-hero h1 { font-family: var(--serif); font-weight: 700; font-size: 28px; line-height: 1.15; letter-spacing: -.015em; margin: 6px 0 4px; }
.aliases { color: var(--ink-3); font-size: 13px; font-style: italic; }
.d-hero .row { margin-top: 12px; }
.crumbs { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .5; }
.d-section { padding: 16px 24px 0; }
.definition { font-family: var(--serif); font-size: 17px; line-height: 1.5; font-weight: 500; margin: 0; color: var(--ink); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 16px; }
.fact { background: var(--panel); padding: 8px 12px; }
.fact span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.fact b { font-weight: 600; font-size: 13px; }
.fact a { text-decoration: none; }
.detail h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); margin: 22px 0 8px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.detail h4 .n { background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-size: 10.5px; color: var(--ink-2); letter-spacing: 0; }
.prose { font-size: 14.5px; line-height: 1.65; color: var(--ink); }
.prose p { margin: 0 0 12px; }
.prose ul { padding-left: 20px; margin: 0 0 12px; }
.prose li { margin-bottom: 4px; }
.prose code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
a.wikilink { text-decoration: none; color: var(--accent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
a.wikilink:hover { border-bottom-color: var(--accent); }
a.wikilink.missing { color: var(--danger); border-bottom: 1px dashed var(--danger); }
.callout { background: var(--panel-2); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; color: var(--ink-2); }
.rel-group { margin-bottom: 12px; }
.rel-type { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.rel-type::before { content: ""; width: 14px; height: 2px; background: var(--rc, var(--ink-3)); border-radius: 2px; }
.rel-list { display: flex; flex-direction: column; gap: 4px; }
.rel-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px; border-radius: 8px; background: var(--panel-2); text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.rel-item:hover { border-color: var(--line-2); background: var(--panel-3); }
.rel-item .dot { margin-top: 6px; width: 8px; height: 8px; }
.rel-item b { font-weight: 600; }
.rel-item small { display: block; color: var(--ink-3); font-size: 12px; line-height: 1.4; }
.rel-note { color: var(--ink-3); font-size: 12px; }
.work-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 6px; }
.work-item svg.i { color: var(--ink-3); margin-top: 2px; }
.work-item a.t { font-weight: 600; text-decoration: none; color: var(--ink); }
.work-item a.t:hover { color: var(--accent); }
.work-item .meta { font-size: 12px; color: var(--ink-3); }
.work-item .meta a { color: var(--ink-2); }
.work-item .role { margin-left: auto; font-size: 11px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.mini-graph { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.mini-graph svg { display: block; width: 100%; }
.mini-graph text { font-size: 10.5px; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; pointer-events: none; }
.mini-graph circle { stroke: var(--bg); stroke-width: 2px; cursor: pointer; }
.mini-graph .center circle { stroke: var(--accent); stroke-width: 3px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-3); white-space: nowrap; }
.sources a { display: block; padding: 3px 0; text-decoration: none; }
.sources a:hover { text-decoration: underline; }

/* Forms */
.form { padding: 18px 24px 30px; }
.form h1 { font-family: var(--serif); font-weight: 700; font-size: 24px; margin: 0 0 4px; }
.form label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 14px 0 5px; font-weight: 700; }
.form input, .form select, .form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); transition: border-color .12s, box-shadow .12s; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.form textarea.tall { min-height: 240px; }
.form .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .actions { position: sticky; bottom: 0; background: var(--panel); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 18px; display: flex; gap: 8px; }
.work-pick { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--bg); }
.work-pick label { display: flex; gap: 8px; font-weight: 400; color: var(--ink); margin: 2px 0; text-transform: none; letter-spacing: 0; font-size: 13px; align-items: baseline; }
.work-pick input { width: auto; }
.rel-edit { display: flex; gap: 6px; align-items: center; margin: 4px 0; font-size: 13px; }
.rel-add { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; }

/* ============ Graph ============ */
.graph-view { flex: 1; position: relative; min-height: 0; }
.graph-controls { position: absolute; top: 12px; left: 14px; right: 14px; z-index: 2; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 13px; pointer-events: none; }
.graph-controls > * { pointer-events: auto; }
.graph-controls .seg { box-shadow: var(--shadow-md); background: var(--panel); }
.graph-controls .hops, #btn-fit { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; box-shadow: var(--shadow-md); display: inline-flex; gap: 6px; align-items: center; }
.graph-hint { color: var(--ink-3); font-size: 12px; margin-left: auto; }
#graph { width: 100%; height: 100%; display: block; cursor: grab; }
#graph:active { cursor: grabbing; }
#graph line { transition: opacity .15s; }
#graph .node { cursor: pointer; transition: opacity .15s; }
#graph .node circle { stroke: var(--bg); stroke-width: 2px; }
#graph .node.sel circle { stroke: var(--accent); stroke-width: 3.5px; }
#graph .node text { font-size: 11.5px; fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; stroke-linejoin: round; opacity: 0; transition: opacity .15s; font-weight: 500; }
#graph .node.big text, #graph.zoomed .node text, #graph .node.hl text, #graph .node.sel text { opacity: 1; }
#graph.hovering .node:not(.hl) { opacity: .14; }
#graph.hovering line:not(.hl) { opacity: .05; }
#graph.hovering line.hl { stroke-width: 2.4px; }
.graph-legend { position: absolute; left: 14px; bottom: 14px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 11.5px; color: var(--ink-2); display: grid; gap: 4px 14px; grid-template-columns: auto auto; max-width: 520px; box-shadow: var(--shadow-md); }
.graph-legend .lg-head { grid-column: 1 / -1; font-weight: 600; color: var(--ink-2); cursor: default; }
.graph-legend:not(:hover) > :not(.lg-head) { display: none; }
.graph-legend .lg-title { grid-column: 1 / -1; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin-top: 2px; }
.graph-legend .lg { display: flex; align-items: center; gap: 6px; }
.graph-legend .lg-line { width: 16px; height: 2px; border-radius: 2px; background: var(--c); }

/* ============ Popover ============ */
.pop { position: fixed; z-index: 50; width: 320px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px 14px; pointer-events: none; animation: popin .12s ease-out; }
.pop::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--dc, var(--accent)); border-radius: 12px 12px 0 0; }
.pop .d-kind { margin-bottom: 2px; }
.pop h5 { margin: 0 0 4px; font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.25; }
.pop p { margin: 0; font-size: 13px; color: var(--ink-2); }
.pop .pop-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
@keyframes popin { from { opacity: 0; transform: translateY(3px); } }

/* ============ Overlays ============ */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(10, 8, 4, .45); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.palette { width: min(640px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
#pal-input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; color: var(--ink); }
.pal-list { overflow: auto; padding: 6px; }
.pal-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; padding: 8px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pal-item.active { background: var(--accent-soft); }
.pal-item .pi { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; background: var(--panel-2); color: var(--ink-2); flex: none; }
.pal-item .pi .dot { width: 10px; height: 10px; }
.pal-item .pl { min-width: 0; flex: 1; }
.pal-item .pl b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item .pl small { color: var(--ink-3); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item .pk { font-size: 11px; color: var(--ink-3); }
.pal-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); }
.pal-foot kbd { margin-right: 3px; }
.help { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 22px 26px; width: min(420px, 100%); }
.help h2 { font-family: var(--serif); margin: 0 0 14px; font-size: 22px; }
.help-grid { display: grid; grid-template-columns: auto auto 1fr; gap: 8px 8px; align-items: center; margin-bottom: 16px; font-size: 13.5px; }
.help-grid kbd { justify-self: start; }
.help-grid kbd:not(.alt) + span { grid-column: 3; }
.help-grid kbd:not(.alt) { grid-column: 1; }
.help-grid kbd.alt { grid-column: 2; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 18px; border-radius: 10px; z-index: 70; box-shadow: var(--shadow-lg); font-weight: 500; animation: popin .15s; }

/* ============ Responsive ============ */
@media (max-width: 1250px) {
  .seg .lbl { display: none; }
  .graph-hint { display: none; }
}
@media (max-width: 1000px) {
  .layout, .layout.no-detail, .layout.detail-collapsed { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; top: 53px; bottom: 0; left: 0; width: min(320px, 86vw); z-index: 20; box-shadow: var(--shadow-lg); }
  .layout.no-sidebar .sidebar { display: none; }
  .detail { position: fixed; top: 53px; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 25; box-shadow: var(--shadow-lg); }
  .layout.detail-collapsed .detail { width: 46px; }
  .resizer { display: none; }
  .brand-name { display: none; }
  .top-actions #btn-palette { display: none; }
}
@media (max-width: 640px) {
  :root { --nav-h: calc(58px + env(safe-area-inset-bottom)); }
  .topbar { gap: 6px; padding: 8px 10px; }
  .brand, .top-actions #btn-random { display: none; }
  .search-wrap { flex: 1; min-width: 0; max-width: none; }
  .search-wrap kbd { display: none; }
  .top-actions { gap: 2px; }
  #btn-new .lbl { display: none; }
  .sidebar, .detail { top: 57px; }
  .sidebar { bottom: var(--nav-h); }

  /* Ansichten als Leiste unten */
  #view-seg { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--nav-h); padding: 6px 8px env(safe-area-inset-bottom); border: 0; border-top: 1px solid var(--line); border-radius: 0; background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(10px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  #view-seg button { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; height: 46px; border-radius: 10px; font-size: 11px; }
  #view-seg .lbl { display: block; }
  .main { padding-bottom: var(--nav-h); }
  .graph-view { margin-bottom: 0; }

  /* Detail als eigene Seite, minimiert als Leiste über der Navigation */
  .detail { left: 0; width: 100vw; bottom: var(--nav-h); border-left: 0; box-shadow: none; }
  .layout.detail-collapsed .detail { top: auto; width: auto; left: 10px; right: 10px; bottom: calc(var(--nav-h) + 10px); height: 46px; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); }
  .layout.detail-collapsed .detail-expand { flex-direction: row; justify-content: flex-start; padding: 0 14px; gap: 10px; }
  .layout.detail-collapsed .detail-expand .chev { transform: rotate(90deg); }
  #detail-expand-label { writing-mode: horizontal-tb; max-height: none; text-overflow: ellipsis; }
  .btn-collapse svg { transform: rotate(90deg); }
  .detail-bar { padding: 4px 6px; }

  .toolbar, .content { padding-left: 16px; padding-right: 16px; }
  .hero h1 { font-size: 26px; }
  .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stat:nth-child(n+5) { display: none; }
  .stat { min-width: 0; padding: 8px 6px; text-align: center; }
  .stat b { font-size: 18px; }
  .stat span { font-size: 11px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .fact b { overflow-wrap: anywhere; hyphens: auto; }
  .graph-legend, .legend { max-width: calc(100vw - 32px); }
}

/* Zitate */
.quotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.qcard { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 14px 16px 12px; cursor: pointer; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; transition: transform .12s, box-shadow .12s, border-color .12s; }
.qcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.qcard.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-md); }
.qcard blockquote { margin: 0; font-family: var(--serif); font-size: 15.5px; line-height: 1.5; white-space: pre-line; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.qmeta { font-size: 12.5px; color: var(--ink-2); }
.qconcepts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-3); margin-top: auto; }
.qconcepts span { display: inline-flex; align-items: center; gap: 5px; }
.qconcepts .dot { width: 7px; height: 7px; }
.d-quote { margin: 8px 0 8px; font-family: var(--serif); font-size: 18px; line-height: 1.5; white-space: pre-line; color: var(--ink); }
.d-quote.orig { font-size: 15px; color: var(--ink-2); font-style: italic; margin: 0; }
button.stat { font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.stat:hover { border-color: var(--line-2); }
@media (max-width: 640px) { .quotes { grid-template-columns: 1fr; } }

/* ============ Zeichnungen (visuals/) ============ */
.vis { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.vis-bar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.vis-bar .spacer { flex: 1; }
.vis-stage svg { display: block; width: 100%; height: auto; background: #0b0f17; user-select: none; }
.vis-stage [data-hot] { cursor: pointer; }
.vis-label { fill: #e8e4da; font: 500 13px var(--sans); paint-order: stroke; stroke: #0b0f17; stroke-width: 3px; stroke-linejoin: round; }
.vis-label.small { fill: #97a0b3; font-size: 11px; }
.vis-ctrl { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 12px 0; }
.vis-ctrl:empty { display: none; }
.vis-slider { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; flex: 1 1 100%; font-size: 12.5px; color: var(--ink-2); }
.vis-slider input { accent-color: var(--accent); width: 100%; }
.vis-slider output { font-variant-numeric: tabular-nums; min-width: 128px; text-align: right; color: var(--ink); font-weight: 600; }
.vis-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: 1 1 100%; }
.vis-ro { background: var(--panel); padding: 6px 10px; }
.vis-ro span { display: block; font-size: 10.5px; color: var(--ink-3); }
.vis-ro b { font-size: 14px; font-variant-numeric: tabular-nums; }
.vis-info { padding: 10px 12px 12px; }
.vis-topic b { font-family: var(--serif); font-size: 15px; }
.vis-topic p { margin: 4px 0 10px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.vis-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.vis-chips .chip { cursor: pointer; font-size: 11.5px; padding: 3px 9px; margin: 0; }
.vis-views:empty { display: none; }
.vis-choice { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; font-size: 12.5px; color: var(--ink-2); }
.vis-chips .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.overlay.vis-overlay { padding: 3vh 16px; align-items: center; }
.vis-full { width: min(1100px, 100%); max-height: 94vh; overflow: auto; border-radius: 14px; box-shadow: var(--shadow-lg); }
.vis-full .vis { border: 0; }
