/* BestekMatch — drawing-centric pro tool for Multical
   MSTR sober principles + Multical blue primary + warm AI accent (terracotta) */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-canvas: #f6f6f7;
  --bg-elevated: #ffffff;
  --bg-hover: #f4f4f5;
  --bg-active: #ececef;
  --bg-overlay: rgba(15, 15, 18, 0.42);

  --border: #ececef;
  --border-strong: #dfe0e3;
  --border-input: #d4d5d9;

  --fg: #111114;
  --fg-secondary: #4b4f57;
  --fg-muted: #6b7079;
  --fg-subtle: #9095a0;
  --fg-disabled: #b8bcc4;

  --primary: #1e54a8;
  --primary-hover: #1a4a96;
  --primary-active: #163f80;
  --primary-fg: #ffffff;
  --primary-soft: #e8f0fb;
  --primary-soft-fg: #1e54a8;
  --primary-ring: rgba(30, 84, 168, 0.22);

  --ai: #b54f2c;
  --ai-strong: #9c4322;
  --ai-soft: #fbe9e4;
  --ai-soft-fg: #8a3b1d;
  --ai-border: #ecbeae;

  --green: #1a7f4a;
  --green-soft: #e3f3e9;
  --green-border: #b8dec7;
  --amber: #a16207;
  --amber-soft: #fbf2db;
  --amber-border: #ecd9a3;
  --red: #b42318;
  --red-soft: #fbe7e4;
  --red-border: #f0bdb6;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --t-xs: 11px;
  --t-sm: 12px;
  --t-base: 13px;
  --t-md: 14px;
  --t-lg: 15px;
  --t-xl: 17px;
  --t-2xl: 20px;
  --t-3xl: 24px;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --sidebar-w: 220px;
  --tree-w: 340px;
  --review-w: 440px;
  --topbar-h: 48px;

  --shadow-sm: 0 1px 2px rgba(15, 15, 18, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 15, 18, 0.08), 0 0 0 1px rgba(15, 15, 18, 0.04);
  --shadow-lg: 0 24px 56px rgba(15, 15, 18, 0.18), 0 0 0 1px rgba(15, 15, 18, 0.06);
  --shadow-popover: 0 8px 28px rgba(15, 15, 18, 0.14), 0 0 0 1px rgba(15, 15, 18, 0.06);
}

[data-theme="dark"] {
  --bg: #0c0d10;
  --bg-subtle: #131418;
  --bg-canvas: #0a0b0e;
  --bg-elevated: #14161a;
  --bg-hover: #1b1d22;
  --bg-active: #22252b;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  --border: #1f2127;
  --border-strong: #2a2d34;
  --border-input: #2f3239;

  --fg: #e9eaec;
  --fg-secondary: #b5b8c0;
  --fg-muted: #8a8e98;
  --fg-subtle: #6a6e78;
  --fg-disabled: #4a4e58;

  --primary: #4f8bd9;
  --primary-hover: #6a9fe2;
  --primary-active: #82b0e8;
  --primary-fg: #0a0b0e;
  --primary-soft: rgba(79, 139, 217, 0.14);
  --primary-soft-fg: #82b0e8;
  --primary-ring: rgba(79, 139, 217, 0.32);

  --ai: #e08763;
  --ai-strong: #ec9c7d;
  --ai-soft: rgba(217, 119, 87, 0.12);
  --ai-soft-fg: #ec9c7d;
  --ai-border: rgba(217, 119, 87, 0.32);

  --green: #4ea776;
  --green-soft: rgba(78, 167, 118, 0.13);
  --green-border: rgba(78, 167, 118, 0.32);
  --amber: #d4a64c;
  --amber-soft: rgba(212, 166, 76, 0.12);
  --amber-border: rgba(212, 166, 76, 0.32);
  --red: #e07060;
  --red-soft: rgba(224, 112, 96, 0.13);
  --red-border: rgba(224, 112, 96, 0.32);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-popover: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; font-size: inherit; padding: 0; }
input, textarea, select { font-family: inherit; color: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01", "zero"; }

.app { display: flex; height: 100vh; overflow: hidden; background: var(--bg); min-width: 1280px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.sidebar { width: var(--sidebar-w); background: var(--bg-subtle); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 22px 18px 16px; display: flex; justify-content: center; }
.logo { display: flex; align-items: center; justify-content: center; }
.logo-img { width: 140px; height: auto; display: block; }
[data-theme="dark"] .logo-img { filter: brightness(1.7) contrast(0.95); }
.logo-mark-img { width: 100px; height: auto; display: block; }
.sidebar-nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav-section { font-size: var(--t-xs); color: var(--fg-subtle); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; padding: 14px 10px 6px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius-sm); font-size: var(--t-base); color: var(--fg-secondary); font-weight: 500; line-height: 1; height: 30px; }
.sidebar-item:hover { background: var(--bg-hover); color: var(--fg); }
.sidebar-item.active { background: var(--bg-active); color: var(--fg); }
.sidebar-item-count { margin-left: auto; font-size: var(--t-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.sidebar-user { border-top: 1px solid var(--border); padding: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-soft-fg); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.sidebar-user-meta { font-size: var(--t-sm); line-height: 1.3; min-width: 0; flex: 1; }
.sidebar-user-meta b { font-weight: 600; display: block; color: var(--fg); }
.sidebar-user-meta span { color: var(--fg-muted); font-size: var(--t-xs); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-more { color: var(--fg-muted); padding: 4px; border-radius: var(--radius-xs); }
.sidebar-user-more:hover { background: var(--bg-hover); color: var(--fg); }

.logo { display: flex; align-items: center; justify-content: center; }
.logo-img { width: 140px; height: auto; display: block; }
[data-theme="dark"] .logo-img { filter: brightness(1.7) contrast(0.95); }
.logo-mark-img { width: 100px; height: auto; display: block; }
.logo-mark { width: 28px; height: 28px; flex-shrink: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; height: 30px; border-radius: var(--radius-sm); font-size: var(--t-base); font-weight: 500; color: var(--fg); background: var(--bg); border: 1px solid var(--border-strong); white-space: nowrap; transition: background 0.08s, border-color 0.08s; }
.btn:hover { background: var(--bg-hover); }
.btn:active { background: var(--bg-active); }
.btn-primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); }
.btn-sm { height: 26px; padding: 0 8px; font-size: var(--t-sm); }
.btn-icon { width: 30px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 26px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red-border); }
.btn-success { color: var(--green); }
.btn-success:hover { background: var(--green-soft); border-color: var(--green-border); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 9px; color: var(--fg-muted); pointer-events: none; }
.input-wrap > input { padding-left: 30px; }
.input { height: 30px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-input); background: var(--bg); color: var(--fg); font-size: var(--t-base); width: 100%; outline: none; transition: border-color 0.08s, box-shadow 0.08s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.input::placeholder { color: var(--fg-subtle); }
textarea.input { padding: 8px 10px; height: auto; line-height: 1.45; resize: vertical; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: var(--t-xs); font-weight: 500; background: var(--bg-active); color: var(--fg-secondary); border: 1px solid var(--border); line-height: 1.3; white-space: nowrap; flex-shrink: 0; height: 18px; }
.badge-primary { background: var(--primary-soft); color: var(--primary-soft-fg); border-color: transparent; }
.badge-ai { background: var(--ai-soft); color: var(--ai-soft-fg); border-color: var(--ai-border); }
.badge-green { background: var(--green-soft); color: var(--green); border-color: var(--green-border); }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.badge-red { background: var(--red-soft); color: var(--red); border-color: var(--red-border); }
.badge-mono { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; font-weight: 500; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.dot-pending { background: var(--amber); }
.dot-accepted { background: var(--green); }
.dot-rejected { background: var(--red); }
.dot-idle { background: var(--fg-disabled); }

.card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 14px; }

.page-topbar { height: var(--topbar-h); border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: var(--bg); }
.page-topbar h1 { font-size: var(--t-md); font-weight: 600; margin: 0; }
.page-topbar-meta { color: var(--fg-muted); font-size: var(--t-sm); }
.page-topbar-actions { display: flex; align-items: center; gap: 8px; }

.page-content { flex: 1; overflow: auto; }
.dashboard { padding: 28px 32px 80px; max-width: 1280px; }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 24px; }
.dashboard-header h2 { font-size: var(--t-2xl); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.dashboard-header p { color: var(--fg-muted); font-size: var(--t-md); margin: 0; }

.insight-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.insight { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.insight-label { font-size: var(--t-xs); color: var(--fg-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.insight-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.insight-value sup { font-size: 13px; font-weight: 500; color: var(--fg-muted); margin-left: 2px; }
.insight-sub { font-size: var(--t-sm); color: var(--fg-muted); }
.insight-spark { display: flex; align-items: flex-end; gap: 2px; height: 18px; margin-top: 2px; }
.insight-spark > i { display: block; width: 4px; background: var(--primary); opacity: 0.4; border-radius: 1px; }
.insight-spark > i.peak { opacity: 1; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input-wrap { flex: 1; max-width: 360px; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--t-base); background: var(--bg); border: 1px solid var(--border-strong); color: var(--fg-secondary); }
.filter-chip:hover { background: var(--bg-hover); }
.filter-chip.active { background: var(--primary-soft); color: var(--primary-soft-fg); border-color: transparent; }

.project-table { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.project-row { display: grid; grid-template-columns: minmax(260px, 2.2fr) 1.2fr 1.4fr 110px 80px; align-items: center; padding: 10px 16px; gap: 16px; border-bottom: 1px solid var(--border); font-size: var(--t-base); cursor: pointer; background: var(--bg-elevated); }
.project-row:last-child { border-bottom: 0; }
.project-row.header { background: var(--bg-subtle); cursor: default; color: var(--fg-muted); font-size: var(--t-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; padding: 9px 16px; }
.project-row:not(.header):hover { background: var(--bg-hover); }
.project-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.project-name b { font-weight: 500; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-name span { color: var(--fg-muted); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-progress { display: flex; align-items: center; gap: 8px; }
.progress-bar { flex: 1; height: 4px; background: var(--bg-active); border-radius: 999px; overflow: hidden; }
.progress-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress-bar.green > i { background: var(--green); }
.progress-text { font-size: var(--t-sm); color: var(--fg-muted); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.project-meta { color: var(--fg-muted); font-size: var(--t-sm); display: flex; align-items: center; gap: 8px; }
.project-job { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: var(--t-sm); }
.spinner { width: 12px; height: 12px; border: 1.5px solid var(--border-strong); border-top-color: var(--primary); border-radius: 999px; animation: spin 0.7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.library { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.library-list { border-right: 1px solid var(--border); background: var(--bg-subtle); overflow: auto; }
.library-list-header { padding: 16px 16px 10px; }
.library-list-header h2 { font-size: var(--t-md); font-weight: 600; margin: 0 0 6px; }
.library-list-header p { color: var(--fg-muted); font-size: var(--t-sm); margin: 0 0 10px; }
.library-list-item { padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.library-list-item:hover { background: var(--bg-hover); }
.library-list-item.active { background: var(--bg-elevated); border-left: 2px solid var(--primary); padding-left: 14px; }
.library-list-item b { font-weight: 500; font-size: var(--t-base); display: block; margin-bottom: 2px; }
.library-list-item span { font-size: var(--t-sm); color: var(--fg-muted); display: block; }
.library-detail { overflow: auto; }
.library-detail-header { padding: 24px 28px 16px; border-bottom: 1px solid var(--border); }
.library-detail-header h1 { font-size: var(--t-2xl); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.library-detail-header-meta { display: flex; gap: 16px; color: var(--fg-muted); font-size: var(--t-sm); margin-top: 8px; }
.library-detail-toolbar { display: flex; gap: 8px; padding: 14px 28px; border-bottom: 1px solid var(--border); align-items: center; }
.library-tree { padding: 14px 28px 60px; }
.stabu-h { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.stabu-h:hover { background: var(--bg-hover); }

.chapter-block { border-bottom: 1px solid var(--border); }
.chapter-block:last-child { border-bottom: 0; }
.chapter-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; cursor: pointer; transition: color 0.08s; }
.chapter-row:hover { color: var(--primary); }
.chapter-row:hover .stabu-title { color: var(--primary); }
.chapter-row .stabu-code { background: transparent; border: 1px solid var(--border); padding: 1px 7px; }
.chapter-row .stabu-title { font-size: var(--t-md); font-weight: 500; }
.chapter-ai-pill { display: inline-flex; align-items: center; gap: 4px; color: var(--ai-soft-fg); background: var(--ai-soft); padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 600; border: 1px solid var(--ai-border); }

.chapter-body { padding: 4px 0 24px 26px; display: flex; flex-direction: column; gap: 18px; }
.chapter-section-h { display: flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin: 4px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

.chapter-context { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chapter-context.empty { background: transparent; border-style: dashed; }
.chapter-context-h { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.chapter-context.empty .chapter-context-h { background: transparent; border-bottom: 0; }
.chapter-context-h-title { font-size: var(--t-sm); font-weight: 600; color: var(--fg); flex: 1; }
.chapter-context-body { }
.chapter-context-rendered { padding: 16px 20px 18px; max-height: 360px; overflow: auto; }
.chapter-context-empty { display: flex; align-items: center; gap: 10px; padding: 18px 20px; width: 100%; background: transparent; border: 0; color: var(--fg-muted); cursor: pointer; font-size: var(--t-sm); }
.chapter-context-empty:hover { color: var(--primary); background: var(--primary-soft); }
.chapter-context-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 360px; }
.chapter-context-textarea { border: 0; border-right: 1px solid var(--border); padding: 16px 20px; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; background: var(--bg-subtle); color: var(--fg); resize: none; outline: none; min-height: 360px; }
.chapter-context-textarea:focus { background: var(--bg); }
.chapter-context-preview { overflow: auto; padding: 16px 20px; max-height: 480px; }
.chapter-context-placeholder { color: var(--fg-muted); font-size: var(--t-sm); font-style: italic; }

.chapter-paragrafen { padding-top: 4px; }
.md-rendered { max-width: 720px; font-size: var(--t-sm); }
.md-rendered h1 { font-size: 18px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.md-rendered h2 { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
.md-rendered h3 { font-size: 12px; font-weight: 600; margin: 14px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-secondary); }
.md-rendered p { margin: 0 0 8px; line-height: 1.55; color: var(--fg-secondary); }
.md-rendered ul { margin: 4px 0 10px; padding-left: 18px; color: var(--fg-secondary); }
.md-rendered li { margin: 3px 0; line-height: 1.5; }
.md-rendered li > ul { margin: 2px 0; }
.md-rendered strong { color: var(--fg); font-weight: 600; }
.md-rendered code { font-family: var(--font-mono); font-size: 0.92em; padding: 1px 5px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 3px; color: var(--ai-soft-fg); }
.md-rendered table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: var(--t-sm); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.md-rendered th { text-align: left; padding: 7px 10px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--fg); }
.md-rendered td { padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--fg-secondary); vertical-align: top; }
.md-rendered tbody tr:last-child td { border-bottom: 0; }
.stabu-chev { color: var(--fg-muted); transition: transform 0.15s; }
.stabu-chev.open { transform: rotate(90deg); }
.stabu-code { font-family: var(--font-mono); font-size: 11px; color: var(--fg-muted); background: var(--bg-subtle); padding: 2px 6px; border-radius: 4px; }
.stabu-title { font-weight: 500; font-size: var(--t-base); }
.stabu-count { margin-left: auto; color: var(--fg-muted); font-size: var(--t-sm); }
.stabu-children { padding-left: 28px; }
.stabu-post { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; padding: 8px 4px; border-bottom: 1px solid var(--border); align-items: center; font-size: var(--t-base); }
.stabu-post .mono { font-size: 11px; color: var(--fg-muted); }
.stabu-post-toggle { width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stabu-post-toggle.on { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }

.workspace { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ws-topbar { border-bottom: 1px solid var(--border); background: var(--bg); padding: 8px 18px 0; display: flex; flex-direction: column; flex-shrink: 0; }
.ws-topbar-row { display: flex; align-items: center; gap: 12px; height: 40px; }
.ws-back { color: var(--fg-muted); }
.ws-back:hover { color: var(--fg); }
.ws-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--t-md); font-weight: 500; min-width: 0; flex: 1; }
.ws-breadcrumb-sep { color: var(--fg-disabled); }
.ws-breadcrumb-meta { color: var(--fg-muted); font-size: var(--t-sm); font-weight: 400; display: flex; gap: 6px; align-items: center; }
.ws-phases { display: flex; align-items: center; gap: 0; padding: 8px 0; flex-wrap: nowrap; }
.ws-phase { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: var(--radius-sm); font-size: var(--t-sm); font-weight: 500; color: var(--fg-muted); }
.ws-phase:hover { background: var(--bg-hover); color: var(--fg); }
.ws-phase.done { color: var(--green); }
.ws-phase.active { background: var(--primary-soft); color: var(--primary-soft-fg); }
.ws-phase-num { width: 18px; height: 18px; border-radius: 999px; background: var(--bg-active); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: var(--fg-muted); }
.ws-phase.done .ws-phase-num { background: var(--green-soft); color: var(--green); }
.ws-phase.active .ws-phase-num { background: var(--primary); color: var(--primary-fg); }
.ws-phase-sep { width: 14px; height: 1px; background: var(--border-strong); margin: 0 2px; }

.ws-body { flex: 1; display: grid; grid-template-columns: var(--tree-w) 1fr var(--review-w); min-height: 0; overflow: hidden; }
.ws-review-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.ws-tree { border-right: 1px solid var(--border); background: var(--bg-subtle); display: flex; flex-direction: column; min-height: 0; }
.ws-tree-toolbar { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.ws-tree-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.tree-filter { font-size: var(--t-xs); padding: 3px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border-strong); color: var(--fg-secondary); display: inline-flex; align-items: center; gap: 4px; }
.tree-filter:hover { background: var(--bg-hover); }
.tree-filter.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.ws-tree-scroll { overflow: auto; flex: 1; padding-bottom: 80px; }

.tree-group { border-bottom: 1px solid var(--border); }
.tree-group-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: var(--t-sm); background: transparent; }
.tree-group-h:hover { background: var(--bg-hover); }
.tree-group-h b { font-weight: 600; font-size: var(--t-sm); color: var(--fg); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-group-count { font-size: 10px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.tree-mat { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 6px 12px 6px 32px; font-size: var(--t-base); cursor: pointer; position: relative; }
.tree-mat:hover { background: var(--bg-hover); }
.tree-mat.selected { background: var(--primary-soft); }
.tree-mat.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--primary); }
.tree-mat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; color: var(--fg); }
.tree-mat-meta { font-size: 10px; color: var(--fg-muted); font-family: var(--font-mono); }
.tree-mat-match-icon { color: var(--fg-subtle); }
.tree-mat-match-icon.chosen { color: var(--green); }
.tree-mat-match-icon.auto { color: var(--ai); }

.ws-viewer { background: var(--bg-canvas); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.viewer-toolbar { border-bottom: 1px solid var(--border); padding: 8px 14px; display: flex; align-items: center; gap: 10px; background: var(--bg); flex-shrink: 0; font-size: var(--t-sm); flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
.viewer-toolbar > * { flex-shrink: 0; }
.viewer-toolbar-spacer { flex: 1; }
.viewer-page-nav { display: flex; align-items: center; gap: 4px; color: var(--fg-secondary); }
.viewer-page-input { width: 36px; text-align: center; height: 22px; border-radius: var(--radius-xs); border: 1px solid var(--border-input); background: var(--bg); font-size: 12px; font-family: var(--font-mono); }
.viewer-canvas { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: safe center; padding: 24px 24px 80px; min-height: 0; }
.pdf-page-wrap { background: white; border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.pdf-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: white; color: var(--fg-muted); font-size: var(--t-sm); }
.viewer-page { background: white; width: 720px; min-height: 980px; border-radius: var(--radius); box-shadow: var(--shadow-md); position: relative; color: #1a1a1a; padding: 56px 64px; font-family: "Inter", sans-serif; flex-shrink: 0; }
[data-theme="dark"] .viewer-page { background: #e9eaec; }
.viewer-page h2 { font-size: 12px; font-weight: 600; margin: 0 0 20px; color: #444; text-transform: uppercase; letter-spacing: 0.06em; }
.viewer-page h3 { font-size: 13px; font-weight: 600; margin: 18px 0 6px; }
.viewer-page-text { font-size: 11px; line-height: 1.55; color: #333; }
.viewer-page-text p { margin: 0 0 7px; }
.viewer-page-spec { font-family: "JetBrains Mono", monospace; font-size: 10px; line-height: 1.7; color: #555; background: #f7f7f7; padding: 12px 14px; border-radius: 4px; margin: 10px 0; }
.viewer-page-table { width: 100%; border-collapse: collapse; font-size: 10px; margin: 10px 0; }
.viewer-page-table th { text-align: left; font-weight: 600; padding: 5px 8px; border-bottom: 1px solid #ccc; background: #f3f3f4; }
.viewer-page-table td { padding: 5px 8px; border-bottom: 1px solid #eaeaea; }
.viewer-page-fig { background: #f4f4f5; border: 1px dashed #c8c9cc; border-radius: 4px; height: 180px; display: flex; align-items: center; justify-content: center; color: #888; font-size: 11px; margin: 10px 0; font-style: italic; }
.viewer-marker { position: absolute; border-radius: 3px; border: 2px solid; cursor: pointer; transition: all 0.15s; }
.viewer-marker:hover { transform: scale(1.02); }
.viewer-marker.pending { border-color: var(--amber); background: rgba(161, 98, 7, 0.08); }
.viewer-marker.accepted { border-color: var(--green); background: rgba(26, 127, 74, 0.08); }
.viewer-marker.rejected { border-color: var(--red); background: rgba(180, 35, 24, 0.08); }
.viewer-marker.selected { animation: markerPulse 1.6s ease-in-out infinite; }
@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(30,84,168,0.6); }
  50% { box-shadow: 0 0 0 6px rgba(30,84,168,0); }
}
.viewer-marker-label { position: absolute; top: -22px; left: -2px; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px; white-space: nowrap; font-family: var(--font-mono); color: white; }
.viewer-marker.pending .viewer-marker-label { background: var(--amber); }
.viewer-marker.accepted .viewer-marker-label { background: var(--green); }
.viewer-marker.rejected .viewer-marker-label { background: var(--red); }

.viewer-controls { position: absolute; right: 16px; bottom: 76px; display: flex; flex-direction: column; gap: 4px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow-md); }
.viewer-thumbs { border-top: 1px solid var(--border); padding: 8px 14px; display: flex; gap: 6px; overflow-x: auto; flex-shrink: 0; background: var(--bg); height: 64px; align-items: center; }
.viewer-thumb { width: 36px; height: 48px; border: 1px solid var(--border-strong); border-radius: 3px; background: white; flex-shrink: 0; cursor: pointer; position: relative; font-size: 9px; color: var(--fg-muted); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px; }
[data-theme="dark"] .viewer-thumb { background: #d1d5db; color: #555; }
.viewer-thumb:hover { border-color: var(--fg-muted); }
.viewer-thumb.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring); }
.viewer-thumb-dot { position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 999px; background: var(--amber); }

.doc-switcher { position: relative; }
.doc-switcher-trigger { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 8px; border-radius: var(--radius-sm); background: var(--bg-subtle); border: 1px solid var(--border); height: 28px; max-width: 360px; cursor: pointer; font-size: var(--t-sm); color: var(--fg); }
.doc-switcher-trigger:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.doc-switcher-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.doc-menu-overlay { position: fixed; inset: 0; z-index: 39; }
.doc-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-popover); width: 420px; padding: 4px; max-height: 360px; overflow: auto; }
.doc-menu-h { padding: 8px 10px 6px; font-size: 10px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.doc-menu-item { display: grid; grid-template-columns: 22px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; width: 100%; border-radius: var(--radius-sm); background: transparent; border: 0; cursor: pointer; text-align: left; color: var(--fg); }
.doc-menu-item:hover { background: var(--bg-hover); }
.doc-menu-item.active { background: var(--primary-soft); }
.doc-menu-item-kbd { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 20px; border-radius: 4px; background: var(--bg-subtle); border: 1px solid var(--border-strong); font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--fg-muted); }
.doc-menu-item-meta { min-width: 0; }
.doc-menu-item-meta b { font-weight: 500; font-size: var(--t-sm); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-menu-item-meta span { color: var(--fg-muted); font-size: 10px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-tab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); background: var(--bg-subtle); border: 1px solid var(--border); cursor: pointer; font-size: var(--t-sm); font-family: var(--font-mono); color: var(--fg-secondary); flex-shrink: 0; }
.doc-tab:hover { background: var(--bg-hover); }
.doc-tab.active { background: var(--bg-elevated); color: var(--fg); border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring); font-weight: 600; }
.doc-tab-count { font-size: 9px; padding: 1px 5px; border-radius: 999px; background: var(--ai-soft); color: var(--ai-soft-fg); font-family: var(--font-sans); font-weight: 600; }
.doc-tab.active .doc-tab-count { background: var(--primary); color: var(--primary-fg); }

.ws-review { border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.review-scroll { overflow: auto; flex: 1; padding-bottom: 40px; }
.review-section { border-bottom: 1px solid var(--border); padding: 16px 18px; }
.review-section-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.review-section-h h3 { font-size: var(--t-sm); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted); }

.material-card { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.material-card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.material-card-name { font-size: var(--t-base); font-weight: 600; margin: 0 0 4px; letter-spacing: -0.005em; line-height: 1.35; min-width: 0; word-wrap: break-word; }
.material-card-system { color: var(--fg-muted); font-size: var(--t-xs); line-height: 1.4; }
.material-card-actions { display: flex; gap: 1px; flex-shrink: 0; margin-top: -2px; }
.material-card-actions .icon-btn { width: 22px; height: 22px; }
.material-card-actions .icon-btn svg { width: 12px; height: 12px; }
.material-quote { background: var(--bg); border-left: 2px solid var(--ai); padding: 8px 10px; border-radius: 0 var(--radius-xs) var(--radius-xs) 0; font-size: var(--t-sm); color: var(--fg-secondary); margin: 10px 0 4px; position: relative; }
.material-quote-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ai-soft-fg); font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.material-quote-src { color: var(--fg-muted); font-size: var(--t-xs); margin-top: 6px; font-family: var(--font-mono); }

.match-list { display: flex; flex-direction: column; gap: 8px; }
.match { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); padding: 10px 12px; cursor: pointer; position: relative; transition: border-color 0.08s, background 0.08s; }
.match:hover { border-color: var(--border-strong); }
.match.chosen { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.match.auto { border-color: var(--ai-border); }
.match.auto.chosen { box-shadow: 0 0 0 1px var(--ai); border-color: var(--ai); }
.match.disabled { opacity: 0.55; cursor: default; }
.match.disabled:hover { border-color: var(--border); }
.match-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.match-head .badge-mono { background: var(--bg-active); color: var(--fg); border: 1px solid var(--border-strong); padding: 1px 6px; font-size: 11px; font-weight: 600; }
.match.chosen .badge-mono { background: var(--primary-soft); color: var(--primary-soft-fg); border-color: var(--primary-soft); }
.match.auto.chosen .badge-mono { background: var(--ai-soft); color: var(--ai-soft-fg); border-color: var(--ai-border); }
.match-title { font-size: var(--t-base); font-weight: 500; margin: 6px 0 2px; line-height: 1.4; }
.match-confidence-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.match-confidence-bar { flex: 1; height: 4px; background: var(--bg-active); border-radius: 999px; overflow: hidden; }
.match-confidence-bar > i { display: block; height: 100%; border-radius: 999px; }
.match-confidence-bar.high > i { background: var(--green); }
.match-confidence-bar.mid > i { background: var(--amber); }
.match-confidence-bar.low > i { background: var(--fg-disabled); }
.match-confidence-pct { font-size: var(--t-xs); font-variant-numeric: tabular-nums; color: var(--fg-muted); min-width: 30px; text-align: right; font-weight: 500; }
.match-explain { margin-top: 6px; padding: 6px 8px; background: var(--ai-soft); border-left: 2px solid var(--ai); color: var(--ai-soft-fg); font-size: var(--t-xs); line-height: 1.5; border-radius: 0 3px 3px 0; }
.match-explain-toggle { font-size: var(--t-xs); color: var(--fg-muted); margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.match-explain-toggle:hover { color: var(--fg); }

.advice-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); margin-bottom: 8px; overflow: hidden; }
.advice-block-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; background: var(--bg-subtle); border-bottom: 1px solid transparent; }
.advice-block.open .advice-block-h { border-bottom-color: var(--border); }
.advice-block-h:hover { background: var(--bg-hover); }
.advice-block-icon { width: 22px; height: 22px; border-radius: var(--radius-xs); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.advice-block.remove .advice-block-icon { background: var(--red-soft); color: var(--red); }
.advice-block.modify .advice-block-icon { background: var(--amber-soft); color: var(--amber); }
.advice-block.add .advice-block-icon { background: var(--green-soft); color: var(--green); }
.advice-block-title { font-weight: 500; font-size: var(--t-base); flex: 1; }
.advice-block-count { font-size: var(--t-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.advice-block-body { padding: 8px 12px 12px; font-size: var(--t-sm); line-height: 1.55; }
.advice-block-body ul { margin: 0; padding: 0 0 0 14px; }
.advice-block-body li { margin-bottom: 5px; color: var(--fg-secondary); }
.advice-block-body li:last-child { margin-bottom: 0; }
.advice-block-body li code { font-family: var(--font-mono); font-size: 11px; padding: 1px 4px; background: var(--bg-subtle); border-radius: 3px; }

.ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ai-soft-fg); background: var(--ai-soft); padding: 1px 5px; border-radius: 3px; }

.skeleton { background: linear-gradient(90deg, var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: var(--radius-xs); height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.job-pill { position: fixed; left: 232px; bottom: 16px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px 6px 8px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-md); font-size: var(--t-sm); z-index: 40; }
.job-pill-name { font-weight: 500; }
.job-pill-meta { color: var(--fg-muted); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.job-pill-progress { width: 60px; height: 3px; background: var(--bg-active); border-radius: 999px; overflow: hidden; }
.job-pill-progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.5s; }

.toasts { position: fixed; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 10px 12px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-md); font-size: var(--t-sm); min-width: 240px; max-width: 360px; animation: toastIn 0.18s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--green); }
.toast.info .toast-icon { color: var(--primary); }
.toast.ai .toast-icon { color: var(--ai); }
.toast b { font-weight: 600; display: block; margin-bottom: 1px; }
.toast span { color: var(--fg-muted); font-size: var(--t-xs); }

.overlay { position: fixed; inset: 0; background: var(--bg-overlay); z-index: 90; display: flex; animation: overlayIn 0.15s ease-out; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.sheet { margin-left: auto; width: 560px; background: var(--bg); height: 100vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: sheetIn 0.22s cubic-bezier(0.32, 0.72, 0.36, 1); }
.sheet.wide { width: 820px; }
@keyframes sheetIn { from { transform: translateX(100%); } to { transform: none; } }
.sheet-h { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; flex-shrink: 0; }
.sheet-h h2 { font-size: var(--t-xl); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.sheet-h p { color: var(--fg-muted); font-size: var(--t-sm); margin: 4px 0 0; }
.sheet-body { overflow: auto; flex: 1; padding: 22px 24px; }
.sheet-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-shrink: 0; }

.dialog { margin: auto; width: 480px; background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: dialogIn 0.16s cubic-bezier(0.32, 0.72, 0.36, 1); border: 1px solid var(--border); }
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog-h { padding: 18px 22px 4px; }
.dialog-h h2 { font-size: var(--t-lg); font-weight: 600; margin: 0; }
.dialog-h p { color: var(--fg-muted); font-size: var(--t-sm); margin: 4px 0 0; }
.dialog-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: var(--t-sm); font-weight: 500; color: var(--fg-secondary); }

.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-meta b { font-weight: 500; font-size: var(--t-base); display: block; margin-bottom: 2px; }
.setting-meta span { font-size: var(--t-sm); color: var(--fg-muted); }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: var(--bg-active); border-radius: 999px; outline: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: 0 1px 2px rgba(0,0,0,0.12); cursor: pointer; }
.slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border-strong); cursor: pointer; }
.toggle { width: 32px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; cursor: pointer; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 999px; background: white; transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 16px; }

.export-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.export-summary > div { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.export-summary-label { font-size: var(--t-xs); color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.export-summary-value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.export-warn { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-soft); border: 1px solid var(--amber-border); color: var(--amber); padding: 10px 12px; border-radius: var(--radius); font-size: var(--t-sm); margin-bottom: 14px; }
.export-warn b { color: var(--amber); }
.export-warn p { margin: 4px 0 0; color: var(--fg-secondary); }
.export-list { display: flex; flex-direction: column; gap: 8px; }
.export-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-elevated); }
.export-item-h { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.export-item-title { font-size: var(--t-base); font-weight: 500; flex: 1; }
.export-item-meta { font-size: var(--t-xs); color: var(--fg-muted); margin-bottom: 8px; }
.export-item-advice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: var(--t-xs); }
.export-item-advice > div { background: var(--bg-subtle); padding: 6px 8px; border-radius: 4px; }
.export-item-advice > div b { font-weight: 600; display: block; margin-bottom: 2px; }

.empty { padding: 60px 24px; text-align: center; color: var(--fg-muted); }
.empty h3 { font-size: var(--t-md); font-weight: 600; color: var(--fg); margin: 12px 0 4px; }
.empty p { font-size: var(--t-sm); margin: 0 0 20px; max-width: 360px; margin-inline: auto; }
.empty-icon { width: 40px; height: 40px; border-radius: var(--radius); background: var(--bg-active); display: inline-flex; align-items: center; justify-content: center; color: var(--fg-muted); margin: 0 auto; }

.divider { height: 1px; background: var(--border); margin: 12px 0; }
.kbd { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; font-family: var(--font-mono); font-size: 10px; font-weight: 500; background: var(--bg-subtle); border: 1px solid var(--border-strong); border-radius: 3px; color: var(--fg-muted); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: var(--radius-xs); color: var(--fg-muted); }
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
.icon-btn.success:hover { color: var(--green); background: var(--green-soft); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); }
.icon-btn.active { color: var(--fg); }

/* ── FLOW STEPS (wizard) ─────────────────────────────── */
.flow-step { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg-canvas); }
.flow-step-h {
  padding: 28px 40px 20px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.flow-step-h h1 { font-size: 22px; font-weight: 600; margin: 6px 0 6px; letter-spacing: -0.015em; }
.flow-step-h p { font-size: var(--t-md); color: var(--fg-muted); margin: 0; max-width: 720px; line-height: 1.5; }
.flow-step-eyebrow { font-size: var(--t-xs); color: var(--fg-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.flow-step-body {
  flex: 1; overflow: auto;
  padding: 24px 40px 24px;
  display: grid; grid-template-columns: 380px 1fr; gap: 24px;
  min-height: 0;
}
.flow-step-foot {
  border-top: 1px solid var(--border);
  padding: 14px 40px;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg);
  flex-shrink: 0;
}
.flow-step-foot > span { flex: 1; }

.flow-mb-side { display: flex; flex-direction: column; gap: 16px; }
.flow-mb-tree { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.flow-mb-tree-toolbar { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.flow-mb-tree-list { overflow: auto; flex: 1; padding: 4px 0; }

.flow-summary { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.flow-summary-row { display: flex; justify-content: space-between; align-items: baseline; }
.flow-summary-label { font-size: var(--t-sm); color: var(--fg-muted); }
.flow-summary-value { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.flow-tip { display: flex; gap: 10px; padding: 12px 14px; background: var(--primary-soft); color: var(--primary-soft-fg); border-radius: var(--radius); font-size: var(--t-sm); }
.flow-tip b { display: block; margin-bottom: 2px; font-weight: 600; }
.flow-tip span { color: var(--fg-secondary); }

.mb-chapter { border-bottom: 1px solid var(--border); }
.mb-chapter:last-child { border-bottom: 0; }
.mb-chapter.off { opacity: 0.6; }
.mb-chapter-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.mb-chapter-title { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; padding: 0; background: transparent; border: 0; color: inherit; text-align: left; }
.mb-chapter-title:hover { background: var(--bg-hover); }
.mb-chapter-title .stabu-title { font-weight: 500; flex: 1; }
.mb-chapter-children { padding: 4px 14px 12px 38px; display: flex; flex-direction: column; gap: 2px; }
.mb-sub { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; padding: 6px 6px; border-radius: var(--radius-xs); }
.mb-sub:hover { background: var(--bg-hover); }
.mb-sub .stabu-title { font-size: var(--t-base); font-weight: 400; }

.ref-dropzone { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--t-xs); color: var(--fg-secondary); background: var(--bg-elevated); transition: border-color 0.1s, background 0.1s; }
.ref-dropzone:hover, .ref-dropzone.hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-fg); }
.ref-dropzone b { font-weight: 600; }
.ref-dropzone svg { color: var(--fg-muted); flex-shrink: 0; }
.ref-dropzone:hover svg, .ref-dropzone.hover svg { color: var(--primary); }
.ref-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.ref-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ref-item-meta { min-width: 0; }
.ref-item-meta b { font-weight: 500; font-size: var(--t-sm); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-item-meta span { color: var(--fg-muted); font-size: 10px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-type-picker { background: var(--bg-elevated); border: 1px solid var(--primary); border-radius: var(--radius); padding: 12px; margin-top: 8px; box-shadow: 0 0 0 3px var(--primary-ring); animation: dialogIn 0.16s; }
.attach-type-picker-h { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.attach-type-picker-h svg:first-child { color: var(--primary); flex-shrink: 0; }
.attach-type-picker-q { font-size: var(--t-sm); font-weight: 600; margin-bottom: 8px; color: var(--fg); }
.attach-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
.attach-type-btn { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--bg-subtle); border: 1px solid var(--border); cursor: pointer; font-size: var(--t-sm); color: var(--fg-secondary); text-align: left; }
.attach-type-btn:hover { background: var(--primary-soft); color: var(--primary-soft-fg); border-color: var(--primary); }
.attach-type-btn svg { color: var(--fg-muted); flex-shrink: 0; }
.attach-type-btn:hover svg { color: var(--primary); }
.attach-type-picker-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--fg-muted); }
.attach-type-picker-foot b { color: var(--fg); font-weight: 600; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 60px 40px 40px;
  text-align: center;
  background: var(--bg-elevated);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 999px; background: var(--bg-active); color: var(--fg-secondary); margin-bottom: 14px; }
.dropzone.hover .dropzone-icon { background: var(--primary); color: white; }
.dropzone h3 { font-size: var(--t-lg); font-weight: 600; margin: 0 0 4px; }
.dropzone p { color: var(--fg-muted); font-size: var(--t-sm); margin: 0; }
.dropzone p u { color: var(--primary); text-decoration: underline; cursor: pointer; }
.dropzone-types { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.upload-list { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.upload-list-h { padding: 10px 14px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); font-size: var(--t-sm); font-weight: 600; color: var(--fg-secondary); }
.upload-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.upload-row:last-child { border-bottom: 0; }
.upload-row-name b { font-weight: 500; display: block; }
.upload-row-name span { color: var(--fg-muted); font-size: var(--t-xs); }

.flow-step.processing { background: var(--bg); }
.flow-elapsed { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-muted); font-size: var(--t-sm); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
.flow-progress-bar { height: 4px; background: var(--bg-active); flex-shrink: 0; }
.flow-progress-bar > i { display: block; height: 100%; background: var(--primary); transition: width 0.15s linear; }

.flow-card-h { font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin: 0 0 10px; }
.processing-steps { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.processing-step { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.processing-step:last-child { border-bottom: 0; }
.processing-step-icon { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 999px; background: var(--bg-active); color: var(--fg-muted); flex-shrink: 0; }
.processing-step.done .processing-step-icon { background: var(--green-soft); color: var(--green); }
.processing-step.active .processing-step-icon { background: var(--primary-soft); color: var(--primary-soft-fg); }
.processing-step.active { background: var(--primary-soft); }
.processing-step-label { font-weight: 500; font-size: var(--t-base); }
.processing-step.done .processing-step-label { color: var(--green); }
.processing-step.active .processing-step-label { color: var(--primary-soft-fg); }
.processing-step-meta { font-size: var(--t-xs); color: var(--fg-muted); text-align: right; }

.processing-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.processing-thumb { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.processing-thumb-img { height: 140px; background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); position: relative; }
.processing-thumb-foot { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; font-size: var(--t-xs); color: var(--fg-secondary); }

.processing-log { background: #0c0d10; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-height: 120px; max-height: 220px; overflow: auto; font-family: var(--font-mono); font-size: 11px; line-height: 1.7; color: #a8b0bb; }
.log-stream { display: flex; flex-direction: column; }
.log-line { display: grid; grid-template-columns: 50px 1fr; gap: 10px; }
.log-line.dim { opacity: 0.5; }
.log-time { color: #6a7180; }
.log-msg { color: #d0d6df; }
.log-cursor { display: inline-block; width: 7px; height: 12px; background: #d0d6df; vertical-align: -2px; animation: cursorBlink 0.7s infinite; }
@keyframes cursorBlink { 50% { opacity: 0; } }

.export-view-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.export-view { flex: 1; display: grid; grid-template-columns: 340px 1fr; min-height: 0; }
.export-view-tree { border-right: 1px solid var(--border); background: var(--bg-subtle); display: flex; flex-direction: column; min-height: 0; }
.export-view-tree-h { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.export-view-tree-h h3 { font-size: var(--t-md); font-weight: 600; margin: 0; }
.export-view-tree-scroll { flex: 1; overflow: auto; }
.export-view-tree-foot { border-top: 1px solid var(--border); padding: 12px 16px; flex-shrink: 0; background: var(--bg); }
.export-view-stats { display: flex; flex-direction: column; gap: 6px; }
.export-stat-row { display: flex; justify-content: space-between; align-items: center; font-size: var(--t-sm); color: var(--fg-secondary); }
.export-stat-row b { font-variant-numeric: tabular-nums; }
.export-stat-row span { display: inline-flex; align-items: center; gap: 6px; }

.export-post-item { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 7px 14px 7px 14px; width: 100%; text-align: left; background: transparent; border: 0; cursor: pointer; font-size: var(--t-base); color: var(--fg); position: relative; }
.export-post-item:hover { background: var(--bg-hover); }
.export-post-item.selected { background: var(--primary-soft); }
.export-post-item.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--primary); }
.export-post-item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-post-item-ai { display: inline-flex; align-items: center; gap: 3px; color: var(--ai-soft-fg); background: var(--ai-soft); padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 600; }

.export-view-doc { display: flex; flex-direction: column; min-height: 0; background: var(--bg-canvas); }
.export-view-doc-toolbar { padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--bg); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.export-view-doc-scroll { flex: 1; overflow: auto; padding: 32px 40px 80px; }

.export-doc-h { padding: 0 0 24px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.export-doc-h h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.015em; }

.export-chapter { margin-bottom: 32px; }
.export-chapter-h { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.export-chapter-code { font-family: var(--font-mono); font-size: var(--t-lg); font-weight: 600; color: var(--fg-muted); }
.export-chapter-h h2 { font-size: var(--t-lg); font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: 0.04em; }

.osf-post { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; transition: box-shadow 0.15s, border-color 0.15s; }
.osf-post.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.osf-post-h { padding: 14px 18px; background: var(--bg-subtle); border-bottom: 1px solid var(--border); }
.osf-post-h-line { display: flex; align-items: center; gap: 10px; }
.osf-post-h-line h3 { font-size: var(--t-md); font-weight: 600; margin: 0; }
.osf-post-h-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; align-items: center; }
.osf-post-koppels { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-muted); font-size: var(--t-xs); flex-wrap: wrap; }

.osf-rubriek { padding: 14px 18px; border-top: 1px solid var(--border); }
.osf-rubriek:first-child { border-top: 0; }
.osf-rubriek.ai { background: linear-gradient(to right, var(--ai-soft) 0, var(--ai-soft) 3px, transparent 3px); border-left: 3px solid var(--ai); padding-left: 18px; }
.osf-rubriek-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.osf-rubriek-code { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--fg-muted); background: var(--bg-subtle); padding: 2px 6px; border-radius: 3px; }
.osf-rubriek.ai .osf-rubriek-code { background: var(--bg); }
.osf-rubriek-title { font-weight: 600; font-size: var(--t-sm); text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-secondary); flex: 1; }
.osf-rubriek-lines { margin: 0; padding: 0 0 0 18px; font-size: var(--t-sm); color: var(--fg-secondary); line-height: 1.55; }
.osf-rubriek-lines li { margin-bottom: 6px; }
.osf-rubriek-edits { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.osf-edit { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.osf-edit.add { border-color: var(--green-border); background: var(--bg); }
.osf-edit.modify { border-color: var(--amber-border); }
.osf-edit.remove { border-color: var(--red-border); }
.advice-pill { width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; line-height: 1; flex-shrink: 0; font-family: var(--font-mono); }
.advice-pill.add { background: var(--green-soft); color: var(--green); }
.advice-pill.modify { background: var(--amber-soft); color: var(--amber); }
.advice-pill.remove { background: var(--red-soft); color: var(--red); }
.osf-edit-body { min-width: 0; }
.osf-edit-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin-bottom: 2px; }
.osf-edit.add .osf-edit-label { color: var(--green); }
.osf-edit.modify .osf-edit-label { color: var(--amber); }
.osf-edit.remove .osf-edit-label { color: var(--red); }
.osf-edit-text { font-size: var(--t-sm); line-height: 1.55; color: var(--fg-secondary); }
.osf-edit-text.strike { text-decoration: line-through; color: var(--fg-muted); }

.osf-edit-label-row { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.osf-edit-actions { display: flex; gap: 2px; flex-shrink: 0; align-self: flex-start; }
.osf-edit.accepted { border-color: var(--green); background: var(--green-soft); }
.osf-edit.accepted .advice-pill { background: var(--green); color: white; }
.osf-edit.rejected { opacity: 0.6; border-style: dashed; background: var(--bg-subtle); }
.osf-edit.feedback { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.osf-edit-state-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 999px; }
.osf-edit-state-tag.accepted { background: var(--green); color: white; }
.osf-edit-state-tag.rejected { background: var(--red); color: white; }
.osf-edit-state-tag.feedback { background: var(--ai-soft); color: var(--ai-soft-fg); border: 1px solid var(--ai-border); }

.osf-edit-feedback { margin-top: 8px; padding: 10px; background: var(--bg-subtle); border-radius: var(--radius-sm); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.osf-edit-feedback textarea.input { resize: vertical; min-height: 56px; font-size: var(--t-sm); }
.osf-edit-feedback-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
