  :root {
    --bg: #0a0a0f; --surface: #111118; --surface2: #1a1a26;
    --ink: #e8e8f0; --muted: #6b7280; --border: rgba(255,255,255,.07);
    --violet: #7c3aed; --cyan: #06b6d4; --good: #22c55e; --warn: #fbbf24;
    --radius: 14px; --radius-sm: 8px;
    --font: "Inter", system-ui, sans-serif;
    /* legacy aliases so existing styles keep working */
    --mut: var(--muted); --line: var(--border);
    --font-display: var(--font); --font-body: var(--font);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font: 15px/1.55 var(--font); background: var(--bg); color: var(--ink); min-height: 100vh; }
  .bg-glow {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background: radial-gradient(ellipse 60% 50% at 20% 0%, rgba(124,58,237,.2), transparent 55%),
                radial-gradient(ellipse 50% 40% at 80% 10%, rgba(6,182,212,.12), transparent 50%);
  }
  .shell { position: relative; z-index: 1; max-width: none; margin: 0; padding: 64px 0 0; }
  .topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 64px;
    background: rgba(10,10,15,.95); backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
  }
  .topbar-inner {
    max-width: none; margin: 0; padding: 0 20px; height: 64px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative;
  }
  .logo { font-family: var(--font-display); font-weight: 700; color: var(--ink); text-decoration: none; }
  .logo span {
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  }
  .topbar-actions { display: flex; align-items: center; gap: 10px; }
  .topbar-select {
    font-family: inherit; font-size: 12px; color: var(--ink);
    background: rgba(255,255,255,.06); border: 1px solid var(--line);
    border-radius: 8px; padding: 5px 8px; outline: none; cursor: pointer; max-width: 160px;
  }
  .topbar-select:focus { border-color: var(--cyan); }
  .engine-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
  .engine-badge.engine-opus { color: #22c55e; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); }
  .engine-badge.engine-fallback { color: #f59e0b; background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4); }
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
    border: none; cursor: pointer; font-family: inherit; text-decoration: none;
    transition: transform .15s, opacity .15s, box-shadow .15s, filter .15s;
  }
  .btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
  .btn:hover:not(:disabled) { transform: translateY(-1px); }
  .btn-primary {
    background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #fff;
    box-shadow: 0 4px 16px rgba(124,58,237,.3);
  }
  .btn-primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(124,58,237,.5); filter: brightness(1.08); }
  .btn-ghost { background: rgba(255,255,255,.06); color: var(--ink); border: 1px solid var(--line); }
  .btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.1); }
  .btn-save { background: rgba(52,211,153,.15); color: var(--good); border: 1px solid rgba(52,211,153,.4); }
  .intro { display: none; }
  .layout { display: grid; grid-template-columns: minmax(240px, 280px) 38fr 62fr; gap: 0; height: calc(100vh - 64px); overflow: hidden; }
  .checklist-panel {
    border-right: 1px solid var(--border); padding: 16px;
    background: rgba(255,255,255,.02);
    height: calc(100vh - 64px); overflow-y: auto;
    position: sticky; top: 64px;
  }
  .checklist-panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--cyan); margin-bottom: 12px; }
  .check-item {
    display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--mut);
    padding: 6px 0; border-bottom: 1px solid var(--line);
    cursor: pointer; user-select: none;
  }
  .check-item:hover { color: var(--ink); }
  .check-item.expanded { color: var(--ink); }
  .check-item:last-child { border: 0; }
  .check-detail {
    margin: -2px 0 8px 16px; padding: 6px 0 6px 10px;
    border-left: 2px solid var(--line); font-size: 12px;
  }
  .check-detail .fact-item { padding: 2px 0; }
  .check-detail-note { color: var(--mut); font-size: 12px; line-height: 1.4; padding: 2px 0; }
  .fact-src { color: var(--mut); font-size: 10px; font-style: italic; }
  .check-item.done { color: var(--good); }
  .check-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 5px; flex-shrink: 0; }
  .check-item.done .check-dot { background: var(--good); }
  .check-section-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
    color: var(--mut); margin: 14px 0 6px; font-weight: 700;
  }
  .check-section-title.required-title { color: var(--warn); }
  .fact-item {
    display: flex; gap: 8px; align-items: baseline;
    font-size: 12px; padding: 3px 0; line-height: 1.35;
  }
  .fact-item .fact-k {
    flex: 0 0 72px; color: var(--mut); font-weight: 700;
    font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  }
  .fact-item .fact-v { color: var(--ink); word-break: break-word; }
  .check-item.required { color: var(--ink); font-weight: 600; }
  .check-item.required:not(.done) .check-dot { background: var(--warn); box-shadow: 0 0 0 2px rgba(251,191,36,.25); }
  .check-item.recommended:not(.done) { color: #b8c5d9; }
  .check-item.optional { color: var(--mut); font-size: 12px; }
  .checklist-hint { font-size: 11px; color: var(--mut); line-height: 1.45; margin-bottom: 10px; }
  .concept-picker-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; margin: 12px 0 16px;
  }
  .concept-pick-card {
    border: 2px solid var(--line); border-radius: 12px; overflow: hidden;
    background: rgba(0,0,0,.25); cursor: pointer; text-align: left; padding: 0;
    font-family: inherit; color: inherit; transition: border-color .15s, transform .15s;
  }
  .concept-pick-card:hover { border-color: var(--cyan); transform: translateY(-2px); }
  .concept-pick-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
  .concept-pick-label { padding: 8px 10px; font-size: 11px; color: var(--mut); line-height: 1.3; }
  .chat-panel {
    border: none; border-right: 1px solid var(--border); border-radius: 0;
    background: var(--bg); display: flex; flex-direction: column;
    height: 100%; min-height: 0; overflow: hidden;
  }
  .messages {
    flex: 1; min-height: 0; overflow-y: auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 14px;
    max-height: none;
  }
  .msg { max-width: 88%; font-size: 15px; line-height: 1.6; }
  .msg-text { white-space: pre-wrap; }
  .msg-time { font-size: 10px; color: var(--muted); margin-top: 4px; opacity: .75; }
  .msg.user .msg-time { text-align: right; }
  .msg-prompt {
    margin-top: 10px; border: 1px solid rgba(124,58,237,.3); border-radius: 10px;
    background: rgba(0,0,0,.35); overflow: hidden;
  }
  .msg-prompt summary {
    cursor: pointer; padding: 8px 12px; font-size: 12px; font-weight: 700;
    color: #c4b5fd; list-style: none; user-select: none;
  }
  .msg-prompt summary::-webkit-details-marker { display: none; }
  .msg-prompt summary::before { content: "▾ "; }
  .msg-prompt:not([open]) summary::before { content: "▸ "; }
  .msg-prompt pre {
    margin: 0; padding: 10px 12px 12px; border-top: 1px solid rgba(124,58,237,.2);
    font-size: 11px; line-height: 1.45; color: #cbd5e1; white-space: pre-wrap; word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    max-height: 220px; overflow-y: auto;
  }
  .msg.user {
    align-self: flex-end; background: var(--surface2); border: 1px solid var(--border);
    padding: 10px 16px; border-radius: 18px 18px 4px 18px;
  }
  .msg.bot { align-self: flex-start; background: transparent; border: none; padding: 0; }
  .msg.bot .msg-text { color: var(--ink); }
  .msg.bot.msg-error {
    background: rgba(127,29,29,.2); border: 1px solid rgba(248,113,113,.45);
    padding: 10px 14px; border-radius: 12px;
  }
  .msg.bot.msg-error .msg-text { color: #fca5a5; }
  .msg-typing { display: flex; align-items: center; gap: 5px; padding: 4px 0; min-height: 20px; }
  .msg-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--mut);
    animation: typing-bounce 1.2s infinite ease-in-out;
  }
  .msg-typing span:nth-child(2) { animation-delay: .15s; }
  .msg-typing span:nth-child(3) { animation-delay: .3s; }
  @keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .35; }
    40% { transform: translateY(-5px); opacity: 1; }
  }
  .msg-images.single-feature { grid-template-columns: 1fr; max-width: 420px; }
  .msg.system { align-self: center; font-size: 13px; color: var(--mut); background: transparent; border: none; text-align: center; max-width: 100%; }
  .msg-images {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px; margin-top: 12px;
  }
  .msg-image-wrap { display: flex; flex-direction: column; gap: 4px; }
  .msg-image-wrap img {
    width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px;
    border: 1px solid var(--line); cursor: pointer; transition: transform .15s;
  }
  .msg-image-wrap img:hover { transform: scale(1.02); }
  .msg-image-label { font-size: 11px; color: var(--mut); line-height: 1.3; }
  .layout-3d-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(0,0,0,.35); }
  .layout-3d-concept { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .layout-3d-concept strong { display: block; font-size: 14px; margin-bottom: 6px; color: var(--cyan); }
  .layout-3d-concept span { font-size: 12px; color: var(--mut); line-height: 1.45; }
  .layout-3d-canvas { width: 100%; height: 380px; min-height: 360px; }
  .layout-3d-canvas canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
  .layout-3d-legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--mut); }
  .layout-3d-legend-item { display: inline-flex; align-items: center; gap: 6px; }
  .layout-3d-legend-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  .layout-3d-hint { font-size: 11px; color: var(--mut); padding: 0 12px 8px; }
  .layout-3d-save { margin: 0 12px 12px; }
  .layout-3d-card {
    display: block; width: 100%; max-width: 300px; margin-top: 12px; padding: 14px 16px;
    border-radius: 12px; border: 1px solid rgba(6,182,212,.35); background: rgba(6,182,212,.08);
    cursor: pointer; text-align: left; font-family: inherit; color: inherit;
    transition: border-color .15s, background .15s;
  }
  .layout-3d-card:hover { border-color: var(--cyan); background: rgba(6,182,212,.14); }
  .layout-3d-card-icon { font-size: 26px; line-height: 1; margin-bottom: 8px; color: var(--cyan); }
  .layout-3d-card-title { font-weight: 700; font-size: 14px; color: var(--cyan); margin-bottom: 4px; }
  .layout-3d-card-sub { font-size: 12px; color: var(--mut); line-height: 1.4; }
  .layout-3d-card-btn { margin-top: 10px; font-size: 12px; color: var(--cyan); font-weight: 600; }
  .layout-3d-modal { width: min(560px, 94vw); padding: 0; overflow: hidden; }
  .layout-3d-modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--line);
  }
  .layout-3d-modal-head h3 { margin: 0; font-size: 1rem; }
  .layout-3d-modal-close { padding: 8px 14px; font-size: 13px; }
  .mesh-3d-split {
    display: grid; grid-template-columns: minmax(200px, 38%) 1fr; gap: 12px;
    padding: 0 16px 8px; align-items: stretch;
  }
  @media (max-width: 640px) {
    .mesh-3d-split { grid-template-columns: 1fr; }
  }
  .mesh-3d-ref {
    border-radius: 12px; border: 1px solid var(--line); overflow: hidden;
    background: rgba(255,255,255,.03); display: flex; flex-direction: column;
  }
  .mesh-3d-ref img {
    width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block;
  }
  .mesh-3d-ref-label {
    padding: 8px 10px; font-size: 11px; color: var(--mut); line-height: 1.35;
  }
  .mesh-3d-viewer-wrap { min-height: 400px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
  .mesh-3d-viewer {
    width: 100%; height: 420px; min-height: 400px; background: #1a1f2e;
    --poster-color: transparent;
  }
  .mesh-3d-hint {
    padding: 0 16px 12px; font-size: 11px; color: var(--mut); margin: 0;
  }
  .layout-3d-modal { width: min(680px, 94vw); }
  .files-bar {
    padding: 8px 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; min-height: 0;
  }
  .file-chip {
    font-size: 12px; padding: 4px 10px; border-radius: 999px;
    background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--muted);
    transition: background .2s, color .2s, border-color .2s;
  }
  .file-chip.reading {
    color: var(--cyan); border-color: rgba(6,182,212,.35);
    background: rgba(6,182,212,.08); animation: chip-pulse .9s infinite;
  }
  .file-chip.done {
    color: var(--good); border-color: rgba(34,197,94,.35);
    background: rgba(34,197,94,.08); animation: none;
  }
  @keyframes chip-pulse { 50% { opacity: .6; } }
  .chat-panel.drag-over { outline: 2px dashed var(--cyan); outline-offset: -4px; background: rgba(6,182,212,.04); }
  .composer {
    padding: 14px 16px; border-top: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 10px;
  }
  .composer-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
  .composer-actions { display: flex; gap: 6px; flex-shrink: 0; }
  .composer textarea {
    flex: 1; min-width: 200px; min-height: 44px; max-height: 140px; resize: vertical;
    padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line);
    background: rgba(255,255,255,.05); color: var(--ink); font-family: inherit; font-size: 15px;
  }
  .composer textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,.12); }
  .icon-btn {
    width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
    background: rgba(255,255,255,.05); color: var(--ink); cursor: pointer; font-size: 18px;
  }
  .icon-btn.recording { border-color: #f87171; color: #f87171; animation: pulse-rec 1s infinite; }
  @keyframes pulse-rec { 50% { opacity: .6; } }
  .status-line { font-size: 12px; color: var(--mut); padding: 0 4px; min-height: 16px; }
  .status-line.err { color: #f87171; font-weight: 600; }
  .status-line.ok { color: var(--good); }
  .mesh-progress {
    display: none;
    margin: 0 4px 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(6,182,212,.12);
    border: 1px solid rgba(6,182,212,.35);
    color: #a5f3fc;
    font-size: 13px;
    line-height: 1.4;
  }
  .mesh-progress.visible { display: block; }
  .mesh-progress strong { color: #e0f2fe; }
  input[type="file"] { display: none; }
  .chat-model-bar { display: none; }
  .chat-model-select { display: none; }
  .ref-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 6px; }
  .ref-chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px;
    border-radius: 10px; border: 1px solid rgba(124,58,237,.4);
    background: rgba(124,58,237,.1); font-size: 12px; color: #ddd6fe;
  }
  .ref-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
  .ref-chip button {
    background: transparent; border: none; color: #fca5a5; cursor: pointer; font-size: 14px; line-height: 1;
  }
  .projects-panel { display: none; } /* legacy aside removed; rule kept harmless */
  /* Projects section (top of left panel) */
  .projects-section { margin-bottom: 14px; }
  .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  .panel-head h2 { margin: 0; }
  .panel-sep { border-top: 1px solid var(--line); margin: 6px 0 14px; }
  .btn-xs { padding: 3px 9px; font-size: 11px; border-radius: var(--radius-sm); font-weight: 700; border: 1px solid var(--border); cursor: pointer; font-family: inherit; }
  /* Site password gate (beta lock, before login) */
  .site-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: var(--bg); }
  .site-gate-card { width: min(360px, 90vw); text-align: center; padding: 32px 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
  .site-gate-logo { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
  .site-gate-card p { color: var(--mut); font-size: 14px; margin-bottom: 16px; }
  .site-gate-card input { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--ink); font-size: 14px; margin-bottom: 12px; }
  .site-gate-card .btn { width: 100%; }
  .site-gate-err { color: #f87171; font-size: 13px; min-height: 18px; margin-top: 10px; margin-bottom: 0; }
  .btn-sm {
    padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); font-weight: 600;
    border: 1px solid var(--border); background: var(--surface2); color: var(--ink);
    cursor: pointer; font-family: inherit;
  }
  .yes-generate-btn { display: block; margin-top: 10px; }
  .projects-empty { font-size: 13px; color: var(--muted); }
  .projects-list { list-style: none; }
  .project-item {
    padding: 10px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
    margin-bottom: 6px; background: var(--surface2);
  }
  .project-item:hover { border-color: var(--border); }
  .project-item.active { border-color: rgba(6,182,212,.45); background: rgba(6,182,212,.08); }
  .project-item-row { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
  .project-item-title { font-size: 13px; font-weight: 600; line-height: 1.3; flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .project-item-actions { display: flex; gap: 2px; flex-shrink: 0; opacity: 0; transition: opacity .12s; }
  .project-item:hover .project-item-actions, .project-item.active .project-item-actions { opacity: 1; }
  .proj-act {
    background: none; border: none; cursor: pointer; font-size: 13px; line-height: 1;
    padding: 2px 4px; border-radius: 6px; color: var(--mut); font-family: inherit;
  }
  .proj-act:hover { background: rgba(255,255,255,.08); color: var(--ink); }
  .proj-act-del:hover { color: #f87171; }
  .project-rename-input {
    flex: 1; min-width: 0; font-size: 13px; font-weight: 600; font-family: inherit;
    padding: 3px 6px; border-radius: 6px; border: 1px solid var(--cyan);
    background: var(--surface); color: var(--ink); margin-bottom: 4px;
  }
  .project-item-meta { font-size: 11px; color: var(--muted); }
  .badge { font-size: 10px; padding: 2px 6px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
  .badge-saved { background: rgba(34,197,94,.15); color: var(--good); }
  .badge-draft { background: rgba(251,191,36,.15); color: var(--warn); }
  .project-del {
    margin-top: 6px; font-size: 11px; color: #f87171; background: none; border: none;
    cursor: pointer; padding: 0; font-family: inherit;
  }
  /* Stage navigation (topbar) */
  .stage-nav {
    display: flex; align-items: center; gap: 2px;
    position: absolute; left: 50%; transform: translateX(-50%);
  }
  .stage-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
    border-radius: 999px; border: none; background: transparent;
    color: var(--muted); font: 500 13px var(--font); cursor: pointer;
    transition: color .15s, background .15s;
  }
  .stage-btn:hover { color: var(--ink); background: rgba(255,255,255,.04); }
  .stage-btn.active { color: #fff; background: rgba(124,58,237,.2); }
  .stage-btn.done { color: var(--cyan); }
  .stage-pip {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
    background: var(--muted); border: 1.5px solid var(--muted);
    transition: background .15s, border-color .15s;
  }
  .stage-btn.active .stage-pip { background: var(--violet); border-color: var(--violet); }
  .stage-btn.done .stage-pip { background: var(--cyan); border-color: var(--cyan); }
  /* Output pane */
  .output-pane {
    background: var(--surface); display: flex; flex-direction: column;
    height: 100%; min-height: 0; overflow: hidden; position: relative;
  }
  .output-content {
    flex: 1; min-height: 0; overflow-y: auto; padding: 24px;
    display: flex; flex-direction: column; gap: 16px;
  }
  .output-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; gap: 12px; padding: 60px 20px;
    opacity: 0.4; pointer-events: none;
  }
  @keyframes empty-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(1.06); }
  }
  .output-empty-icon { font-size: 48px; line-height: 1; animation: empty-pulse 3.5s ease-in-out infinite; }
  .output-empty h3 { font-size: 15px; font-weight: 600; }
  .output-empty p { font-size: 13px; color: var(--muted); max-width: 260px; line-height: 1.55; }
  /* Skip / placeholder panes (3D, Specs-before-content) */
  .output-skip {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; gap: 12px; padding: 60px 20px;
    opacity: 0.55;
  }
  .output-skip h3 { font-size: 15px; font-weight: 600; }
  .output-skip p { font-size: 13px; color: var(--muted); max-width: 320px; line-height: 1.55; }
  /* Stage 1 — Brief tab (requirements collected, files, references) */
  .output-brief { display: flex; flex-direction: column; gap: 16px; animation: fade-up .3s ease both; }
  .brief-head h3 { font-size: 16px; font-weight: 700; color: var(--ink); }
  .brief-head p { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
  /* "Что я понял" spec table */
  .brief-spec-section { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .brief-spec-head { font-size: 13px; font-weight: 700; color: var(--cyan); padding: 10px 12px; background: rgba(6,182,212,.08); border-bottom: 1px solid var(--line); }
  .brief-spec-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  .brief-spec-table th { text-align: left; vertical-align: top; width: 38%; color: var(--muted); font-weight: 600; padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .brief-spec-table td { vertical-align: top; padding: 7px 12px; border-bottom: 1px solid var(--line); color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
  .brief-spec-table tr:last-child th, .brief-spec-table tr:last-child td { border-bottom: none; }
  .brief-spec-table .fact-src { font-size: 10.5px; color: var(--muted); }
  /* Unified "Бриф проекта" table */
  .brief-table-section { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .brief-table-head { font-size: 13px; font-weight: 700; color: var(--cyan); padding: 10px 12px; background: rgba(6,182,212,.08); border-bottom: 1px solid var(--line); }
  .brief-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  .brief-table th { text-align: left; vertical-align: top; width: 36%; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .brief-table td { vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--ink); line-height: 1.45; overflow-wrap: anywhere; }
  .brief-table tr:last-child th, .brief-table tr:last-child td { border-bottom: none; }
  .bt-row { cursor: pointer; transition: background .12s; }
  .bt-row:hover { background: rgba(6,182,212,.06); }
  .bt-row-conflict { background: rgba(245,158,11,.07); }
  .bt-row-conflict:hover { background: rgba(245,158,11,.12); }
  .bt-entry + .bt-entry { margin-top: 3px; }
  .bt-src { font-size: 10.5px; color: var(--muted); }
  .bt-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: middle; cursor: help; }
  .bt-dot-need { background: #ef4444; box-shadow: 0 0 0 2px rgba(239,68,68,.18); }
  .bt-dot-ok { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.18); }
  .bt-conflict { font-size: 10px; font-weight: 700; color: #f59e0b; margin-left: 6px; }
  .bt-missing { font-size: 12px; color: #f59e0b; opacity: .85; }
  .bt-resolve { font-size: 10.5px; color: #f59e0b; margin-top: 4px; opacity: .9; }
  /* Specs tab (BOM + DXF) */
  .specs-section { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .specs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; font-size: 13px; font-weight: 700; color: var(--cyan); background: rgba(6,182,212,.08); border-bottom: 1px solid var(--line); }
  .specs-body { padding: 12px; }
  .specs-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
  .specs-actions { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
  .specs-table { font-size: 12px; }
  .specs-table thead th { color: var(--cyan); font-weight: 700; width: auto; }
  .specs-table th:nth-child(1) { width: 26%; }
  .specs-table td:nth-child(3), .specs-table td:nth-child(4) { white-space: nowrap; }
  .brief-uploads-section { border-top: 1px solid var(--border); padding-top: 14px; }
  .brief-uploads-head { font-size: 13px; font-weight: 700; color: var(--cyan); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .brief-uploads-hint { font-size: 11px; font-weight: 400; color: var(--muted); }
  .brief-uploads-list { display: flex; flex-direction: column; gap: 8px; }
  .brief-upload-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02);
  }
  .brief-upload-icon { font-size: 18px; flex-shrink: 0; }
  .brief-upload-name { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brief-upload-act { font-size: 12px; color: var(--cyan); cursor: pointer; background: none; border: none; padding: 2px 6px; }
  .brief-upload-act:hover { text-decoration: underline; }
  .brief-upload-del { font-size: 13px; color: var(--muted); cursor: pointer; background: none; border: none; padding: 2px 6px; flex-shrink: 0; opacity: .65; }
  .brief-upload-del:hover { color: #ef4444; opacity: 1; }
  .brief-uploads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .project-json { margin-top: 8px; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5; color: var(--ink); white-space: pre; overflow: auto; max-height: 420px; tab-size: 2; }
  .brief-ref-thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: pointer; }
  .brief-ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .brief-ref-thumb .brief-ref-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 6px; font-size: 11px; cursor: pointer; padding: 1px 5px; }
  /* Skipped stage tab (3D) */
  .stage-btn-skip { opacity: 0.6; }
  .stage-soon { font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; margin-left: 2px; }
  /* Upload classify modal */
  .upload-classify-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; max-height: 50vh; overflow-y: auto; }
  .upload-classify-row { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
  .upload-classify-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 20px; }
  .upload-classify-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .upload-kind-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
  .upload-kind-toggle button { background: none; border: none; color: var(--muted); font-size: 12px; padding: 6px 10px; cursor: pointer; }
  .upload-kind-toggle button.active { background: var(--cyan); color: #04222a; font-weight: 600; }
  /* Brief re-sync banner (2D pane) */
  .brief-resync-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 12px; margin-bottom: 14px; border-radius: 10px;
    background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4);
  }
  .brief-resync-banner span { font-size: 13px; color: var(--ink); flex: 1; min-width: 160px; }
  .brief-resync-dismiss { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; }
  @keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  /* 2D concept cards */
  .output-2d { display: flex; flex-direction: column; gap: 22px; animation: fade-up .3s ease both; }
  /* 2D feed — each generation/edit is a batch, newest on top */
  .concept-batch { display: flex; flex-direction: column; gap: 12px; }
  .concept-batch + .concept-batch { padding-top: 22px; border-top: 1px solid var(--line); }
  .concept-batch-head { display: flex; align-items: center; gap: 10px; }
  .concept-batch-tag {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    padding: 3px 9px; border-radius: 999px; flex-shrink: 0;
    background: rgba(255,255,255,.06); color: var(--mut);
  }
  .concept-batch-tag.latest { background: rgba(6,182,212,.18); color: var(--cyan); }
  .concept-batch-note { font-size: 12px; color: var(--mut); line-height: 1.3; overflow-wrap: anywhere; }
  .concept-batch-grid { display: flex; flex-direction: column; gap: 16px; }
  .output-concept-card {
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface2);
  }
  .output-concept-card img {
    width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; cursor: zoom-in;
    transition: transform .2s;
  }
  .output-concept-card:hover img { transform: scale(1.01); }
  .output-concept-card-footer {
    padding: 12px 14px; display: flex; align-items: center;
    justify-content: space-between; gap: 10px;
  }
  .output-concept-label { font-size: 13px; font-weight: 500; color: var(--ink); }
  .output-concept-caption { font-size: 11px; color: var(--muted); padding: 4px 14px 0; line-height: 1.35; }
  /* "generated by model X" caption on any artifact (for testing) */
  .artifact-model { font-size: 10.5px; color: var(--muted); padding: 3px 10px 0; letter-spacing: .02em; opacity: .85; }
  .footprint-plan { margin: 0 0 14px; }
  .footprint-svg { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; overflow: auto; }
  .footprint-svg svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
  /* Metric 2D plan (top view, exact dimensions) */
  .metric-plan-section { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; background: rgba(0,0,0,.18); }
  .metric-plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; font-size: 13px; font-weight: 700; color: var(--cyan); border-bottom: 1px solid var(--line); }
  .metric-plan-canvas { padding: 10px 12px; background: #e9e7e2; }
  .metric-plan-canvas svg { width: 100%; height: auto; display: block; }
  .metric-plan-loading { font-size: 12.5px; color: var(--muted); padding: 24px 8px; text-align: center; }
  .metric-plan-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: #555; }
  .metric-plan-legend i { display: inline-block; width: 20px; height: 0; vertical-align: middle; margin-right: 5px; }
  .metric-plan-legend i.ln-wall { border-top: 5px solid #3a3a3c; }
  .metric-plan-legend i.ln-open { border-top: 2.5px dashed #cc0033; }
  .output-concept-pick-btn { font-size: 12px; padding: 6px 14px; flex-shrink: 0; }
  /* 3D renders gallery */
  .output-3d { display: flex; flex-direction: column; gap: 12px; animation: fade-up .3s ease both; }
  .output-3d-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .output-3d-render-card {
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: var(--surface);
    cursor: pointer; transition: border-color .18s, transform .18s;
  }
  .output-3d-render-card:hover { border-color: rgba(124,58,237,.5); transform: translateY(-2px); }
  .output-3d-render-card img {
    width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover;
  }
  .output-3d-render-card .render-label {
    padding: 8px 12px; font-size: 12px; font-weight: 600;
    color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  }
  .output-3d-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
  .output-3d-approve { text-align: center; padding: 8px 0 4px; }
  /* Live parametric 3D scene (brief-3d.js) */
  .output-3d-scene { width: 100%; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border); background: #10141d; }
  .output-3d-scene .layout-3d-wrap { margin-top: 0; border: 0; border-radius: 0; background: transparent; }
  .output-3d-scene .layout-3d-canvas { height: min(56vh, 480px); min-height: 320px; }
  .output-3d-scene .layout-3d-canvas canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
  .output-3d-scene .layout-3d-canvas canvas:active { cursor: grabbing; }
  /* Legacy model viewer (kept for existing sessions) */
  .output-model-viewer {
    width: 100%; height: min(52vh, 440px); min-height: 260px;
    border-radius: var(--radius); overflow: hidden;
    background: var(--surface2); border: 1px solid var(--border); display: block;
  }
  /* Pack downloads */
  .output-pack { display: flex; flex-direction: column; gap: 16px; }
  .output-pack-header { font-size: 15px; font-weight: 600; color: var(--good); }
  /* Output footer: confirm bar / pack buttons */
  .output-footer {
    padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface);
    flex-shrink: 0;
  }
  .modal-overlay {
    position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.65);
    display: none; align-items: center; justify-content: center; padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    width: min(440px, 100%); background: #0c0c18; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 24px;
  }
  .modal h3 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 8px; }
  .modal p { color: var(--mut); font-size: 14px; margin-bottom: 14px; }
  .modal label { display: block; font-size: 12px; color: var(--mut); margin-bottom: 6px; }
  .modal input {
    width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
    background: rgba(255,255,255,.05); color: var(--ink); font-family: inherit; font-size: 15px;
    margin-bottom: 16px;
  }
  .modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
  .lightbox {
    position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out;
  }
  .lightbox.open { display: flex; }
  .lightbox img { max-width: 95vw; max-height: 90vh; border-radius: 12px; }
  @media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
    .checklist-panel { height: auto; max-height: 40vh; position: static; border-right: none; border-bottom: 1px solid var(--border); }
    .chat-panel { height: auto; min-height: 60vh; overflow: visible; border-right: none; border-bottom: 1px solid var(--border); }
    .output-pane { height: auto; min-height: 50vh; overflow: visible; }
    .stage-nav { position: static; transform: none; }
    .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
    .output-3d-gallery { grid-template-columns: 1fr; }
  }
  /* Password gate */
  /* Auth overlay */
  .auth-overlay {
    position: fixed; inset: 0; z-index: 999; background: rgba(8,8,20,.96);
    display: flex; align-items: center; justify-content: center; padding: 20px;
  }
  .auth-box {
    width: min(400px, 100%); background: var(--surface);
    border: 1px solid rgba(124,58,237,.3);
    border-radius: var(--radius); padding: 36px 32px; text-align: center;
    box-shadow: 0 0 60px rgba(124,58,237,.15), 0 24px 80px rgba(0,0,0,.5);
  }
  .auth-box .logo { font-family: var(--font-display); font-size: 1.8rem; margin-bottom: 4px; font-weight: 700; }
  .auth-box .logo span {
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  }
  .auth-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
  .auth-tabs {
    display: flex; border-radius: 8px; background: var(--surface2);
    padding: 3px; margin-bottom: 20px; gap: 2px;
  }
  .auth-tab {
    flex: 1; padding: 8px 12px; border: none; border-radius: 6px; background: transparent;
    color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s;
    font-family: inherit;
  }
  .auth-tab.active { background: var(--bg); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
  .auth-input {
    width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
    background: rgba(255,255,255,.05); color: var(--ink); font-family: inherit;
    font-size: 15px; margin-bottom: 10px; display: block; box-sizing: border-box;
  }
  .auth-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,.15); }
  .auth-error { color: #f87171; font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: left; }
  .auth-submit { width: 100%; margin-top: 4px; }
  .auth-link {
    background: none; border: none; color: var(--muted); font-size: 13px;
    cursor: pointer; margin-top: 12px; text-decoration: underline; display: inline-block;
    font-family: inherit;
  }
  .auth-link:hover { color: var(--ink); }
  .auth-success { color: var(--good); font-size: 13px; margin-top: 8px; }
  /* User chip in topbar */
  .user-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 200px; }
  .user-avatar {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--violet), var(--cyan));
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
  }
  .user-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* M4: Confirm bar + design pack panel */
  .confirm-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(6,182,212,.07), rgba(52,211,153,.07));
    border: 1px solid rgba(52,211,153,.35); border-radius: 12px;
    padding: 12px 16px; margin: 10px 0 4px;
  }
  .confirm-bar-note { font-size: 12px; color: var(--mut); flex: 1; min-width: 180px; }
  .btn-confirm {
    background: rgba(52,211,153,.18); color: var(--good);
    border: 1px solid rgba(52,211,153,.55); font-weight: 700; white-space: nowrap;
  }
  .btn-confirm:hover:not(:disabled) { background: rgba(52,211,153,.3); }
  .design-pack-panel {
    background: rgba(52,211,153,.07); border: 1px solid rgba(52,211,153,.4);
    border-radius: 12px; padding: 14px 16px; margin: 10px 0 4px;
  }
  .design-pack-header {
    font-weight: 700; color: var(--good); font-size: 14px; margin-bottom: 10px;
  }
  .design-pack-btns { display: flex; gap: 8px; flex-wrap: wrap; }
  .design-pack-note { font-size: 11px; color: var(--mut); margin-top: 8px; }
