:root {
  --blue: #0e5bb8;
  --blue-hover: #0b4f9f;
  --blue-active: #052d63;
  --ink: #1f2328;
  --muted: #6a737d;
  --line: #d8dee6;
  --line-soft: #e6ebf1;
  --panel: #ffffff;
  --bg: #f3f4f6;
  --surface: #f8f9fb;
  --surface-hover: #edf2f7;
  --green: #1a7f37;
  --red: #b42318;
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --font-code: Consolas, "Cascadia Mono", "Courier New", monospace;
  --sidebar-width: 258px;
  font-family: var(--font-ui);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }
.analysis-result-hidden { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef1f5; }
.auth-panel { width: min(430px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 26px; box-shadow: 0 12px 36px rgba(31, 35, 40, .12); }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 4px; background: var(--blue); color: white; font-weight: 700; letter-spacing: .2px; }
.brain-logo svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-panel h1, .view h1 { margin: 16px 0 8px; font-size: 24px; font-weight: 650; letter-spacing: 0; }
.auth-panel p, .page-title p, .view p { color: var(--muted); line-height: 1.55; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #30363d; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 9px 10px; background: #fff; color: var(--ink); outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
textarea { resize: vertical; line-height: 1.45; font-family: var(--font-code); font-size: 13px; }
form { display: grid; gap: 14px; }
.message { min-height: 22px; color: var(--red); }

.app-shell { width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); overflow: hidden; }
.app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app-shell.sidebar-collapsed .content { max-width: 100vw; }
.sidebar { height: 100vh; height: 100dvh; min-height: 0; background: #063f88; color: white; display: flex; flex-direction: column; padding: 14px 10px 52px; border-right: 1px solid #052f66; overflow: hidden; }
.sidebar-collapsed .sidebar { padding-left: 0; padding-right: 0; border-right: 0; visibility: hidden; }
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.16); }
.brand strong { font-size: 16px; font-weight: 650; }
.brand span { display: block; opacity: .82; margin-top: 2px; font-size: 13px; }
nav { display: grid; gap: 2px; padding-top: 12px; overflow: auto; }
.nav-item { text-align: left; color: white; background: transparent; border: 0; border-radius: 3px; padding: 10px 12px; font-size: 14px; }
.nav-item.active { background: var(--blue-active); box-shadow: inset 4px 0 0 #9cc7ff; font-weight: 650; }
.nav-item:hover { background: var(--blue-hover); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 8px 0; font-size: 13px; }
.user-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.user-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { width: 100%; min-width: 0; max-width: calc(100vw - var(--sidebar-width)); height: 100vh; height: 100dvh; padding: 18px 20px 58px; overflow-y: auto; overflow-x: hidden; background: var(--bg); }
.sidebar-toggle { width: 36px; height: 34px; display: inline-grid; place-content: center; gap: 4px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--ink); }
.sidebar-toggle:hover { background: var(--surface-hover); border-color: #b8c5d4; }
.sidebar-toggle span { width: 18px; height: 2px; background: currentColor; border-radius: 999px; display: block; }
.view { display: none; min-width: 0; max-width: 100%; }
.view.active { display: block; }
.page-title { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-title h1 { margin: 0 0 4px; }
.status-pill { border: 1px solid var(--line); border-radius: 3px; background: var(--panel); padding: 8px 11px; color: var(--green); font-weight: 650; display: grid; gap: 2px; min-width: 190px; }
.status-pill small { color: var(--muted); font-weight: 500; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.info-grid article, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 14px; box-shadow: 0 1px 2px rgba(31, 35, 40, .04); }
.info-grid article { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px 12px; align-items: start; }
.info-grid h3 { margin: 0 0 8px; font-size: 15px; }
.info-grid p { grid-column: 2; margin: 0; }
.info-card-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 4px; background: #eef5ff; color: var(--blue); }
.info-card-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.step-title { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.mode-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.mode-card { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); padding: 13px; display: grid; grid-template-columns: auto 44px 1fr; align-items: center; column-gap: 12px; }
.mode-card input { grid-row: span 2; }
.mode-card strong { align-self: end; }
.mode-card > span:not(.mode-icon) { display: block; grid-column: 3; color: var(--muted); font-weight: 400; margin-top: 2px; }
.mode-card.selected { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.mode-icon { grid-row: span 2; width: 44px; height: 44px; border-radius: 5px; display: grid; place-items: center; color: white; }
.mode-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.code-icon { background: var(--blue); }
.chat-icon { background: #2da44e; }

.analysis-layout { display: grid; grid-template-columns: 330px minmax(380px, 1fr) 390px; gap: 12px; align-items: start; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; min-width: 0; max-width: 100%; }
.panel h2 { font-size: 15px; font-weight: 650; margin: 0; }
.actions { display: flex; gap: 8px; }
.primary, .secondary, .ghost { border-radius: 3px; padding: 8px 12px; border: 1px solid transparent; min-height: 34px; }
.primary:disabled, .secondary:disabled, .ghost:disabled { cursor: wait; opacity: .65; }
.primary { background: var(--blue); color: white; font-weight: 650; }
.primary:hover { background: var(--blue-hover); }
.secondary { background: #f3f7fc; color: #174a7c; border-color: #c9d8ea; }
.secondary:hover { background: #e8f1fb; }
.secondary.danger-action { color: var(--red); border-color: #f0c6c2; background: #fff5f4; }
.secondary.danger-action:hover { background: #ffe7e5; }
.ghost { background: transparent; color: inherit; border-color: var(--line); }
.ghost:hover { background: var(--surface-hover); }
.sidebar .ghost { border-color: rgba(255,255,255,.28); color: white; }
.sidebar .ghost:hover { background: rgba(255,255,255,.1); }

.tree { min-height: 360px; max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 3px; padding: 6px 0; background: #fbfcfd; font-family: var(--font-ui); }
.tree-search { margin-bottom: 8px; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }
.tree > ul { padding-left: 0; }
.tree li { margin: 0; }
.tree-row { display: grid; grid-template-columns: 18px 18px 18px minmax(0, 1fr); align-items: center; gap: 5px; min-height: 26px; padding: 2px 8px; border-radius: 0; color: #24292f; }
.tree-row:hover { background: var(--surface-hover); }
.tree-toggle { width: 18px; height: 18px; border: 0; background: transparent; padding: 0; color: #24292f; display: grid; place-items: center; }
.tree-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; }
.tree-toggle:hover { color: var(--blue); }
.tree-check, .tree-check-placeholder { width: 14px; height: 14px; margin: 0; justify-self: center; }
.tree-icon { width: 16px; height: 16px; display: grid; place-items: center; color: #57606a; }
.tree-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tree-icon.folder { color: #d19a1d; }
.tree-icon.dfm { color: #1a7f37; }
.tree-icon.pas { color: #0e5bb8; }
.tree-icon.folder svg { fill: color-mix(in srgb, currentColor 18%, transparent); }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 10px; background: var(--surface); }
.tab { border: 0; border-right: 1px solid var(--line-soft); background: transparent; padding: 8px 11px; color: var(--muted); font-size: 13px; }
.tab.active { color: var(--ink); background: var(--panel); border-bottom: 2px solid var(--blue); font-weight: 650; }
.result-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 12px; background: var(--surface); }
.result-tab { border: 0; border-right: 1px solid var(--line-soft); background: transparent; padding: 9px 12px; color: var(--muted); font-size: 13px; }
.result-tab.active { color: var(--ink); background: var(--panel); border-bottom: 2px solid var(--blue); font-weight: 650; }
.result-pane { display: none; }
.result-pane.active { display: block; }
.preview, .result-table { min-height: 280px; max-width: 100%; overflow: auto; }
.result-table { border: 1px solid var(--line-soft); border-radius: 3px; background: #fff; }
.result-table table { width: 100%; }
.usecase-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: visible; scrollbar-gutter: stable; overscroll-behavior-x: contain; }
.usecase-wide-table { width: max-content !important; min-width: 2300px; }
.empty { color: var(--muted); display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 3px; background: var(--surface); }
.preview-list { display: grid; gap: 7px; }
.preview-item { border: 1px solid var(--line-soft); border-radius: 3px; padding: 9px; background: #fbfcfd; font-family: var(--font-code); font-size: 12px; }
.rich-preview { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 9px; align-items: start; }
.preview-icon { width: 22px; height: 22px; display: grid; place-items: center; color: #57606a; }
.preview-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.preview-icon.database { color: #1a7f37; }
.preview-icon.rule { color: #7c5c00; }
.preview-icon.clock { color: #8250df; }
.preview-icon.window { color: #0e5bb8; }
.preview-icon.button { color: #0969da; }
.preview-icon.input { color: #57606a; }
.preview-icon.grid { color: #0a7f8f; }
.preview-icon.list { color: #6f42c1; }
.preview-icon.calendar { color: #bf3989; }
.preview-icon.label { color: #6a737d; }
.rich-preview pre { margin: 7px 0; padding: 8px; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line-soft); background: #fff; border-radius: 3px; }
.rich-preview small { display: block; margin-top: 4px; }
.nested-components { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.nested-components > strong { display: block; margin-bottom: 8px; font-family: var(--font-ui); font-size: 12px; }
.nested-components p { margin: 0; color: var(--muted); font-family: var(--font-ui); }
.nested-component { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 7px; align-items: center; padding: 5px 0; border-top: 1px solid #f0f2f5; }
.nested-component:first-of-type { border-top: 0; }
.nested-component .preview-icon { width: 18px; height: 18px; }
.nested-component .preview-icon svg { width: 17px; height: 17px; }
.nested-component span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nested-component small { display: inline; margin-left: 4px; color: var(--muted); }
.prompt-panel { display: grid; gap: 12px; }
.result-panel { margin-top: 12px; }
.step-hint { margin: -2px 0 12px; color: var(--muted); font-size: 13px; }
.diagram-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.diagram-layout { display: grid; grid-template-columns: minmax(360px, 1.2fr) minmax(320px, .8fr); gap: 12px; align-items: start; }
.diagram-canvas, .uml-card { min-height: 360px; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfd; padding: 14px; overflow: auto; }
.diagram-canvas svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.diagram-canvas pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--font-code); font-size: 12px; }
.uml-card { font-size: 13px; line-height: 1.45; }
.uml-card h3 { margin: 0 0 10px; font-size: 16px; }
.uml-case { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 10px; }
.uml-case h4 { margin: 0 0 8px; font-size: 14px; color: var(--blue-active); }
.uml-case p { margin: 7px 0; color: var(--ink); }
.uml-case ul { margin: 5px 0 10px 18px; padding: 0; color: #30363d; }

table { width: 100%; border-collapse: collapse; background: white; font-size: 13px; }
th { background: #eef2f7; color: #24292f; font-weight: 650; }
th, td { border: 1px solid var(--line); padding: 9px; vertical-align: top; text-align: left; min-width: 150px; }
td { color: #30363d; line-height: 1.45; }
.result-table th, .result-table td { min-width: 160px; max-width: 360px; overflow-wrap: anywhere; }
.history-list { display: grid; gap: 9px; margin-top: 16px; }
.history-item { background: white; border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.history-item:hover { border-color: #b8c5d4; background: #fbfcfd; }
.history-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); margin: 8px 0; }
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.request-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.job-search { width: min(340px, 42vw); min-height: 34px; }
.jobs-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 14px; width: 100%; min-width: 0; max-width: 100%; overflow: hidden; contain: inline-size; }
.jobs-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 4px; color: var(--muted); font-size: 13px; }
.pager-actions { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.pager-actions strong { font-weight: 650; white-space: nowrap; }
.job-item { width: 100%; min-width: 0; max-width: 100%; overflow: hidden; contain: inline-size; background: white; border: 1px solid var(--line); border-left: 4px solid #8c959f; border-radius: 4px; padding: 13px; }
.job-item.status-queued { border-left-color: #bf8700; }
.job-item.status-running { border-left-color: var(--blue); }
.job-item.status-completed { border-left-color: var(--green); }
.job-item.status-failed, .job-item.status-cancelled, .job-item.status-interrupted { border-left-color: var(--red); }
.job-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; min-width: 0; max-width: 100%; }
.job-header > div { min-width: 0; }
.job-header h3 { margin: 0 0 4px; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; }
.job-header p { margin: 0; color: var(--muted); }
.job-header small { max-width: 190px; white-space: normal; text-align: right; overflow-wrap: anywhere; }
.job-header .job-error-type { margin-top: 5px; color: var(--red); font-weight: 650; }
.job-brain { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 4px; background: #eef5ff; color: var(--blue); flex: 0 0 auto; }
.job-brain svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.job-files { margin: 8px 0 2px; color: var(--muted); }
.job-files strong { display: block; margin-bottom: 5px; color: #30363d; }
.job-files ol { margin: 0; padding-left: 22px; display: grid; gap: 3px; }
.job-files li { padding-left: 2px; }
.job-file-label { display: inline-flex; align-items: center; gap: 5px; color: #30363d; }
.job-file-label svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: #57606a; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.job-result { display: block; width: 100%; min-width: 0; max-width: 100%; max-height: none; overflow: hidden; border: 1px solid var(--line-soft); }
.job-result .usecase-table-scroll { max-height: 420px; overflow-x: auto; overflow-y: auto; }
.job-result-tabs { margin-top: 10px; margin-bottom: 0; }
.job-result-pane { display: none; min-width: 0; max-width: 100%; overflow: hidden; }
.job-result-pane.active { display: block; }
.job-diagram-toolbar { margin: 10px 0; }
.job-diagram-layout { grid-template-columns: minmax(320px, 1.2fr) minmax(280px, .8fr); }
.job-diagram-layout .diagram-canvas,
.job-diagram-layout .uml-card { min-height: 300px; max-height: 520px; }
.object-location-list { display: grid; gap: 8px; margin-top: 10px; }
.object-location-item { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line-soft); border-left: 3px solid #8c959f; background: #fbfcfd; border-radius: 3px; }
.object-location-item.is-tfrm { border-left-color: var(--blue); background: #f5f9ff; }
.object-location-item strong { display: block; margin-bottom: 4px; }
.object-location-item span, .object-location-item small { display: block; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.object-source-path { color: var(--blue) !important; font-weight: 750; overflow-wrap: anywhere; word-break: break-word; }
.object-source-path strong { display: inline; color: var(--blue); font-weight: 750; }
.job-spinner { width: 15px; height: 15px; border: 2px solid #c9d8ea; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
.job-elapsed { display: inline-flex; align-items: center; gap: 5px; font-weight: 750; color: var(--blue-active); }
.job-elapsed svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-form { max-width: 900px; background: white; border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.user-form-panel { margin: 14px 0; }
.user-form-panel h2 { margin: 0 0 12px; font-size: 16px; }
.storage-path { margin: -4px 0 12px; color: var(--blue); font-family: var(--font-code); font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.user-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.checkbox-row input { width: auto; }
.users-list { display: grid; gap: 10px; margin-top: 14px; }
.user-item { background: white; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 4px; padding: 12px; }
.user-item.deleted { border-left-color: var(--red); opacity: .72; }
.user-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(420px, 1.7fr); gap: 14px; align-items: center; }
.user-row strong { display: block; margin-bottom: 3px; }
.user-row span, .user-row small { display: block; color: var(--muted); }
.user-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.user-actions input { width: 180px; }
.password-result { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 9px; border: 1px solid #b7dfc5; background: #f0fbf4; color: var(--green); border-radius: 3px; }
.switch-row { grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-slider { width: 44px; height: 24px; border-radius: 999px; background: #cfd7e3; position: relative; transition: background .18s ease; }
.switch-slider::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(31,35,40,.25); transition: transform .18s ease; }
.switch-row input:checked + .switch-slider { background: var(--blue); }
.switch-row input:checked + .switch-slider::after { transform: translateX(20px); }
.test-message { margin: 0; color: var(--muted); }
.prompt-panel .test-message { display: grid; gap: 4px; }
.generation-timer { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; font-weight: 750; text-align: right; color: var(--blue-active); }
.generation-timer svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.test-message.ok { color: var(--green); font-weight: 650; }
.test-message.error { color: var(--red); font-weight: 650; }
.fixed-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; height: 34px; display: grid; place-items: center; border-top: 1px solid var(--line); background: rgba(248,249,251,.96); color: var(--muted); font-size: 12px; box-shadow: 0 -1px 4px rgba(31, 35, 40, .04); }
small { color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgba(31, 35, 40, .36); }
.modal { width: min(680px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 18px 54px rgba(31, 35, 40, .24); overflow: hidden; }
.modal-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-header h2 { margin: 0 0 4px; font-size: 18px; font-weight: 650; }
.modal-header p { margin: 0; color: var(--muted); }
.modal-close { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 3px; background: white; color: var(--muted); }
.modal-close:hover { background: var(--surface-hover); color: var(--ink); }
.modal-status { margin: 16px 18px 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font-weight: 650; }
.modal-status.ok { border-color: #b7dfc5; background: #f0fbf4; color: var(--green); }
.modal-status.error { border-color: #f0c6c2; background: #fff5f4; color: var(--red); }
.modal-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 18px; }
.modal-details div { border: 1px solid var(--line-soft); border-radius: 4px; padding: 10px; background: #fbfcfd; }
.modal-details dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; }
.modal-details dd { margin: 0; color: var(--ink); font-family: var(--font-code); font-size: 13px; overflow-wrap: anywhere; }
.modal-response-label { margin: 0 18px 18px; }
.modal-response-label textarea { margin-top: 6px; background: #fbfcfd; }

.ollama-cursor { position: fixed; z-index: 100; left: 0; top: 0; display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #b8c5d4; border-radius: 999px; background: rgba(255,255,255,.96); box-shadow: 0 8px 24px rgba(31, 35, 40, .18); color: var(--blue-active); font-size: 12px; font-weight: 650; pointer-events: none; transform: translate(18px, 18px); }
.ollama-spinner { width: 14px; height: 14px; border: 2px solid #c9d8ea; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
.ollama-cursor.ready { color: var(--green); border-color: #b7dfc5; }
.ollama-check { width: 14px; height: 14px; display: inline-grid; place-items: center; color: var(--green); }
.ollama-check svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
body.ollama-busy { cursor: progress; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 220px; }
  .app-shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .analysis-layout { grid-template-columns: 1fr; }
  .diagram-layout { grid-template-columns: 1fr; }
  .info-grid, .mode-row { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; grid-template-columns: 1fr; overflow: visible; }
  .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; min-height: auto; overflow: visible; }
  .sidebar-collapsed .sidebar { display: none; }
  nav { overflow: visible; }
  .content { height: auto; max-width: 100vw; overflow: visible; }
  .content { padding: 14px 14px 58px; }
  .page-title, .panel-header { flex-direction: column; align-items: stretch; }
}
