:root {
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --surface-3: #edf1f0;
  --canvas: #fbfcfc;
  --line: #e2e8e6;
  --line-2: #cdd6d3;
  --ink: #102420;
  --ink-2: #475a55;
  --ink-3: #7d8d88;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #dcf1ed;
  --on-accent: #ffffff;
  --pos: #16a34a;
  --pos-soft: #dcfce7;
  --neg: #dc4a26;
  --neg-soft: #fde5dc;
  --driver: #e08a00;
  --receiver: #3b6fe0;
  --ordinary: #0f8f84;
  --isolated: #9aa8b4;
  --warn: #b45309;
  --danger: #c0262d;
  --shadow-sm: 0 1px 2px rgba(16, 36, 32, .06);
  --shadow: 0 1px 2px rgba(16, 36, 32, .05), 0 8px 24px -6px rgba(16, 36, 32, .12);
  --radius: 12px;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1211; --surface: #121b19; --surface-2: #16211f; --surface-3: #1c2926; --canvas: #0e1614;
    --line: #22302d; --line-2: #2f403c; --ink: #e5efec; --ink-2: #a3b5b0; --ink-3: #6f827d;
    --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #10332f; --on-accent: #05201c;
    --pos: #4ade80; --pos-soft: #10301d; --neg: #fb8a5c; --neg-soft: #3a1c12;
    --driver: #fbbf24; --receiver: #7aa2ff; --ordinary: #2dd4bf; --isolated: #5f7080;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px -8px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1211; --surface: #121b19; --surface-2: #16211f; --surface-3: #1c2926; --canvas: #0e1614;
  --line: #22302d; --line-2: #2f403c; --ink: #e5efec; --ink-2: #a3b5b0; --ink-3: #6f827d;
  --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #10332f; --on-accent: #05201c;
  --pos: #4ade80; --pos-soft: #10301d; --neg: #fb8a5c; --neg-soft: #3a1c12;
  --driver: #fbbf24; --receiver: #7aa2ff; --ordinary: #2dd4bf; --isolated: #5f7080;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px -8px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-3); font-weight: 400; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
::-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; }

/* ── top bar ───────────────────────────────────────── */
.topbar { height: 60px; display: flex; align-items: center; gap: 28px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #0f766e, #134e4a); display: grid; place-items: center; box-shadow: 0 4px 12px -4px rgba(15, 118, 110, .6); }
.logo svg { width: 26px; height: 26px; }
.logo path { stroke: rgba(255,255,255,.55); stroke-width: 1.8; fill: none; }
.logo .c1 { fill: #fff; } .logo .c2 { fill: #fbbf24; } .logo .c3 { fill: #93c5fd; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.015em; line-height: 1.2; }
.brand span { display: block; font-size: 11.5px; color: var(--ink-3); }
.project-picker { display: flex; gap: 6px; align-items: center; }
.project-picker .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; margin-right: 2px; }
.project-picker select { min-width: 230px; padding: 7px 30px 7px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); max-width: 420px; }
.pill b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--isolated); flex: none; }
.pill.ok i { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.pill.bad i { background: var(--danger); }

/* ── controls ─────────────────────────────────────── */
.btn { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 12px; border-radius: 9px; cursor: pointer; font-weight: 500; white-space: nowrap; transition: border-color .15s, background .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 6px 10px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.warn-btn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); justify-content: center; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.input { width: 100%; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); outline: none; }
.input.small { padding: 6px 11px; font-size: 13px; }
.input:focus, textarea:focus, select:focus, .search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
select { border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); padding: 5px 8px; cursor: pointer; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chk input, input[type=range] { accent-color: var(--accent); }
.badge { background: var(--accent); color: var(--on-accent); font: 600 10.5px var(--mono); border-radius: 99px; padding: 1px 6px; }

/* ── layout ───────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr) auto; height: calc(100vh - 60px); }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* dropzone */
.dropzone { display: block; border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 18px 12px 16px; text-align: center; cursor: pointer; background: var(--surface-2); transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { transform: scale(1.01); }
.dz-icon { width: 38px; height: 38px; margin: 0 auto 8px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; }
.dz-icon svg { width: 20px; height: 20px; stroke: var(--accent); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.dz-title { font-weight: 600; font-size: 13.5px; }
.dz-title u { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.dz-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

.job { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: var(--radius); padding: 10px 12px; background: var(--accent-soft); }
.job-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 12.5px; }
.job-head #jobCount { font-family: var(--mono); }
.bar { height: 6px; background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 99px; margin: 8px 0 6px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .5s; }
.job-msg { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.docs-head { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.docs-head h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.count { background: var(--surface-3); color: var(--ink-2); font: 600 10.5px var(--mono); padding: 1px 7px; border-radius: 99px; letter-spacing: 0; }
.count:empty { display: none; }
.docs-actions { display: flex; gap: 10px; }
.hint { margin: 0; font-size: 11.5px; color: var(--ink-3); }
.docs { list-style: none; margin: 0 -6px; padding: 0 6px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.doc { display: grid; grid-template-columns: 16px 30px 1fr 18px; gap: 9px; align-items: center; padding: 7px 8px; border-radius: 9px; cursor: default; }
.doc:hover { background: var(--surface-2); }
.doc.off .ficon, .doc.off .name { opacity: .45; }
.doc input { margin: 0; accent-color: var(--accent); cursor: pointer; }
.ficon { width: 30px; height: 34px; border-radius: 6px; display: grid; place-items: end center; padding-bottom: 4px; font: 700 8.5px var(--mono); color: #fff; letter-spacing: .02em; position: relative; background: var(--isolated); }
.ficon::before { content: ""; position: absolute; top: 0; right: 0; border-width: 0 8px 8px 0; border-style: solid; border-color: var(--surface) color-mix(in srgb, #000 20%, transparent) color-mix(in srgb, #000 20%, transparent) var(--surface); border-radius: 0 0 0 3px; }
.ficon.pdf { background: #d9412e; } .ficon.docx { background: #2f6fd6; }
.ficon.xlsx, .ficon.xls, .ficon.xlsm { background: #1d8a4e; } .ficon.csv, .ficon.tsv { background: #0f8f84; }
.ficon.txt, .ficon.md { background: #6b7a86; }
.doc .name { font-weight: 500; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .meta { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; margin-top: 1px; }
.doc .err { grid-column: 3 / 5; color: var(--danger); font-size: 11.5px; line-height: 1.35; }
.doc .del { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0; font-size: 12px; }
.doc:hover .del { opacity: 1; }
.doc .del:hover { color: var(--danger); }
.status { font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.status.done { color: var(--pos); } .status.failed { color: var(--danger); }
.status.queued, .status.parsing, .status.extracting { color: var(--warn); }
.status.parsing::before, .status.extracting::before, .status.queued::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; padding: 14px 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat b { display: block; font: 600 19px var(--mono); letter-spacing: -.02em; line-height: 1.25; }
.stat span { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.stat.pos b { color: var(--pos); } .stat.pos::after { background: var(--pos); }
.stat.neg b { color: var(--neg); } .stat.neg::after { background: var(--neg); }
.stat.drv::after { background: var(--driver); } .stat.rcv::after { background: var(--receiver); }

/* filters */
.filters { display: flex; gap: 10px; align-items: center; padding: 12px 20px 0; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 0 6px 0 11px; min-width: 0; height: 38px; }
.search svg { width: 17px; height: 17px; stroke: var(--ink-3); stroke-width: 2; fill: none; flex: none; }
.search input { flex: 1; border: 0; outline: none; background: transparent; min-width: 0; padding: 8px 0; }
.search .depth { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 4px; border-left: 1px solid var(--line); padding-left: 8px; }
.search .depth select { border: 0; padding: 4px 2px; background: transparent; font-size: 12.5px; color: var(--ink-2); box-shadow: none; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; height: 38px; }
.seg button { border: 0; background: transparent; padding: 0 12px; cursor: pointer; font-size: 13px; border-radius: 7px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.pos { background: var(--pos); } .sw.neg { background: var(--neg); }
.filters > .btn { height: 38px; }
.adv { display: flex; flex-wrap: wrap; gap: 14px 26px; align-items: center; margin: 10px 20px 0; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.adv label { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
.adv label span { font-weight: 500; }
.rng input { width: 110px; }
.rng b { font: 500 12px var(--mono); color: var(--ink); min-width: 34px; }
.num input { width: 64px; padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 20px 0; }
.chips:empty { display: none; }
.chip { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; font-weight: 500; background: var(--accent-soft); color: var(--ink); padding: 3px 4px 3px 11px; border-radius: 99px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--ink-2); padding: 0 6px; border-radius: 99px; }
.chip button:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 0 20px; margin-top: 10px; border-bottom: 1px solid var(--line); align-items: flex-end; }
.tabs > button { border: 0; background: none; padding: 10px 12px 11px; cursor: pointer; color: var(--ink-3); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs > button:hover { color: var(--ink); }
.tabs > button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs > button span { font: 600 10.5px var(--mono); color: var(--ink-3); background: var(--surface-3); padding: 1px 6px; border-radius: 99px; margin-left: 4px; }
.tabs > button span:empty { display: none; }
.tabs-right { margin-left: auto; align-self: center; padding-bottom: 4px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px; z-index: 30; min-width: 240px; }
.menu-list button { display: flex; justify-content: space-between; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.menu-list button em { font: 600 10.5px var(--mono); font-style: normal; color: var(--ink-3); }
.menu-list button:hover { background: var(--surface-2); }

.panels { flex: 1; min-height: 0; position: relative; }
.panel { position: absolute; inset: 0; display: none; flex-direction: column; }
.panel.on { display: flex; }

/* map */
[data-panel="map"] { margin: 14px 20px 20px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--canvas); box-shadow: var(--shadow-sm); }
#cy { position: absolute; inset: 0; background-image: radial-gradient(circle, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.2px); background-size: 24px 24px; }
.overlay { position: absolute; z-index: 3; display: flex; gap: 8px; align-items: center; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 11px; padding: 6px 8px; box-shadow: var(--shadow); }
.overlay.tl { top: 12px; left: 12px; flex-wrap: wrap; max-width: calc(100% - 120px); }
.overlay.tl select { border-color: transparent; background: var(--surface-2); font-weight: 500; font-size: 13px; }
.overlay .btn { padding: 4px 10px; font-size: 13px; }
.overlay.zoom { top: 12px; right: 12px; flex-direction: column; gap: 0; padding: 3px; }
.overlay.zoom button { width: 32px; height: 30px; border: 0; background: none; cursor: pointer; font-size: 16px; border-radius: 7px; color: var(--ink-2); }
.overlay.zoom button:hover { background: var(--surface-3); color: var(--ink); }
.overlay.legend { left: 12px; bottom: 12px; gap: 14px; font-size: 12px; color: var(--ink-2); padding: 7px 12px; flex-wrap: wrap; max-width: calc(100% - 24px); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sep { width: 1px; height: 14px; background: var(--line-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.driver { background: var(--driver); } .dot.receiver { background: var(--receiver); } .dot.ordinary { background: var(--ordinary); }
.ln { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.ln.pos { background: var(--pos); } .ln.neg { background: var(--neg); }
.tip { position: absolute; z-index: 4; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow); max-width: 280px; font-size: 12.5px; transform: translate(-50%, calc(-100% - 14px)); }
.tip b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.tip .row { display: flex; gap: 10px; color: var(--ink-3); font-family: var(--mono); font-size: 11.5px; margin-top: 4px; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--ink-3); padding: 20px; pointer-events: none; z-index: 2; }
.empty h2 { color: var(--ink); margin: 10px 0 6px; font-size: 19px; letter-spacing: -.01em; }
.empty .art { font-size: 34px; color: var(--accent); }

/* tables */
.table-tools { display: flex; gap: 10px; align-items: center; padding: 14px 20px 10px; flex-wrap: wrap; }
.table-tools .input { max-width: 280px; }
.table-wrap { flex: 1; overflow: auto; margin: 0 20px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; white-space: nowrap; z-index: 1; }
table.grid th:hover { color: var(--ink); }
table.grid th.n { text-align: right; }
table.grid th.sorted { color: var(--accent); }
table.grid th.sorted::after { content: " ↓"; } table.grid th.sorted.asc::after { content: " ↑"; }
table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--surface-2); }
table.grid tbody tr.sel td { background: var(--accent-soft); }
table.grid td.n { font-family: var(--mono); font-size: 12.5px; text-align: right; white-space: nowrap; color: var(--ink-2); }
table.grid td.w { width: 32px; }
table.grid .clickable { cursor: pointer; font-weight: 600; color: var(--ink); }
table.grid .clickable:hover { color: var(--accent); }
table.grid .sub { color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.type { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px; text-transform: capitalize; display: inline-flex; align-items: center; gap: 5px; }
.type::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.type.driver { background: color-mix(in srgb, var(--driver) 15%, transparent); color: var(--driver); }
.type.receiver { background: color-mix(in srgb, var(--receiver) 15%, transparent); color: var(--receiver); }
.type.ordinary { background: color-mix(in srgb, var(--ordinary) 15%, transparent); color: var(--ordinary); }
.type.isolated { background: var(--surface-3); color: var(--ink-3); }
.cbar { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cbar i { display: inline-block; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 60%, transparent); }
.arrow { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 22px; border-radius: 6px; font: 700 12px var(--mono); }
.arrow.pos { background: var(--pos-soft); color: var(--pos); } .arrow.neg { background: var(--neg-soft); color: var(--neg); } .arrow.amb { background: var(--surface-3); color: var(--ink-3); }
.sign { font: 700 13px var(--mono); }
.sign.pos { color: var(--pos); } .sign.neg { color: var(--neg); } .sign.amb { color: var(--ink-3); }
.wbar { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.wbar .track { width: 60px; height: 6px; border-radius: 3px; background: var(--surface-3); position: relative; overflow: hidden; }
.wbar .track i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.wbar i.pos { background: var(--pos); } .wbar i.neg { background: var(--neg); }

/* matrix */
.matrix-wrap { flex: 1; overflow: auto; margin: 0 20px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.matrix { border-collapse: separate; border-spacing: 0; font: 11px var(--mono); }
table.matrix th { background: var(--surface); position: sticky; z-index: 2; font: 500 11.5px var(--sans); color: var(--ink-2); }
table.matrix thead th { top: 0; height: 170px; vertical-align: bottom; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
table.matrix thead th div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 160px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; }
table.matrix tbody th { left: 0; text-align: right; padding: 0 10px; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--line-2); }
table.matrix thead th.corner { left: 0; z-index: 3; font: 600 10.5px var(--sans); color: var(--ink-3); text-align: right; padding-right: 10px; text-transform: uppercase; letter-spacing: .06em; }
table.matrix td { width: 34px; min-width: 34px; height: 28px; text-align: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 600; }
table.matrix td.v { cursor: pointer; }
table.matrix td.v:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
table.matrix td.diag { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--line) 3px 4px); }
table.matrix tr:hover th, table.matrix th.hl { color: var(--accent); background: var(--accent-soft); }
table.matrix tr:hover td:not(.v):not(.diag) { background: var(--surface-2); }

/* chat */
.chat { flex: 1; overflow: auto; padding: 24px 20px 8px; display: flex; flex-direction: column; gap: 18px; }
.chat-empty { margin: auto; text-align: center; max-width: 680px; color: var(--ink-2); }
.chat-empty .spark { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, var(--accent), #134e4a); box-shadow: 0 8px 22px -8px var(--accent); }
.chat-empty h2 { color: var(--ink); margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; text-align: left; }
.suggest button { border: 1px solid var(--line); background: var(--surface); padding: 12px 14px; border-radius: 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); box-shadow: var(--shadow-sm); line-height: 1.4; transition: .15s; }
.suggest button:hover { border-color: var(--accent); color: var(--ink); transform: translateY(-1px); }
.msg { max-width: 860px; width: 100%; margin: 0 auto; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); margin-left: auto; width: fit-content; max-width: 78%; padding: 10px 15px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg.bot { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.msg.bot::before { content: "✦"; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 14px; }
.msg.bot .bubble { line-height: 1.6; min-width: 0; }
.msg.bot .bubble > :first-child { margin-top: 3px; }
.msg.bot .bubble ul { padding-left: 20px; }
.msg.bot .bubble li { margin: 3px 0; }
.cite { display: inline-block; font: 600 10.5px var(--mono); background: var(--accent-soft); color: var(--accent); padding: 0 5px; border-radius: 5px; cursor: pointer; vertical-align: 1px; line-height: 1.6; }
.cite:hover { background: var(--accent); color: var(--on-accent); }
.cite.map { background: color-mix(in srgb, var(--driver) 16%, transparent); color: var(--driver); cursor: default; }
.msg-foot { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg-foot .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-3); }
.concept-chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 99px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.concept-chip:hover { border-color: var(--accent); color: var(--accent); }
.srcs { display: grid; gap: 6px; }
details.src { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
details.src summary { cursor: pointer; padding: 7px 12px; font-size: 12.5px; list-style: none; display: flex; gap: 8px; align-items: center; }
details.src summary::-webkit-details-marker { display: none; }
details.src summary b { font-family: var(--mono); color: var(--accent); font-size: 11px; background: var(--accent-soft); padding: 0 6px; border-radius: 5px; }
details.src summary .muted { margin-left: auto; font-family: var(--mono); font-size: 11px; }
details.src p { margin: 0; padding: 2px 14px 12px; font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap; max-height: 220px; overflow: auto; }
details.src.flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); margin-right: 4px; animation: pulse 1s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
.composer { padding: 8px 20px 18px; }
.composer-box { max-width: 860px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow); }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.composer-box textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; padding: 7px 0; max-height: 180px; box-shadow: none; }
.send { width: 38px; height: 38px; border-radius: 11px; border: 0; background: var(--accent); cursor: pointer; display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .45; cursor: default; }
.send svg { width: 18px; height: 18px; stroke: var(--on-accent); stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.composer-row { max-width: 860px; margin: 8px auto 0; display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); padding: 0 6px; }

/* inspector */
.inspector { width: 400px; border-left: 1px solid var(--line); background: var(--surface); overflow: auto; padding: 20px; position: relative; animation: drawer .18s ease-out; }
@keyframes drawer { from { transform: translateX(16px); opacity: 0; } }
.inspector .close { position: absolute; right: 14px; top: 14px; }
.inspector h2 { margin: 8px 36px 4px 0; font-size: 19px; letter-spacing: -.015em; line-height: 1.3; }
.inspector h4 { margin: 22px 0 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.inspector h4::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.inspector .desc { color: var(--ink-2); margin: 6px 0 0; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.kv div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kv b { display: block; font: 600 16px var(--mono); } .kv span { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.insp-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.occ { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 7px; font-size: 12.5px; background: var(--surface); }
.occ .head { display: flex; gap: 7px; align-items: center; }
.occ .head .who { font-weight: 600; cursor: pointer; }
.occ .head .who:hover { color: var(--accent); }
.occ q { display: block; color: var(--ink-2); margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line-2); font-style: italic; }
.occ q::before, .occ q::after { content: ""; }
.occ .src { color: var(--ink-3); font-size: 11.5px; margin-top: 5px; }
.sim { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.sim .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.sim-res { margin-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.sim-res .r { display: grid; grid-template-columns: 1fr 110px 54px; gap: 8px; align-items: center; font-size: 12.5px; }
.sim-res .track { height: 8px; background: var(--line); position: relative; border-radius: 4px; }
.sim-res .track i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.sim-res .track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--ink-3); }
.sim-res .v { font: 500 11.5px var(--mono); text-align: right; }

/* toasts & dialog */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 15px; border-radius: 11px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; animation: slide .2s; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 22px; width: 440px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 18, 16, .5); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 12px; font-size: 18px; }
.dialog-row { display: flex; gap: 8px; margin-top: 18px; }
.dialog-row span { flex: 1; }

@media (max-width: 1280px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .brand span, .project-picker .label { display: none; } .brand { min-width: 0; }
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .inspector { position: fixed; right: 0; top: 60px; bottom: 0; z-index: 40; box-shadow: var(--shadow); max-width: 100vw; }
  .pill b { display: none; }
  .filters { flex-wrap: wrap; } .search { flex-basis: 100%; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { height: 100vh; }
  .topbar { gap: 10px; padding: 0 12px; } .project-picker select { min-width: 0; width: 140px; }
  .overlay.legend { display: none; } .suggest { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px 0; }
  .filters, .tabs, .chips { padding-left: 16px; padding-right: 16px; }
  #newProjectBtn { display: none; }
}

/* ── level switch, main-node dialog, full-screen map ─────────────── */
.seg.level button.on { background: var(--accent); color: var(--on-accent); }
.seg.level button:disabled { opacity: .5; cursor: default; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.main-status { font-size: 12.5px; }
dialog code { font: 12px var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.members { display: flex; flex-wrap: wrap; gap: 5px; }
.members .concept-chip { font-size: 11.5px; }
.members .concept-chip small { color: var(--ink-3); font-family: var(--mono); margin-left: 3px; }
.mainref { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.si { font-family: var(--mono); font-size: 12px; }
.si.pos { color: var(--pos); } .si.neg { color: var(--neg); }
body.fullmap .sidebar, body.fullmap .stats, body.fullmap .filters, body.fullmap .adv,
body.fullmap .chips, body.fullmap .tabs, body.fullmap .topbar { display: none !important; }
body.fullmap .layout { height: 100vh; grid-template-columns: minmax(0, 1fr) auto; }
body.fullmap [data-panel="map"] { margin: 0; border-radius: 0; border: 0; }

/* ── figure-style map (node plates + panels, after fcm_figure.draw_fcm) ───────── */
:root { --fig-bg: #e8eef1; --fig-ink: #12365a; --fig-ink2: #3d5a75; --fig-line: #b9c6cf; }
:root[data-theme="dark"] { --fig-bg: #0f1a1f; --fig-ink: #dbe7ef; --fig-ink2: #9fb3c2; --fig-line: #2c3e48; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fig-bg: #0f1a1f; --fig-ink: #dbe7ef; --fig-ink2: #9fb3c2; --fig-line: #2c3e48; } }
[data-panel="map"] { background: var(--fig-bg); }
#cy { background-image: none; }
.overlay.bl.toolbar { left: 12px; bottom: 12px; top: auto; flex-wrap: wrap; max-width: calc(100% - 90px); }
.overlay.bl.toolbar select { border-color: transparent; background: var(--surface-2); font-weight: 500; font-size: 13px; }
.overlay.br.zoom { right: 12px; bottom: 12px; top: auto; flex-direction: column; gap: 0; padding: 3px; }
.overlay.br.zoom button { width: 32px; height: 30px; border: 0; background: none; cursor: pointer; font-size: 16px; border-radius: 7px; color: var(--ink-2); }
.overlay.br.zoom button:hover { background: var(--surface-3); color: var(--ink); }
.fig-panel { position: absolute; z-index: 3; background: rgba(255, 255, 255, .94); border: 1px solid #b9c6cf;
  border-radius: 4px; color: #12365a; box-shadow: 0 2px 10px rgba(18, 54, 90, .08); max-height: calc(100% - 90px); overflow: auto; }
.fig-panel[hidden] { display: none; }
.stats-panel { top: 12px; left: 12px; font: 11.5px/1.45 var(--mono); padding: 10px 12px; white-space: pre; min-width: 250px; cursor: pointer; }
.stats-panel .h { font-weight: 600; }
.stats-panel .rule { color: #9aa9b5; }
.stats-panel.min .body { display: none; }
.legend-panel { top: 12px; right: 12px; padding: 10px 14px 12px; font: 12.5px/1.5 var(--sans); min-width: 250px; }
.legend-panel h5 { margin: 0 0 6px; font-size: 13px; font-weight: 700; text-align: center; letter-spacing: .01em; }
.legend-panel .row { display: flex; align-items: center; gap: 9px; margin: 2px 0; white-space: nowrap; }
.legend-panel .row.mod { cursor: pointer; border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.legend-panel .row.mod:hover { background: #e8eef1; }
.legend-panel .row.mod.off { opacity: .35; }
.legend-panel .gap { height: 8px; }
.legend-panel .sw-box { width: 22px; height: 9px; border-radius: 1px; flex: none; }
.legend-panel .sw-line { width: 22px; height: 3px; border-radius: 2px; flex: none; }
.legend-panel .sw-ring { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; flex: none; margin: 0 5px; }
.legend-panel .more { color: #7d8d98; font-size: 11.5px; }
@media (max-width: 1100px) { .fig-panel { display: none; } }
.stats-panel.min { min-width: 0; }

/* ── compact, theme-aware map panels ─────────────────────────────── */
.fig-panel { background: color-mix(in srgb, var(--surface) 93%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 10px; color: var(--ink); box-shadow: var(--shadow); }
.stats-panel .rule { color: var(--ink-3); }
.legend-panel { width: 290px; min-width: 0; padding: 0; font: 12px/1.35 var(--sans); overflow: hidden; }
.lg-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent;
  padding: 8px 12px; cursor: pointer; font: 700 12.5px var(--sans); color: var(--ink); text-align: left; }
.lg-head span { font-weight: 500; font-size: 11.5px; color: var(--ink-3); }
.lg-head b { margin-left: auto; color: var(--ink-3); font-size: 11px; }
.legend-panel.min .lg-body { display: none; }
.lg-body { padding: 0 12px 10px; border-top: 1px solid var(--line); }
.lg-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 8px 0 4px; }
.lg-mods { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.lg-mod { display: flex; align-items: center; gap: 5px; min-width: 0; border: 0; background: transparent; padding: 2px 4px;
  margin-left: -4px; border-radius: 5px; cursor: pointer; color: var(--ink); font: 12px var(--sans); text-align: left; }
.lg-mod:hover { background: var(--surface-3); }
.lg-mod.off { opacity: .35; text-decoration: line-through; }
.lg-mod i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.lg-mod b { font: 600 10.5px var(--mono); color: var(--ink-3); }
.lg-mod span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-more { border: 0; background: transparent; padding: 2px 0; margin-top: 2px; color: var(--accent); cursor: pointer; font: 500 11.5px var(--sans); }
.lg-line { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lg-item em { font: 600 11px var(--mono); font-style: normal; color: var(--ink-3); }
.lg-item i.line { width: 16px; height: 3px; border-radius: 2px; }
.lg-item i.ring { width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid; }

/* ── start screen ─────────────────────────────────────────────────── */
.brand[role="button"] { cursor: pointer; border-radius: 10px; }
.brand[role="button"]:hover strong { color: var(--accent); }
.home { height: calc(100vh - 60px); overflow: auto; padding: 48px 24px;
  background: radial-gradient(1200px 500px at 50% -120px, var(--accent-soft), transparent 70%), var(--bg); }
.home-inner { max-width: 1080px; margin: 0 auto; }
.home-hero { text-align: center; max-width: 720px; margin: 0 auto 36px; }
.home-eyebrow { font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.home-hero h1 { font-size: 36px; letter-spacing: -.03em; line-height: 1.15; margin: 10px 0 12px; }
.home-hero p { color: var(--ink-2); font-size: 15.5px; margin: 0; }
.home-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.home-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.home-card h3 { margin: 0 0 14px; font-size: 16px; }
.home-drop { padding: 34px 16px; margin-bottom: 10px; }
.home-drop .dz-icon { width: 48px; height: 48px; }
.home-drop .dz-title { font-size: 15px; }
.home-list-head { display: flex; align-items: baseline; justify-content: space-between; }
.home-list-head h3 { margin-bottom: 10px; }
.home-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.home-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface-2); transition: .15s; }
.home-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.home-item .avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font: 700 14px var(--sans); color: #fff; background: linear-gradient(135deg, var(--accent), #134e4a); }
.home-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-item .s { font-size: 12px; color: var(--ink-3); }
.home-item .go { color: var(--accent); font-weight: 600; font-size: 13px; }
.home-empty { color: var(--ink-3); font-size: 13px; padding: 18px 4px; text-align: center; }
body.at-home .layout { display: none; }
body.at-home #projectPicker { visibility: hidden; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } .home-hero h1 { font-size: 28px; } }
.home-item .actions { display: flex; align-items: center; gap: 6px; }
.del-analysis { width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-3); opacity: .55; transition: .15s; }
.del-analysis svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.home-item:hover .del-analysis { opacity: 1; }
.del-analysis:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent); }
.del-analysis:disabled { opacity: .3; cursor: default; }
.home-single { max-width: 620px; margin: 0 auto; }
.home-single h3 { display: flex; align-items: baseline; justify-content: space-between; }
.home-single h3 .muted { font: 500 12.5px var(--mono); }
.home-note { margin: 12px 0 0; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.user-badge { font: 600 13px var(--mono); padding: 6px 12px; border-radius: 9px; background: var(--accent-soft);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }

/* ── new-project form ─────────────────────────────────────────────── */
.np-card { max-width: 660px; margin: 0 auto; padding: 26px 28px 22px; }
.np-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.np-head h3 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.01em; }
.np-head p { margin: 0; font-size: 13px; }
.np-number { flex: none; font: 600 13px var(--mono); padding: 6px 12px; border-radius: 9px; background: var(--accent-soft);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.np-step { display: grid; grid-template-columns: 28px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.np-step-no { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 700 13px var(--mono);
  background: var(--surface-3); color: var(--ink-2); }
.np-step-body { min-width: 0; }
.np-label { display: block; font-weight: 600; font-size: 13.5px; margin: 3px 0 8px; }
.np-label em { font-style: normal; font-weight: 500; font-size: 12px; color: var(--ink-3); margin-left: 6px; }
.np-input { font-size: 15px; padding: 10px 13px; }
.np-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.home-drop { padding: 26px 16px; margin: 0; }
.np-files { margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.np-files-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px;
  background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.np-files ul { list-style: none; margin: 0; padding: 4px; max-height: 210px; overflow: auto; }
.np-files li { display: grid; grid-template-columns: 30px 1fr auto 24px; gap: 10px; align-items: center; padding: 5px 8px; border-radius: 8px; }
.np-files li:hover { background: var(--surface-2); }
.np-files li .n { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-files li .z { font: 11.5px var(--mono); color: var(--ink-3); }
.np-files li .x { border: 0; background: none; cursor: pointer; color: var(--ink-3); border-radius: 6px; height: 24px; }
.np-files li .x:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.np-files li.bad .n { color: var(--danger); }
.np-files .ficon { width: 26px; height: 30px; font-size: 7.5px; }
.np-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.np-summary { font-size: 12.5px; color: var(--ink-3); }
.np-summary b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.np-create { padding: 10px 18px; font-size: 14px; font-weight: 600; }
.np-create:disabled { opacity: .6; cursor: progress; }
.current-project { display: flex; align-items: center; gap: 10px; min-width: 0; }
.project-title { font-weight: 600; font-size: 14px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .np-card { padding: 20px; } .np-actions { flex-direction: column-reverse; align-items: stretch; } .project-title { display: none; } }

/* ═════════ Your projects (start screen) ═════════ */
.home-projects { max-width: 1080px; margin: 34px auto 0; }
.home-projects[hidden] { display: none; }
.hp-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.hp-head h3 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.hp-head .muted { font-size: 13px; }
.hp-search { width: 240px; }
.hp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hp-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; border-radius: 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s, box-shadow .15s; }
.hp-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.hp-thumb { position: relative; display: block; height: 150px; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.hp-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.hp-ph { display: grid; place-items: center; height: 100%; background: linear-gradient(160deg, var(--surface-2), var(--surface-3)); color: var(--ink-3); }
.hp-ph svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .5; }
.hp-badge { position: absolute; top: 10px; left: 10px; font: 600 11px var(--mono); padding: 3px 8px; border-radius: 99px; background: var(--warn); color: #fff; }
.hp-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 6px; }
.hp-name { font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-3); }
.hp-stats i { font-style: normal; font: 600 13px var(--mono); color: var(--ink); }
.hp-meta { font-size: 12px; color: var(--ink-3); }
.hp-open { margin: 6px 16px 14px; font-size: 13px; font-weight: 600; color: var(--accent); }
.hp-card:hover .hp-open span { margin-left: 4px; }
.hp-empty, .hp-loading { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; text-align: center;
  color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: 16px; font-size: 13.5px; }
.hp-empty svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.hp-empty b { color: var(--ink); font-size: 15px; }

/* top bar: project switcher */
.current-project.menu { position: relative; }
.project-title-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; color: var(--ink); cursor: pointer;
  padding: 6px 10px; border-radius: 10px; font: inherit; }
.project-title-btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.pt-caret { font-size: 10px; color: var(--ink-3); }
.project-switch { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 380px; max-height: 70vh; overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.project-switch[hidden] { display: none; }
.ps-head { padding: 8px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.ps-head span { font-family: var(--mono); color: var(--accent); margin-left: 4px; }
.ps-list { display: flex; flex-direction: column; gap: 2px; }
.ps-list button { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px;
  border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.ps-list button:hover { background: var(--surface-2); }
.ps-list button.on { background: var(--accent-soft); }
.ps-dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font: 700 13px var(--sans); color: #fff; background: linear-gradient(135deg, #14b8a6, #0f766e); }
.ps-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-main em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-cur { font: 600 10px var(--mono); text-transform: uppercase; color: var(--accent); }
.ps-foot { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.ps-foot button { width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; border: 0; background: none; color: var(--accent); font: 600 13px var(--sans); cursor: pointer; }
.ps-foot button:hover { background: var(--surface-2); }
/* projects first, then the new-project form */
.home-inner { display: flex; flex-direction: column; }
.home-hero { order: 0; }
.home-projects { order: 1; margin: 0 auto 34px; width: 100%; }
#newProjectForm { order: 2; width: 100%; }
.hp-thumb img { object-fit: cover; object-position: center; background: var(--canvas); }
.hp-resume { position: absolute; right: 10px; bottom: 10px; font: 600 10.5px var(--sans); padding: 3px 9px; border-radius: 99px;
  color: #fff; background: rgba(10, 30, 32, .78); backdrop-filter: blur(6px); }
