/* ═══════════════════════════════════════════════════════════
   APanel v1.0 — Design System
   ═══════════════════════════════════════════════════════════ */

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

:root {
    --bg:       #050508;
    --surface:  #0a0a10;
    --surface2: #0d0d15;
    --border:   rgba(255,255,255,0.06);
    --border2:  rgba(255,255,255,0.10);

    --cyan:    #06b6d4;
    --cyan-dim: rgba(6,182,212,0.12);
    --cyan-border: rgba(6,182,212,0.22);

    --green:  #10b981;
    --yellow: #f59e0b;
    --red:    #f43f5e;
    --red-dim: rgba(244,63,94,0.10);
    --red-border: rgba(244,63,94,0.22);
    --purple: #7c3aed;

    --text:   #e2e8f0;
    --muted:  #64748b;
    --dim:    #2a3444;

    --mono:    'Space Mono', monospace;
    --display: 'Syne', sans-serif;

    --sidebar-w: 210px;
    --sub-w:     168px;
    --right-w:   272px;
    --topbar-h:  44px;
    --term-h:    118px;

    --radius:  6px;
    --radius-lg: 10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    min-height: 100vh;
    overflow: hidden;
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(6,182,212,0.18); border-radius: 2px; }

/* ── GRID BACKGROUND ─────────────────────────────────────── */
.grid-bg {
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image:
        linear-gradient(rgba(6,182,212,0.012) 1px, transparent 1px),
        linear-gradient(90deg, rgba(6,182,212,0.012) 1px, transparent 1px);
    background-size: 44px 44px;
}

/* ── LOGIN ───────────────────────────────────────────────── */
#login-screen {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-box {
    width: 360px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-lg);
    padding: 36px;
}
.login-logo {
    font-family: var(--display);
    font-size: 22px; font-weight: 800;
    color: #fff; letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.login-sub { font-size: 10px; color: var(--muted); margin-bottom: 28px; }
.login-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.login-field label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* ── APP SHELL ───────────────────────────────────────────── */
#app { display: none; position: relative; z-index: 1; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.ap-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 50;
}
.ap-logo {
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ap-logo-name {
    font-family: var(--display);
    font-size: 14px; font-weight: 800;
    color: #fff; letter-spacing: 0.06em;
}
.ap-logo-ver { font-size: 9px; color: var(--dim); margin-top: 2px; }

.ap-nav { flex: 1; padding: 10px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.ap-nav-section {
    font-size: 9px; color: var(--dim);
    text-transform: uppercase; letter-spacing: 0.14em;
    padding: 10px 8px 4px;
}
.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    transition: color 0.15s, background 0.15s;
    border-left: 2px solid transparent;
    user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    border-left-color: var(--cyan);
    padding-left: 8px;
}
.nav-item i { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
    margin-left: auto; font-size: 9px;
    padding: 1px 5px; border-radius: 3px;
    background: var(--cyan-dim); color: var(--cyan);
}

.ap-nav-bottom {
    padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── SUB-SIDEBAR (Vhosts list) ───────────────────────────── */
.ap-sub {
    position: fixed; top: 0; bottom: 0;
    left: var(--sidebar-w);
    width: var(--sub-w);
    background: var(--surface2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: transform 0.25s ease;
}
.ap-sub.hidden { transform: translateX(-100%); pointer-events: none; }
.ap-sub-header {
    padding: 12px 10px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.ap-sub-title { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.12em; }
.ap-sub-body { flex: 1; overflow-y: auto; padding: 8px; }
.vhost-item {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 8px; border-radius: var(--radius);
    font-size: 10px; color: var(--muted);
    cursor: pointer; transition: all 0.15s;
}
.vhost-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.vhost-item.active { background: rgba(255,255,255,0.05); color: var(--text); }
.vhost-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.vhost-dot.off { background: var(--dim); }
.ap-sub-footer { padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.btn-new-host {
    width: 100%; padding: 6px; font-size: 9px;
    text-align: center; font-family: var(--mono);
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--cyan-border); cursor: pointer;
    border: 1px dashed var(--cyan-border);
    border-radius: var(--radius); background: transparent;
    transition: all 0.15s;
}
.btn-new-host:hover { color: var(--cyan); border-color: var(--cyan); }

/* ── MAIN AREA ───────────────────────────────────────────── */
.ap-main {
    position: fixed; top: 0; bottom: 0; right: 0;
    left: calc(var(--sidebar-w) + var(--sub-w));
    display: flex; flex-direction: column;
    transition: left 0.25s ease;
}
.ap-main.no-sub { left: var(--sidebar-w); }

/* ── TOPBAR ──────────────────────────────────────────────── */
.ap-topbar {
    height: var(--topbar-h); flex-shrink: 0;
    background: rgba(5,5,8,0.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; gap: 12px;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.breadcrumb i { font-size: 13px; }
.breadcrumb-sep { color: var(--dim); }
.breadcrumb-cur { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.status-pill {
    display: flex; align-items: center; gap: 5px;
    font-size: 9px; color: var(--muted);
    padding: 4px 8px; border-radius: 20px;
    border: 1px solid var(--border);
}
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.status-dot.dead { background: var(--red); }
.ap-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--cyan-dim); border: 1px solid var(--cyan-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: var(--cyan); flex-shrink: 0;
}

/* ── CONTENT ─────────────────────────────────────────────── */
.ap-content {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 12px;
    min-height: 0;
}
/* When terminal is open, shrink content */
.has-terminal .ap-content { padding-bottom: 6px; }

/* ── STATS ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex-shrink: 0; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
}
.stat-label { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; }
.stat-val { font-size: 15px; color: var(--text); font-weight: bold; margin-top: 3px; }
.stat-bar { height: 2px; background: var(--bg); border-radius: 1px; margin-top: 6px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 1px; background: var(--cyan); transition: width 0.4s; }
.stat-fill.warn { background: var(--yellow); }
.stat-fill.danger { background: var(--red); }

/* ── CARD ────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); display: flex; flex-direction: column;
    overflow: hidden;
}
.card-header {
    padding: 9px 14px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0; gap: 8px;
}
.card-title { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text); }
.card-title i { font-size: 13px; color: var(--muted); }
.card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }

/* ── BADGE ───────────────────────────────────────────────── */
.badge {
    font-size: 9px; padding: 2px 7px; border-radius: 3px;
    background: var(--cyan-dim); border: 1px solid var(--cyan-border); color: var(--cyan);
}
.badge-green { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.25); color: var(--green); }
.badge-red   { background: var(--red-dim); border-color: var(--red-border); color: var(--red); }
.badge-muted { background: rgba(255,255,255,0.04); border-color: var(--border2); color: var(--muted); }

/* ── CODEMIRROR EDITOR ───────────────────────────────────── */
.CodeMirror {
    height: 100% !important;
    font-family: var(--mono) !important;
    font-size: 12px !important;
    border-radius: var(--radius);
}
.editor-wrap { flex: 1; min-height: 0; overflow: hidden; border-radius: var(--radius); }

/* ── EDITOR ACTIONS ──────────────────────────────────────── */
.editor-actions {
    padding: 10px 14px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
    font-family: var(--mono); font-size: 9px; font-weight: bold;
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 7px 14px; border-radius: var(--radius);
    border: none; cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary   { background: var(--cyan); color: #020608; }
.btn-primary:hover { background: #0891b2; }
.btn-green     { background: var(--green); color: #020a06; }
.btn-green:hover { background: #059669; }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-border); }
.btn-danger:hover { background: rgba(244,63,94,0.18); }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--border2); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-icon      { padding: 7px; display: flex; align-items: center; justify-content: center; }
.btn-icon i    { font-size: 14px; }

/* ── INPUTS ──────────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    background: #030305 !important;
    border: 1px solid var(--border2) !important;
    color: var(--text) !important;
    font-family: var(--mono); font-size: 12px;
    padding: 9px 12px; border-radius: var(--radius);
    outline: none; transition: border-color 0.2s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--cyan) !important;
    box-shadow: 0 0 0 2px rgba(6,182,212,0.08);
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 80px; }

/* ── RIGHT PANEL (AI + Logs) ─────────────────────────────── */
.ap-right {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: var(--right-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 50;
    transition: transform 0.25s ease;
}
.ap-right.hidden { transform: translateX(100%); pointer-events: none; }

.right-tabs {
    display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
    padding: 0 2px;
}
.right-tab {
    flex: 1; padding: 10px 4px; font-size: 10px;
    text-align: center; color: var(--dim); cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.15s;
    font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
}
.right-tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.right-tab:hover:not(.active) { color: var(--muted); }

/* Chat */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 10px;
    display: flex; flex-direction: column; gap: 8px;
}
.chat-msg { font-size: 11px; line-height: 1.55; padding: 8px 10px; border-radius: var(--radius); }
.chat-msg-label { font-size: 9px; color: var(--dim); margin-bottom: 3px; }
.chat-msg.ai { background: var(--surface2); border: 1px solid var(--border); }
.chat-msg.user {
    background: var(--cyan-dim); border: 1px solid var(--cyan-border);
    align-self: flex-end; max-width: 95%;
}
.think-block {
    background: rgba(0,0,0,0.3); border-left: 2px solid var(--purple);
    padding: 6px 10px; font-style: italic; color: var(--muted);
    font-size: 10px; margin-bottom: 5px; border-radius: 0 var(--radius) var(--radius) 0;
}
.ai-action-box {
    margin-top: 10px; padding: 10px;
    background: rgba(6,182,212,0.03); border: 1px solid var(--cyan-border);
    border-radius: var(--radius);
}
.ai-action-label { font-size: 9px; color: var(--cyan); font-weight: bold; margin-bottom: 7px; letter-spacing: 0.04em; }
.ai-action-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.chat-input-area {
    padding: 10px; border-top: 1px solid var(--border);
    display: flex; gap: 6px; flex-shrink: 0;
}
.chat-input-area input { flex: 1; width: auto !important; }
.btn-send {
    background: var(--cyan-dim); color: var(--cyan);
    border: 1px solid var(--cyan-border);
    border-radius: var(--radius); padding: 0 12px;
    font-size: 13px; cursor: pointer; transition: all 0.15s;
    font-family: var(--mono);
}
.btn-send:hover { background: var(--cyan); color: #020608; }

/* Logs tab */
.logs-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.log-entry {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 10px;
    font-size: 10px; line-height: 1.5;
}
.log-ts { font-size: 9px; color: var(--dim); margin-bottom: 3px; }
.log-op { color: var(--text); font-weight: bold; margin-bottom: 2px; }
.log-msg { color: var(--muted); }

/* ── TERMINAL DRAWER ─────────────────────────────────────── */
.ap-terminal {
    height: var(--term-h); flex-shrink: 0;
    background: #020204;
    border-top: 1px solid rgba(6,182,212,0.18);
    display: flex; flex-direction: column;
    transition: height 0.2s ease;
}
.ap-terminal.collapsed { height: 34px; }
.term-header {
    padding: 0 12px; height: 34px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.term-title { font-size: 9px; color: #1a3040; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: 0.1em; }
.term-title span { color: var(--cyan); }
.term-collapse-btn {
    background: none; border: none; color: var(--dim); cursor: pointer; padding: 2px 4px;
    font-size: 12px; transition: color 0.15s;
}
.term-collapse-btn:hover { color: var(--cyan); }
.term-body { flex: 1; padding: 8px 12px; font-size: 11px; line-height: 1.65; color: #1a4a35; overflow-y: auto; min-height: 0; }
.term-green { color: #10b981; }
.term-cyan  { color: #06b6d4; }
.term-white { color: #475569; }
.term-red   { color: #f43f5e; }
.term-input-row {
    padding: 6px 12px; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.term-prompt { font-size: 10px; color: var(--cyan); white-space: nowrap; flex-shrink: 0; }
.term-input {
    flex: 1; background: transparent !important;
    border: none !important; outline: none !important;
    box-shadow: none !important;
    color: var(--text) !important;
    font-size: 11px; font-family: var(--mono); padding: 0 !important; width: auto !important;
}
.term-cursor {
    display: inline-block; width: 7px; height: 12px;
    background: var(--cyan); opacity: 0.7; vertical-align: middle;
    animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(2,2,4,0.82); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
}
.modal-box {
    width: 440px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: var(--radius-lg); padding: 26px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    position: relative; max-height: 90vh; overflow-y: auto;
}
.modal-box::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 2px; background: linear-gradient(90deg, var(--cyan), var(--purple));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-family: var(--display); font-size: 14px; font-weight: 800; color: #fff; margin-bottom: 20px; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast {
    position: fixed; bottom: 20px; right: 20px; z-index: 300;
    padding: 10px 18px; font-size: 11px; border-radius: var(--radius);
    display: none; animation: slideup 0.2s ease;
}
@keyframes slideup { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
#toast.success { background: var(--green); color: #fff; }
#toast.error   { background: var(--red); color: #fff; }

/* ── SECTION PAGES (non-hosts sections full width) ───────── */
.section-page { padding: 20px; display: flex; flex-direction: column; gap: 16px; flex: 1; overflow-y: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.page-title { font-family: var(--display); font-size: 18px; font-weight: 800; color: #fff; }
.page-sub { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* Table */
.ap-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ap-table th {
    text-align: left; padding: 8px 10px; font-size: 9px;
    color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border); background: var(--surface2);
}
.ap-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--muted); }
.ap-table tr:hover td { background: rgba(255,255,255,0.02); }
.ap-table td.mono { font-family: var(--mono); color: var(--cyan); }

/* Playground */
.pg-grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; flex: 1; min-height: 0; }
.pg-settings { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.pg-chat { display: flex; flex-direction: column; min-height: 0; }
.pg-messages {
    flex: 1; overflow-y: auto; padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--border); border-bottom: none;
}
.pg-msg-user { align-self: flex-end; max-width: 88%; background: var(--cyan-dim); border: 1px solid var(--cyan-border); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.pg-msg-ai   { align-self: flex-start; max-width: 95%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.pg-msg-ai.media img { max-width: 100%; border-radius: var(--radius); margin-top: 6px; }
.pg-msg-ai.media audio { width: 100%; margin-top: 6px; }
.pg-input-row {
    background: var(--surface); border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 10px; display: flex; gap: 8px;
}
.pg-input-row input { flex: 1; width: auto !important; }
.streaming-indicator { color: var(--cyan); font-size: 10px; display: flex; align-items: center; gap: 6px; padding: 6px 0; }

/* Docs */
.docs-hero {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px;
    position: relative; overflow: hidden;
}
.docs-hero::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--purple), var(--green));
}
.docs-title { font-family: var(--display); font-size: 20px; font-weight: 800; color: #fff; }
.docs-desc { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.docs-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.docs-tag {
    font-size: 10px; padding: 3px 10px; border-radius: 4px; font-family: var(--mono);
}
.docs-tag.green { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: var(--green); }
.docs-tag.cyan  { background: var(--cyan-dim); border: 1px solid var(--cyan-border); color: var(--cyan); }
.docs-tag.yellow { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); color: var(--yellow); }

.docs-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.docs-section-title { font-size: 12px; font-weight: bold; color: var(--text); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.docs-section-title i { color: var(--cyan); font-size: 14px; }

pre.code-block {
    background: #020204; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; overflow-x: auto;
    font-family: var(--mono); font-size: 11px; color: #94a3b8; line-height: 1.7;
    white-space: pre; tab-size: 2;
}
.lang-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.lang-tab {
    padding: 4px 10px; font-size: 9px; font-family: var(--mono);
    text-transform: uppercase; letter-spacing: 0.08em;
    border: 1px solid var(--border); border-radius: 4px;
    color: var(--muted); cursor: pointer; transition: all 0.15s; background: transparent;
}
.lang-tab.active { background: var(--cyan-dim); border-color: var(--cyan-border); color: var(--cyan); }

/* Personas */
.personas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.persona-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.persona-name { font-size: 11px; font-weight: bold; font-family: var(--mono); color: var(--cyan); margin-bottom: 4px; }
.persona-desc { font-size: 10px; color: var(--muted); line-height: 1.5; }

/* Markdown in AI chat */
.md-body p { margin-bottom: 0.7rem; }
.md-body code { background: rgba(6,182,212,0.1); padding: 0.1rem 0.35rem; border-radius: 3px; font-family: var(--mono); font-size: 0.9em; color: var(--cyan); }
.md-body pre { background: #020204; padding: 10px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 0.7rem; border: 1px solid var(--border); }
.md-body pre code { background: transparent; padding: 0; color: #94a3b8; }
.md-body ul, .md-body ol { margin-left: 1.2rem; margin-bottom: 0.7rem; }
.md-body li { margin-bottom: 0.2rem; }
.md-body strong { color: #fff; }

/* Resources page */
.resources-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ═══════════════════════════════════════════════════════════
   MOBILE — fullscreen nav (< 1024px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
    body { overflow: hidden; }

    /* Sidebar becomes bottom tab bar */
    .ap-sidebar {
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%; height: 54px;
        flex-direction: row;
        border-right: none; border-top: 1px solid var(--border);
        z-index: 100;
    }
    .ap-logo { display: none; }
    .ap-nav {
        flex-direction: row; padding: 0;
        overflow-x: auto; overflow-y: hidden;
        gap: 0; flex: 1;
        -webkit-overflow-scrolling: touch;
    }
    .ap-nav-section { display: none; }
    .nav-item {
        flex-direction: column; gap: 2px;
        padding: 8px 6px; font-size: 8px;
        border-left: none; border-top: 2px solid transparent;
        border-radius: 0; min-width: 54px;
        justify-content: center; align-items: center;
    }
    .nav-item span { display: block; line-height: 1.1; text-align: center; }
    .nav-item.active { border-left: none; border-top-color: var(--cyan); background: var(--cyan-dim); padding-left: 6px; }
    .nav-item i { font-size: 18px; width: auto; }
    .nav-item .nav-badge { display: none; }
    .ap-nav-bottom { display: none; }

    /* Sub-sidebar becomes fullscreen */
    .ap-sub {
        top: 0; left: 0; bottom: 54px; right: 0;
        width: 100%; border-right: none;
        z-index: 90;
    }
    .ap-sub.hidden { transform: translateX(-100%); }

    /* Main takes full screen minus bottom bar */
    .ap-main {
        left: 0 !important; top: 0; bottom: 54px; right: 0;
    }

    /* Right panel fullscreen */
    .ap-right {
        top: 0; bottom: 54px; right: 0; left: 0;
        width: 100%; border-left: none;
        z-index: 90;
    }
    .ap-right.hidden { transform: translateX(100%); }

    /* Terminal */
    .ap-terminal { height: 180px; }
    .ap-terminal.collapsed { height: 34px; }

    /* Stats: stack 1 col on very small screens */
    .stats-grid { grid-template-columns: repeat(3, 1fr); }

    /* Playground: stack */
    .pg-grid { grid-template-columns: 1fr; }

    /* Personas: 1 col */
    .personas-grid { grid-template-columns: 1fr; }

    /* Resources */
    .resources-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .modal-box { width: 100%; margin: 0 16px; }
    .ap-table th:nth-child(2), .ap-table td:nth-child(2) { display: none; }
}
