        :root {
            --bg: #0d1117;
            --bg-secondary: #0d1117;
            --surface: #161b22;
            --border: #30363d;
            --border-bright: #484f58;
            --text-primary: #c9d1d9;
            --text-bright: #ffffff;
            --text-dim: #8b949e;
            --accent: #58a6ff;
            --accent-glow: rgba(88, 166, 255, 0.15);
            --success: #238636;
            --warning: #d29922;
            --error: #f85149;
            --code-bg: #161b22;
            --table-header-bg: #161b22;
            --table-row-hover: #21262d;
            --input-bg: #0d1117;
            --control-bg: #161b22;
            --control-bg-hover: #21262d;
            --control-active-bg: rgba(88, 166, 255, 0.14);
            --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.18);
        }

        body.vscode-light {
            --bg: #ffffff;
            --bg-secondary: #f6f8fa;
            --surface: #ffffff;
            --border: #d0d7de;
            --border-bright: #afb8c1;
            --text-primary: #24292f;
            --text-bright: #111118;
            --text-dim: #57606a;
            --accent: #0969da;
            --accent-glow: rgba(9, 105, 218, 0.1);
            --success: #1a7f37;
            --warning: #9a6700;
            --error: #cf222e;
            --code-bg: #f6f8fa;
            --table-header-bg: #f6f8fa;
            --table-row-hover: #f3f4f6;
            --input-bg: #ffffff;
            --control-bg: #ffffff;
            --control-bg-hover: #f6f8fa;
            --control-active-bg: rgba(9, 105, 218, 0.1);
            --shadow-soft: 0 8px 20px rgba(31, 35, 40, 0.08);
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        
        html, body {
            height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Helvetica, Arial, sans-serif;
            font-size: 13px;
            line-height: 1.6;
            background: var(--bg);
            color: var(--text-primary);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* --- Header --- */
        .header {
            display: flex;
            flex-direction: column;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            z-index: 100;
        }

        .header-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px 6px;
            gap: 10px;
        }

        .header-actions,
        .tool-group {
            display: flex;
            align-items: center;
        }

        .header-actions { gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
        .tool-group {
            gap: 4px;
            padding: 3px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: rgba(255, 255, 255, 0.02);
        }
        .control-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 6px;
            width: 100%;
            align-items: center;
        }

        .brand { font-weight: 700; font-size: 14px; color: var(--text-bright); letter-spacing: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
        .logo { width: 22px; height: 22px; background: var(--accent); color: #fff; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 900; }

        .status-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: var(--text-dim);
            box-shadow: 0 0 0 2px rgba(139, 148, 158, 0.12);
            flex-shrink: 0;
        }
        .status-dot.ready {
            background: #3fb950;
            box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.16);
        }

        .chat {
            flex: 1;
            overflow-y: auto;
            padding: 16px 14px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            scroll-behavior: smooth;
        }

        /* --- Messages --- */
        .msg {
            display: flex;
            flex-direction: column;
            gap: 8px;
            position: relative;
            animation: msgIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .msg-user {
            align-items: flex-end;
        }

        .msg-ai {
            align-items: flex-start;
        }

        @keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

        .msg-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 11px; color: var(--text-dim); }
        .msg-user .msg-head { flex-direction: row-reverse; }
        .av { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
        
        /* Tooltip System */
        [data-tooltip] { position: relative; }
        [data-tooltip]::after {
            content: attr(data-tooltip);
            position: absolute; bottom: -30px; left: 50%; transform: translateX(-50%);
            background: #333; color: #fff; padding: 4px 8px; border-radius: 4px;
            font-size: 10px; white-space: nowrap; opacity: 0; pointer-events: none;
            transition: all 0.2s ease; z-index: 100; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
        }
        [data-tooltip]:hover::after { opacity: 1; bottom: -35px; }
        
        #input::placeholder { color: var(--accent); opacity: 0.6; font-weight: 500; }


        .msg-body {
            color: var(--text-primary);
            font-size: 13.5px;
            word-break: break-word;
            max-width: min(88%, 760px);
        }

        .msg-user .msg-body {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 10px 14px;
            white-space: pre-wrap;
            text-align: left;
        }

        .msg-ai .msg-body {
            padding-left: 30px;
            width: 100%;
            max-width: 100%;
        }

        /* --- Markdown Style --- */
        .markdown-body h1, .markdown-body h2, .markdown-body h3 {
            color: var(--text-bright);
            margin: 1.5em 0 0.8em;
            font-weight: 600;
            line-height: 1.3;
        }

        .markdown-body h1 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; color: var(--accent); }
        .markdown-body h2 { font-size: 1.45em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
        .markdown-body h3 { font-size: 1.2em; }
        .markdown-body p { margin: 0.75em 0 1.1em; }
        .markdown-body ol, .markdown-body ul { margin: 0.7em 0 1.1em; padding-left: 1.45em; }
        .markdown-body li { margin: 0.35em 0 0.65em; }
        .markdown-body li + li { margin-top: 0.55em; }
        .markdown-body table {
            width: 100%;
            border-collapse: collapse;
            margin: 1.2em 0;
            font-size: 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
        }
        .markdown-body th { background: var(--table-header-bg); color: var(--accent); font-weight: 600; text-align: left; padding: 10px 12px; border: 1px solid var(--border); }
        .markdown-body td { padding: 8px 12px; border: 1px solid var(--border); color: var(--text-primary); }
        .markdown-body tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }

        .markdown-body pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow-x: auto; margin: 12px 0; }
        .markdown-body code { font-family: 'SF Mono', monospace; font-size: 11.5px; background: rgba(175, 184, 193, 0.2); padding: 0.2em 0.4em; border-radius: 4px; }

        /* --- UI Elements --- */
        .msg-actions {
            position: absolute; bottom: -12px; right: 0; display: flex; gap: 4px; opacity: 0; transition: 0.2s; z-index: 20;
        }
        .msg:hover .msg-actions { opacity: 1; }
        .action-btn {
            background: var(--bg-secondary); border: 1px solid var(--border);
            color: var(--text-dim); padding: 4px 10px; border-radius: 6px; font-size: 10px; cursor: pointer; transition: 0.2s;
            display: flex; align-items: center; gap: 4px;
        }
        .action-btn:hover { color: var(--text-bright); border-color: var(--accent); background: var(--accent-glow); }

        .icon-btn {
            background: var(--control-bg);
            border: 1px solid var(--border);
            color: var(--text-dim);
            min-width: 28px;
            height: 28px;
            padding: 0 8px;
            border-radius: 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
            font-size: 12px;
            font-weight: 700;
            line-height: 1;
            flex: 0 0 auto;
        }
        .icon-btn:hover { color: var(--text-bright); border-color: var(--border-bright); background: var(--control-bg-hover); box-shadow: var(--shadow-soft); }
        .icon-btn.active { color: var(--accent); border-color: var(--accent); background: var(--control-active-bg); }

        .select-wrap {
            position: relative;
            min-width: 0;
            flex: 1 1 0;
        }

        .select-wrap::after {
            content: '';
            position: absolute;
            right: 10px;
            top: 50%;
            width: 6px;
            height: 6px;
            border-right: 1.5px solid var(--text-dim);
            border-bottom: 1.5px solid var(--text-dim);
            transform: translateY(-65%) rotate(45deg);
            pointer-events: none;
        }

        select {
            width: 100%;
            min-width: 0;
            height: 30px;
            background: var(--control-bg);
            color: var(--text-primary);
            border: 1px solid var(--border);
            padding: 0 28px 0 10px;
            border-radius: 6px;
            font-size: 11px;
            font-weight: 600;
            cursor: pointer;
            outline: none;
            appearance: none;
            transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
        }

        select:hover { border-color: var(--border-bright); background: var(--control-bg-hover); }
        select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

        /* --- Input & Attachments --- */
        .input-wrap {
            padding: 12px 14px 16px; background: var(--bg); border-top: 1px solid var(--border); flex-shrink: 0;
        }

        .input-box {
            background: var(--input-bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px;
            display: flex; flex-direction: column; gap: 8px; transition: 0.2s;
            position: relative; /* Toast 위치 앙커 */
        }
        .input-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

        textarea {
            width: 100%; background: transparent; border: none; color: var(--text-bright);
            font-family: inherit; font-size: 13.5px; resize: none; outline: none; min-height: 24px; max-height: 160px;
        }

        .attachment-preview {
            display: none; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
        }
        .attachment-preview.visible { display: flex; }

        .file-chip {
            display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
            padding: 4px 8px; border-radius: 6px; font-size: 11px; color: var(--text-primary);
        }
        .file-chip .remove { cursor: pointer; color: var(--text-dim); }
        .file-chip .remove:hover { color: var(--error); }

        .input-footer { display: flex; align-items: center; justify-content: space-between; }
        .footer-left { display: flex; align-items: center; gap: 8px; }

        /* (Removed) Pill-shaped `.company-chip` / `.company-manage-btn` —
           the Corp toggle now lives in the header toolbar reusing the
           existing `.icon-btn.toggle-chip` rounded-rectangle look. See
           #companyChip in sidebar.html. */
        .company-name-input {
            flex: 1; background: var(--input-bg); border: 1px solid var(--border);
            border-radius: 6px; padding: 6px 10px; color: var(--text-primary); font-size: 12px;
        }
        .company-name-input:focus { border-color: var(--accent); outline: none; }

        /* Agent cards inside the manage overlay. */
        .company-agent-list { display: flex; flex-direction: column; gap: 8px; padding: 0; }
        .company-agent-section-label {
            list-style: none;
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 8px;
            margin: 6px 2px -2px;
            color: var(--text-bright);
            font-size: 11px;
            font-weight: 700;
        }
        .company-agent-section-label small {
            color: var(--text-dim);
            font-size: 9.5px;
            font-weight: 500;
            text-align: right;
        }
        /*
         * Agent card layout, rebuilt 2026-05-14 to fix overflow:
         *  - Card itself stacks its rows VERTICALLY (`flex-direction: column`).
         *    The old version was a horizontal flex container, which caused
         *    the head row, mix row, and editor row to compete for the same
         *    horizontal space — content spilled past the overlay's right edge.
         *  - The head row uses `flex-wrap: wrap` so when the sidebar is too
         *    narrow to fit emoji + body + 3 controls in one line, the
         *    controls drop to a second row instead of clipping the tagline.
         *  - The mix row likewise wraps; slider takes priority and the
         *    hint/checkbox fall to the next line when there's no room.
         *  - `overflow: hidden` on the card itself prevents any one-pixel
         *    overflow from leaking past the rounded border.
         */
        .company-agent-card {
            display: flex;
            flex-direction: column;
            gap: 6px;
            padding: 10px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            list-style: none;
            overflow: hidden;
            position: relative;
            transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
        }
        /* 비활성 카드는 더 흐릿하게 + 좌측 액센트 바를 떨궈서 한 눈에 그룹 구분되도록. */
        .company-agent-card[data-active="false"] {
            opacity: 0.5;
            background: transparent;
            border-style: dashed;
        }
        .company-agent-card[data-active="true"] {
            border-left: 3px solid var(--agent-color, var(--accent));
        }
        .company-agent-card[data-locked="true"] {
            border-left-color: #FACC15;          /* CEO는 골드 액센트 */
            background: linear-gradient(180deg, rgba(250,204,21,0.06) 0%, transparent 100%);
        }
        .company-agent-card[data-locked="true"] .company-agent-toggle { cursor: not-allowed; opacity: 0.4; }

        /* 삭제 버튼 — 평소엔 다른 controls 톤과 동일, 파이프라인에서 사용 중이면 disabled. */
        .company-agent-delete { color: var(--text-dim); }
        .company-agent-delete:hover:not(.disabled) {
            color: var(--error); border-color: var(--error);
        }
        .company-agent-delete.disabled {
            opacity: 0.35; cursor: not-allowed;
        }

        /* 숨겨진 빌트인 복원 영역 — 평소엔 시야에 안 들어오게 차분한 톤. */
        .company-agent-hidden-section {
            margin-top: 12px; padding: 10px 12px;
            border: 1px dashed var(--border); border-radius: 8px;
            background: transparent; list-style: none;
        }
        .company-agent-hidden-head {
            font-size: 11px; color: var(--text-dim); font-weight: 600;
            margin-bottom: 2px;
        }
        .company-agent-hidden-hint {
            font-size: 10px; color: var(--text-dim); opacity: 0.8;
            margin-bottom: 8px;
        }
        .company-agent-hidden-list {
            display: flex; flex-wrap: wrap; gap: 6px;
        }
        .company-agent-hidden-chip {
            background: var(--surface); border: 1px solid var(--border);
            color: var(--text-primary); font-size: 10.5px;
            padding: 4px 9px; border-radius: 999px; cursor: pointer;
        }
        .company-agent-hidden-chip:hover {
            border-color: var(--accent); color: var(--accent);
        }

        .company-agent-head {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;           /* controls drop to row 2 when narrow */
            row-gap: 6px;
            width: 100%;
            min-width: 0;
        }

        .company-agent-emoji {
            font-size: 18px; flex-shrink: 0;
            display: inline-flex; align-items: center; justify-content: center;
            width: 28px; height: 28px;
            border-radius: 6px; background: var(--bg-secondary);
            border: 1px solid var(--border);
        }
        .company-agent-body {
            flex: 1 1 180px;          /* prefer ≥180px, shrink down to its content */
            min-width: 0;
            line-height: 1.35;
            overflow: hidden;
        }
        .company-agent-name {
            color: var(--text-bright); font-weight: 600; font-size: 12px;
            display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap;
        }
        .company-agent-role { color: var(--text-dim); font-size: 10px; }
        .company-agent-tagline {
            color: var(--text-primary); font-size: 10.5px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
            margin-top: 1px;
        }
        .company-agent-meta {
            display: flex;
            gap: 5px;
            flex-wrap: wrap;
            margin-top: 5px;
        }
        .company-agent-chip {
            display: inline-flex;
            align-items: center;
            height: 18px;
            padding: 0 7px;
            border-radius: 999px;
            border: 1px solid var(--border);
            color: var(--text-dim);
            background: var(--bg-secondary);
            font-size: 9.5px;
            line-height: 1;
            white-space: nowrap;
        }
        .company-agent-chip.tuned {
            color: var(--accent);
            border-color: var(--accent);
            background: var(--accent-glow);
        }
        .company-agent-controls {
            display: flex; align-items: center; gap: 6px;
            flex-shrink: 0;
            margin-left: auto;        /* push to the right of the head row */
            max-width: 100%;
            flex-wrap: wrap;
            justify-content: flex-end;
        }
        .company-agent-toggle {
            background: transparent; border: 1px solid var(--border);
            color: var(--text-dim); font-size: 10px; font-weight: 600;
            padding: 4px 9px; border-radius: 999px; cursor: pointer;
            flex-shrink: 0;
        }
        .company-agent-card[data-active="true"] .company-agent-toggle {
            border-color: var(--agent-color, var(--accent)); color: var(--text-bright);
            background: var(--accent-glow);
        }
        .company-agent-model {
            background: var(--input-bg); border: 1px solid var(--border);
            color: var(--text-primary); font-size: 10px;
            padding: 3px 6px; border-radius: 6px;
            width: 120px; min-width: 0;        /* fixed width keeps row predictable */
            max-width: 100%;
            cursor: pointer;
        }
        .company-agent-model option { color: var(--text-primary); background: var(--bg); }
        .company-agent-role-select {
            font-size: 10px; padding: 3px 6px; border-radius: 5px;
            background: var(--surface); color: var(--text-primary);
            border: 1px solid var(--border); cursor: pointer; max-width: 90px;
        }
        .company-agent-role-select:disabled { opacity: 0.6; cursor: not-allowed; }
        .company-agent-role-select.overridden { border-color: var(--accent); color: var(--accent); }
        .company-agent-role-select option { color: var(--text-primary); background: var(--bg); }
        .company-agent-edit {
            background: transparent; border: 1px solid var(--border);
            color: var(--text-dim); font-size: 10px;
            padding: 4px 8px; border-radius: 6px; cursor: pointer;
            flex-shrink: 0;
        }
        .company-agent-edit:hover { color: var(--accent); border-color: var(--accent); }
        .company-agent-edit.dirty {
            color: var(--accent); border-color: var(--accent);
            background: var(--accent-glow);
        }

        .company-agent-settings {
            display: none;
            margin-top: 2px;
            padding: 8px;
            border: 1px solid var(--border);
            border-radius: 6px;
            background: var(--bg-secondary);
        }
        .company-agent-card[data-settings-expanded="true"] .company-agent-settings { display: block; }
        .company-agent-settings-grid {
            display: grid;
            grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
            gap: 8px;
            margin-bottom: 8px;
        }
        .company-agent-settings-grid label {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
            color: var(--text-dim);
            font-size: 10px;
        }
        .company-agent-settings .company-agent-role-select,
        .company-agent-settings .company-agent-model {
            width: 100%;
            max-width: 100%;
            height: 28px;
        }

        /* Per-agent Knowledge Mix slider. Wraps so the slider always has
           breathing room — hint + checkbox flow to next line when needed. */
        .company-agent-mix-row {
            display: flex; align-items: center; gap: 8px;
            flex-wrap: wrap;
            row-gap: 4px;
            margin: 0;                 /* gap on parent handles the spacing */
            font-size: 10px; color: var(--text-dim);
        }
        .company-agent-mix-label { flex-shrink: 0; }
        .company-agent-mix-slider {
            flex: 1 1 120px;           /* slider is the row's hero */
            min-width: 80px;
            accent-color: var(--accent);
            cursor: pointer;
        }
        .company-agent-mix-slider:disabled { opacity: 0.5; cursor: not-allowed; }
        .company-agent-mix-hint {
            flex-shrink: 0; font-size: 9.5px; color: var(--text-dim);
            white-space: nowrap;
        }
        .company-agent-mix-source {
            font-size: 9px; color: var(--text-dim);
            padding: 1px 6px;
            border: 1px solid var(--border);
            border-radius: 8px;
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .company-agent-mix-source.override {
            color: var(--accent); border-color: var(--accent);
            background: var(--accent-glow);
        }
        .company-agent-mix-cbwrap {
            display: inline-flex; align-items: center; gap: 3px;
            font-size: 9.5px; cursor: pointer; color: var(--text-dim);
            flex-shrink: 0;
        }
        .company-agent-mix-cbwrap input[type="checkbox"] { accent-color: var(--accent); }

        /* Expandable prompt editor under each agent card. Toggled via the
           Edit button. Three textareas (tagline / specialty / persona) +
           Reset / Save / Cancel — empty save clears that field's override. */
        .company-agent-editor {
            display: none;
            margin: 0;
            padding: 8px;
            background: var(--bg-secondary);
            border: 1px dashed var(--border);
            border-radius: 6px;
        }
        .company-agent-card[data-expanded="true"] .company-agent-editor { display: block; }
        .company-agent-editor .field-label {
            display: flex; justify-content: space-between; align-items: center;
            margin-top: 6px; font-size: 10px; color: var(--text-dim);
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .company-agent-editor .field-label:first-child { margin-top: 0; }
        .company-agent-editor .field-label .field-flag {
            text-transform: none; letter-spacing: 0;
            color: var(--accent); font-size: 9.5px;
        }
        .company-agent-editor input[type="text"],
        .company-agent-editor textarea {
            width: 100%; box-sizing: border-box;
            background: var(--input-bg); color: var(--text-primary);
            border: 1px solid var(--border); border-radius: 4px;
            padding: 6px 8px; font-size: 11px; font-family: inherit;
            margin-top: 3px;
        }
        .company-agent-editor textarea { resize: vertical; min-height: 60px; }
        .company-agent-editor .editor-actions {
            display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px;
        }
        .company-agent-editor .editor-actions button {
            font-size: 10px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
            background: var(--surface); color: var(--text-primary);
            border: 1px solid var(--border);
        }
        .company-agent-editor .editor-actions button.primary {
            background: var(--accent); border-color: var(--accent); color: #fff;
        }
        .company-agent-editor .editor-actions button.danger { color: var(--error); }
        .company-agent-editor .editor-actions button:hover { border-color: var(--border-bright); }

        /* Add-agent inline form. Default closed; toggled via [data-open="true"]. */
        .company-agent-add-form { display: none; }
        .company-agent-add-form[data-open="true"] { display: block; }
        .company-agent-add-grid {
            display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
        }
        .company-agent-add-grid .field-label {
            display: flex; flex-direction: column; gap: 4px;
            font-size: 10px; color: var(--text-dim);
        }
        .company-agent-add-grid input[type="text"],
        .company-agent-add-grid textarea {
            font-size: 11px; padding: 6px 8px; border-radius: 6px;
            background: var(--bg); color: var(--text-primary);
            border: 1px solid var(--border); font-family: inherit;
        }
        .company-agent-add-grid textarea { resize: vertical; min-height: 44px; }
        .company-agent-add-form .editor-actions {
            display: flex; gap: 6px; justify-content: flex-end;
        }
        .company-agent-add-form .editor-actions button {
            font-size: 10px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
            background: var(--surface); color: var(--text-primary);
            border: 1px solid var(--border);
        }
        .company-agent-add-form .editor-actions button.primary {
            background: var(--accent); border-color: var(--accent); color: #fff;
        }

        .pipeline-empty-state {
            list-style: none;
            color: var(--text-dim);
            padding: 12px 10px;
            border: 1px dashed var(--border);
            border-radius: 8px;
            background: var(--bg-secondary);
            font-size: 11px;
            text-align: center;
        }
        .pipeline-summary-card {
            list-style: none;
            padding: 10px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
        }

        /* 이어서 진행 섹션 — 빈 목록이면 통째로 숨김. 있을 때만 노출돼서
           평소 시야 부담이 없고, 사용자가 멈춘 작업을 즉시 식별 가능. */
        .company-resumable-section[data-empty="true"] { display: none; }
        .company-resumable-list {
            list-style: none;
            display: flex; flex-direction: column; gap: 8px;
            margin-top: 8px; padding: 0;
        }
        .company-resumable-card {
            border: 1px solid var(--warning);
            background: linear-gradient(180deg, rgba(210,153,34,0.08), transparent 70%);
            border-radius: 8px;
            padding: 10px 12px;
            display: flex; flex-direction: column; gap: 6px;
        }
        .company-resumable-head {
            display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
        }
        .company-resumable-prompt {
            color: var(--text-bright); font-size: 12.5px; font-weight: 600;
            line-height: 1.4; flex: 1; min-width: 0;
            overflow: hidden; text-overflow: ellipsis;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
        }
        .company-resumable-actions {
            display: flex; gap: 6px; flex-shrink: 0;
        }
        .company-resumable-resume {
            font-size: 11px; padding: 5px 11px;
            background: var(--accent); color: var(--bg);
            border: 0; border-radius: 6px; cursor: pointer; font-weight: 600;
        }
        .company-resumable-resume:hover { filter: brightness(1.1); }
        .company-resumable-resume[disabled] { opacity: 0.55; cursor: progress; }
        .company-resumable-discard {
            font-size: 11px; padding: 5px 11px;
            background: transparent; color: var(--text-dim);
            border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
        }
        .company-resumable-discard:hover {
            color: var(--error); border-color: var(--error);
        }
        .company-resumable-meta {
            display: flex; flex-wrap: wrap; gap: 8px;
            font-size: 10px; color: var(--text-dim);
        }
        .company-resumable-meta span { white-space: nowrap; }
        .pipeline-summary-head {
            display: flex;
            gap: 8px;
            align-items: center;
            justify-content: space-between;
        }
        .pipeline-summary-title {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 2px;
            line-height: 1.25;
        }
        .pipeline-summary-title strong {
            color: var(--text-bright);
            font-size: 12px;
        }
        .pipeline-summary-title span {
            color: var(--text-dim);
            font-size: 10px;
        }
        .pipeline-summary-actions {
            display: flex;
            gap: 4px;
            flex-shrink: 0;
        }
        .pipeline-summary-flow {
            margin-top: 8px;
            padding: 7px 8px;
            border-radius: 6px;
            background: var(--bg-secondary);
            color: var(--text-primary);
            font-size: 10.5px;
            line-height: 1.4;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* ── Pipeline stage cards ───────────────────────────────────── */
        .pipeline-stage-list {
            list-style: none; margin: 0; padding: 0;
            display: flex; flex-direction: column; gap: 8px;
        }
        .pipeline-stage-list:empty::before {
            content: '아직 단계가 없습니다. "+ 단계 추가" 로 첫 작업을 만드세요.';
            font-size: 11px; color: var(--text-dim); font-style: italic;
            padding: 12px 4px; display: block; text-align: center;
        }
        .pipeline-stage-card {
            border: 1px solid var(--border);
            background: var(--surface);
            border-radius: 8px;
            padding: 10px;
            transition: opacity 0.15s, border-color 0.15s;
        }
        .pipeline-stage-card.dragging {
            opacity: 0.4;
        }
        .pipeline-stage-card.drop-above {
            border-top: 2px solid var(--accent);
        }
        .pipeline-stage-card.drop-below {
            border-bottom: 2px solid var(--accent);
        }
        .psc-head {
            display: flex; align-items: center; gap: 8px;
            margin-bottom: 8px;
        }
        .psc-num {
            display: inline-flex; align-items: center; justify-content: center;
            width: 22px; height: 22px; border-radius: 50%;
            background: var(--accent); color: #fff;
            font-size: 11px; font-weight: 700; flex-shrink: 0;
            cursor: grab;
            user-select: none;
        }
        .psc-num:active { cursor: grabbing; }
        .psc-num::after {
            /* 드래그 가능 힌트. 마우스 호버 시만 살짝 보이게. */
            content: ''; opacity: 0;
        }
        .pipeline-stage-card:hover .psc-num {
            box-shadow: 0 0 0 2px var(--accent-glow, rgba(99,102,241,0.25));
        }
        .psc-label {
            flex: 1; min-width: 0;
            font-size: 12px; font-weight: 600;
            padding: 5px 8px; border-radius: 6px;
            background: var(--bg); color: var(--text-bright);
            border: 1px solid var(--border); font-family: inherit;
        }
        .psc-controls { display: flex; gap: 4px; flex-shrink: 0; }
        .psc-controls button {
            font-size: 11px; padding: 3px 8px; border-radius: 5px;
            background: var(--surface); color: var(--text-primary);
            border: 1px solid var(--border); cursor: pointer; line-height: 1;
        }
        .psc-controls button:hover { border-color: var(--accent); color: var(--accent); }
        .psc-controls button:disabled { opacity: 0.3; cursor: not-allowed; }
        .psc-controls button.del:hover { border-color: var(--error); color: var(--error); }

        .psc-body { display: flex; flex-direction: column; gap: 8px; }
        .psc-row {
            display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
            font-size: 10px; color: var(--text-dim);
        }
        .psc-row > label { white-space: nowrap; }
        .psc-row select {
            font-size: 11px; padding: 4px 6px; border-radius: 5px;
            background: var(--bg); color: var(--text-primary);
            border: 1px solid var(--border); min-width: 100px;
        }
        .psc-row select option { color: var(--text-primary); background: var(--bg); }

        .psc-field-label { font-size: 10px; color: var(--text-dim); margin-bottom: 2px; }
        .psc-tokens { display: flex; gap: 4px; flex-wrap: wrap; }
        .psc-tokens button {
            font-size: 10px; padding: 2px 8px; border-radius: 10px;
            background: var(--bg); color: var(--text-dim);
            border: 1px dashed var(--border); cursor: pointer;
        }
        .psc-tokens button:hover { color: var(--accent); border-color: var(--accent); }
        .psc-instr {
            width: 100%; box-sizing: border-box;
            font-size: 11px; padding: 6px 8px; border-radius: 6px;
            background: var(--bg); color: var(--text-primary);
            border: 1px solid var(--border); font-family: inherit;
            resize: vertical; min-height: 50px;
        }
        .psc-loop {
            font-size: 10px; color: var(--text-dim);
            border-top: 1px dashed var(--border);
            padding-top: 6px;
        }
        .psc-loop summary {
            cursor: pointer; user-select: none;
            padding: 2px 0;
        }
        .psc-loop summary:hover { color: var(--accent); }
        .psc-loop[open] summary { color: var(--text-bright); margin-bottom: 6px; }
        .psc-loop-grid {
            display: grid; grid-template-columns: auto 1fr; gap: 6px 10px;
            align-items: center; padding-left: 14px;
        }
        .psc-loop-grid input[type="text"],
        .psc-loop-grid input[type="number"],
        .psc-loop-grid select {
            font-size: 11px; padding: 4px 6px; border-radius: 5px;
            background: var(--bg); color: var(--text-primary);
            border: 1px solid var(--border);
        }
        .psc-loop-grid input[type="number"] { max-width: 60px; }

        /* Per-phase company turn header in chat. */
        .company-phase-card {
            border: 1px solid var(--border);
            background: var(--surface);
            border-radius: 8px;
            padding: 8px 10px;
            margin: 4px 0;
            font-size: 11px;
            color: var(--text-primary);
        }
        .company-phase-card .cph-head {
            color: var(--text-bright); font-weight: 600;
            display: flex; gap: 6px; align-items: center; margin-bottom: 4px;
        }
        .company-phase-card .cph-meta { color: var(--text-dim); font-size: 10px; }
        .company-phase-card.report .cph-head { color: var(--accent); }
        .company-phase-card.approval {
            border-color: var(--accent);
            background: var(--accent-glow, rgba(99,102,241,0.08));
        }
        .company-phase-card.approval .cph-head { color: var(--accent); }
        .company-phase-card.approval button {
            font-size: 11px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
        }
        .company-phase-card.approval button:disabled { opacity: 0.55; cursor: default; }

        /* 3-way 합의 검수 사이클 카드. review-start이 컨테이너를 만들고
           review-round 이벤트가 .rev-rounds 안에 라운드 한 줄씩 누적. */
        .company-phase-card.review {
            border-color: var(--accent-glow, rgba(99,102,241,0.4));
        }
        .company-phase-card.review .rev-rounds {
            display: flex; flex-direction: column; gap: 8px; margin-top: 8px;
        }
        .company-phase-card.review .rev-round {
            border-left: 2px solid var(--border);
            padding: 4px 8px;
            background: rgba(99,102,241,0.04);
            border-radius: 4px;
        }
        .company-phase-card.review .rev-round-head {
            font-size: 10.5px; color: var(--text-bright); font-weight: 600; margin-bottom: 4px;
        }
        .company-phase-card.review .rev-line {
            display: flex; gap: 6px; align-items: flex-start; margin-top: 4px;
            font-size: 11px;
        }
        .company-phase-card.review .rev-actor {
            flex-shrink: 0; min-width: 64px;
            color: var(--text-dim); font-weight: 600;
        }
        .company-phase-card.review .rev-body { flex: 1; min-width: 0; }
        .company-phase-card.review .rev-body p { margin: 0 0 4px 0; }
        .company-phase-card.review .rev-end {
            margin-top: 8px; padding: 4px 8px;
            font-size: 11px; font-weight: 600;
            color: var(--text-bright);
            border-top: 1px dashed var(--border);
        }

        /* Devil's Advocate (도현) 반박 카드 — main 답변 직후 한 장씩.
           accent 와 구분되도록 보라색 톤 + 마스크 이모지 prefix 로 시선 끌기. */
        .devil-rebuttal-card {
            border: 1px solid rgba(167, 139, 250, 0.55);
            background: rgba(167, 139, 250, 0.06);
            border-radius: 10px;
            padding: 10px 12px;
            margin: 8px 0;
            font-size: 12px;
            line-height: 1.55;
            color: var(--text);
        }
        .devil-rebuttal-head {
            font-size: 11px;
            color: #a78bfa;
            margin-bottom: 6px;
            letter-spacing: 0.02em;
        }
        .devil-rebuttal-body {
            white-space: pre-wrap;
            margin-bottom: 8px;
        }
        .devil-rebuttal-actions {
            display: flex;
            gap: 8px;
        }
        .devil-rebuttal-actions button {
            background: rgba(167, 139, 250, 0.16);
            border: 1px solid rgba(167, 139, 250, 0.4);
            color: #c7b7ff;
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 11px;
            cursor: pointer;
        }
        .devil-rebuttal-actions button.ghost {
            background: transparent;
            border-color: var(--line);
            color: var(--muted);
        }
        .devil-rebuttal-actions button:hover {
            background: rgba(167, 139, 250, 0.28);
        }

        /* Intent Alignment 카드 — new_task 요청 직후 C-G-C-F 분석 결과를 보여주고
           질문 / 확인 버튼을 띄움. 다른 phase 카드보다 살짝 무게감을 주려고
           accent 테두리. */
        .company-alignment-card {
            border: 1px solid var(--accent);
            background: var(--surface);
            border-radius: 10px;
            padding: 10px 12px;
            margin: 6px 0;
            font-size: 11.5px;
        }
        .company-alignment-card.cancelled {
            border-color: var(--border);
            opacity: 0.7;
        }
        .company-alignment-card .cph-head {
            color: var(--text-bright); margin-bottom: 6px;
        }
        .company-alignment-card .cal-summary {
            display: grid; grid-template-columns: auto 1fr; gap: 4px 10px;
            margin: 6px 0; padding: 6px 8px;
            background: rgba(99,102,241,0.05);
            border-radius: 6px;
        }
        .company-alignment-card .cal-row {
            display: contents;
        }
        .company-alignment-card .cal-key {
            font-weight: 700; color: var(--text-bright);
            white-space: nowrap;
        }
        .company-alignment-card .cal-val {
            color: var(--text-primary); word-break: break-word;
        }
        .company-alignment-card .cal-val em { color: var(--text-dim); font-style: italic; }
        .company-alignment-card .cal-questions {
            margin-top: 6px; padding: 6px 8px;
            border-left: 2px solid var(--accent);
            background: rgba(99,102,241,0.04);
        }
        .company-alignment-card .cal-self-research {
            margin-top: 6px; padding: 6px 8px;
            border-left: 2px solid #22c55e;
            background: rgba(34,197,94,0.05);
        }
        .company-alignment-card .cal-self-research ul {
            margin: 4px 0 4px 16px; padding: 0;
        }
        .company-alignment-card .cal-self-research li {
            margin-bottom: 2px; color: var(--text-primary);
        }
        .company-alignment-card .cal-q-head {
            font-weight: 600; color: var(--text-bright); margin-bottom: 4px;
        }
        .company-alignment-card .cal-questions ul {
            margin: 4px 0 4px 16px; padding: 0;
        }
        .company-alignment-card .cal-questions li {
            margin-bottom: 2px;
        }
        .company-alignment-card .cal-hint {
            margin-top: 4px; font-size: 10.5px;
            color: var(--text-dim); font-style: italic;
        }
        .company-alignment-card .cal-conf {
            margin-top: 6px; font-size: 10.5px; font-weight: 600;
        }
        .company-alignment-card .cal-conf-high { color: #10B981; }
        .company-alignment-card .cal-conf-medium { color: #F5C518; }
        .company-alignment-card .cal-conf-low { color: var(--error); }
        .company-alignment-card .cal-actions {
            display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
        }
        .company-alignment-card .cal-actions button {
            font-size: 11px; padding: 4px 10px; border-radius: 5px; cursor: pointer;
        }
        .company-alignment-card .cal-actions button:disabled {
            opacity: 0.55; cursor: default;
        }

        /* 고급: 작업 흐름 편집 영역. 기본 접힘 — 일반 사용자는 만질 일 X. */
        details.pipeline-advanced {
            border-style: dashed;
            opacity: 0.85;
        }
        details.pipeline-advanced:not([open]) { padding: 8px 12px; }
        details.pipeline-advanced summary.pipeline-advanced-summary {
            list-style: none;
            cursor: pointer;
            display: flex; align-items: center; gap: 8px;
            user-select: none;
            outline: none;
        }
        details.pipeline-advanced summary::-webkit-details-marker { display: none; }
        details.pipeline-advanced summary .pa-icon { font-size: 13px; }
        details.pipeline-advanced summary .pa-title {
            font-size: 11px; font-weight: 700; color: var(--text-bright);
        }
        details.pipeline-advanced summary .pa-hint {
            font-size: 10px; color: var(--text-dim); flex: 1;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        }
        details.pipeline-advanced[open] summary { margin-bottom: 4px; }
        details.pipeline-advanced[open] {
            opacity: 1;
            border-style: solid;
        }

        /* ─────────────── Pixel Office ─────────────── */
        .pixel-office {
            display: none;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 10px;
            margin: 0 12px 6px 12px;
            overflow: hidden;
        }
        .pixel-office[data-enabled="true"] { display: block; }
        .pixel-office[data-collapsed="true"] .po-body { display: none; }
        .po-head {
            display: flex; align-items: center; justify-content: space-between;
            padding: 6px 10px;
            background: rgba(99,102,241,0.08);
            border-bottom: 1px solid var(--border);
        }
        .pixel-office[data-collapsed="true"] .po-head { border-bottom: none; }
        .po-head-left { display: flex; align-items: center; gap: 8px; }
        .po-title { font-size: 11px; font-weight: 700; color: var(--text-bright); }
        .po-status-label {
            font-size: 10px; padding: 2px 8px; border-radius: 9999px;
            background: var(--bg); color: var(--text-dim);
            font-weight: 600; letter-spacing: 0.02em;
            border: 1px solid var(--border);
        }
        /* 상태별 색상 강조 — webview JS가 po-status-{status} 클래스를 셋팅. */
        .po-status-label.po-status-idle             { color: var(--text-dim); }
        .po-status-label.po-status-intake           { color: #60A5FA; border-color: #60A5FA; }
        .po-status-label.po-status-analyzing        { color: #A78BFA; border-color: #A78BFA; }
        .po-status-label.po-status-need_clarification { color: #F5C518; border-color: #F5C518; }
        .po-status-label.po-status-contract_ready   { color: #10B981; border-color: #10B981; }
        .po-status-label.po-status-planning         { color: #22D3EE; border-color: #22D3EE; }
        .po-status-label.po-status-executing        { color: var(--accent); border-color: var(--accent); }
        .po-status-label.po-status-reviewing        { color: #FB923C; border-color: #FB923C; }
        .po-status-label.po-status-waiting_approval { color: #F472B6; border-color: #F472B6; }
        .po-status-label.po-status-error            { color: var(--error); border-color: var(--error); }
        .po-status-label.po-status-done             { color: #10B981; border-color: #10B981; }

        .po-head-actions { display: flex; gap: 4px; align-items: center; }
        .po-collapse, .po-expand {
            background: transparent; border: none; cursor: pointer;
            color: var(--text-dim); font-size: 12px; line-height: 1;
            padding: 2px 6px; border-radius: 4px;
        }
        .po-collapse:hover, .po-expand:hover {
            color: var(--accent); background: rgba(99,102,241,0.1);
        }
        .pixel-office[data-collapsed="true"] .po-collapse { transform: rotate(-90deg); }

        .po-body {
            display: grid; grid-template-columns: minmax(140px, 180px) 1fr;
            gap: 8px; padding: 8px 10px;
        }
        @media (max-width: 540px) {
            .po-body { grid-template-columns: 1fr; }
        }
        /* 좌측 — 픽셀 오피스 씬 (캐릭터 + 책상 + 진행률) */
        .po-scene {
            display: flex; flex-direction: column; gap: 4px;
            align-items: center;
        }
        .po-char-wrap {
            position: relative;
            width: 100%; min-height: 90px;
            display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
            padding: 4px 0;
            border-radius: 8px;
            background: linear-gradient(180deg, rgba(99,102,241,0.05) 0%, rgba(99,102,241,0.0) 70%);
        }
        .po-char {
            position: relative;
            width: 48px; height: 48px;
            display: flex; align-items: center; justify-content: center;
            background: var(--bg);
            border: 2px solid var(--border);
            border-radius: 8px;
            transition: transform 0.18s, border-color 0.18s;
        }
        .po-char-emoji {
            font-size: 28px; line-height: 1;
        }
        /* 상태에 따른 캐릭터 동작 */
        .pixel-office[data-status="executing"] .po-char { animation: po-bob 1.6s ease-in-out infinite; }
        .pixel-office[data-status="analyzing"] .po-char { animation: po-tilt 2.4s ease-in-out infinite; }
        .pixel-office[data-status="reviewing"] .po-char { animation: po-tilt 1.8s ease-in-out infinite; }
        .pixel-office[data-status="need_clarification"] .po-char { border-color: #F5C518; }
        .pixel-office[data-status="waiting_approval"] .po-char { border-color: #F472B6; }
        .pixel-office[data-status="error"] .po-char {
            border-color: var(--error);
            animation: po-shake 0.4s ease-in-out infinite;
        }
        .pixel-office[data-status="done"] .po-char { border-color: #10B981; }
        @keyframes po-bob {
            0%,100% { transform: translateY(0); }
            50% { transform: translateY(-3px); }
        }
        @keyframes po-tilt {
            0%,100% { transform: rotate(0deg); }
            50% { transform: rotate(-4deg); }
        }
        @keyframes po-shake {
            0%,100% { transform: translateX(0); }
            25% { transform: translateX(-2px); }
            75% { transform: translateX(2px); }
        }

        /* 캐릭터 옆 소품 — 상태에 따라 작은 이모지 (돋보기·체크리스트·코드 등) */
        .po-char-prop {
            position: absolute;
            right: -22px; top: 50%;
            transform: translateY(-50%);
            font-size: 16px;
            opacity: 0.85;
        }

        .po-desk {
            width: 100%;
            height: 8px;
            margin-top: -4px;
            background: linear-gradient(180deg, var(--border) 0%, var(--bg) 100%);
            border-radius: 0 0 6px 6px;
        }
        .po-progress {
            width: 100%; height: 4px;
            background: var(--border);
            border-radius: 2px;
            overflow: hidden;
            margin-top: 6px;
        }
        .po-progress-bar {
            height: 100%; background: var(--accent);
            transition: width 0.3s ease;
        }

        /* 말풍선 영역 */
        .po-bubbles {
            position: absolute;
            left: 50%; transform: translateX(-50%);
            bottom: 56px;
            display: flex; flex-direction: column; align-items: center; gap: 4px;
            pointer-events: none;
            width: max-content; max-width: 220px;
        }
        .po-bubble {
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--text-primary);
            font-size: 10.5px;
            padding: 4px 8px;
            border-radius: 12px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.15);
            position: relative;
            animation: po-bubble-in 0.25s ease-out;
            max-width: 220px;
            line-height: 1.35;
            text-align: center;
        }
        .po-bubble::after {
            content: '';
            position: absolute;
            left: 50%; bottom: -4px;
            transform: translateX(-50%) rotate(45deg);
            width: 6px; height: 6px;
            background: var(--bg);
            border-right: 1px solid var(--border);
            border-bottom: 1px solid var(--border);
        }
        .po-bubble.po-bubble-warning { border-color: #F5C518; color: #F5C518; }
        .po-bubble.po-bubble-warning::after { border-color: #F5C518; }
        .po-bubble.po-bubble-error { border-color: var(--error); color: var(--error); }
        .po-bubble.po-bubble-error::after { border-color: var(--error); }
        .po-bubble.po-bubble-success { border-color: #10B981; color: #10B981; }
        .po-bubble.po-bubble-success::after { border-color: #10B981; }
        .po-bubble.po-bubble-fading { animation: po-bubble-out 0.3s ease-in forwards; }
        @keyframes po-bubble-in {
            from { opacity: 0; transform: translateY(4px) scale(0.92); }
            to   { opacity: 1; transform: translateY(0) scale(1); }
        }
        @keyframes po-bubble-out {
            to { opacity: 0; transform: translateY(-4px) scale(0.92); }
        }

        /* 우측 — 정보 패널 */
        .po-panel {
            display: flex; flex-direction: column; gap: 4px;
            font-size: 10.5px;
            min-width: 0;
        }
        .po-row {
            display: grid; grid-template-columns: 60px 1fr;
            gap: 6px; align-items: baseline;
        }
        .po-key {
            color: var(--text-dim); font-weight: 600;
            white-space: nowrap;
        }
        .po-val {
            color: var(--text-primary);
            word-break: break-word;
            overflow-wrap: anywhere;
        }
        .po-val-status { font-weight: 700; text-transform: lowercase; }
        .po-section {
            margin-top: 4px; padding-top: 4px;
            border-top: 1px dashed var(--border);
        }
        .po-section-head {
            font-size: 10px; font-weight: 700; color: var(--text-bright);
            margin-bottom: 3px;
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .po-need-input { margin: 0 0 0 14px; padding: 0; color: var(--text-primary); }
        .po-need-input li { margin-bottom: 2px; }
        .po-approval {
            color: #F472B6; font-style: italic;
        }
        .po-contract {
            display: grid; grid-template-columns: 40px 1fr;
            gap: 2px 6px;
            font-size: 10px;
        }
        .po-contract-key { color: var(--text-dim); font-weight: 600; }
        .po-contract-val { color: var(--text-primary); word-break: break-word; }
        .po-logs {
            font-size: 9.5px; line-height: 1.4;
            color: var(--text-dim);
            max-height: 90px; overflow-y: auto;
            font-family: var(--font-mono, ui-monospace, monospace);
        }
        .po-logs div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

        /* 의도 분류기가 chat/followup 으로 판정했을 때 채팅에 끼우는 작은 라벨.
           파이프라인 카드는 절대 만들지 않고 한 줄짜리 메타 텍스트만 — 사용자가
           "왜 파이프라인이 안 돌았지?" 의문을 즉시 해소할 수 있게 한다. */
        .company-intent-note {
            font-size: 10.5px; color: var(--text-dim);
            padding: 4px 8px; margin: 4px 0;
            border-left: 2px solid var(--border);
        }
        .company-intent-note .cin-label {
            color: var(--text-bright); font-weight: 600; margin-right: 6px;
        }
        .company-intent-note .cin-reason { font-style: italic; }

        /* Project Architecture chip — three-state surface above the input. */
        .arch-chip {
            display: none;
            align-items: center;
            gap: 8px;
            margin-bottom: 6px;
            padding: 6px 10px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            font-size: 11px;
        }
        .arch-chip[data-state="active"],
        .arch-chip[data-state="inactive"] { display: flex; }
        /* Inactive state has a muted look so it doesn't compete with active chips. */
        .arch-chip[data-state="inactive"] {
            background: var(--bg-secondary);
            border-style: dashed;
        }
        .arch-chip[data-state="inactive"] .arch-chip-title { color: var(--text-dim); }
        /* Per-state button visibility — JS only flips the chip's data-state. */
        .arch-chip[data-state="active"] .arch-chip-inactive-only { display: none; }
        .arch-chip[data-state="inactive"] .arch-chip-active-only { display: none; }
        .arch-chip[data-state="inactive"] #archAttachBtn {
            color: var(--accent); border-color: var(--accent);
        }
        .arch-chip-icon { font-size: 14px; flex-shrink: 0; }
        .arch-chip-info { flex: 1; min-width: 0; line-height: 1.3; }
        .arch-chip-title {
            color: var(--text-bright); font-weight: 600;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }
        .arch-chip-meta { color: var(--text-dim); font-size: 10px; }
        .arch-chip-actions { display: flex; gap: 4px; flex-shrink: 0; }
        .arch-chip-btn {
            background: transparent;
            color: var(--text-primary);
            border: 1px solid var(--border);
            padding: 3px 8px;
            border-radius: 6px;
            font-size: 10px;
            cursor: pointer;
            transition: all 0.12s ease;
        }
        .arch-chip-btn:hover {
            background: var(--control-bg-hover);
            border-color: var(--border-bright);
        }

        /* Inline refresh-result card so the user sees what the refresh did. */
        .arch-refresh-card {
            border: 1px solid var(--border);
            background: var(--surface);
            border-radius: 8px;
            padding: 6px 10px;
            margin: 4px 0;
            font-size: 10.5px;
            color: var(--text-primary);
            opacity: 1;
            transition: opacity 600ms ease, margin 600ms ease, padding 600ms ease, max-height 600ms ease;
            max-height: 80px;
            overflow: hidden;
        }
        .arch-refresh-card .arc-head {
            color: var(--text-bright); font-weight: 600; margin-bottom: 2px;
        }
        .arch-refresh-card .arc-meta { color: var(--text-dim); font-size: 9.5px; }
        .arch-refresh-card.no-changes { border-style: dashed; }
        .arch-refresh-card.fading {
            opacity: 0;
            max-height: 0;
            margin: 0;
            padding-top: 0;
            padding-bottom: 0;
            border-width: 0;
        }

        /* Inline model picker that lives in the input footer, next to the attach
           button. Replaces the (now-removed) bottom model row + the separate
           "Model: ..." status text — one surface, click to change. */
        .model-pill {
            display: inline-flex; align-items: center; gap: 4px;
            font-size: 10px; color: var(--text-dim); max-width: 220px;
        }
        .model-prefix { color: var(--text-dim); flex-shrink: 0; }
        .model-inline-sel {
            background: transparent; border: none; outline: none;
            color: var(--text-primary); font-size: 10px;
            padding: 0; margin: 0; cursor: pointer;
            max-width: 180px; min-width: 0;
            text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
            font-weight: 500;
        }
        .model-inline-sel:hover { color: var(--accent); }
        .model-inline-sel:focus-visible { outline: 1px dashed var(--accent); outline-offset: 2px; }
        .status-label { font-size: 10px; color: var(--text-dim); }

        .send-btn {
            background: var(--accent); color: #fff; border: none; padding: 6px 14px; border-radius: 6px;
            font-weight: 600; font-size: 12px; cursor: pointer;
        }
        .send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

        .footer-right { display: flex; align-items: center; gap: 6px; }

        .cancel-btn {
            background: transparent; color: var(--text-dim); border: 1px solid var(--border);
            padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: 11px;
            cursor: pointer; align-items: center; gap: 4px; transition: all 0.15s ease;
        }
        .cancel-btn:hover { background: rgba(248, 81, 73, 0.12); color: var(--error); border-color: var(--error); }

        .stop-btn {
            background: rgba(248, 81, 73, 0.15); color: var(--error); border: 1px solid var(--error);
            padding: 6px 14px; border-radius: 6px; font-weight: 700; font-size: 12px;
            cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
            animation: stopPulse 1.2s ease-in-out infinite;
        }
        .stop-btn:hover { background: rgba(248, 81, 73, 0.3); }
        @keyframes stopPulse {
            0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.4); }
            50% { box-shadow: 0 0 0 5px rgba(248,81,73,0); }
        }

        /* --- Drag and Drop Overlay --- */
        body.drag-over::after {
            content: '📂 파일을 여기에 놓으세요';
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(88, 166, 255, 0.2);
            backdrop-filter: blur(4px);
            border: 2px dashed var(--accent);
            display: flex; align-items: center; justify-content: center;
            color: var(--text-bright); font-size: 18px; font-weight: 700;
            z-index: 9999; pointer-events: none;
            animation: fadeIn 0.2s ease-out;
        }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        /* --- Toast Notification --- */
        .toast-notif {
            position: absolute; bottom: calc(100% + 8px); left: 50%;
            transform: translateX(-50%) translateY(4px);
            background: var(--surface); border: 1px solid var(--border-bright);
            color: var(--text-primary); font-size: 11px; font-weight: 600;
            padding: 7px 14px; border-radius: 20px; white-space: nowrap;
            opacity: 0; pointer-events: none;
            transition: opacity 0.2s ease, transform 0.2s ease;
            z-index: 500; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
        }
        .toast-notif.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
        .toast-notif.toast-warn { border-color: var(--error); color: var(--error); background: rgba(248,81,73,0.08); }
        .toast-notif.toast-success { border-color: var(--success); color: var(--success); background: rgba(35,134,54,0.08); }

        /* --- Overlays & Others --- */
        .thinking-bar { height: 2px; background: transparent; position: relative; overflow: hidden; margin-top: -1px; }
        .thinking-bar.active {
            display: block;
            background: linear-gradient(90deg, transparent, #2196f3, #bb86fc, transparent);
            background-size: 200% 100%;
            animation: thinking 1.5s infinite linear;
        }
        @keyframes thinking { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

        .history-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.8);
            backdrop-filter: blur(10px); z-index: 1000; display: none; flex-direction: column; padding: 20px;
            /* 본문이 뷰포트보다 길어지면 자체 스크롤. companyOverlay의 에이전트 목록처럼
               동적으로 늘어나는 컨텐츠가 잘리는 문제를 막는다.
               `historyOverlay`처럼 내부에 별도 스크롤 div를 둔 곳도 있는데
               그쪽은 본인 wrapper가 우선이라 영향 없음. */
            overflow-y: auto;
        }
        .history-overlay.visible { display: flex; }

        .stream-active::after {
            content: ''; display: inline-block; width: 6px; height: 14px; background: var(--accent);
            margin-left: 4px; animation: blink 0.8s step-end infinite; vertical-align: middle;
        }
        @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

        .welcome { text-align: center; padding: 36px 18px 24px; color: var(--text-dim); }
        .welcome-logo { font-size: 44px; color: var(--accent); margin-bottom: 12px; opacity: 0.85; }
        .welcome-title { font-size: 18px; font-weight: 700; color: var(--text-bright); margin-bottom: 6px; }
        .welcome-lead { font-size: 12px; color: var(--text-dim); margin: 0 auto 18px; max-width: 360px; line-height: 1.55; }

        /* 시작 체크리스트 — 신규 사용자에게만 노출 */
        .welcome-checklist {
            display: flex; flex-direction: column; gap: 10px;
            max-width: 420px; margin: 0 auto;
            text-align: left;
        }
        .wc-step {
            display: flex; align-items: flex-start; gap: 12px;
            padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
            background: var(--surface);
        }
        .wc-step.done { opacity: 0.55; }
        .wc-bullet {
            flex-shrink: 0;
            width: 22px; height: 22px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center;
            font-size: 11px; font-weight: 700;
            background: var(--bg-secondary); color: var(--text-dim);
            border: 1px solid var(--border);
        }
        .wc-step.done .wc-bullet {
            background: var(--accent); color: var(--bg); border-color: var(--accent);
        }
        .wc-text { flex: 1; min-width: 0; }
        .wc-label { color: var(--text-bright); font-weight: 600; font-size: 12.5px; }
        .wc-hint { color: var(--text-dim); font-size: 10.5px; margin-top: 2px; line-height: 1.45; }
        .wc-action {
            flex-shrink: 0; align-self: center;
            font-size: 10.5px; padding: 5px 11px;
            background: var(--accent); color: var(--bg);
            border: 0; border-radius: 6px; cursor: pointer; font-weight: 600;
        }
        .wc-action:hover { filter: brightness(1.1); }

        /* 준비된 사용자용 예시 질문 chip */
        .welcome-chips {
            display: flex; flex-direction: column; gap: 8px;
            max-width: 420px; margin: 0 auto 14px;
        }
        .welcome-chip {
            display: flex; align-items: center; gap: 10px;
            padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
            background: var(--surface); color: var(--text-primary);
            font-size: 12px; text-align: left; cursor: pointer;
            line-height: 1.45; transition: 0.15s;
        }
        .welcome-chip:hover {
            border-color: var(--accent); color: var(--text-bright);
            background: var(--bg-secondary);
        }
        .welcome-chip-emoji { font-size: 16px; flex-shrink: 0; }
        .welcome-chip-text { flex: 1; min-width: 0; }

        .welcome-tips {
            margin-top: 16px; font-size: 10.5px; color: var(--text-dim);
            max-width: 420px; margin-left: auto; margin-right: auto;
            line-height: 1.55;
        }
        .welcome-tips b { color: var(--text-bright); font-weight: 600; }

        /* --- History List --- */
        .history-item {
            padding: 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
            margin-bottom: 10px; cursor: pointer; transition: 0.2s;
        }
        .history-item:hover { border-color: var(--accent); background: var(--accent-glow); }

        /* --- Approval UI --- */
        .approval-box {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin: 15px 0;
            padding: 16px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-bright);
            border-radius: 12px;
            animation: msgIn 0.3s ease-out;
        }
        .approval-title { font-weight: 700; color: var(--accent); font-size: 12px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
        .approval-btns { display: flex; gap: 10px; }
        .btn-approve { flex: 1; background: var(--success); color: white; border: none; padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; transition: 0.2s; }
        .btn-approve:hover { filter: brightness(1.1); transform: translateY(-1px); }
        .btn-reject { flex: 1; background: var(--error); color: white; border: none; padding: 10px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; transition: 0.2s; }
        .btn-reject:hover { filter: brightness(1.1); transform: translateY(-1px); }

        .panel {
            display: none;
            flex-direction: column;
            gap: 8px;
            padding-bottom: 10px;
        }

        .field-label {
            color: var(--text-dim);
            font-size: 10px;
            font-weight: 700;
            line-height: 1.2;
        }

        .panel textarea {
            font-size: 11.5px;
            padding: 8px;
            border-radius: 8px;
            border: 1px solid var(--border);
            background: var(--input-bg);
            color: var(--text-bright);
            width: 100%;
            resize: vertical;
            font-family: inherit;
            outline: none;
        }

        .panel textarea:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-glow);
        }

        .secondary-btn {
            height: 30px;
            background: var(--control-bg);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: 0 10px;
            font-size: 11px;
            font-weight: 700;
            border-radius: 6px;
            cursor: pointer;
        }

        .secondary-btn:hover {
            border-color: var(--accent);
            background: var(--control-active-bg);
            color: var(--text-bright);
        }

        /* --- Agent Map Modal --- */
        .map-agent-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            margin-bottom: 14px;
        }
        .map-agent-name {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-bright);
        }
        .map-section {
            margin-bottom: 16px;
            padding: 12px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 10px;
        }
        .map-section-head {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 12px;
            margin-bottom: 10px;
        }
        .map-section-title {
            font-size: 12px;
            font-weight: 800;
            color: var(--text-bright);
            margin-bottom: 4px;
        }
        .map-section-hint {
            font-size: 10.5px;
            color: var(--text-dim);
            line-height: 1.4;
            max-width: 360px;
        }
        .map-btn-group {
            display: flex;
            gap: 6px;
            flex-shrink: 0;
        }
        .map-list {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .map-list:empty::before {
            content: '아직 연결된 항목이 없습니다.';
            font-size: 11px;
            color: var(--text-dim);
            font-style: italic;
            padding: 8px 4px;
            display: block;
        }
        .map-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            background: var(--input-bg);
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 11.5px;
            color: var(--text-primary);
        }
        .map-item-icon {
            flex-shrink: 0;
            font-size: 13px;
        }
        .map-item-path {
            flex: 1;
            font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
            font-size: 11px;
            word-break: break-all;
            color: var(--text-bright);
        }
        .map-item-meta {
            font-size: 10px;
            color: var(--text-dim);
        }
        .map-item-remove {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-dim);
            border-radius: 4px;
            padding: 2px 6px;
            font-size: 11px;
            cursor: pointer;
        }
        .map-item-remove:hover {
            border-color: var(--error);
            color: var(--error);
        }
        .map-footer {
            display: flex;
            gap: 8px;
            align-items: center;
            margin-top: 10px;
            padding-top: 12px;
            border-top: 1px solid var(--border);
        }
        .map-footer .send-btn {
            min-width: 80px;
        }
        .map-status {
            margin-top: 10px;
            font-size: 11px;
            min-height: 16px;
            color: var(--text-dim);
        }
        .map-status.ok { color: var(--success); }
        .map-status.error { color: var(--error); }

        /* --- Physics & Micro-interactions --- */
        button {
            transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
            user-select: none;
            outline: none;
        }
        button:active {
            transform: scale(0.96);
            filter: brightness(0.9);
        }

        /* --- Hierarchical Grouping --- */
        .input-group {
            background: rgba(255, 255, 255, 0.02);
            border-radius: 12px;
            padding: 8px;
            margin-top: 10px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            display: flex;
            gap: 8px;
        }

        /* --- Storytelling Stepper --- */
        .stepper-container {
            display: none;
            margin: 12px 16px;
            padding: 12px;
            background: rgba(var(--accent-rgb), 0.05);
            border-radius: 8px;
            border: 1px solid rgba(var(--accent-rgb), 0.1);
            animation: slideIn 0.3s ease-out;
        }
        .stepper-container.active { display: block; }
        .steps {
            display: flex;
            justify-content: space-between;
            position: relative;
        }
        .step {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            flex: 1;
        }
        .step-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--text-dim);
            transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        .step.active .step-dot {
            background: var(--accent);
            box-shadow: 0 0 12px var(--accent);
            transform: scale(1.5);
        }
        .step.complete .step-dot {
            background: var(--success);
            box-shadow: 0 0 8px var(--success);
        }
        .step-label {
            font-size: 9px;
            color: var(--text-dim);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }
        .step.active .step-label { color: var(--accent); }
        .step.complete .step-label { color: var(--success); }

        @media (max-width: 520px) {
            .header-top { align-items: flex-start; }
        }
        @keyframes slideIn {
            from { opacity: 0; transform: translateX(-10px); }
            to { opacity: 1; transform: translateX(0); }
        }

        /* ── Ready-status bar ───────────────────────────────────────────── */
        .ready-bar {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 4px 12px;
            font-size: 10.5px;
            line-height: 1.4;
            color: var(--text-dim);
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            white-space: nowrap;
            overflow-x: auto;
            scrollbar-width: none;
        }
        .ready-bar::-webkit-scrollbar { display: none; }
        .ready-bar .rb-dot {
            width: 6px; height: 6px; border-radius: 50%;
            background: var(--text-dim); flex-shrink: 0;
        }
        .ready-bar .rb-dot.ok { background: var(--success); }
        .ready-bar .rb-dot.bad { background: var(--error); }
        .ready-bar .rb-dot.warn { background: var(--warning); }
        .ready-bar .rb-content { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
        .ready-bar .rb-seg { color: var(--text-dim); }
        .ready-bar .rb-seg.ok { color: var(--success); }
        .ready-bar .rb-seg.bad { color: var(--error); }
        .ready-bar .rb-seg.rb-dim, .ready-bar .rb-dim { color: var(--border-bright); }
        .ready-bar .rb-seg.rb-warn { color: var(--warning); font-weight: 600; }
        .ready-bar .rb-sep { color: var(--border); margin: 0 1px; }
        .ready-bar .rb-link { color: var(--accent); cursor: pointer; }
        .ready-bar .rb-link:hover { text-decoration: underline; }

        /* ── Context-budget badge (input footer) ────────────────────────── */
        .ctx-badge {
            font-size: 10px;
            color: var(--text-dim);
            padding: 1px 6px;
            border-radius: 9px;
            border: 1px solid var(--border);
            background: transparent;
            white-space: nowrap;
            max-width: 60vw;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .ctx-badge:empty { display: none; }
        .ctx-badge.ok { border-color: var(--border); }
        .ctx-badge.warn { color: var(--warning); border-color: var(--warning); }

        /* ── Per-answer "scope used" footer ─────────────────────────────── */
        .msg-scope-footer {
            margin-top: 6px;
            padding-top: 6px;
            border-top: 1px dashed var(--border);
            font-size: 10px;
            color: var(--text-dim);
            line-height: 1.5;
            word-break: break-word;
        }
        .msg-scope-footer .scope-link {
            color: var(--accent);
            cursor: pointer;
        }
        .msg-scope-footer .scope-link:hover { text-decoration: underline; }
        .msg-scope-footer .scope-dim { color: var(--border-bright); }

        .msg-scope-footer .scope-lesson { color: var(--warning); cursor: pointer; }
        .msg-scope-footer .scope-lesson:hover { text-decoration: underline; }
        .msg-scope-footer .scope-unaddressed {
            margin-top: 5px;
            color: var(--warning);
            font-size: 9.5px;
            line-height: 1.5;
        }
        .msg-scope-footer .scope-mix {
            margin-top: 4px;
            color: var(--text-dim);
            font-size: 9.5px;
        }

        /* ── "Record a lesson?" prompt after a rollback / rejected change / repeated complaint ── */
        .lesson-candidate-box {
            margin-top: 8px;
            padding: 8px 10px;
            border: 1px solid var(--warning);
            border-radius: 8px;
            background: var(--bg-secondary);
            font-size: 11px;
            color: var(--text-dim);
        }
        .lesson-candidate-box .lc-title { color: var(--text-bright); margin-bottom: 4px; }
        .lesson-candidate-box .lc-reason { font-size: 10px; margin-bottom: 6px; word-break: break-word; }
        .lesson-candidate-box .lc-btns { display: flex; gap: 6px; }
        .lesson-candidate-box button {
            font-size: 10px;
            padding: 3px 8px;
            border-radius: 6px;
            border: 1px solid var(--border);
            background: var(--surface);
            color: var(--text-bright);
            cursor: pointer;
        }
        .lesson-candidate-box .lc-rec { border-color: var(--warning); color: var(--warning); }
        .lesson-candidate-box button:hover { border-color: var(--border-bright); }

        /* ════════════════════════════════════════════════════════════════
           Compact header: top-bar dropdowns + Context Bar + Records line
           (collapse the old "select bomb" into role-grouped popovers)
           ════════════════════════════════════════════════════════════════ */

        /* compact toggle chips kept visible in the top bar (Trace / Web) */
        .toggle-chip { font-size: 10.5px; padding: 0 8px; }

        /* 스코프 프리셋 segmented control — 기업 모드 chip 옆에 붙임.
           세 버튼이 하나의 그룹으로 보이도록 inner border-radius 제거 + 사이 1px 분리.
           hidden 속성은 HTML5 기본 inherit, JS 가 toggle. */
        .scope-seg { display: inline-flex; align-items: center; gap: 1px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 5px; background: rgba(255, 255, 255, 0.03); padding: 0; height: 24px; }
        .scope-seg[hidden] { display: none; }
        .scope-seg-btn {
            background: transparent;
            color: var(--muted, #94a3b8);
            border: 0;
            padding: 0 8px;
            height: 100%;
            font-size: 10.5px;
            font-weight: 500;
            cursor: pointer;
            letter-spacing: 0.02em;
            border-radius: 0;
        }
        .scope-seg-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text, #e5e7eb); }
        .scope-seg-btn.active {
            background: rgba(99, 102, 241, 0.18);
            color: #c7d2fe;
            font-weight: 700;
        }
        .scope-seg-btn:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
        .scope-seg-btn:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

        /* a trigger + popover menu (Tools ▾ / Edit ▾ / Records ▾) */
        .hdr-dropdown { position: relative; display: inline-flex; }
        .hdr-menu {
            position: absolute;
            top: calc(100% + 5px);
            right: 0;
            display: none;
            flex-direction: column;
            gap: 2px;
            min-width: 190px;
            max-width: calc(100vw - 16px);
            padding: 5px;
            background: var(--surface);
            border: 1px solid var(--border-bright);
            border-radius: 9px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.35);
            z-index: 300;
        }
        .hdr-menu.open { display: flex; }
        .hdr-menu-wide { width: min(330px, calc(100vw - 16px)); }
        .hdr-menu-label {
            font-size: 9.5px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .04em;
            color: var(--text-dim);
            padding: 5px 8px 2px;
        }
        .hdr-menu-label:first-child { padding-top: 2px; }
        .hdr-menu-hint {
            font-weight: 500;
            text-transform: none;
            letter-spacing: 0;
            color: var(--text-dim);
            font-size: 9.5px;
            margin-left: 6px;
        }

        /* Compact bipolar slider used both in the header menu and inside the agent-map modal. */
        .knowledge-mix-control {
            display: flex; align-items: center; gap: 8px;
            padding: 4px 8px 6px;
        }
        .knowledge-mix-control .km-end-label {
            font-size: 9.5px;
            text-transform: uppercase;
            letter-spacing: .04em;
            color: var(--text-dim);
            flex-shrink: 0;
            min-width: 30px;
        }
        .knowledge-mix-control .km-end-label:last-of-type { text-align: right; }
        .knowledge-mix-control .km-slider {
            flex: 1; min-width: 0; cursor: pointer; accent-color: var(--accent);
        }
        .knowledge-mix-control .km-slider:disabled { opacity: 0.5; cursor: not-allowed; }

        .map-mix-control { padding: 0; }
        .map-checkbox-row {
            display: flex; align-items: center; gap: 6px;
            font-size: 11px; color: var(--text-primary); cursor: pointer;
        }
        .map-checkbox-row input[type="checkbox"] { accent-color: var(--accent); }
        .hdr-menu-item {
            display: block;
            width: 100%;
            text-align: left;
            padding: 6px 9px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 12px;
            cursor: pointer;
            white-space: nowrap;
        }
        .hdr-menu-item:hover { background: var(--control-bg-hover); color: var(--text-bright); }
        .hdr-menu .toggle-item::after { content: ' · 꺼짐'; color: var(--text-dim); font-size: 10px; }
        .hdr-menu .toggle-item.active { color: var(--accent); }
        .hdr-menu .toggle-item.active::after { content: ' · 켜짐'; color: var(--accent); }
        .hdr-menu .control-row { margin: 0 4px 2px; }
        .hdr-menu .select-wrap { margin: 0 4px 2px; }

        /* Context Bar — "what knowledge context this answer uses" */
        .context-bar {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 5px 12px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            font-size: 11px;
            min-width: 0;
        }
        .context-summary {
            flex: 1;
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 5px;
            overflow-x: auto;
            scrollbar-width: none;
            white-space: nowrap;
            color: var(--text-dim);
        }
        .context-summary::-webkit-scrollbar { display: none; }
        .context-summary .cb-key { color: var(--text-dim); }
        .context-summary .cb-val { color: var(--text-bright); font-weight: 600; }
        .context-summary .cb-sep { color: var(--border); }
        .context-edit-dd { flex-shrink: 0; }

        /* Records line — auto-records status + collapsed record picker */
        .records-line {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 4px 12px;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            font-size: 10.5px;
            color: var(--text-dim);
            min-width: 0;
        }
        .records-line .rl-summary {
            flex: 1;
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 6px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .records-line .rl-latest { color: var(--border-bright); overflow: hidden; text-overflow: ellipsis; }
        .records-line .hdr-dropdown { flex-shrink: 0; }

        /* Slash 명령 자동완성 dropdown — input 바로 위에 floating. */
        .slash-suggest {
            position: absolute;
            bottom: 100%;
            left: 12px;
            right: 12px;
            margin-bottom: 6px;
            background: var(--bg-secondary, #2a2a2a);
            border: 1px solid var(--border, #444);
            border-radius: 6px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            max-height: 240px;
            overflow-y: auto;
            z-index: 100;
            font-size: 13px;
        }
        .slash-suggest .ss-item {
            padding: 6px 12px;
            cursor: pointer;
            display: flex;
            gap: 10px;
            align-items: baseline;
            border-bottom: 1px solid var(--border-faint, #333);
        }
        .slash-suggest .ss-item:last-child { border-bottom: none; }
        .slash-suggest .ss-item.active { background: var(--accent-faint, #094771); }
        .slash-suggest .ss-item:hover { background: var(--bg-hover, #353535); }
        .slash-suggest .ss-name { font-weight: 600; color: var(--accent, #4ec9b0); flex-shrink: 0; }
        .slash-suggest .ss-desc { color: var(--text-dim, #999); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .slash-suggest .ss-empty { padding: 8px 12px; color: var(--text-dim, #999); font-style: italic; }
        /* input-box 가 position:relative 여야 absolute 가 제대로 anchored. */
        .input-box { position: relative; }
