:root {
  --bg: #0A0A0F;
  --surface: #11121C;
  --surface-muted: #171827;
  --surface-raised: #24283A;
  --ink: #FFFFFF;
  --muted: #D1D4E0;
  --subtle: #A4A7B2;
  --line: rgba(148, 163, 255, .14);
  --line-strong: rgba(148, 163, 255, .14);
  --accent-cyan: #00F2FF;
  --accent: #2F9CFF;
  --accent-hover: #4D67FF;
  --accent-indigo: #4D67FF;
  --accent-violet: #582CFF;
  --accent-soft: rgba(77, 103, 255, .12);
  --success: #3DDC97;
  --warning: #FFB454;
  --danger: #FF5C7A;
  --brand-gradient: linear-gradient(90deg, #582CFF 0%, #2F9CFF 55%, #00F2FF 100%);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --shadow-glow: 0 0 24px rgba(77, 103, 255, .25);
  --shadow-glow-cyan: 0 0 18px rgba(0, 242, 255, .2);
  --radius: 16px;
  --control-radius: 12px;
  --badge-radius: 6px;
  --page-gutter: clamp(24px, 3vw, 48px);
  --sidebar-gutter: clamp(20px, 1.75vw, 28px);
}

:root[data-theme="light"] {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-muted: #F2F5FB;
  --surface-raised: #E8EDF7;
  --ink: #101320;
  --muted: #30384F;
  --subtle: #657089;
  --line: rgba(69, 82, 120, .18);
  --line-strong: rgba(69, 82, 120, .24);
  --accent-cyan: #2563EB;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-indigo: #C7D2FE;
  --accent-violet: #6D5BD0;
  --accent-soft: #EEF2FF;
  --shadow: 0 12px 28px rgba(39, 54, 92, .12);
  --shadow-glow: none;
  --shadow-glow-cyan: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 2%, rgba(88, 44, 255, .16), transparent 30rem),
    radial-gradient(circle at 8% 92%, rgba(47, 156, 255, .11), transparent 34rem),
    radial-gradient(circle at 54% 48%, rgba(0, 242, 255, .035), transparent 26rem),
    var(--bg);
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 88% 2%, rgba(88, 44, 255, .09), transparent 30rem),
    radial-gradient(circle at 8% 92%, rgba(47, 156, 255, .10), transparent 34rem),
    var(--bg);
}
button, input, textarea { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter);
  background: rgba(10, 10, 15, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
:root[data-theme="light"] .app-header { background: rgba(255, 255, 255, .86); }
.brand { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand-logo { display: block; width: auto; height: 34px; object-fit: contain; }
.header-meta { display: flex; align-items: center; gap: 12px; }
.theme-toggle { display: inline-flex; height: 30px; align-items: center; gap: 2px; padding: 2px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--control-radius); }
.theme-option { height: 24px; padding: 0 9px; color: var(--subtle); background: transparent; border: 0; border-radius: 9px; font-size: 11px; font-weight: 700; cursor: pointer; }
.theme-option:hover { color: var(--muted); }
.theme-option.is-active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-glow); }
.sync-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.sync-status i { width: 7px; height: 7px; background: var(--subtle); border-radius: 999px; }
.sync-status.connected i { background: var(--success); box-shadow: 0 0 18px rgba(61, 220, 151, .2); }
.icon-button { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; background: transparent; border: 1px solid transparent; border-radius: var(--control-radius); cursor: pointer; }
.icon-button:hover { background: var(--surface-muted); border-color: var(--line); }
.icon-button svg { width: 18px; }

.workspace { display: grid; min-height: calc(100vh - 58px); grid-template-columns: minmax(0, 1fr) clamp(360px, 30vw, 480px); }
.document-column { min-width: 0; padding: 44px var(--page-gutter) 80px; border-right: 1px solid var(--line); }
.page-heading { display: flex; max-width: 980px; margin: 0 auto 28px; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow { display: inline-flex; margin: 0 0 10px; padding: 4px 7px; align-items: center; gap: 6px; color: var(--muted); border: 1px solid var(--accent-indigo); border-radius: var(--badge-radius); font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.eyebrow::before { width: 5px; height: 5px; content: ""; background: var(--accent-cyan); border-radius: 999px; box-shadow: var(--shadow-glow-cyan); }
h1, h2 { margin: 0; letter-spacing: -.025em; }
h1 { font-size: clamp(26px, 2.25vw, 34px); font-weight: 800; }
h1 span { color: transparent; background: var(--brand-gradient); background-clip: text; -webkit-background-clip: text; }
h2 { font-size: 17px; font-weight: 700; }
.subtitle { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.file-count { flex: none; padding: 5px 9px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 11px/1.5 "JetBrains Mono", monospace; }
.document-feed { display: grid; max-width: 980px; margin: 0 auto; gap: 22px; }

.stage-section { overflow: visible; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17, 18, 28, .72); box-shadow: var(--shadow); }
:root[data-theme="light"] .stage-section { background: rgba(255, 255, 255, .78); }
.step-index { position: sticky; z-index: 18; top: 58px; display: grid; padding: 10px 16px; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(17, 18, 28, .94); backdrop-filter: blur(12px); box-shadow: 0 14px 30px rgba(0, 0, 0, .24); }
:root[data-theme="light"] .step-index { background: rgba(255, 255, 255, .94); box-shadow: 0 14px 30px rgba(39, 54, 92, .10); }
.step-index-item { display: grid; min-width: 0; padding: 7px 8px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 5px; color: var(--subtle); border: 1px solid transparent; border-radius: var(--badge-radius); text-decoration: none; }
.step-index-item:hover { color: var(--muted); background: var(--surface-raised); border-color: var(--line); }
.step-index-item.has-data { color: var(--muted); background: var(--surface-muted); border-color: var(--line); }
.step-index-item span, .step-index-item small { font: 400 8px/1 "JetBrains Mono", monospace; }
.step-index-item strong { overflow: hidden; font: 500 9px/1 "JetBrains Mono", monospace; text-overflow: ellipsis; white-space: nowrap; }
.step-index-item.has-data small { color: var(--accent-cyan); }
.step-progress { display: flex; min-width: 0; grid-column: 1 / -1; align-items: center; gap: 4px; color: var(--subtle); }
.step-progress-item { display: inline-flex; min-width: 0; align-items: center; gap: 3px; font: 500 7px/1 "JetBrains Mono", monospace; }
.step-progress-item svg { width: 10px; }
.step-progress-item.is-partial { color: var(--warning); }
.step-progress-item.is-complete { color: var(--success); }
.stage-steps { display: grid; }
.step-section { position: relative; display: grid; gap: 18px; padding: 0 24px 24px; scroll-margin-top: 114px; }
.step-section + .step-section { border-top: 1px solid var(--line); }
.step-section.is-empty { padding-block: 18px; background: rgba(10, 10, 15, .22); }
.step-header { position: sticky; z-index: 14; top: 114px; display: grid; margin: 0 -24px; padding: 14px 24px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; background: rgba(17, 18, 28, .98); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); box-shadow: 0 14px 24px rgba(0, 0, 0, .18); }
:root[data-theme="light"] .step-section.is-empty { background: rgba(232, 237, 247, .58); }
:root[data-theme="light"] .step-header { background: rgba(255, 255, 255, .98); box-shadow: 0 14px 24px rgba(39, 54, 92, .08); }
:root[data-theme="light"] .theme-option.is-active,
:root[data-theme="light"] .sync-status.connected i,
:root[data-theme="light"] .entity-id,
:root[data-theme="light"] .product-objective,
:root[data-theme="light"] .entity-group.is-highlighted,
:root[data-theme="light"] .entity-status.is-active,
:root[data-theme="light"] .entity-status.is-commented,
:root[data-theme="light"] .insight-icon,
:root[data-theme="light"] .objective-insight.signal .insight-icon,
:root[data-theme="light"] .objective-insight.metric .insight-icon,
:root[data-theme="light"] .selection-preview,
:root[data-theme="light"] .comment-group.is-highlighted,
:root[data-theme="light"] .comment-card.is-navigable:hover,
:root[data-theme="light"] .comment-card.is-navigable:focus-visible,
:root[data-theme="light"] .comment-card.is-highlighted {
  box-shadow: none;
}
:root[data-theme="light"] .product-objective { border-color: var(--line); }
:root[data-theme="light"] .entity-group.is-highlighted,
:root[data-theme="light"] .comment-card.is-highlighted,
:root[data-theme="light"] .selection-preview { border-color: var(--line-strong); }
:root[data-theme="light"] .entity-status.is-active { color: #047857; border-color: rgba(4, 120, 87, .24); }
:root[data-theme="light"] .entity-status.is-commented { color: #1D4ED8; border-color: rgba(37, 99, 235, .24); }
:root[data-theme="light"] .primary-button { box-shadow: none; border-color: transparent; }
:root[data-theme="light"] textarea:focus,
:root[data-theme="light"] input:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.step-heading h3 { margin: 0; color: var(--ink); font-size: clamp(18px, 1.55vw, 24px); font-weight: 800; letter-spacing: -.025em; }
.step-count { color: var(--subtle); font: 400 9px/1.3 "JetBrains Mono", monospace; white-space: nowrap; }
.entity-list { display: grid; gap: 14px; }
.entity-group { overflow: hidden; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--control-radius); }
.entity-header { display: flex; min-height: 48px; padding: 10px 14px; align-items: center; justify-content: space-between; gap: 14px; background: var(--surface-raised); border-bottom: 1px solid var(--line); }
.entity-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.entity-id { flex: none; padding: 4px 6px; color: var(--accent-cyan); background: var(--surface); border: 1px solid var(--accent-indigo); border-radius: var(--badge-radius); box-shadow: var(--shadow-glow-cyan); font: 500 9px/1 "JetBrains Mono", monospace; }
.entity-header h4 { overflow: hidden; margin: 0; color: var(--ink); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.entity-file-count { flex: none; color: var(--subtle); font: 400 8px/1 "JetBrains Mono", monospace; }
.entity-files { display: grid; gap: 1px; background: var(--line); }
.entity-files .file-card { border: 0; border-radius: 0; box-shadow: none; }
.entity-files .file-header { min-height: 44px; background: var(--surface); }
.entity-files .file-content { background: var(--surface); }
.step-empty { padding: 15px 18px; color: var(--subtle); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--control-radius); font-size: 10px; text-align: center; }

.product-objective { background: var(--surface); border-color: rgba(77, 103, 255, .34); box-shadow: var(--shadow-glow); }
.entity-group.is-highlighted { border-color: var(--accent-cyan); box-shadow: 0 0 0 3px rgba(0, 242, 255, .14), var(--shadow-glow-cyan); }
.objective-header { display: flex; min-height: 112px; padding: 18px 20px; align-items: start; justify-content: space-between; gap: 20px; background: var(--surface-raised); border-bottom: 1px solid var(--line); }
.objective-heading { min-width: 0; }
.objective-meta { display: flex; margin-bottom: 10px; align-items: center; flex-wrap: wrap; gap: 8px; }
.entity-statuses { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.entity-status { display: inline-flex; height: 22px; padding: 0 7px; align-items: center; gap: 5px; color: var(--subtle); background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 500 8px/1 "JetBrains Mono", monospace; white-space: nowrap; }
.entity-status svg { width: 12px; }
.review-toggle { cursor: pointer; }
.review-toggle:hover { color: var(--muted); border-color: var(--accent-indigo); }
.entity-status.is-active { color: var(--success); border-color: rgba(61, 220, 151, .42); box-shadow: 0 0 18px rgba(61, 220, 151, .12); }
.entity-status.is-commented { color: var(--accent-cyan); border-color: rgba(0, 242, 255, .42); box-shadow: var(--shadow-glow-cyan); }
.objective-heading h4 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.objective-heading > p { max-width: 680px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.objective-insights { display: grid; padding: 14px; grid-template-columns: 1fr; gap: 10px; background: var(--surface); }
.objective-insight { position: relative; display: grid; min-width: 0; min-height: auto; padding: 14px 16px 14px 18px; overflow: hidden; grid-template-columns: auto minmax(0, 1fr); align-items: start; column-gap: 14px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--control-radius); }
.objective-insight::before { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; content: ""; background: var(--accent-cyan); }
.objective-insight.signal::before { background: var(--accent); }
.objective-insight.metric::before { background: var(--accent-violet); }
.insight-icon { display: grid; width: 32px; height: 32px; place-items: center; color: var(--accent-cyan); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--badge-radius); box-shadow: var(--shadow-glow-cyan); }
.objective-insight.signal .insight-icon { color: var(--accent); box-shadow: var(--shadow-glow); }
.objective-insight.metric .insight-icon { color: var(--accent-violet); box-shadow: var(--shadow-glow); }
.insight-icon svg { width: 18px; }
.insight-label { min-height: 0; color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1.3; }
.objective-insight p, .insight-list { grid-column: 2; margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.insight-list { padding-left: 16px; }
.insight-list li + li { margin-top: 5px; }
.objective-insight ::selection, .objective-heading ::selection { color: var(--ink); background: var(--accent-indigo); }
.process-diagram { --diagram-zoom: 1; padding: 14px; background: var(--surface); }
.process-diagram-header { display: grid; min-height: 38px; padding: 0 10px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; color: var(--subtle); background: var(--surface-muted); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--control-radius) var(--control-radius) 0 0; font: 500 9px/1 "JetBrains Mono", monospace; }
.process-diagram-header > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.diagram-open-button { display: inline-flex; height: 26px; padding: 0 10px; align-items: center; color: var(--accent-cyan); background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 600 9px/1 "JetBrains Mono", monospace; cursor: pointer; }
.diagram-open-button:hover { color: var(--ink); border-color: var(--accent-indigo); }
.diagram-controls { display: inline-flex; height: 26px; align-items: center; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); }
.diagram-control, .diagram-zoom-label { display: inline-grid; height: 26px; min-width: 28px; padding: 0 8px; place-items: center; color: var(--muted); background: transparent; border: 0; border-left: 1px solid var(--line); font: 600 10px/1 "JetBrains Mono", monospace; cursor: pointer; }
.diagram-control:first-child { border-left: 0; }
.diagram-zoom-label { min-width: 48px; color: var(--accent-cyan); }
.diagram-control:hover, .diagram-zoom-label:hover { color: var(--ink); background: var(--surface-raised); }
.diagram-control:disabled, .diagram-zoom-label:disabled { color: var(--subtle); cursor: not-allowed; opacity: .42; }
.process-diagram-canvas { position: relative; overflow: hidden; padding: 12px; cursor: zoom-in; background: #fff; border: 1px solid var(--line); border-radius: 0 0 var(--control-radius) var(--control-radius); transition: border-color .15s, box-shadow .15s; }
.process-diagram-canvas:hover { border-color: var(--accent-indigo); box-shadow: inset 0 0 0 2px rgba(77, 103, 255, .10); }
.process-diagram-canvas:focus-visible, .diagram-dialog-canvas:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: -2px; }
.process-diagram-svg { width: 100%; min-width: 0; }
.process-diagram-svg svg { display: block; user-select: text; }
.process-diagram > .process-diagram-canvas .process-diagram-svg svg { width: 100% !important; max-width: 100% !important; height: clamp(300px, 46vw, 520px) !important; }
.process-diagram-svg svg, .process-diagram-svg text, .process-diagram-svg tspan { font-synthesis-weight: none; }
.process-diagram-svg text, .process-diagram-svg tspan { fill: #0b1020 !important; color: #0b1020 !important; stroke: none !important; stroke-width: 0 !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important; font-weight: 400 !important; text-rendering: geometricPrecision; -webkit-font-smoothing: antialiased; user-select: text; }
.process-diagram-svg text *, .process-diagram-svg tspan * { stroke: none !important; stroke-width: 0 !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important; font-weight: 400 !important; }
.diagram-loading, .diagram-error { display: grid; min-height: 180px; place-items: center; gap: 6px; color: var(--subtle); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--control-radius); font-size: 11px; text-align: center; }
.diagram-error strong { color: var(--ink); }
.diagram-error span { color: var(--muted); }
.process-diagram ::selection, .process-code-raw::selection { color: var(--ink); background: var(--accent-indigo); }
.process-code-raw { max-height: 680px; margin: 0; overflow: auto; padding: 14px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--control-radius); font: 11px/1.6 "JetBrains Mono", monospace; white-space: pre-wrap; }

.file-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); scroll-margin-top: 82px; }
.file-header { display: flex; min-height: 52px; padding: 10px 14px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.file-identity { display: flex; min-width: 0; align-items: center; gap: 10px; }
.file-icon { display: grid; width: 30px; height: 30px; flex: none; place-items: center; color: var(--accent-cyan); background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 500 9px/1 "JetBrains Mono", monospace; text-transform: uppercase; }
.file-name { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--subtle); font: 10px/1.5 "JetBrains Mono", monospace; }
.file-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.file-link { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; color: var(--muted); border-radius: var(--control-radius); }
.file-link:hover { color: var(--ink); background: var(--surface-muted); }
.file-link svg { width: 16px; }
.file-content { position: relative; min-height: 180px; }
.text-document { max-height: 680px; margin: 0; overflow: auto; padding: 28px clamp(22px, 4vw, 48px) 40px; color: var(--muted); background: var(--surface); font: 13px/1.75 "JetBrains Mono", ui-monospace, monospace; white-space: pre-wrap; word-break: break-word; }
.text-document::selection, .text-document *::selection { color: var(--ink); background: var(--accent-indigo); }
.image-document { display: grid; padding: 24px; place-items: center; background: var(--surface-muted); }
.image-document img { display: block; max-width: 100%; max-height: 760px; background: var(--surface); box-shadow: var(--shadow); }
.pdf-document { display: block; width: 100%; height: 720px; border: 0; }
.media-document { width: 100%; max-height: 620px; display: block; background: var(--surface); }
.audio-document { width: calc(100% - 48px); margin: 36px 24px; }
.unsupported-document { display: flex; min-height: 180px; padding: 32px; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.unsupported-document svg { width: 28px; color: var(--subtle); }
.unsupported-document strong { margin-top: 10px; }
.unsupported-document p { max-width: 380px; margin: 6px 0 16px; color: var(--muted); font-size: 12px; }

.comments-panel { position: sticky; top: 58px; height: calc(100vh - 58px); min-width: 0; overflow-y: auto; padding: 28px var(--sidebar-gutter) 48px; background: var(--surface); }
.panel-header { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.panel-header h2 span { display: inline-grid; min-width: 21px; height: 21px; margin-left: 5px; place-items: center; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 10px/1 "JetBrains Mono", monospace; vertical-align: 2px; }
.text-button { padding: 3px 0; color: var(--accent); background: none; border: 0; font-size: 11px; font-weight: 600; cursor: pointer; }
.text-button:disabled { color: var(--subtle); cursor: default; }
.text-button.danger { color: var(--danger); }
.comment-form { display: grid; min-width: 0; margin-top: 20px; gap: 8px; }
.comment-form label, .settings-dialog label { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.selection-preview { min-width: 0; padding: 12px; background: var(--accent-soft); border: 1px solid var(--accent-indigo); border-radius: var(--control-radius); box-shadow: var(--shadow-glow); }
.selection-preview.empty { color: var(--muted); background: var(--surface-muted); border-color: var(--line); }
.selection-label { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; color: var(--accent); font-size: 10px; font-weight: 650; }
.selection-label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-preview.empty .selection-label { color: var(--muted); }
.selection-preview blockquote { display: -webkit-box; min-width: 0; max-width: 100%; margin: 6px 0 0; overflow: hidden; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; word-break: break-word; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.selection-preview.empty blockquote { color: var(--subtle); }
.clear-selection { flex: none; padding: 0; color: var(--muted); background: none; border: 0; font-size: 17px; line-height: 1; cursor: pointer; }
textarea, input { width: 100%; color: var(--ink); background: var(--surface-muted); border: 1px solid var(--line-strong); border-radius: var(--control-radius); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 72px; padding: 10px 11px; line-height: 1.5; resize: vertical; }
input { height: 38px; padding: 0 11px; }
.manual-quote-field { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
textarea:focus, input:focus { border-color: var(--accent-indigo); box-shadow: 0 0 0 3px rgba(77, 103, 255, .14), var(--shadow-glow); }
textarea::placeholder, input::placeholder { color: var(--subtle); }
.comment-form-actions { display: grid; margin-top: 4px; grid-template-columns: 1fr auto; gap: 8px; }
.primary-button, .secondary-button { display: inline-flex; height: 40px; padding: 0 13px; align-items: center; justify-content: center; gap: 8px; border-radius: var(--control-radius); font-weight: 700; cursor: pointer; }
.primary-button { margin-top: 4px; color: white; background: var(--brand-gradient); border: 1px solid var(--accent-indigo); box-shadow: var(--shadow-glow); }
.comment-form-actions .primary-button { margin-top: 0; }
.primary-button:hover { filter: brightness(1.08); }
.primary-button svg { width: 15px; }
.primary-button.compact, .secondary-button { width: auto; height: 36px; margin: 0; }
.secondary-button { color: var(--muted); background: var(--surface-muted); border: 1px solid var(--line-strong); }
.form-hint { min-height: 18px; margin: 1px 0 0; color: var(--subtle); font-size: 10px; text-align: center; }
.form-hint.error { color: var(--danger); }
.history-heading { display: flex; margin: 24px 0 10px; padding-top: 18px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); font-size: 11px; font-weight: 650; }
.comment-history { display: grid; min-width: 0; gap: 12px; scroll-padding-top: 14px; }
.empty-comments { display: flex; min-height: 150px; padding: 18px; flex-direction: column; align-items: center; justify-content: center; color: var(--subtle); background: var(--surface-muted); border: 1px dashed var(--line-strong); border-radius: var(--control-radius); text-align: center; }
.empty-comments svg { width: 26px; }
.empty-comments p { margin: 9px 0 1px; color: var(--muted); font-size: 12px; font-weight: 600; }
.empty-comments span { font-size: 10px; }
.comment-group { display: grid; min-width: 0; gap: 8px; border-radius: var(--control-radius); transition: box-shadow .15s; scroll-margin-top: 14px; }
.comment-group.is-highlighted { box-shadow: 0 0 0 3px rgba(0, 242, 255, .14), var(--shadow-glow-cyan); }
.comment-group-header { display: grid; min-width: 0; width: 100%; max-width: 100%; padding: 9px 10px; overflow: hidden; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--muted); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--control-radius); cursor: pointer; text-align: left; }
.comment-group-header:hover { border-color: var(--accent-indigo); }
.comment-group-id { color: var(--accent-cyan); font: 600 9px/1 "JetBrains Mono", monospace; }
.comment-group-title { overflow: hidden; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.comment-group-count { display: inline-grid; min-width: 20px; height: 20px; place-items: center; color: var(--subtle); background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); font: 500 9px/1 "JetBrains Mono", monospace; }
.comment-group-list { display: grid; min-width: 0; gap: 8px; }
.comment-card { min-width: 0; max-width: 100%; padding: 12px; overflow: hidden; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--control-radius); transition: border-color .15s, background .15s, box-shadow .15s; }
.comment-card.is-navigable { cursor: pointer; }
.comment-card.is-navigable:hover, .comment-card.is-navigable:focus-visible { background: var(--surface-raised); border-color: var(--accent-indigo); box-shadow: var(--shadow-glow); outline: none; }
.comment-card.is-highlighted { background: var(--surface-raised); border-color: var(--accent-cyan); box-shadow: var(--shadow-glow-cyan); }
.comment-card-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.comment-file { min-width: 0; overflow: hidden; color: var(--accent); font-size: 10px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.comment-time { flex: none; color: var(--subtle); font-size: 9px; }
.comment-quote { margin: 8px 0; padding-left: 9px; overflow-wrap: anywhere; color: var(--muted); border-left: 2px solid var(--accent-indigo); font-size: 10px; line-height: 1.45; word-break: break-word; }
.comment-body { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; white-space: pre-wrap; word-break: break-word; }
.comment-card-actions { display: flex; min-width: 0; margin-top: 9px; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.comment-actions { display: inline-flex; flex: none; margin-left: auto; align-items: center; gap: 10px; }
.comment-edit-button, .comment-delete-button { flex: none; }
.comment-state { display: flex; min-width: 0; flex: 1 1 130px; align-items: center; gap: 5px; color: var(--subtle); font-size: 9px; }
.comment-state.synced { color: var(--success); }
.comment-state.failed { color: var(--danger); }

.empty-state { display: grid; min-height: 320px; padding: 40px; place-items: center; align-content: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; }
.empty-state p { margin: 10px 0 4px; font-weight: 600; }
.empty-state span:not(.loader) { color: var(--subtle); font-size: 12px; }
.empty-state code { padding: 2px 5px; color: var(--accent-cyan); background: var(--surface-raised); border-radius: var(--badge-radius); font-family: "JetBrains Mono", monospace; }
.loader { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.settings-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: rgba(10, 10, 15, .72); backdrop-filter: blur(4px); }
.settings-dialog form { padding: 22px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; }
.dialog-copy { margin: 16px 0 18px; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; margin-top: 20px; justify-content: end; gap: 8px; }

.diagram-dialog { width: calc(100vw - 24px); max-width: none; height: calc(100vh - 24px); max-height: none; margin: auto; padding: 0; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.diagram-dialog::backdrop { background: rgba(10, 10, 15, .84); backdrop-filter: blur(5px); }
.diagram-dialog-shell { --diagram-zoom: 1; display: grid; width: 100%; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
.diagram-dialog-header { display: flex; min-height: 72px; padding: 12px 14px; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface-raised); border-bottom: 1px solid var(--line); }
.diagram-dialog-heading { min-width: 0; }
.diagram-dialog-heading .eyebrow { margin-bottom: 4px; }
.diagram-dialog-heading h2 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }
.diagram-dialog-heading > span { display: block; overflow: hidden; margin-top: 3px; color: var(--subtle); font: 8px/1.3 "JetBrains Mono", monospace; text-overflow: ellipsis; white-space: nowrap; }
.diagram-dialog-toolbar { display: flex; flex: none; align-items: center; flex-wrap: wrap; justify-content: end; gap: 8px; }
.diagram-mode-toggle { display: inline-flex; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--badge-radius); }
.diagram-mode-button { height: 28px; padding: 0 10px; color: var(--subtle); background: transparent; border: 0; border-radius: 7px; font-size: 10px; font-weight: 650; cursor: pointer; }
.diagram-mode-button.is-active { color: var(--ink); background: var(--surface-raised); box-shadow: var(--shadow); }
.diagram-dialog-body { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) auto; background: #fff; }
.diagram-dialog-canvas { min-width: 0; min-height: 0; overflow: auto; padding: 16px; cursor: grab; touch-action: none; overscroll-behavior: contain; overscroll-behavior-x: none; background: #fff; }
.diagram-dialog-canvas.is-panning { cursor: grabbing; }
.diagram-dialog-canvas.is-panning, .diagram-dialog-canvas.is-panning * { user-select: none !important; }
.diagram-dialog .process-diagram-svg { width: max-content; min-width: 0; margin: auto; }
.diagram-dialog .process-diagram-svg svg { width: auto !important; max-width: none !important; height: auto !important; transform: scale(var(--diagram-zoom)); transform-origin: 0 0; will-change: transform; }
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas { cursor: crosshair; }
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas svg text,
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas svg tspan,
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas svg rect,
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas svg polygon,
.diagram-dialog-shell[data-diagram-mode="comment"] .diagram-dialog-canvas svg ellipse { cursor: crosshair; user-select: none; }
.diagram-dialog .diagram-comment-selected:not(text):not(tspan) { stroke: #2563EB !important; stroke-width: 3 !important; filter: drop-shadow(0 0 5px rgba(37, 99, 235, .55)); }
.diagram-dialog text.diagram-comment-selected, .diagram-dialog tspan.diagram-comment-selected { fill: #1D4ED8 !important; stroke: none !important; font-weight: 600 !important; }
.diagram-comment-panel { display: grid; width: 320px; padding: 18px; align-content: start; gap: 18px; color: var(--ink); background: var(--surface); border-left: 1px solid var(--line); }
.diagram-comment-panel[hidden] { display: none; }
.diagram-comment-panel h3 { max-height: 110px; margin: 6px 0 0; overflow: auto; font-size: 13px; line-height: 1.45; }
.diagram-comment-help { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.diagram-comment-panel form { display: grid; gap: 8px; }
.diagram-comment-panel label { color: var(--muted); font-size: 11px; font-weight: 600; }
.diagram-comment-panel .primary-button { width: 100%; }
.diagram-dialog-footer { min-height: 30px; padding: 7px 14px; color: var(--subtle); background: var(--surface-raised); border-top: 1px solid var(--line); font: 9px/1.5 "JetBrains Mono", monospace; text-align: center; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: 360px; padding: 10px 13px; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--control-radius); box-shadow: var(--shadow); font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .workspace { display: block; }
  .document-column { padding: 30px 18px 44px; border-right: 0; }
  .comments-panel { position: relative; top: auto; height: auto; border-top: 1px solid var(--line); }
  .pdf-document { height: 560px; }
  .step-index { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .objective-insights { grid-template-columns: 1fr; }
  .objective-insight { min-height: auto; }
  .diagram-dialog-header { align-items: start; flex-direction: column; }
  .diagram-dialog-toolbar { width: 100%; justify-content: space-between; }
  .diagram-dialog-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .diagram-comment-panel { width: auto; max-height: 250px; overflow: auto; grid-template-columns: minmax(0, 1fr) minmax(260px, .8fr); border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 540px) {
  .app-header { padding: 0 16px; }
  .sync-status { display: none; }
  .page-heading { align-items: start; flex-direction: column; gap: 14px; }
  .document-column { padding-inline: 12px; }
  .text-document { padding: 20px 16px 30px; }
  .comments-panel { padding: 24px 16px 40px; }
  .brand-logo { height: 30px; }
  .step-index { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-section { padding: 0 14px 18px; }
  .step-header { top: 118px; margin: 0 -14px; padding: 12px 14px; grid-template-columns: minmax(0, 1fr); }
  .step-count { display: none; }
  .entity-header { align-items: start; }
  .entity-header h4 { white-space: normal; }
  .objective-header { padding: 16px; flex-direction: column; }
  .objective-insights { padding: 10px; }
  .process-diagram-header { grid-template-columns: 1fr; align-items: start; padding-block: 10px; }
  .process-diagram-header > span:nth-child(2) { text-align: left; }
  .diagram-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .diagram-dialog-toolbar { justify-content: start; }
  .diagram-dialog-heading h2 { white-space: normal; }
  .diagram-comment-panel { grid-template-columns: 1fr; }
  .diagram-dialog-footer { display: none; }
}
