*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0A0A0A;
    --surface:   #111111;
    --surface2:  #1A1A1A;
    --surface3:  #222222;
    --border:    #1F1F1F;
    --border-2:  #2A2A2A;
    --accent:    #FFFFFF;
    --accent-dim:#A0A0A0;
    --green:     #22C55E;
    --green-dim: rgba(34,197,94,0.1);
    --red:       #EF4444;
    --red-dim:   rgba(239,68,68,0.1);
    --yellow:    #EAB308;
    --yellow-dim:rgba(234,179,8,0.1);
    --indigo:    #6366F1;
    --indigo-dim:rgba(99,102,241,0.12);
    --text:      #EDEDED;
    --text-2:    #6B6B6B;
    --text-3:    #3A3A3A;
    --font:      'Geist', 'Inter', system-ui, sans-serif;
    --mono:      'Geist Mono', 'Cascadia Code', 'Consolas', monospace;
    --radius:    6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --sidebar-w: 220px;
    --topbar-h:  48px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ─── Light ──────────────────────────────────────────────────── */
body.light {
    --bg:        #FAFAFA;
    --surface:   #FFFFFF;
    --surface2:  #F5F5F5;
    --surface3:  #EBEBEB;
    --border:    #E5E5E5;
    --border-2:  #D4D4D4;
    --accent:    #0A0A0A;
    --accent-dim:#404040;
    --text:      #0A0A0A;
    --text-2:    #737373;
    --text-3:    #A3A3A3;
    --green:     #16A34A;
    --red:       #DC2626;
    --yellow:    #CA8A04;
    --indigo:    #4F46E5;
}

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ─── Auth ───────────────────────────────────────────────────── */
.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-box {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.4px;
}

.auth-logo p {
    color: var(--text-2);
    font-size: 13px;
    margin-top: 4px;
}

.auth-error {
    color: var(--red);
    font-size: 12px;
    min-height: 16px;
}

/* ─── Layout ─────────────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    padding: 0 16px 0 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    gap: 0;
}

.topbar-logo {
    width: var(--sidebar-w);
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 16px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    height: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.2px;
    text-decoration: none;
    cursor: default;
    user-select: none;
}

.topbar-logo-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--bg);
}

.topbar-actions {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.topbar-btn {
    height: 28px;
    padding: 0 10px;
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.1s, color 0.1s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.topbar-btn:hover { background: var(--surface2); color: var(--text); }
.topbar-btn svg  { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 1px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 8px 4px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.08s, color 0.08s;
    user-select: none;
    position: relative;
    font-size: 13px;
    font-weight: 500;
}

.sidebar a svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.sidebar a .label { flex: 1; }

.sidebar a .sidebar-badge {
    margin-left: auto;
}

.sidebar a:hover { background: var(--surface2); color: var(--text); }
.sidebar a.active { background: var(--surface2); color: var(--text); }
.sidebar a.active svg { color: var(--text); }

body.light .sidebar a:hover  { background: var(--surface2); }
body.light .sidebar a.active { background: var(--surface2); }

/* ─── Sidebar bottom ─────────────────────────────────────────── */
.sidebar-spacer { flex: 1; }

.sidebar-footer {
    padding-top: 8px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* ─── Main ───────────────────────────────────────────────────── */
.main {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--bg);
    min-height: 0;
}

.main--fullscreen {
    padding: 0 !important;
    overflow: hidden !important;
    gap: 0 !important;
}

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
    margin-bottom: 4px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.4px;
}

.page-desc {
    font-size: 13px;
    color: var(--text-2);
    margin-top: 3px;
}

/* ─── Section ────────────────────────────────────────────────── */
.section {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.section-header {
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ─── Inputs ─────────────────────────────────────────────────── */
input[type=text],
input[type=password],
input[type=search] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text);
    padding: 7px 11px;
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.12s;
}

input:focus { border-color: var(--text-2); }
input::placeholder { color: var(--text-3); }

.totp-input {
    letter-spacing: 0.35em;
    font-size: 22px !important;
    text-align: center;
    font-family: var(--mono) !important;
    padding: 10px 14px !important;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s, opacity 0.1s, border-color 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: -0.1px;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:active:not(:disabled) { opacity: 0.8; }

.btn-primary  { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }

.btn-success  { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.2); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.16); }

.btn-danger   { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.2); }
.btn-danger:hover:not(:disabled)  { background: rgba(239,68,68,0.16); }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); border-color: var(--border-2); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-full { width: 100%; }

/* ─── Badge ──────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
}

.badge::before {
    content: '';
    width: 5px; height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-on  { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.badge-on::before  { background: var(--green); animation: pulse 2s infinite; }

.badge-off { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.badge-off::before { background: var(--red); }

.badge-busy { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(234,179,8,0.2); }
.badge-busy::before { background: var(--yellow); animation: pulse 1.4s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ─── Server glow ────────────────────────────────────────────── */
.server-glow {
    position: absolute;
    top: 0; right: 0;
    width: 60%;
    height: 100%;
    pointer-events: none;
    transition: background 1.5s ease;
}
.server-glow-on  { background: radial-gradient(ellipse at 100% 50%, rgba(34,197,94,0.07) 0%, transparent 70%); }
.server-glow-off { background: radial-gradient(ellipse at 100% 50%, rgba(239,68,68,0.05) 0%, transparent 70%); }

/* ─── Stat rows ──────────────────────────────────────────────── */
.stat-rows { display: flex; flex-direction: column; }

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.stat-row:last-child  { border-bottom: none; padding-bottom: 0; }
.stat-row:first-child { padding-top: 0; }

.stat-label { color: var(--text-2); font-size: 12px; }
.stat-value { font-size: 12px; font-weight: 500; }

/* ─── Button row ─────────────────────────────────────────────── */
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Settings rows ──────────────────────────────────────────── */
.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child  { border-bottom: none; }
.settings-row:first-child { padding-top: 0; }

.settings-row-body { flex: 1; min-width: 0; }

.settings-row-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.settings-row-desc {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 1px;
}

.settings-row-action { flex-shrink: 0; }

/* Toggle */
.toggle {
    display: inline-block;
    position: relative;
    width: 36px;
    height: 20px;
    min-width: 36px;
    flex-shrink: 0;
    cursor: pointer;
    vertical-align: middle;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: #333;
    border-radius: 99px;
    border: 1px solid #444;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
[data-theme="light"] .toggle-track {
    background: #DCDCDC;
    border-color: #BFBFBF;
}
.toggle input:checked + .toggle-track {
    background: var(--text);
    border-color: var(--text);
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #B0B0B0;
    transition: transform 0.15s, background 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
[data-theme="light"] .toggle-track::after { background: #FFFFFF; }
.toggle input:checked + .toggle-track::after {
    transform: translateX(16px);
    background: var(--bg);
}

/* Compile spinner */
.compile-spinner {
    display: inline-block;
    width: 10px; height: 10px;
    border: 1.5px solid var(--text-3);
    border-top-color: var(--text);
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -1px;
    animation: compile-spin 0.7s linear infinite;
}
@keyframes compile-spin { to { transform: rotate(360deg); } }

/* ─── Console ────────────────────────────────────────────────── */
.console-wrap {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.console {
    background: #080808;
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.8;
    height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-2);
}

.console-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.console-count {
    font-size: 11px;
    color: var(--text-3);
    margin-left: auto;
    font-family: var(--mono);
}

/* ─── Compile output ─────────────────────────────────────────── */
.compile-out {
    background: #080808;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-2);
}
.compile-out .line-err  { color: var(--red); }
.compile-out .line-warn { color: var(--text-2); }
.compile-out .line-ok   { color: var(--green); }

@keyframes highlight-in {
    0%   { background: rgba(255,255,255,0.06); }
    100% { background: transparent; }
}

/* ─── File tree ──────────────────────────────────────────────── */
.files-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 100%;
    overflow: hidden;
    border-top: 1px solid var(--border);
    transition: grid-template-columns .2s ease;
}

.file-tree {
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 6px 0;
    background: var(--bg);
}

.file-tree-search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}

.file-tree-search input {
    background: var(--surface2);
    font-size: 12px;
    padding: 5px 9px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.06s, color 0.06s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-item:hover  { background: var(--surface2); color: var(--text); }
.file-item.active { background: var(--surface2); color: var(--text); }

.file-item .file-icon { flex-shrink: 0; font-size: 12px; }

.file-editor {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.editor-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 38px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
}

.editor-filename {
    font-size: 12px;
    color: var(--text-2);
    flex: 1;
    font-family: var(--mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-filename.modified::after {
    content: '●';
    color: var(--yellow);
    margin-left: 6px;
    font-size: 8px;
}

.editor-area {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#monaco-editor { width: 100%; height: 100%; }

.editor-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-3);
    font-size: 13px;
    flex-direction: column;
    gap: 8px;
}
.editor-empty .big { font-size: 24px; }

/* ─── Search results ─────────────────────────────────────────── */
.sq-file-group { border-bottom: 1px solid var(--border); }
.sq-file-group:last-child { border-bottom: none; }

.sq-file-header {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 12px; background: rgba(255,255,255,0.01);
    border-bottom: 1px solid var(--border); font-size: 12px; user-select: none;
}
.sq-file-icon  { font-size: 11px; flex-shrink: 0; }
.sq-file-dir   { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.sq-file-name  { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 12px; }
.sq-file-count { margin-left: 8px; color: var(--text-3); font-size: 10px; background: var(--surface2); padding: 1px 6px; border-radius: 99px; }
.sq-file-actions { margin-left: auto; display: flex; gap: 4px; }
.sq-header-btn { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: var(--radius); transition: color .1s, background .1s; }
.sq-header-btn:hover { color: var(--text); background: var(--surface2); }

.sq-file-blocks { padding: 2px 0; }

.sq-block-row {
    display: flex; align-items: center; gap: 8px;
    padding: 3px 12px; font-size: 12px; font-family: var(--mono);
    transition: background .06s; min-height: 26px;
}
.sq-block-row:hover { background: rgba(255,255,255,0.02); }
.sq-block-parent > .sq-block-row { cursor: pointer; }

.sq-toggle-icon { color: var(--text-3); font-size: 9px; flex-shrink: 0; width: 12px; text-align: center; }
.sq-line-num { color: var(--text-3); font-size: 10px; flex-shrink: 0; min-width: 44px; text-align: right; }
.sq-block-label { flex: 1; display: flex; align-items: center; gap: 5px; overflow: hidden; min-width: 0; }
.sq-type-tag { font-size: 9px; color: var(--indigo); border: 1px solid rgba(99,102,241,0.25); border-radius: 3px; padding: 1px 4px; flex-shrink: 0; font-family: var(--font); }
.sq-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-lines-badge { font-size: 10px; flex-shrink: 0; font-family: var(--font); }

.sq-row-actions { display: flex; gap: 2px; margin-left: auto; flex-shrink: 0; opacity: 0; transition: opacity .1s; }
.sq-block-row:hover .sq-row-actions { opacity: 1; }

.sq-act-btn {
    background: none; border: none; color: var(--text-2); cursor: pointer;
    font-size: 10px; padding: 2px 6px; border-radius: var(--radius);
    font-family: var(--font); white-space: nowrap; transition: color .1s, background .1s; line-height: 1.4;
}
.sq-act-btn:hover { color: var(--text); background: var(--surface2); }
.sq-act-btn:disabled { opacity: .4; cursor: not-allowed; }

.sq-preview-code { color: var(--green); white-space: pre-wrap; word-break: break-all; }
.sq-has-preview { background: rgba(34,197,94,0.03) !important; }

.sq-block-children { padding-left: 20px; border-left: 1px solid var(--border); margin-left: 18px; }
.sq-hidden { display: none !important; }
.sq-gap { padding: 2px 12px 2px 68px; color: var(--text-3); font-size: 10px; font-family: var(--mono); }
mark.sq-hl { background: rgba(234,179,8,0.15); color: var(--yellow); border-radius: 2px; padding: 0 1px; }

.sq-hist-drop {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    z-index: 100;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.sq-hist-item {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: background .06s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sq-hist-item:hover { background: var(--surface2); color: var(--text); }

.sq-bm-item {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.sq-bm-item:last-child { border-bottom: none; }
.sq-bm-name { flex: 1; color: var(--indigo); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.sq-bm-name:hover { text-decoration: underline; }
.sq-bm-file { color: var(--text-3); font-size: 10px; flex-shrink: 0; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-bm-del { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 11px; padding: 2px 4px; flex-shrink: 0; }
.sq-bm-del:hover { color: var(--red); }

.sr-block-children { padding-left: 18px; border-left: 1px solid var(--border); margin: 2px 0 2px 8px; }
.sr-brace { font-family: var(--mono); color: var(--text-3); font-size: 12px; padding: 2px 6px; }
.sr-gap   { color: var(--text-3); font-size: 11px; padding: 2px 6px; font-family: var(--mono); }

#tab-search {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 18px 20px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#search-root { display: flex; flex-direction: column; gap: 18px; }

/* ─── Editor tabs ────────────────────────────────────────────── */
.editor-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.etab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--text-2);
    font-size: 12px;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.1s, border-color 0.1s;
}
.etab:hover  { color: var(--text); }
.etab.active { color: var(--text); border-bottom-color: var(--text); }

.editor-tab-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.editor-tab-content.hidden { display: none !important; }

/* ─── File tree extras ───────────────────────────────────────── */
.file-tree-section {
    font-size: 10px; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: .08em;
    padding: 10px 12px 4px;
}
.file-tree-sep { height: 1px; background: var(--border); margin: 4px 0; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.fav-btn {
    flex-shrink: 0; opacity: 0; font-size: 11px;
    color: var(--yellow); transition: opacity 0.1s;
    padding: 0 2px; cursor: pointer;
}
.file-item:hover .fav-btn { opacity: 0.5; }
.file-item:hover .fav-btn:hover { opacity: 1; }

#delete-access-bar:not(.hidden) { display: flex; }

.del-access-bar {
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 12px;
}

.del-bar-label { color: var(--text-2); font-size: 11px; flex-shrink: 0; }

.del-access-bar input[type=number] {
    width: 64px; padding: 3px 7px; font-size: 12px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); outline: none;
    -moz-appearance: textfield;
}
.del-access-bar input[type=number]::-webkit-inner-spin-button { display: none; }
.del-access-bar input[type=number]:focus { border-color: var(--text-2); }
.del-bar-sep    { color: var(--text-3); font-size: 11px; }
.del-bar-divider { width: 1px; height: 12px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
.del-bar-danger { color: var(--red) !important; }
.del-bar-danger:hover { background: var(--red-dim) !important; }

/* ─── Part tabs ──────────────────────────────────────────────── */
.part-tabs-horizontal {
    display: flex;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}
.part-tabs-horizontal::-webkit-scrollbar { display: none; }

.ptab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: background .06s, border-color .06s;
    user-select: none;
    flex-shrink: 0;
    max-width: 200px;
    background: var(--bg);
    font-size: 11px;
}
.ptab:hover { background: var(--surface2); }
.ptab.active { border-bottom-color: var(--text); }

.ptab-line {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--text-3);
    font-weight: 600;
    background: var(--surface2);
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}
.ptab.active .ptab-line { background: rgba(255,255,255,0.08); color: var(--text-2); }

.ptab-label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}
.ptab.active .ptab-label { color: var(--text); }

/* ─── History modal ──────────────────────────────────────────── */
.hist-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .06s;
    border-left: 2px solid transparent;
}
.hist-item:hover  { background: var(--surface2); }
.hist-item.active { background: var(--surface2); border-left-color: var(--text); }
.hist-item-ts   { font-size: 12px; font-weight: 500; color: var(--text); }
.hist-item-line { font-size: 10px; color: var(--text-3); margin-top: 2px; font-family: var(--mono); }

.part-tab-active {
    background: var(--surface2) !important;
    color: var(--text) !important;
}

/* ─── Console colorize ───────────────────────────────────────── */
.con-fatal  { color: #FF3B30; font-weight: 600; }
.con-error  { color: var(--red); }
.con-warn   { color: var(--yellow); }
.con-debug  { color: var(--text-3); }
.con-info   { color: #818CF8; }
.con-default{ color: var(--text-2); }

/* ─── Editor statusbar ───────────────────────────────────────── */
.editor-statusbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 12px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 10px;
    color: var(--text-3);
    font-family: var(--mono);
    flex-shrink: 0;
    order: 10;
}
.sb-sep { color: var(--border-2); }

/* ─── Monaco suggest ─────────────────────────────────────────── */
.monaco-editor {
    --vscode-editorSuggestWidget-background: #111111;
    --vscode-editorSuggestWidget-border: #1F1F1F;
    --vscode-editorSuggestWidget-foreground: #EDEDED;
    --vscode-editorSuggestWidget-selectedBackground: rgba(255,255,255,0.06);
    --vscode-editorSuggestWidget-selectedForeground: #ffffff;
    --vscode-editorSuggestWidget-highlightForeground: #EDEDED;
    --vscode-editorSuggestWidget-focusHighlightForeground: #EDEDED;
    --vscode-editorHoverWidget-background: #111111;
    --vscode-editorHoverWidget-foreground: #EDEDED;
    --vscode-editorHoverWidget-border: #1F1F1F;
    --vscode-list-hoverBackground: rgba(255,255,255,0.04);
    --vscode-list-activeSelectionBackground: rgba(255,255,255,0.08);
    --vscode-list-activeSelectionForeground: #ffffff;
    --vscode-foreground: #EDEDED;
}
.monaco-editor .suggest-widget { background: #111111 !important; border: 1px solid #1F1F1F !important; }
.monaco-editor .suggest-widget .suggest-status-bar { background: #0A0A0A !important; }

/* ─── WS status ──────────────────────────────────────────────── */
.ws-status {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s;
}
.ws-online  { background: var(--green); }
.ws-offline { background: var(--red); animation: pulse-red 1.5s infinite; }

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 9999; pointer-events: none; }
.toast {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text);
    min-width: 180px; max-width: 300px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    animation: toast-in 0.15s ease;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
}
.toast.success::before { background: var(--green); }
.toast.error::before   { background: var(--red); }
.toast.info::before    { background: var(--text-2); }
@keyframes toast-in { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

/* ─── Queries ────────────────────────────────────────────────── */
.q-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.q-item:last-child { border-bottom: none; }
.q-item-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.q-item-user { font-size: 12px; font-weight: 500; color: var(--text); flex-shrink: 0; }
.q-item-file { font-size: 11px; color: var(--indigo); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 400px; }
.q-item-code { font-family: var(--mono); font-size: 11px; color: var(--text-2); background: var(--surface2); border-radius: var(--radius); padding: 3px 8px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Command Palette ────────────────────────────────────────── */
#palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 99000;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}

#palette {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    overflow: hidden;
    animation: palette-in 0.1s ease;
}
@keyframes palette-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.99); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.palette-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.palette-icon { font-size: 13px; color: var(--text-3); flex-shrink: 0; }

#palette-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    padding: 0;
    width: 100%;
}
#palette-input::placeholder { color: var(--text-3); }

.palette-hint { font-size: 10px; color: var(--text-3); flex-shrink: 0; font-family: var(--mono); }

#palette-list { max-height: 360px; overflow-y: auto; padding: 4px 0; }

.palette-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    transition: background 0.06s;
}
.palette-item:hover, .palette-item.active { background: var(--surface2); }

.palette-item-icon  { font-size: 12px; flex-shrink: 0; width: 18px; text-align: center; color: var(--text-3); }
.palette-item-title { flex: 1; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-group { font-size: 9px; color: var(--text-3); background: var(--surface2); padding: 1px 6px; border-radius: 99px; flex-shrink: 0; }
.palette-item-hint  { font-size: 10px; color: var(--text-3); font-family: var(--mono); flex-shrink: 0; }
mark.palette-hl { background: rgba(234,179,8,0.15); color: var(--yellow); border-radius: 2px; padding: 0 1px; }
.palette-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 12px; }

/* ─── Workspace manager ──────────────────────────────────────── */
.ws-item {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 18px; border-bottom: 1px solid var(--border);
    cursor: default; transition: background 0.06s;
}
.ws-item:last-child { border-bottom: none; }
.ws-item:hover  { background: var(--surface2); }
.ws-item.active { background: var(--surface2); }
.ws-name { font-size: 12px; font-weight: 500; color: var(--text); }
.ws-meta { font-size: 10px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ws-restore-btn, .ws-del-btn {
    background: none; border: 1px solid var(--border-2);
    color: var(--text-2); cursor: pointer; font-size: 11px;
    padding: 2px 7px; border-radius: var(--radius);
    transition: background 0.08s, color 0.08s; flex-shrink: 0;
}
.ws-restore-btn:hover { background: var(--surface2); color: var(--text); }
.ws-del-btn:hover { background: var(--red-dim); color: var(--red); border-color: var(--red); }

/* ─── Sidebar badge ──────────────────────────────────────────── */
.sidebar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    font-size: 9px;
    font-weight: 700;
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.15);
    flex-shrink: 0;
}

/* ─── TODO tracker ───────────────────────────────────────────── */
.todo-wrap { display: flex; flex-direction: column; gap: 0; }
.todo-filters { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.todo-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 99px;
    font-size: 11px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent;
    transition: opacity 0.1s, border-color 0.1s; user-select: none;
}
.todo-tag.todo-todo  { background: var(--indigo-dim); color: #818CF8; }
.todo-tag.todo-fixme { background: var(--red-dim); color: var(--red); }
.todo-tag.todo-hack  { background: var(--yellow-dim); color: var(--yellow); }
.todo-tag.todo-note  { background: var(--green-dim); color: var(--green); }
.todo-tag.active   { border-color: currentColor; }
.todo-tag.inactive { opacity: 0.3; }

.todo-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 0; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.06s;
}
.todo-item:last-child { border-bottom: none; }
.todo-item:hover { background: rgba(255,255,255,0.01); }

.todo-badge {
    font-size: 9px; font-weight: 700;
    padding: 2px 5px; border-radius: 99px;
    flex-shrink: 0; margin-top: 2px; letter-spacing: .04em;
}
.todo-badge.todo-todo  { background: var(--indigo-dim); color: #818CF8; }
.todo-badge.todo-fixme { background: var(--red-dim); color: var(--red); }
.todo-badge.todo-hack  { background: var(--yellow-dim); color: var(--yellow); }
.todo-badge.todo-note  { background: var(--green-dim); color: var(--green); }

.todo-body { flex: 1; overflow: hidden; }
.todo-text { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo-loc  { font-size: 10px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; }

/* ─── DB interface ───────────────────────────────────────────── */
.db-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0;
    height: calc(100vh - var(--topbar-h));
    margin: -32px -40px;
    overflow: hidden;
}

.db-sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.db-sidebar-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.db-table-list { flex: 1; overflow-y: auto; padding: 4px 0; }

.db-table-item {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 12px; font-size: 11px; color: var(--text-2);
    cursor: pointer; transition: background 0.06s, color 0.06s;
    font-family: var(--mono);
}
.db-table-item:hover  { background: var(--surface2); color: var(--text); }
.db-table-item.active { background: var(--surface2); color: var(--text); }

.db-toolbar .btn.active {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border-2);
}

.db-main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

#db-query-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.db-toolbar {
    display: flex; align-items: center; gap: 5px;
    padding: 7px 12px; border-bottom: 1px solid var(--border);
    background: var(--bg); flex-shrink: 0;
}

.db-query-wrap {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.db-query-input {
    width: 100%; min-height: 72px; max-height: 180px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    padding: 8px 12px;
    resize: vertical;
    outline: none;
    transition: border-color 0.12s;
}
.db-query-input:focus { border-color: var(--text-2); }

.db-result-wrap  { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.db-result-inner { flex: 1; overflow: auto; }

.db-table-result {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    font-family: var(--mono);
}
.db-table-result th {
    background: var(--surface);
    color: var(--text-3);
    font-weight: 600;
    padding: 6px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1;
    white-space: nowrap;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.db-table-result td {
    padding: 4px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    color: var(--text);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}
.db-table-result td.db-null { color: var(--text-3); font-style: italic; }
.db-table-result td.db-num  { color: #818CF8; }
.db-table-result td.db-str  { color: var(--green); }
.db-table-result tr:hover td { background: rgba(255,255,255,0.015); }

.db-status {
    padding: 5px 12px; font-size: 10px; font-family: var(--mono);
    border-top: 1px solid var(--border); background: var(--bg);
    flex-shrink: 0; color: var(--text-3);
}
.db-status.ok  { color: var(--green); }
.db-status.err { color: var(--red); }

.db-cell-edit {
    position: fixed; z-index: 50000;
    background: var(--surface); border: 1px solid var(--border-2);
    border-radius: var(--radius); padding: 4px 9px;
    font-family: var(--mono); font-size: 12px; color: var(--text);
    outline: none; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    min-width: 140px;
}

/* ─── Widget ─────────────────────────────────────────────────── */
.widget {
    position: fixed; z-index: 9000; display: flex; flex-direction: column;
    background: rgba(10,10,10,0.92);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    overflow: hidden;
    min-width: 220px; min-height: 140px;
}

.widget-header {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 8px; border-bottom: 1px solid var(--border);
    flex-shrink: 0; cursor: grab; user-select: none;
}
.widget-header:active { cursor: grabbing; }

.widget-title { font-size: 10px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; flex: 1; }
.widget-controls { display: flex; align-items: center; gap: 5px; }
.widget-opacity { width: 54px; height: 2px; cursor: pointer; accent-color: var(--text-2); }
.widget-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 11px; padding: 2px 4px; line-height: 1; border-radius: 3px; transition: background .1s; }
.widget-close:hover { background: var(--surface2); color: var(--text); }
.widget-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.widget-resize { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; background: linear-gradient(135deg, transparent 50%, var(--border-2) 50%); }

/* ─── AI Assistant (widget + page) ───────────────────────────── */
.ai { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ai-page { padding: 0 4px; height: calc(100vh - 90px); }
.ai-page-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0 10px; flex-shrink: 0; }

.ai-status { display: flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 11px; color: var(--text-2); border-bottom: 1px solid var(--border); }
.ai-status-inline { padding: 4px 0 0; border: none; font-size: 11px; }
.ai-status a { color: var(--text); text-decoration: underline; }
.ai-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.ai-dot-ok   { background: var(--green); }
.ai-dot-warn { background: #F59E0B; }

.ai-ctx { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.ai-ctx-page { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 14px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.ai-ctx-row { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; }
.ai-field { display: flex; flex-direction: column; gap: 4px; font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; min-width: 0; }
.ai-field > span { font-weight: 500; }
.ai-select { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; font-size: 12px; font-family: inherit; outline: none; cursor: pointer; min-width: 0; width: 100%; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path fill='%236B6B6B' d='M5 7L1 3h8z'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }
.ai-select:focus { border-color: var(--border-2); }
.ai-num { background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; font-size: 12px; width: 64px; outline: none; font-family: var(--mono); text-align: center; }
.ai-num:focus { border-color: var(--border-2); }
/* Обёртка для toggle с подписью — сам .toggle остаётся 36x20px */
.ai-toggle-row { display: inline-flex; align-items: center; gap: 8px; user-select: none; padding: 2px 0; }
.ai-toggle-row .toggle { flex-shrink: 0; }
.ai-toggle-label { font-size: 12px; color: var(--text-2); cursor: pointer; }

.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.ai-chips-page { background: transparent; border: none; padding: 0; }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; background: var(--surface2); border: 1px solid var(--border-2); border-radius: 99px; font-size: 11px; color: var(--text); max-width: 240px; }
.ai-chip-name { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-chip-x { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 0 4px; font-size: 11px; line-height: 1; border-radius: 99px; }
.ai-chip-x:hover { background: var(--surface3); color: var(--text); }

.ai-page-attached { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; flex-shrink: 0; }
.ai-attached-header { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }

.ai-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; min-height: 0; }
.ai-messages-page { padding: 14px 0; }
.ai-empty { margin: auto; color: var(--text-3); font-size: 12px; text-align: center; padding: 24px 12px; line-height: 1.6; }
.ai-hint { font-size: 10px; color: var(--text-3); }
.ai-suggestions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.ai-suggest { background: var(--surface); border: 1px solid var(--border-2); color: var(--text-2); padding: 6px 12px; border-radius: var(--radius); font-size: 12px; cursor: pointer; transition: background .15s, color .15s; }
.ai-suggest:hover { background: var(--surface2); color: var(--text); }

.ai-msg { display: flex; flex-direction: column; gap: 3px; max-width: 100%; }
.ai-msg-user   { align-items: flex-end; }
.ai-msg-claude { align-items: flex-start; }
.ai-msg-label { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 0 4px; }
.ai-msg-body { font-size: 13px; line-height: 1.6; padding: 9px 13px; border-radius: var(--radius-md); max-width: 92%; word-wrap: break-word; }
.ai-msg-user .ai-msg-body   { background: var(--surface3); color: var(--text); border: 1px solid var(--border-2); }
.ai-msg-claude .ai-msg-body { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.ai-page .ai-msg-body { max-width: min(800px, 92%); }
.ai-typing { opacity: .4; }

.ai-code { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px; overflow-x: auto; font-family: var(--mono); font-size: 12px; line-height: 1.55; margin: 6px 0; }
.ai-inline-code { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-family: var(--mono); font-size: 11px; }

/* Markdown tables */
.ai-table-wrap { overflow-x: auto; margin: 8px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.ai-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ai-table thead th { background: var(--surface2); color: var(--text); text-align: left; padding: 7px 12px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ai-table tbody td { padding: 6px 12px; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: top; }
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-table tbody tr:hover { background: var(--surface2); }
.ai-table code.ai-inline-code { font-size: 11px; }

/* Tool-use timeline (что Claude делал по дороге) */
.ai-tools { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 6px; max-width: 92%; }
.ai-tool { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 10.5px; color: var(--text-2); font-family: var(--mono); }
.ai-tool-icon { font-size: 10px; opacity: .85; }
.ai-tool-path { background: transparent; border: none; padding: 0; font-size: 10.5px; color: var(--text); }

/* Edits — карточка с кнопками */
.ai-edits { margin-top: 8px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-md); overflow: hidden; max-width: 92%; }
.ai-page .ai-edits { max-width: min(800px, 92%); }
.ai-edits-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface2); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.ai-edits-list { display: flex; flex-direction: column; }
.ai-edit { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; gap: 10px; border-top: 1px solid var(--border); }
.ai-edit:first-child { border-top: none; }
.ai-edit-done { opacity: .6; }
.ai-edit-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.ai-edit-icon { font-size: 12px; color: var(--text-2); width: 16px; text-align: center; }
.ai-edit-path { font-family: var(--mono); font-size: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ai-edit-stats { display: inline-flex; gap: 6px; font-family: var(--mono); font-size: 11px; flex-shrink: 0; }
.ai-edit-plus  { color: var(--green); }
.ai-edit-minus { color: var(--red); }
.ai-edit-actions { display: flex; gap: 4px; flex-shrink: 0; }
.ai-edit-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.ai-edit-badge-ok    { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.ai-edit-badge-err   { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.25); cursor: help; }
.ai-edit-badge-muted { background: var(--surface2); color: var(--text-3); border: 1px solid var(--border); }

/* Usage badge + modal */
.ai-statusbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ai-statusbar .ai-status { border: none; padding: 0; flex: 1; }
.ai-usage-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; font-size: 11px; color: var(--text-2); cursor: pointer; font-family: var(--mono); transition: background .15s, color .15s; }
.ai-usage-btn:hover { background: var(--surface3); color: var(--text); }
.ai-usage { display: inline-flex; gap: 4px; align-items: center; }
.ai-usage-warn { color: #F59E0B; }
.ai-usage-over { color: var(--red); background: var(--red-dim); padding: 1px 6px; border-radius: 4px; border: 1px solid rgba(239,68,68,0.3); }
.ai-usage-budget { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 4px; }
.ai-usage-budget span { font-size: 12px; color: var(--text-2); flex: 1; }
.ai-usage-budget input { width: 80px; padding: 5px 8px; font-family: var(--mono); font-size: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); outline: none; text-align: right; }
.ai-usage-budget input:focus { border-color: var(--border-2); }
.ai-usage b { color: var(--text); font-weight: 600; }

.ai-usage-window { width: 100%; max-width: 720px; max-height: 80vh; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,0.7); }
.ai-usage-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ai-usage-title { font-size: 13px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.ai-usage-close { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; }
.ai-usage-body { padding: 16px; overflow-y: auto; }
.ai-usage-section-title { font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin: 10px 0 8px; }
.ai-usage-section-title:first-child { margin-top: 0; }
.ai-usage-empty { padding: 14px; color: var(--text-3); font-size: 12px; text-align: center; background: var(--surface2); border-radius: var(--radius); }
.ai-usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ai-usage-stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); }
.ai-usage-stat span { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.ai-usage-stat b { font-size: 16px; color: var(--text); font-weight: 600; font-family: var(--mono); }
.ai-usage-stat-accent { border-color: var(--border-2); background: var(--bg); }
.ai-usage-models { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.ai-usage-model { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; }
.ai-usage-model-name { color: var(--text); font-weight: 600; text-transform: uppercase; font-family: var(--mono); }
.ai-usage-model-stats { color: var(--text-2); flex: 1; text-align: right; font-family: var(--mono); font-size: 11px; }
.ai-usage-model-cost { color: var(--text); font-weight: 600; font-family: var(--mono); }
.ai-usage-history { display: flex; flex-direction: column; gap: 2px; }
.ai-usage-day { display: grid; grid-template-columns: 100px 70px 80px 70px; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 11px; }
.ai-usage-day-date { color: var(--text); }
.ai-usage-day-req,
.ai-usage-day-tok { color: var(--text-2); }
.ai-usage-day-cost { color: var(--text); text-align: right; }
.ai-usage-note { margin-top: 16px; padding: 10px 12px; background: var(--surface2); border-radius: var(--radius); font-size: 11px; color: var(--text-3); line-height: 1.5; }

/* Active task picker button */
.ai-active-task-bar { padding: 6px 12px; border-bottom: 1px solid var(--border); display: flex; }
.ai-active-task { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 11.5px; color: var(--text-2); cursor: pointer; max-width: 100%; transition: background .15s, color .15s, border-color .15s; }
.ai-active-task:hover { background: var(--surface3); color: var(--text); }
.ai-active-task-on { color: var(--text); border-color: var(--border-2); background: var(--bg); }
.ai-active-task-icon { font-size: 11px; opacity: .8; }
.ai-active-task-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; font-family: var(--mono); }

/* Thread pill */
.ai-thread-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 11.5px; color: var(--text); cursor: pointer; max-width: 100%; transition: background .15s, border-color .15s; }
.ai-thread-pill:hover { background: var(--surface3); border-color: var(--border-2); }
.ai-thread-pill-task { border-color: var(--border-2); background: var(--bg); }
.ai-thread-icon { font-size: 11px; opacity: .85; }
.ai-thread-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; font-family: var(--mono); }

/* Thread picker modal */
.ai-thread-picker { max-width: 540px; height: 70vh; }
.ai-thread-section { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px 4px; font-weight: 600; }
.ai-thread-row { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; border-bottom: 1px solid transparent; transition: background .12s; }
.ai-thread-row:hover { background: var(--surface2); }
.ai-thread-row.attached { background: var(--surface3); }
.ai-thread-row-body { flex: 1; min-width: 0; }
.ai-thread-row-title { color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-thread-row-sub { color: var(--text-3); font-size: 10.5px; margin-top: 2px; font-family: var(--mono); }
.ai-thread-row-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.ai-thread-mini { background: none; border: 1px solid var(--border); color: var(--text-3); border-radius: var(--radius); padding: 2px 7px; font-size: 11px; cursor: pointer; transition: all .12s; }
.ai-thread-mini:hover { color: var(--text); border-color: var(--border-2); background: var(--surface2); }

/* ─── Tasks page ─────────────────────────────────────────────── */
.tasks-page { display: flex; flex-direction: column; height: calc(100vh - 90px); min-height: 0; }
.tasks-page-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 10px; flex-shrink: 0; }
.tasks-page-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.tasks-page-sub b { color: var(--text); font-weight: 500; }
.tasks-layout { display: grid; grid-template-columns: 320px 1fr; flex: 1; gap: 14px; min-height: 0; }
.tasks-list-pane { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 0; }
.tasks-filters { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; flex-shrink: 0; }
.task-filter { background: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); padding: 3px 9px; font-size: 11px; cursor: pointer; transition: all .15s; }
.task-filter:hover { color: var(--text); background: var(--surface2); }
.task-filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tasks-list { flex: 1; overflow-y: auto; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.task-row:hover { background: var(--surface2); }
.task-row.selected { background: var(--surface3); }
.task-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.task-dot-open        { background: var(--text-3); }
.task-dot-in_progress { background: #F59E0B; }
.task-dot-done        { background: var(--green); }
.task-dot-blocked     { background: var(--red); }
.task-row-body { flex: 1; min-width: 0; }
.task-row-title { font-size: 13px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-row-meta { display: flex; gap: 6px; margin-top: 3px; font-size: 10px; flex-wrap: wrap; align-items: center; }
.task-status { color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--border); }
.task-status-in_progress { color: #F59E0B; border-color: rgba(245,158,11,0.2); background: rgba(245,158,11,0.08); }
.task-status-done { color: var(--green); border-color: rgba(34,197,94,0.2); background: var(--green-dim); }
.task-status-blocked { color: var(--red); border-color: rgba(239,68,68,0.2); background: var(--red-dim); }
.task-prio { color: var(--text-3); padding: 1px 6px; border-radius: 99px; border: 1px solid var(--border); }
.task-prio-high { color: var(--red); border-color: rgba(239,68,68,0.2); }
.task-prio-low { opacity: .6; }
.task-row-files { color: var(--text-3); font-size: 10px; }
.task-active-badge { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.2); padding: 1px 6px; border-radius: 99px; font-size: 9px; text-transform: uppercase; font-weight: 600; letter-spacing: .04em; margin-left: 6px; }

.task-detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-y: auto; padding: 18px 22px; min-height: 0; }
.task-detail-header { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.task-detail-header input { flex: 1; background: transparent; border: 1px solid transparent; border-radius: var(--radius); padding: 6px 8px; font-size: 17px; font-weight: 600; color: var(--text); outline: none; transition: border-color .15s, background .15s; }
.task-detail-header input:hover, .task-detail-header input:focus { background: var(--surface2); border-color: var(--border); }
.task-detail-actions { display: flex; gap: 6px; flex-shrink: 0; }
.task-meta-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.task-meta-spacer { flex: 1; }
.task-detail-times { display: flex; flex-direction: column; gap: 2px; font-size: 10px; color: var(--text-3); text-align: right; }
.task-section { margin-bottom: 16px; }
.task-section-title { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.task-section-hint { font-weight: 400; text-transform: none; color: var(--text-3); letter-spacing: 0; }
.task-section textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-size: 13px; line-height: 1.55; font-family: inherit; outline: none; resize: vertical; box-sizing: border-box; }
.task-section textarea:focus { border-color: var(--border-2); }
.task-section-actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.task-search { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; color: var(--text); font-size: 12px; outline: none; flex: 1; max-width: 360px; }
.task-search:focus { border-color: var(--border-2); }
.task-file-results { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-height: 220px; overflow-y: auto; display: none; margin-top: 4px; max-width: 360px; }
.task-file-result { display: flex; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px; align-items: baseline; }
.task-file-result:hover { background: var(--surface2); }
.task-file-result-name { color: var(--text); font-family: var(--mono); }
.task-file-result-path { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-file-empty { padding: 10px; color: var(--text-3); font-size: 11px; text-align: center; }
.task-link { background: none; border: none; color: var(--text); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }

.task-dropzone { border: 1.5px dashed var(--border-2); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--text-3); font-size: 12px; transition: all .15s; cursor: pointer; }
.task-dropzone.over { background: var(--surface2); border-color: var(--text-2); color: var(--text); }
.task-attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.task-att { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; position: relative; }
.task-att img { display: block; width: 100%; height: 130px; object-fit: cover; }
.task-att-bar { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px; font-size: 11px; gap: 6px; }
.task-att-name { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 10.5px; }
.task-att-x { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 11px; padding: 0 4px; }
.task-att-x:hover { color: var(--red); }
.task-att-file { display: flex; justify-content: space-between; padding: 10px 12px; align-items: center; }
.task-att-file a { color: var(--text); font-family: var(--mono); font-size: 12px; text-decoration: none; flex: 1; }
.task-att-file a:hover { text-decoration: underline; }

.task-note-composer { display: flex; gap: 6px; align-items: stretch; }
.task-note-composer textarea { flex: 1; }
.task-notes { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.task-note { padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); }
.task-note-meta { font-size: 10px; color: var(--text-3); margin-bottom: 3px; }
.task-note-text { color: var(--text); font-size: 12.5px; line-height: 1.5; }

.task-ai-log { display: flex; flex-direction: column; gap: 4px; }
.task-ai-log-item { padding: 6px 10px; background: var(--surface2); border-radius: var(--radius); font-size: 11px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.task-ai-log-time { color: var(--text-3); font-family: var(--mono); }
.task-ai-log-kind { color: var(--text); text-transform: uppercase; font-weight: 600; font-size: 9.5px; letter-spacing: .04em; }
.task-ai-log-summary { color: var(--text-2); flex: 1; }
.task-ai-log-files { width: 100%; display: flex; gap: 4px; margin-top: 2px; flex-wrap: wrap; }

/* Create task modal */
.task-create-window { width: 100%; max-width: 540px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,0.7); }
.task-create-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text); }
.task-create-close { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; }
.task-create-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.task-create-body input[type=text] { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 11px; color: var(--text); font-size: 14px; font-weight: 500; outline: none; }
.task-create-body input[type=text]:focus { border-color: var(--border-2); }
.task-create-body textarea { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-size: 13px; font-family: inherit; outline: none; resize: vertical; }
.task-create-body textarea:focus { border-color: var(--border-2); }
.task-create-row { display: flex; gap: 12px; align-items: flex-end; }
.task-create-footer { display: flex; justify-content: flex-end; gap: 6px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* Pending action cards */
.ai-actions-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-width: 92%; }
.ai-page .ai-actions-list { max-width: min(800px, 92%); }
.ai-action { display: flex; gap: 10px; align-items: center; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-md); font-size: 12.5px; }
.ai-action-done { opacity: .7; }
.ai-action-icon { font-size: 16px; flex-shrink: 0; }
.ai-action-summary { color: var(--text); flex: 1; min-width: 0; }
.ai-action-state { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.ai-action-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.ai-action-badge-ok    { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.ai-action-badge-err   { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.25); cursor: help; }
.ai-action-badge-muted { background: var(--surface2); color: var(--text-3); border: 1px solid var(--border); }

/* AI memory modal */
.ai-mem-window { width: 100%; height: 100%; max-width: 1400px; max-height: calc(100vh - 40px); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,0.7); }
.ai-mem-header { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-mem-title { font-size: 13px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.ai-mem-sub { font-size: 11px; color: var(--text-3); flex: 1; }
.ai-mem-close { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; }
.ai-mem-body { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.ai-mem-sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.ai-mem-list-actions { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-mem-list { flex: 1; overflow-y: auto; }
.ai-mem-item { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.ai-mem-item:hover { background: var(--surface2); }
.ai-mem-item.active { background: var(--surface3); }
.ai-mem-item-name { font-size: 12px; color: var(--text); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-mem-item-meta { font-size: 10px; color: var(--text-3); margin-top: 2px; font-family: var(--mono); }
.ai-mem-editor-pane { display: flex; flex-direction: column; min-height: 0; }
.ai-mem-editor-bar { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-mem-current { font-size: 12px; color: var(--text); font-family: var(--mono); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-mem-editor { flex: 1; min-height: 0; }

/* Diff modal */
.ai-diff-window { width: 100%; height: 100%; max-width: 1600px; max-height: calc(100vh - 40px); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,0.7); }
.ai-diff-header { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ai-diff-title { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.ai-diff-path { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 2px 6px; flex: 1; }
.ai-diff-close { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; }
.ai-diff-body { flex: 1; position: relative; min-height: 0; }

.ai-composer-wrap { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.ai-composer-wrap-page { padding: 12px 0 0; border-top: 1px solid var(--border); background: transparent; }
.ai-composer { width: 100%; }
.ai-composer textarea { width: 100%; resize: none; font-family: inherit; font-size: 13px; padding: 9px 11px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); outline: none; min-height: 48px; max-height: 200px; box-sizing: border-box; line-height: 1.55; }
.ai-composer textarea:focus { border-color: var(--border-2); }
.ai-composer textarea::placeholder { color: var(--text-3); }
.ai-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* @-mentions dropdown */
.ai-mentions { position: absolute; bottom: 100%; left: 12px; right: 12px; max-height: 240px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.4); z-index: 100; margin-bottom: 4px; }
.ai-mention-item { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.ai-mention-item:hover, .ai-mention-item.active { background: var(--surface2); }
.ai-mention-name { color: var(--text); font-family: var(--mono); }
.ai-mention-path { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

/* File picker modal (page) */
.ai-picker { width: 100%; max-width: 600px; height: 70vh; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 16px 48px rgba(0,0,0,0.7); }
.ai-picker-header { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); align-items: center; }
.ai-picker-header input { flex: 1; background: var(--surface2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; outline: none; }
.ai-picker-header input:focus { border-color: var(--border-2); }
.ai-picker-close { background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; padding: 4px 8px; }
.ai-picker-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.ai-picker-item { display: flex; align-items: baseline; gap: 8px; padding: 8px 14px; cursor: pointer; font-size: 12px; border-bottom: 1px solid transparent; }
.ai-picker-item:hover { background: var(--surface2); }
.ai-picker-item.attached { background: var(--green-dim); }
.ai-picker-name { color: var(--text); font-family: var(--mono); }
.ai-picker-path { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-picker-state { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.ai-picker-item.attached .ai-picker-state { color: var(--green); }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Utility ────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.spacer  { flex: 1; }

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
    :root { --sidebar-w: 100%; }
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-h) 44px 1fr;
        height: 100dvh;
    }
    .topbar-logo { width: auto; border-right: none; }
    .sidebar {
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0 6px;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .sidebar-section { display: none; }
    .sidebar a { padding: 0 10px; height: 44px; border-radius: 0; }
    .sidebar a .label { display: none; }
    .sidebar-footer { display: none; }
    .main { padding: 14px; }
    .files-layout { grid-template-columns: 1fr; grid-template-rows: 180px 1fr; }
    .file-tree { border-right: none; border-bottom: 1px solid var(--border); }
    .db-layout { grid-template-columns: 1fr; margin: -14px; }
    .db-sidebar { display: none; }
}
