@import url('https://rsms.me/inter/inter.css');

:root {
    --bg: #f4f5f9;
    --bg-soft: #eceef4;
    --panel: #ffffff;
    --panel-2: #f5f6fa;
    --panel-3: #eaecf2;
    --border: #e4e7ee;
    --border-strong: #cfd4e0;
    --text: #101828;
    --text-soft: #344054;
    --muted: #667085;
    --muted-soft: #98a2b3;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --success: #157f3c;
    --success-soft: #ecfdf3;
    --warn: #b54708;
    --warn-soft: #fffaeb;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.10), 0 2px 6px -2px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 16px 40px -12px rgba(16, 24, 40, 0.18), 0 6px 16px -6px rgba(16, 24, 40, 0.08);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

@supports (font-variation-settings: normal) {
    :root { --font-sans: 'Inter var', -apple-system, BlinkMacSystemFont, sans-serif; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--primary-hover); }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

::selection { background: #c7d2fe; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 58px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand::before {
    content: '';
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--primary-grad);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

.topbar nav {
    display: flex;
    gap: 14px;
    align-items: center;
}
.topbar nav a.nav-link, .topbar nav a:not(.user) {
    color: var(--text-soft);
    font-size: 13.5px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background 0.15s ease, color 0.15s ease;
}
.topbar nav a.nav-link:hover, .topbar nav a:not(.user):hover {
    color: var(--primary);
    background: var(--primary-soft);
}
.topbar nav .user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px 5px 5px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar nav .user:hover {
    text-decoration: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-grad);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.role-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--panel-3);
    color: var(--muted);
}
.role-tag.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-tag.role-dev { background: var(--success-soft); color: var(--success); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
    max-width: 1240px;
    margin: 28px auto;
    padding: 0 24px;
}
.container-full { margin: 0; padding: 0; }
.chromeless .footer { display: none; }

/* Page head (title + actions row) */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 2px 0 4px; }
.page-head-actions { display: flex; gap: 10px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}
.card.slim { padding: 16px 20px; }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.narrow-left { max-width: 560px; }
.card.danger-zone { border-color: #fecdca; }
.card.danger-zone h2 { color: var(--danger); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
    gap: 16px;
}
.card-header h1 { margin: 0 0 4px; }
.card-header .muted { font-size: 13px; }

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 {
    margin: 0 0 16px;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
}
h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 10px;
}
h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--text);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
label {
    display: block;
    margin-bottom: 16px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
}
label > input, label > select, label > textarea { margin-top: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=file], select, textarea {
    display: block;
    width: 100%;
    padding: 9px 13px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type=file] { padding: 7px 9px; background: var(--panel-2); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled { background: var(--panel-2); color: var(--muted); }
textarea { resize: vertical; line-height: 1.5; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}
button.primary, .btn.primary {
    background: var(--primary-grad);
    border-color: transparent;
    color: white;
    box-shadow: 0 1px 3px rgba(79, 70, 229, 0.4);
}
button.primary:hover, .btn.primary:hover {
    filter: brightness(1.08);
    color: white;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.45);
    transform: translateY(-1px);
}
button.primary:active, .btn.primary:active { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

button.link, .danger-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 4px 9px;
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: none;
}
button.link:hover { background: var(--primary-soft); }
.danger-link { color: var(--danger); }
.danger-link:hover { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

.danger-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.danger-btn:hover { background: #b42318; border-color: #b42318; color: #fff; }

button.small, .btn.small { padding: 5px 11px; font-size: 12px; }

/* ── Inline form rows ───────────────────────────────────────────────────── */
.row-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    align-items: stretch;
}
.row-form input, .row-form select { flex: 1; margin: 0; }
.row-form button { margin: 0; }
.inline { display: inline; margin: 0; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
table.data th, table.data td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 0.1s ease; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data th {
    color: var(--muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--panel-2);
}
table.data code { color: var(--muted); }
table.data .actions { white-space: nowrap; }
table.data .actions form { display: inline; margin-left: 4px; }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    animation: flash-in 0.25s ease;
}
@keyframes flash-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.flash::before { font-weight: 700; }
.flash-error { border-color: #fda29b; background: var(--danger-soft); color: var(--danger); }
.flash-error::before { content: '⨯'; }
.flash-success { border-color: #6ce9a6; background: var(--success-soft); color: var(--success); }
.flash-success::before { content: '✓'; }
.flash-info { border-left: 3px solid var(--primary); }

.footer {
    text-align: center;
    color: var(--muted-soft);
    padding: 36px 0;
    font-size: 12px;
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 22px;
    align-items: start;
}
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 16px;
}
.project-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.project-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #c7d2fe;
    color: var(--text);
    text-decoration: none;
}
.project-card-top {
    display: flex;
    align-items: center;
    gap: 12px;
}
.project-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--primary-grad);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}
.project-card-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.project-card-title strong {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-card-title code { font-size: 11px; }
.project-card-desc {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.5;
}
.project-card-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.project-card-stats b { color: var(--text); font-weight: 600; }
.project-card-foot { margin-top: -2px; }

.live-pill, .draft-pill {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 9px;
    border-radius: 999px;
}
.live-pill { background: var(--success-soft); color: var(--success); }
.draft-pill { background: var(--panel-3); color: var(--muted); }

/* Activity feed */
.activity-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.activity-feed li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13px;
}
.feed-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
    margin-top: 6px;
    flex-shrink: 0;
}
.feed-file { background: var(--primary); }
.feed-site { background: #12b76a; }
.feed-project { background: #f79009; }
.feed-auth { background: var(--muted-soft); }
.feed-ai { background: #7c3aed; }
.feed-line { line-height: 1.45; }
.feed-detail {
    font-family: var(--font-mono);
    font-size: 11px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}
.empty-glyph {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

/* ── Workspace (project view) ───────────────────────────────────────────── */
.workspace {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 0;
    height: calc(100vh - 58px);
    margin: -28px -24px 0;
    background: var(--bg);
}
.workspace.with-preview { grid-template-columns: 270px 1fr 1fr; }
.workspace.narrow-workspace {
    grid-template-columns: 1fr;
    height: auto;
    margin: 0;
}

/* Sidebar */
.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px 16px;
}
.sidebar-header { margin-bottom: 16px; }
.sidebar-header h2 { margin: 6px 0 4px; font-size: 15.5px; letter-spacing: -0.01em; }
.back-link {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    display: inline-block;
}
.back-link:hover { color: var(--primary); text-decoration: none; }

.sidebar-form { margin-bottom: 8px; }
.sidebar-form input[type=text],
.sidebar-form input[type=search],
.sidebar-form input[type=file] {
    padding: 7px 10px;
    font-size: 12.5px;
}
.sidebar-form button.small { padding: 6px 11px; }

.sidebar-nav {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav a {
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 9px;
    transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-nav a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.sidebar-nav a::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-strong);
    flex-shrink: 0;
    transition: background 0.12s ease;
}
.sidebar-nav a:hover::before { background: var(--primary); }

.active-banner {
    margin-top: 12px;
    padding: 10px 13px;
    background: var(--primary-soft);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    font-size: 12.5px;
    color: var(--text-soft);
}
.active-banner.muted { background: var(--panel-2); border-left-color: var(--border-strong); }

/* Drop zone */
.drop-zone {
    margin: 8px 0;
    padding: 14px 12px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--muted-soft);
    font-size: 12px;
    transition: all 0.15s ease;
}
.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

/* File tree */
.file-tree {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}
.file-tree li {
    border-radius: var(--radius-sm);
    margin-bottom: 1px;
}
.file-tree li.active { background: var(--primary-soft); }
.file-tree li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--text-soft);
    font-size: 13px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background 0.1s ease;
}
.file-tree li a:hover { background: var(--panel-2); text-decoration: none; }
.file-tree li.active a { color: var(--primary); font-weight: 600; }

.ftype {
    width: 4px;
    height: 18px;
    border-radius: 2px;
    flex-shrink: 0;
}
.ftype-text { background: var(--primary); }
.ftype-binary { background: var(--warn); }

.ver-badge {
    margin-left: auto;
    font-size: 10.5px;
    color: var(--muted);
    font-family: var(--font-mono);
    padding: 1px 7px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.file-tree li.active .ver-badge { background: #fff; border-color: #c7d2fe; color: var(--primary); }

/* Folder tree */
.file-tree .tree-dir > details > summary {
    cursor: pointer;
    padding: 5px 10px;
    font-weight: 600;
    color: var(--text-soft);
    font-size: 12.5px;
    user-select: none;
    list-style: none;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
}
.file-tree .tree-dir > details > summary:hover { background: var(--panel-2); }
.file-tree .tree-dir > details > summary::before { content: '▸ '; font-size: 0.7rem; color: var(--muted-soft); }
.file-tree .tree-dir > details[open] > summary::before { content: '▾ '; }
.file-tree .tree-dir > details > ul {
    list-style: none;
    margin: 0;
    padding-left: 13px;
    border-left: 1px solid var(--border);
    margin-left: 13px;
}
#file-filter { width: 100%; }
.dirty-dot { color: #f59e0b; margin-left: 6px; font-size: 0.9rem; }

/* ── Editor pane ────────────────────────────────────────────────────────── */
.editor-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    border-right: 1px solid var(--border);
}
.workspace:not(.with-preview) .editor-pane { border-right: none; }

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    min-height: 54px;
    gap: 16px;
}
.editor-header strong { font-size: 13.5px; font-weight: 600; font-family: var(--font-mono); }
.editor-actions { display: flex; gap: 8px; align-items: center; }

#editor-host {
    flex: 1;
    min-height: 300px;
    background: #ffffff;
}

.editor-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}
.editor-footer #comment { flex: 1; padding: 8px 11px; }
.editor-footer select {
    width: auto;
    flex-shrink: 0;
    padding: 8px 10px;
    font-size: 12.5px;
}

/* ── Preview pane ───────────────────────────────────────────────────────── */
.preview-pane {
    display: flex;
    flex-direction: column;
    background: var(--panel-2);
    overflow: hidden;
}
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    min-height: 54px;
    font-size: 13px;
    color: var(--muted);
}
.preview-header strong { color: var(--text); font-size: 13.5px; }
#preview-frame {
    flex: 1;
    border: 0;
    background: white;
    width: 100%;
}
.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    text-align: center;
    padding: 40px 20px;
}
.preview-empty h3 { margin-bottom: 8px; }
.preview-mode-toggle {
    display: inline-flex;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
    gap: 2px;
}
.preview-mode-toggle button {
    border: none;
    padding: 4px 11px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    border-radius: 5px;
    box-shadow: none;
}
.preview-mode-toggle button.active {
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.preview-mode-toggle button:hover:not(.active) { color: var(--text); background: transparent; }

/* ── Empty / binary states ──────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--muted);
    text-align: center;
    padding: 60px 32px;
}
.empty-state h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.empty-state p { margin: 0 0 16px; max-width: 420px; }

.binary-preview {
    padding: 60px 32px;
    text-align: center;
    color: var(--muted);
}

/* ── Status pills ───────────────────────────────────────────────────────── */
.stab {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.6;
}
.stab-green { background: var(--success-soft); color: var(--success); }
.stab-yellow { background: var(--warn-soft); color: var(--warn); }
.stab-red { background: var(--danger-soft); color: var(--danger); }

.active-row { background: var(--primary-soft); }
.active-row td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

/* ── Manifest ───────────────────────────────────────────────────────────── */
.manifest-table select {
    padding: 5px 9px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 12px;
    max-width: 320px;
}
.pin-form { display: inline; }

/* ── Diff page ──────────────────────────────────────────────────────────── */
.diff-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 58px);
    margin: -28px -24px 0;
}
#diff-host { flex: 1; min-height: 400px; }

.diff-summary { margin: 16px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.diff-summary .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.diff-summary .added { background: var(--success-soft); color: var(--success); }
.diff-summary .removed { background: var(--danger-soft); color: var(--danger); }
.diff-summary .changed { background: var(--primary-soft); color: var(--primary); }
.diff-summary .unchanged { background: var(--panel-2); color: var(--muted); }
.diff-h { margin-top: 28px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.topbar-select {
    padding: 6px 11px;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 12.5px;
    max-width: 200px;
    cursor: pointer;
}

/* ── AI assistant ───────────────────────────────────────────────────────── */
.ai-shell {
    display: grid;
    grid-template-columns: 290px 1fr;
    height: calc(100vh - 58px);
    margin: -28px -24px 0;
}
.ai-sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px 16px;
}
.conv-list { list-style: none; padding: 0; margin: 14px 0 0; }
.conv-list li { margin-bottom: 1px; border-radius: var(--radius-sm); }
.conv-list li.active { background: var(--primary-soft); }
.conv-list li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--text-soft);
    font-size: 13px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}
.conv-list li a:hover { background: var(--panel-2); text-decoration: none; }
.conv-list li.active a { color: var(--primary); }

.ai-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}
.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    min-height: 54px;
}
.ai-messages { flex: 1; overflow-y: auto; padding: 24px; }

.ai-msg {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}
.ai-msg-user { border-left: 3px solid var(--primary); }
.ai-msg-assistant { border-left: 3px solid var(--success); }
.ai-msg-tool { border-left: 3px solid var(--warn); background: var(--panel-2); }
.ai-msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12.5px;
}
.ai-msg-text { white-space: pre-wrap; line-height: 1.6; color: var(--text); }
.ai-msg-meta { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }

.ai-tool-call, .ai-tool-result {
    margin-top: 10px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12.5px;
}
.ai-tool-call summary, .ai-tool-result summary {
    cursor: pointer;
    user-select: none;
    color: var(--muted);
    font-weight: 500;
}
.ai-tool-call summary:hover, .ai-tool-result summary:hover { color: var(--text); }
.ai-tool-call pre, .ai-tool-result pre {
    background: var(--panel);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin: 10px 0 0;
    overflow-x: auto;
    font-size: 11.5px;
    max-height: 320px;
    border: 1px solid var(--border);
    color: var(--text-soft);
}
.ai-tool-result.is-error { border-color: #fda29b; }
.ai-tool-result.is-error summary { color: var(--danger); }

.ai-input {
    padding: 14px 24px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}
.ai-input textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    font: inherit;
    resize: vertical;
}
.ai-input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* ── Login (split-screen) ───────────────────────────────────────────────── */
.login-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}
@media (max-width: 880px) { .login-split { grid-template-columns: 1fr; } .login-brand-side { display: none; } }

.login-brand-side {
    background: linear-gradient(150deg, #1e1b4b 0%, #312e81 45%, #4f46e5 110%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 48px;
    position: relative;
    overflow: hidden;
}
.login-brand-side::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.35) 0%, transparent 65%);
    bottom: -200px;
    right: -150px;
    pointer-events: none;
}
.login-brand-inner { max-width: 420px; position: relative; z-index: 1; }
.login-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #818cf8, #c4b5fd);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    margin-bottom: 22px;
}
.login-brand-inner h1 {
    color: #fff;
    font-size: 34px;
    margin: 0 0 8px;
    letter-spacing: -0.03em;
}
.login-tagline {
    color: #c7d2fe;
    font-size: 16px;
    margin: 0 0 30px;
    line-height: 1.5;
}
.login-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 13px;
}
.login-points li {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    color: #e0e7ff;
    font-size: 14px;
    line-height: 1.5;
}
.login-points li::before {
    content: '✓';
    color: #a5b4fc;
    font-weight: 700;
    flex-shrink: 0;
}

.login-form-side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: var(--bg);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 34px 32px;
    box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.02em; }

/* Legacy login shell (kept for compatibility) */
.login-shell {
    min-height: calc(100vh - 58px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
}

details summary { cursor: pointer; user-select: none; }
details summary:hover { color: var(--text); }

.error { color: var(--danger); font-weight: 500; }
.success { color: var(--success); font-weight: 500; }

a.user { text-decoration: none; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 880px) {
    .workspace { grid-template-columns: 1fr; height: auto; }
    .workspace.with-preview { grid-template-columns: 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
    #editor-host { min-height: 50vh; }
    .ai-shell { grid-template-columns: 1fr; height: auto; }
    .container { margin: 20px auto; padding: 0 16px; }
    .workspace { margin: -20px -16px 0; }
    .diff-shell { margin: -20px -16px 0; }
    .ai-shell { margin: -20px -16px 0; }
    .page-head { align-items: flex-start; flex-direction: column; }
}
