/* ==========================================================================
   Bot Panel — design tokens
   ========================================================================== */
:root {
    color-scheme: dark;
    --bg: #0a0b10;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, 0.10), transparent 60%),
               radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, 0.06), transparent 60%);
    --surface: #111319;
    --surface-2: #171a22;
    --surface-3: #1e222c;
    --border: #232733;
    --border-strong: #2f3442;
    --text: #e8eaf0;
    --text-2: #b4b9c7;
    --muted: #7d8395;
    --accent: #7c5cff;
    --accent-hover: #6a48f5;
    --accent-soft: rgba(124, 92, 255, 0.14);
    --accent-text: #a996ff;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.13);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.13);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.14);
    --info: #22d3ee;
    --code-bg: #0b0d12;
    --code-text: #d6dae4;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --radius: 14px;
    --radius-sm: 9px;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f6f9;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, 0.08), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f6f7fa;
    --surface-3: #eceef3;
    --border: #e4e6ec;
    --border-strong: #d3d6df;
    --text: #12141a;
    --text-2: #3d4250;
    --muted: #6b7183;
    --accent: #6d4aff;
    --accent-hover: #5b37f0;
    --accent-soft: rgba(109, 74, 255, 0.10);
    --accent-text: #5b37f0;
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.10);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.09);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.10);
    --code-bg: #0f1117;
    --code-text: #d6dae4;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 20px 60px rgba(16, 24, 40, 0.18);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --bg: #f5f6f9;
        --bg-grad: radial-gradient(1200px 600px at 100% -10%, rgba(124, 92, 255, 0.08), transparent 60%);
        --surface: #ffffff;
        --surface-2: #f6f7fa;
        --surface-3: #eceef3;
        --border: #e4e6ec;
        --border-strong: #d3d6df;
        --text: #12141a;
        --text-2: #3d4250;
        --muted: #6b7183;
        --accent: #6d4aff;
        --accent-hover: #5b37f0;
        --accent-soft: rgba(109, 74, 255, 0.10);
        --accent-text: #5b37f0;
        --success: #16a34a;
        --success-soft: rgba(22, 163, 74, 0.10);
        --danger: #dc2626;
        --danger-soft: rgba(220, 38, 38, 0.09);
        --warning: #d97706;
        --warning-soft: rgba(217, 119, 6, 0.10);
        --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
        --shadow-lg: 0 20px 60px rgba(16, 24, 40, 0.18);
    }
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-grad), var(--bg);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
code, pre, kbd { font-family: var(--mono); }

.icon { flex-shrink: 0; display: block; }

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Layout + sidebar
   ========================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    width: 256px;
    height: 100vh;
    flex-shrink: 0;
    padding: 20px 14px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; }
.brand-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #22d3ee);
    box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand .sidebar-close { display: none; margin-left: auto; }

.side-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 8px 8px;
}

.project-switch {
    position: relative;
    display: flex;
    align-items: center;
}
.project-switch .dot { position: absolute; left: 12px; pointer-events: none; }
.project-switch select { width: 100%; padding-left: 30px; font-weight: 600; }

.new-bot-btn { margin-top: 8px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-link .icon { color: var(--muted); transition: color 0.15s; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link.active .icon { color: var(--accent-text); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.version { font-size: 12px; color: var(--muted); padding-right: 6px; }

.theme-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-ic-light { display: none; }
:root[data-theme="light"] .theme-ic-light { display: block; }
:root[data-theme="light"] .theme-ic-dark { display: none; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-ic-light { display: block; }
    :root:not([data-theme="dark"]) .theme-ic-dark { display: none; }
}

.sidebar-backdrop { display: none; }

.content {
    flex: 1;
    min-width: 0;
    padding: 32px clamp(16px, 3vw, 40px) 48px;
    max-width: 1280px;
}

.mobile-bar { display: none; }

/* ==========================================================================
   Page header
   ========================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 700; }
.page-sub { color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   Buttons + form controls
   ========================================================================== */
.btn {
    --btn-bg: var(--surface-2);
    --btn-border: var(--border);
    --btn-text: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-text);
    font: inherit;
    font-weight: 550;
    font-size: 13.5px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { --btn-bg: var(--surface-3); --btn-border: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

.btn-primary { --btn-bg: var(--accent); --btn-border: var(--accent); --btn-text: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, 0.3); }
.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-border: var(--accent-hover); }
.btn-success { --btn-bg: var(--success); --btn-border: var(--success); --btn-text: #fff; box-shadow: 0 4px 14px rgba(34, 197, 94, 0.25); }
.btn-success:hover { --btn-bg: #16a34a; --btn-border: #16a34a; }
.btn-danger { --btn-bg: var(--danger-soft); --btn-border: transparent; --btn-text: var(--danger); }
.btn-danger:hover { --btn-bg: var(--danger); --btn-border: var(--danger); --btn-text: #fff; }
.btn-warning { --btn-bg: var(--warning-soft); --btn-border: transparent; --btn-text: var(--warning); }
.btn-warning:hover { --btn-bg: var(--warning); --btn-border: var(--warning); --btn-text: #fff; }
.btn-ghost { --btn-bg: transparent; }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }

.icon-btn {
    width: 32px; height: 32px;
    display: inline-grid; place-items: center;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

input[type="text"], input[type="search"], select, textarea {
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
select {
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d8395' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field input { width: 100%; height: 40px; }

/* ==========================================================================
   Cards, panels, stats
   ========================================================================== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 9px; }
.panel-title .icon { color: var(--muted); }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.grid-2 > .panel { margin-bottom: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0;
}
.stat-icon {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    flex-shrink: 0;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent-text);
}
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.cyan { background: rgba(34, 211, 238, 0.12); color: #0ea5c6; }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat > div:last-child { min-width: 0; }

/* Hero (bot status) */
.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 24px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, var(--hero-tint, transparent), transparent 55%);
    pointer-events: none;
}
.hero.is-running { --hero-tint: rgba(34, 197, 94, 0.10); }
.hero.is-stopped { --hero-tint: rgba(124, 92, 255, 0.08); }
.hero-main { position: relative; display: flex; align-items: center; gap: 18px; min-width: 0; }
.hero-avatar {
    width: 56px; height: 56px;
    display: grid; place-items: center;
    flex-shrink: 0;
    border-radius: 16px;
    background: var(--surface-3);
    color: var(--text-2);
}
.is-running .hero-avatar { background: var(--success-soft); color: var(--success); }
.hero-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-meta { color: var(--muted); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero-actions { position: relative; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Status pill + dots */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
}
.pill-on { background: var(--success-soft); color: var(--success); }
.pill-off { background: var(--surface-3); color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--muted); }
.dot-on { background: var(--success); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: pulse 2s infinite; }
.dot-off { background: var(--muted); opacity: 0.7; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Bot list */
.bot-list { list-style: none; margin: 0; padding: 6px; }
.bot-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
}
.bot-list a:hover { background: var(--surface-2); }
.bot-list a.current { background: var(--accent-soft); }
.bot-list .bot-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-list .bot-state { font-size: 12px; color: var(--muted); }

/* Quick actions */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.quick {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.quick:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--surface); }
.quick .stat-icon { width: 36px; height: 36px; }
.quick strong { display: block; font-size: 13.5px; }
.quick small { color: var(--muted); font-size: 12px; }

/* ==========================================================================
   Log preview / log viewer / terminal
   ========================================================================== */
.console {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
}
.log-preview { margin: 0; padding: 14px 18px; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 0 0 var(--radius) var(--radius); }

.log-view {
    height: calc(100vh - 210px);
    min-height: 360px;
    overflow: auto;
    padding: 10px 0;
    border-radius: 0 0 var(--radius) var(--radius);
    counter-reset: line;
}
.log-line {
    display: flex;
    padding: 0 18px 0 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.log-line::before {
    counter-increment: line;
    content: counter(line);
    flex-shrink: 0;
    width: 56px;
    padding-right: 14px;
    text-align: right;
    color: #4b5263;
    user-select: none;
}
.log-line:hover { background: rgba(255, 255, 255, 0.03); }
.log-line.l-error { color: #ff7b7b; background: rgba(239, 68, 68, 0.06); }
.log-line.l-warn { color: #fbbf24; }
.log-line.l-sys { color: #a996ff; }
.log-line.hidden { display: none; }
.log-empty { padding: 40px; text-align: center; color: #6b7183; font-family: var(--font); }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle .track {
    width: 32px; height: 18px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    position: relative;
    transition: background 0.15s;
}
.toggle .track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(14px); background: #fff; }

/* Terminal */
.term {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    background: var(--code-bg);
}
.term-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    background: #12151c;
    border-bottom: 1px solid #1f2430;
    color: #8b92a5;
    font-size: 12.5px;
}
.term-dots { display: flex; gap: 7px; }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-dots i:nth-child(2) { background: #febc2e; }
.term-dots i:nth-child(3) { background: #28c840; }
.term-title { flex: 1; text-align: center; font-family: var(--mono); }
.term-bar .icon-btn { color: #8b92a5; width: 28px; height: 28px; }
.term-bar .icon-btn:hover { background: #1f2430; color: #e8eaf0; }

.term-body {
    height: calc(100vh - 290px);
    min-height: 340px;
    overflow-y: auto;
    padding: 16px 18px;
    cursor: text;
}
.term-body pre { margin: 2px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--code-text); font: inherit; }
.term-welcome { color: #7d8395; white-space: pre-wrap; margin-bottom: 8px; }
.term-welcome b { color: #a996ff; font-weight: 500; }
.term-cmd { color: #e8eaf0; margin-top: 6px; }
.term-cmd .prompt, .term-input .prompt { color: #22c55e; font-weight: 500; }
.term-cmd .prompt i, .term-input .prompt i { color: #7c8cff; font-style: normal; }
.term-exit { color: #6b7183; font-size: 11.5px; }
.term-exit.fail { color: #ff7b7b; }

.term-input { display: flex; align-items: center; gap: 10px; }
.term-input input {
    flex: 1;
    height: auto;
    padding: 2px 0;
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    box-shadow: none !important;
}
.term-running .term-input { opacity: 0.45; }
.spinner {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #a996ff;
    animation: spin 0.7s linear infinite;
    display: none;
}
.term-running .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip .icon { color: var(--muted); }

kbd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    font-size: 11px;
    color: var(--text-2);
}

/* ==========================================================================
   File manager
   ========================================================================== */
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13.5px; }
.crumbs a { color: var(--text-2); text-decoration: none; padding: 3px 7px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-3); color: var(--text); }
.crumbs a:last-child { color: var(--text); font-weight: 600; }
.crumbs .icon { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.muted { color: var(--muted); font-size: 13px; }
.col-name { width: 100%; }
.col-actions { text-align: right; }

.fname { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 500; color: var(--text); max-width: 520px; }
.fname span:last-child { overflow: hidden; text-overflow: ellipsis; }
a.fname:hover span:last-child { color: var(--accent-text); }

.ficon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; flex-shrink: 0; background: var(--surface-3); color: var(--muted); }
.ficon-folder { background: rgba(245, 158, 11, 0.13); color: #f59e0b; }
.ficon-py { background: rgba(59, 130, 246, 0.13); color: #3b82f6; }
.ficon-js, .ficon-php { background: rgba(234, 179, 8, 0.13); color: #ca8a04; }
.ficon-web { background: rgba(236, 72, 153, 0.12); color: #ec4899; }
.ficon-sh { background: var(--success-soft); color: var(--success); }
.ficon-data { background: rgba(34, 211, 238, 0.12); color: #0ea5c6; }
.ficon-zip { background: var(--accent-soft); color: var(--accent-text); }
.ficon-img { background: rgba(16, 185, 129, 0.12); color: #10b981; }

.row-actions { display: inline-flex; gap: 2px; opacity: 0.55; transition: opacity 0.15s; }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.03em; }

.dropzone { position: relative; }
.dropzone-overlay {
    position: absolute;
    inset: 8px;
    z-index: 5;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed var(--accent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--accent-text);
    font-weight: 600;
    font-size: 15px;
}
.dropzone.dragging .dropzone-overlay { display: flex; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-3); color: var(--muted); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { margin: 0 0 16px; }

.upload-progress { height: 3px; background: var(--accent); width: 0; transition: width 0.2s; border-radius: 3px; }

/* ==========================================================================
   Editor
   ========================================================================== */
.editor-shell { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); background: var(--code-bg); }
.editor-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    background: #12151c;
    border-bottom: 1px solid #1f2430;
    color: #8b92a5;
    font-size: 12.5px;
}
.editor-bar .file-tab { display: inline-flex; align-items: center; gap: 8px; color: #e8eaf0; font-family: var(--mono); }
.editor-bar .dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: #febc2e; display: none; }
.editor-shell.dirty .dirty-dot { display: inline-block; }
.code-editor {
    display: block;
    width: 100%;
    height: calc(100vh - 230px);
    min-height: 400px;
    margin: 0;
    padding: 16px;
    border: 0;
    border-radius: 0;
    resize: none;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.6;
    tab-size: 4;
    box-shadow: none !important;
}

/* CodeMirror theme */
.editor-shell .CodeMirror {
    height: calc(100vh - 230px);
    min-height: 400px;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.6;
}
.editor-shell .CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid #1a1e28; }
.editor-shell .CodeMirror-linenumber { color: #464d5e; padding: 0 12px 0 8px; }
.editor-shell .CodeMirror-cursor { border-left: 2px solid #a996ff; }
.editor-shell .CodeMirror-selected { background: rgba(124, 92, 255, 0.22) !important; }
.editor-shell .CodeMirror-activeline-background { background: rgba(255, 255, 255, 0.035); }
.editor-shell .CodeMirror-activeline-gutter .CodeMirror-linenumber { color: #a996ff; }
.editor-shell .CodeMirror-matchingbracket { color: #fff !important; background: rgba(124, 92, 255, 0.35); }
.editor-shell .CodeMirror-lines { padding: 12px 0; }
.editor-shell .cm-s-default .cm-keyword { color: #c792ea; }
.editor-shell .cm-s-default .cm-def { color: #82aaff; }
.editor-shell .cm-s-default .cm-variable { color: #d6dae4; }
.editor-shell .cm-s-default .cm-variable-2 { color: #f78c6c; }
.editor-shell .cm-s-default .cm-variable-3, .editor-shell .cm-s-default .cm-type { color: #ffcb6b; }
.editor-shell .cm-s-default .cm-property { color: #80cbc4; }
.editor-shell .cm-s-default .cm-builtin { color: #ffcb6b; }
.editor-shell .cm-s-default .cm-string, .editor-shell .cm-s-default .cm-string-2 { color: #c3e88d; }
.editor-shell .cm-s-default .cm-number { color: #f78c6c; }
.editor-shell .cm-s-default .cm-atom { color: #f78c6c; }
.editor-shell .cm-s-default .cm-comment { color: #5f6880; font-style: italic; }
.editor-shell .cm-s-default .cm-operator { color: #89ddff; }
.editor-shell .cm-s-default .cm-meta { color: #ffcb6b; }
.editor-shell .cm-s-default .cm-tag { color: #f07178; }
.editor-shell .cm-s-default .cm-attribute { color: #c792ea; }
.editor-shell .cm-s-default .cm-header { color: #82aaff; font-weight: 600; }
.editor-shell .cm-s-default .cm-link { color: #89ddff; }
.editor-shell .cm-s-default .cm-qualifier { color: #ffcb6b; }
.editor-shell .cm-s-default .cm-bracket { color: #89ddff; }

/* ==========================================================================
   Dialog + toasts + notice
   ========================================================================== */
.dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(5, 6, 10, 0.55); backdrop-filter: blur(4px); }
.dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.dialog form { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; }
.dialog-head h3 { font-size: 16px; }
.dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.dialog-icon { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent-text); }
.dialog-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 10px;
    min-width: 240px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    animation: toast-in 0.2s ease-out;
}
.toast .icon { color: var(--success); }
.toast.error .icon { color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.notice {
    display: flex; gap: 10px; align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 13px;
    margin-bottom: 20px;
}
.notice .icon { flex-shrink: 0; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.92em; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        z-index: 50;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        background: var(--surface);
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(5, 6, 10, 0.5); }
    .brand .sidebar-close { display: inline-grid; }

    .content { padding: 0 16px 32px; }
    .mobile-bar {
        position: sticky; top: 0; z-index: 30;
        display: flex; align-items: center; gap: 10px;
        margin: 0 -16px 20px;
        padding: 10px 16px;
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--border);
    }
    .mobile-project { margin-left: auto; font-size: 12px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .page-title { font-size: 20px; }
    .hero { padding: 18px; }
    .hero-actions { width: 100%; }
    .col-hide-sm { display: none; }
    .row-actions { opacity: 1; }
    th, td { padding: 10px 12px; }
    .fname { max-width: 52vw; }
    .term-body, .log-view, .code-editor, .editor-shell .CodeMirror { height: calc(100vh - 240px); }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
