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

:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface2: #1e1e1e;
    --surface3: #252525;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text-dim: #888;
    --text-faint: #555;
    --accent: #4a9eff;
    --accent-dim: #1a3a5f;
    --success: #4caf50;
    --success-dim: #1a3a1e;
    --warning: #ff9800;
    --warning-dim: #3a2a00;
    --error: #f44336;
    --error-dim: #3a1010;
    --font: 'Menlo', 'Consolas', 'Monaco', monospace;
    --radius: 6px;
    --header-h: 44px;
    --mobile-nav-h: 56px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ── Header ── */
header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

header h1 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--accent);
    flex-shrink: 0;
}

.status { font-size: 9px; transition: color 0.3s; flex-shrink: 0; }
.status.connected { color: var(--success); }
.status.disconnected { color: var(--error); }

#desktop-nav { display: flex; gap: 1px; margin-left: auto; overflow-x: auto; }

.tab {
    background: none;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 5px 11px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 11px;
    border-radius: var(--radius);
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { color: var(--accent); border-color: var(--border); background: var(--surface2); }
.tab.has-alert { color: var(--warning); }
.tab.has-alert.active { color: var(--warning); border-color: var(--warning-dim); }

main { flex: 1; overflow: hidden; position: relative; min-height: 0; }

.tab-content { display: none; height: 100%; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* ── Mobile bottom nav (hidden on desktop) ── */
#mobile-nav { display: none; }

/* ── mobile-only elements are hidden on desktop ── */
.mobile-only { display: none; }

/* ── Split-pane containers (Identity, Tools, Memories, Scheduler, Agents, Logs) ── */
.split-container { display: flex; height: 100%; overflow: hidden; }

/* ── Shared editor layout ── */
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    flex-shrink: 0;
    min-height: 36px;
    gap: 8px;
}
.editor-filename { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.editor-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.error-msg { color: var(--error); font-size: 11px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

.btn-save {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 4px 14px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.btn-save:hover { opacity: 0.85; }
.btn-save:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-delete {
    background: var(--error-dim);
    color: var(--error);
    border: 1px solid var(--error);
    padding: 4px 14px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.btn-delete:hover { opacity: 0.8; }
.btn-delete:disabled { opacity: 0.25; cursor: not-allowed; }

.btn-new {
    background: var(--success-dim);
    color: var(--success);
    border: 1px solid var(--success);
    padding: 4px 10px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
}
.btn-new:hover { opacity: 0.8; }

/* Back button — desktop no-op, shown on mobile */
.btn-back {
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--font);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 8px 2px 0;
    flex-shrink: 0;
}
.btn-back:hover { opacity: 0.75; }

/* Detail-back-bar: a slim bar at the top of non-textarea detail panes */
.detail-back-bar {
    display: none; /* shown only on mobile via media query */
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* Scroll wrapper inside detail panes that don't have a textarea */
.detail-scroll-inner { flex: 1; overflow-y: auto; padding: 16px; }

.panel-title { font-size: 11px; color: var(--text-dim); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.dim { color: var(--text-faint); font-size: 11px; }
.placeholder { color: var(--text-dim); font-style: italic; font-size: 12px; }

/* ── Shared sidebar ── */
.sidebar-list {
    overflow-y: auto;
    padding: 6px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.list-item {
    padding: 7px 10px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    margin-bottom: 2px;
    transition: background 0.1s;
}
.list-item:hover { background: var(--surface2); }
.list-item.active { background: var(--accent-dim); color: var(--accent); }
.list-item.quarantined { color: var(--error); }
.list-item.quarantined .item-sub { color: var(--error); opacity: 0.7; }
.item-name { font-weight: 600; }
.item-sub { font-size: 10px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Chat ── */
#chat-messages { flex: 1; overflow-y: auto; padding: 16px; }

.message { margin-bottom: 16px; max-width: 85%; line-height: 1.5; }
.message.user { margin-left: auto; text-align: right; }
.message .role {
    font-size: 10px; color: var(--text-dim); margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: 1px;
}
.message .content {
    background: var(--surface2); padding: 10px 14px; border-radius: 8px;
    font-size: 13px; white-space: pre-wrap; word-break: break-word;
}
.message.user .content { background: var(--accent-dim); }
.message.status .content {
    background: none; color: var(--text-dim); font-style: italic; font-size: 12px; padding: 4px 0;
}

#chat-input-area {
    display: flex; gap: 8px; padding: 12px 16px;
    border-top: 1px solid var(--border); background: var(--surface);
    flex-shrink: 0;
}
#chat-input {
    flex: 1; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 12px; font-family: var(--font);
    font-size: 13px; border-radius: var(--radius); resize: none; max-height: 120px;
}
#chat-input:focus { outline: none; border-color: var(--accent); }
#chat-send {
    background: var(--accent); color: #000; border: none; padding: 10px 20px;
    font-family: var(--font); font-size: 13px; font-weight: 700;
    border-radius: var(--radius); cursor: pointer;
}
#chat-send:hover { opacity: 0.9; }

/* ── Status ── */
#status-container { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

#status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.stat-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-card.has-warning { border-color: var(--warning); background: var(--warning-dim); }
.stat-card.has-error { border-color: var(--error); background: var(--error-dim); }
.stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-value.ok { color: var(--success); }
.stat-value.warn { color: var(--warning); }
.stat-value.bad { color: var(--error); }
.stat-sub { font-size: 10px; color: var(--text-dim); margin-top: 4px; }

#status-broken { flex: 1; overflow-y: auto; padding: 16px; }
#status-broken h3 { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }

.broken-card {
    background: var(--surface2);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.broken-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; background: var(--error-dim); cursor: pointer;
}
.broken-card-name { font-weight: 700; color: var(--error); font-size: 13px; }
.broken-card-meta { font-size: 10px; color: var(--text-dim); }
.broken-card-body { padding: 12px 14px; display: none; }
.broken-card-body.open { display: block; }
.broken-reason { font-size: 12px; color: var(--warning); margin-bottom: 8px; }
.broken-repair { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.broken-error {
    background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
    padding: 10px; font-size: 11px; line-height: 1.5; overflow-x: auto;
    white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}

/* ── Identity ── */
#identity-container { display: flex; height: 100%; }
#identity-file-list { width: 190px; }
#identity-editor-area { flex: 1; display: flex; flex-direction: column; }
#identity-editor {
    flex: 1; background: var(--bg); border: none; color: var(--text);
    padding: 16px; font-family: var(--font); font-size: 13px;
    resize: none; line-height: 1.6;
}
#identity-editor:focus { outline: none; }
#identity-editor:disabled { color: var(--text-dim); }

/* ── Tools ── */
#tools-container { display: flex; height: 100%; }
#tools-list { width: 220px; }
#tool-detail { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#tool-detail .detail-scroll-inner h3 { font-size: 15px; margin-bottom: 6px; color: var(--accent); }
#tool-detail .detail-scroll-inner .tool-description { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
#tool-detail .detail-scroll-inner h4 { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; margin-top: 14px; }
#tool-detail .detail-scroll-inner pre {
    background: var(--surface2); padding: 12px 14px; border-radius: var(--radius);
    font-size: 12px; overflow-x: auto; line-height: 1.5; margin-bottom: 10px;
}
/* Legacy selectors kept for JS innerHTML injection */
#tool-detail h3 { font-size: 15px; margin-bottom: 6px; color: var(--accent); }
#tool-detail .tool-description { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.5; }
#tool-detail h4 { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; margin-top: 14px; }
#tool-detail pre {
    background: var(--surface2); padding: 12px 14px; border-radius: var(--radius);
    font-size: 12px; overflow-x: auto; line-height: 1.5; margin-bottom: 10px;
}
.tool-quarantine-banner {
    background: var(--error-dim); border: 1px solid var(--error);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
    font-size: 12px; color: var(--error); line-height: 1.5;
}
.tool-quarantine-banner strong { display: block; margin-bottom: 4px; }

/* ── Memories ── */
#memories-container { display: flex; height: 100%; }
#memories-sidebar { width: 240px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
#memories-toolbar { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
#memories-search {
    flex: 1; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 5px 9px; font-family: var(--font);
    font-size: 11px; border-radius: 4px; min-width: 0;
}
#memories-search:focus { outline: none; border-color: var(--accent); }
#memories-list { flex: 1; overflow-y: auto; padding: 6px; }

.memory-item { padding: 8px 10px; cursor: pointer; border-radius: 4px; margin-bottom: 2px; }
.memory-item:hover { background: var(--surface2); }
.memory-item.active { background: var(--accent-dim); color: var(--accent); }
.memory-title { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-meta { font-size: 10px; color: var(--text-dim); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.memory-tag {
    background: var(--surface3); border-radius: 3px; padding: 1px 5px;
    font-size: 10px; color: var(--text-dim);
}
.importance-high .memory-title::before { content: "⬆ "; color: var(--warning); }
.importance-low .memory-title::before { content: "⬇ "; color: var(--text-faint); }

#memory-editor-area { flex: 1; display: flex; flex-direction: column; }
#memory-editor {
    flex: 1; background: var(--bg); border: none; color: var(--text);
    padding: 16px; font-family: var(--font); font-size: 13px;
    resize: none; line-height: 1.6;
}
#memory-editor:focus { outline: none; }
#memory-editor:disabled { color: var(--text-dim); }

/* ── Scheduler ── */
#scheduler-container { display: flex; height: 100%; }
#scheduler-jobs-panel { width: 260px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
#scheduler-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
#scheduler-jobs-list { flex: 1; overflow-y: auto; padding: 8px; }

.cron-item {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
}
.cron-item.enabled { border-color: var(--success-dim); }
.cron-item.disabled { opacity: 0.5; }
.cron-schedule { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.cron-type { font-size: 10px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 4px; }
.cron-task { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cron-enabled { font-size: 10px; margin-top: 4px; }
.cron-enabled.on { color: var(--success); }
.cron-enabled.off { color: var(--text-faint); }

#scheduler-editor-area { flex: 1; display: flex; flex-direction: column; }
#scheduler-editor {
    flex: 1; background: var(--bg); border: none; color: var(--text);
    padding: 16px; font-family: var(--font); font-size: 12px;
    resize: none; line-height: 1.6; tab-size: 2;
}
#scheduler-editor:focus { outline: none; }

/* ── Agents ── */
#agents-container { display: flex; height: 100%; }
#agents-list { width: 200px; }
#agent-detail { flex: 1; display: flex; flex-direction: column; }
#agent-detail .detail-scroll-inner h3 { font-size: 15px; color: var(--accent); margin-bottom: 14px; }
#agent-detail .detail-scroll-inner h4 { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 6px; }
#agent-detail .detail-scroll-inner pre {
    background: var(--surface2); padding: 12px 14px; border-radius: var(--radius);
    font-size: 12px; overflow-x: auto; line-height: 1.5;
}
/* Legacy */
#agent-detail h3 { font-size: 15px; color: var(--accent); margin-bottom: 14px; }
#agent-detail h4 { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 6px; }
#agent-detail pre {
    background: var(--surface2); padding: 12px 14px; border-radius: var(--radius);
    font-size: 12px; overflow-x: auto; line-height: 1.5;
}

/* ── Logs ── */
#logs-container { display: flex; height: 100%; }
#logs-date-list { width: 120px; }
#logs-file-list { width: 230px; }
#log-content {
    flex: 1; overflow: auto; padding: 16px;
    font-size: 12px; line-height: 1.5;
    white-space: pre-wrap; word-break: break-all;
}
#log-content.placeholder { color: var(--text-dim); font-style: italic; }
.log-size { font-size: 10px; color: var(--text-faint); float: right; }

/* Apply sidebar-list styles */
#identity-file-list,
#tools-list,
#agents-list,
#logs-date-list,
#logs-file-list {
    overflow-y: auto;
    padding: 6px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.file-item { padding: 7px 10px; cursor: pointer; font-size: 12px; border-radius: 4px; margin-bottom: 2px; }
.file-item:hover { background: var(--surface2); }
.file-item.active { background: var(--accent-dim); color: var(--accent); }
.file-item.readonly { color: var(--text-dim); }

.tool-item { padding: 8px 10px; cursor: pointer; font-size: 12px; border-radius: 4px; margin-bottom: 2px; }
.tool-item:hover { background: var(--surface2); }
.tool-item.active { background: var(--accent-dim); color: var(--accent); }
.tool-item.quarantined-item { border-left: 2px solid var(--error); padding-left: 8px; }
.tool-item .tool-name { font-weight: 600; }
.tool-item .tool-desc { font-size: 10px; color: var(--text-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.agent-item { padding: 8px 10px; cursor: pointer; font-size: 12px; border-radius: 4px; margin-bottom: 2px; }
.agent-item:hover { background: var(--surface2); }
.agent-item.active { background: var(--accent-dim); color: var(--accent); }

.log-date-item, .log-file-item {
    padding: 6px 10px; cursor: pointer; font-size: 12px; border-radius: 4px; margin-bottom: 2px;
}
.log-date-item:hover, .log-file-item:hover { background: var(--surface2); }
.log-date-item.active, .log-file-item.active { background: var(--accent-dim); color: var(--accent); }

/* ── Auth & confirm modals ── */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }

.modal-content {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 28px 32px; text-align: center; min-width: 300px;
}
.modal-content h2 { font-size: 18px; color: var(--accent); margin-bottom: 20px; letter-spacing: 3px; }
.modal-content p { font-size: 13px; color: var(--text); margin-bottom: 20px; }
.modal-content input {
    width: 100%; background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 10px 12px; font-family: var(--font);
    font-size: 13px; border-radius: var(--radius); margin-bottom: 12px;
}
.modal-content input:focus { outline: none; border-color: var(--accent); }
.modal-content button {
    background: var(--accent); color: #000; border: none; padding: 10px;
    font-family: var(--font); font-size: 13px; font-weight: 700;
    border-radius: var(--radius); cursor: pointer; width: 100%;
}
.confirm-buttons { display: flex; gap: 8px; }
.confirm-buttons button { flex: 1; }

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


/* ════════════════════════════════════════════════════════════════════════════
   MOBILE  (≤ 768 px)
   Everything below only applies to narrow viewports.
   Desktop layout is completely untouched.
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* -- Slightly larger base text for readability on small screens -- */
    :root {
        --radius: 8px;
    }

    /* -- Header: hide desktop nav, shrink height -- */
    #desktop-nav { display: none; }

    header {
        height: 48px;
        padding: 0 14px;
    }
    header h1 { font-size: 14px; letter-spacing: 4px; }

    /* -- Show mobile-only elements -- */
    .mobile-only { display: flex !important; }

    /* -- Bottom navigation bar -- */
    #mobile-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
        height: var(--mobile-nav-h);
        background: var(--surface);
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        /* safe area inset for iPhone home indicator */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mob-tab {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        background: none;
        border: none;
        font-size: 20px;
        cursor: pointer;
        position: relative;
        transition: background 0.12s;
        -webkit-tap-highlight-color: transparent;
    }
    .mob-tab:active { background: var(--surface2); }
    .mob-tab.active::after {
        content: '';
        position: absolute;
        bottom: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--accent);
    }
    .mob-tab.has-alert::before {
        content: '●';
        position: absolute;
        top: 6px;
        right: calc(50% - 14px);
        font-size: 7px;
        color: var(--warning);
    }

    /* -- Main area must account for both header and bottom nav -- */
    main {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    /* ── Split-pane mobile behaviour ──
       On mobile, the list and detail panes are stacked full-width.
       Only one is visible at a time, toggled by JS adding .mob-show-detail.
    ── */
    .split-container {
        position: relative;
        overflow: hidden;
    }

    .split-pane {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        transition: transform 0.22s ease;
        background: var(--bg);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* List pane: default visible, slides left when detail is shown */
    .split-list {
        transform: translateX(0);
        z-index: 1;
        /* Remove fixed desktop widths */
        width: 100% !important;
        border-right: none !important;
        flex-shrink: unset !important;
    }

    /* Detail pane: starts off-screen to the right */
    .split-detail {
        transform: translateX(100%);
        z-index: 2;
        width: 100% !important;
    }

    /* When JS adds .mob-show-detail to .split-container: */
    .split-container.mob-show-detail .split-list {
        transform: translateX(-100%);
    }
    .split-container.mob-show-detail .split-detail {
        transform: translateX(0);
    }

    /* -- Back button bar in detail panes -- */
    .detail-back-bar {
        display: flex !important;
    }

    /* -- Textareas inside detail panes grow to fill -- */
    #identity-editor,
    #memory-editor,
    #scheduler-editor {
        font-size: 14px;
        padding: 12px;
    }

    /* -- Editor header: tighten up on small screens -- */
    .editor-header {
        padding: 8px 10px;
        min-height: 44px; /* bigger tap target */
    }
    .btn-save, .btn-delete {
        padding: 6px 12px;
        font-size: 12px;
    }
    .btn-back {
        font-size: 15px;
        padding: 2px 10px 2px 0;
    }

    /* -- Chat: bigger input area, full-width send button on very narrow screens -- */
    #chat-messages { padding: 12px; }
    #chat-input-area {
        padding: 10px 12px;
        /* Push above the home indicator on iPhone */
        padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    }
    #chat-input {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 10px;
    }
    #chat-send {
        padding: 10px 16px;
        font-size: 14px;
    }
    .message { max-width: 92%; }
    .message .content { font-size: 14px; }

    /* -- Status: single-column grid -- */
    #status-grid {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
        gap: 8px;
    }
    .stat-value { font-size: 20px; }

    /* -- Memories sidebar search -- */
    #memories-toolbar { padding: 10px 8px; gap: 8px; }
    #memories-search { font-size: 14px; padding: 8px 10px; }
    .memory-item { padding: 10px 12px; }
    .memory-title { font-size: 13px; }

    /* -- Cron list items -- */
    .cron-item { padding: 12px; }
    .cron-schedule { font-size: 13px; }
    .cron-task { white-space: normal; }

    /* -- Logs: three-pane becomes two steps on mobile --
       date list → file list → content
       We reuse the same .mob-show-detail class on the outer container,
       but the logs JS manages two levels with data-logs-level attribute.
    ── */
    #logs-container {
        flex-direction: column; /* stack in DOM order; JS handles visibility */
    }
    #logs-date-list, #logs-file-list {
        width: 100% !important;
        border-right: none !important;
    }
    #logs-content-pane {
        width: 100% !important;
    }
    #log-content {
        padding: 12px;
        font-size: 12px;
    }

    /* -- Tool detail -- */
    #tool-detail pre { font-size: 11px; }

    /* -- Modals -- */
    .modal-content {
        min-width: unset;
        width: calc(100vw - 32px);
        padding: 24px 20px;
    }
}
