/* ══════════════════════════════════════════════════
   shell.css — persistent shell: variables, reset, rail, sidebar, account menu, app-container
   ══════════════════════════════════════════════════ */

/* ── CSS Variables & Reset ─────────────────────── */
:root {
    color-scheme: dark;
    --bg-primary: #0f0f0f;
    --bg-panel: #1a1a1a;
    --bg-surface: #242424;
    --bg-hover: #2a2a2a;
    --border: #2e2e2e;
    --text-primary: #e5e5e5;
    --text-secondary: #888;
    --text-muted: #555;
    --accent: #00B4EA;
    --accent-hover: #007CD5;
    --accent-magenta: #ED1A77;
    --user-bubble: #1e3a5f;
    --link: #60a5fa;
    --radius: 8px;
    /* Layout shell */
    --rail-width: 58px;
    --sidebar-width: 280px;
    --sidebar-bg: #1b1b1b;
}

/* ── Light theme overrides ──────────────────────── */
html[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f5f5f5;
    --bg-panel: #ffffff;
    --bg-surface: #ebebeb;
    --bg-hover: #e2e2e2;
    --border: #d4d4d4;
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #999;
    --user-bubble: #dbeafe;
    --link: #2563eb;
    --sidebar-bg: #ebebeb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ── App shell (column: content-row + status-bar) ── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.app-shell-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Icon rail ──────────────────────────────────── */
.icon-rail {
    width: var(--rail-width);
    min-width: var(--rail-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    flex-shrink: 0;
}
.icon-rail-top, .icon-rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.rail-logo {
    background: none; border: none; cursor: pointer;
    padding: 4px; border-radius: 8px;
    color: var(--text-primary);
    transition: opacity 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.rail-logo:hover { opacity: 0.7; }
.rail-separator {
    width: 28px; height: 1px;
    background: var(--border); margin: 4px 0;
}
.rail-btn {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    background: none; border: none; cursor: pointer;
    padding: 8px 4px; border-radius: 10px;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
    width: 48px;
}
.rail-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.rail-btn.active {
    color: var(--accent);
    background: radial-gradient(ellipse at center,
        color-mix(in srgb, var(--accent) 22%, transparent) 0%,
        color-mix(in srgb, var(--accent-magenta, var(--accent)) 8%, transparent) 50%,
        transparent 80%);
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 45%, transparent),
                0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
}
.rail-label { font-size: 10px; line-height: 1.1; white-space: nowrap; }

/* ── Rail context actions (per-app) ────────────── */
.rail-context-sep {
    width: 28px;
    margin: 6px 0 4px;
    opacity: 0.6;
}
.rail-context-btn {
    width: 38px;
    padding: 6px 4px !important;
}
.rail-context-btn svg { opacity: 0.75; }
.rail-context-btn:hover svg { opacity: 1; }
.rail-context-btn.active svg { opacity: 1; }

/* ── Docs button — smaller than main app buttons ── */
.rail-docs {
    width: 38px;
    padding: 6px 4px;
    opacity: 0.7;
}
.rail-docs:hover { opacity: 1; }
.rail-docs svg { width: 18px; height: 18px; }

/* ── Bottom-rail apps container ─────────────────── */
#icon-rail-bottom-apps {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.account-menu {
    display: none;
    position: fixed;
    top: 40px;
    right: 12px;
    width: 260px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    z-index: 600;
    padding: 6px;
    animation: account-menu-in 0.15s ease-out;
}
.account-menu.open { display: block; }
@keyframes account-menu-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.account-menu-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 8px; cursor: pointer;
    transition: background 0.15s;
}
.account-menu-user:hover { background: var(--bg-hover); }

.account-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-surface); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); flex-shrink: 0;
    font-size: 14px; font-weight: 600;
    overflow: hidden;
}
.account-avatar.has-initial { font-size: 16px; color: var(--text-primary); background: var(--accent); border-color: var(--accent); }

.account-info { flex: 1; min-width: 0; }
.account-name {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-email {
    font-size: 11px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.account-menu-sep {
    height: 1px; background: var(--border); margin: 4px 6px;
}

.account-menu-item {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 8px 10px; border-radius: 6px;
    background: none; border: none; cursor: pointer;
    color: var(--text-primary); font-size: 13px;
    transition: background 0.15s;
    text-decoration: none;
}
.account-menu-item:hover { background: var(--bg-hover); }
.account-menu-item svg { color: var(--text-secondary); flex-shrink: 0; }
.account-login { color: var(--accent); }
.account-login svg { color: var(--accent); }

/* ── Profile editor ────────────────────────────── */
.profile-editor-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.profile-editor-panel {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; width: 360px; max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.profile-editor-panel h3 { margin: 0 0 16px; font-size: 16px; color: var(--text-primary); }
.profile-editor-panel label {
    display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px;
}
.profile-editor-panel input {
    width: 100%; padding: 8px 12px; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-primary); font-size: 14px; margin-bottom: 12px;
    box-sizing: border-box;
}
.profile-editor-panel input:focus { outline: none; border-color: var(--accent); }
.profile-editor-actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px;
}
.profile-editor-actions button {
    padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; border: none;
}
.profile-editor-actions .pe-cancel {
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary);
}
.profile-editor-actions .pe-save {
    background: var(--accent); color: white; font-weight: 600;
}

/* ── Sign-in Modal ────────────────────────────── */
.signin-panel {
    width: 420px; max-width: 92vw;
    padding: 32px; text-align: center;
    border-radius: 16px;
}
.signin-panel h3 {
    font-size: 20px; font-weight: 700; margin: 0 0 8px;
    color: var(--text-primary);
}
.signin-subtitle {
    font-size: 13px; color: var(--text-secondary);
    margin: 0 0 24px; line-height: 1.5;
}
.signin-providers {
    display: flex; flex-direction: column; gap: 10px;
}
.signin-provider-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; width: 100%; height: 48px;
    border-radius: 12px; border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-primary);
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.signin-provider-btn:hover {
    background: var(--bg-hover); border-color: var(--text-muted);
}
.signin-provider-btn:active {
    background: var(--border);
}
.signin-provider-btn svg {
    flex-shrink: 0;
}
.signin-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0;
}
.signin-divider::before,
.signin-divider::after {
    content: ''; flex: 1; height: 1px;
    background: var(--border);
}
.signin-divider span {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.1em; color: var(--text-muted);
}
.signin-email {
    display: flex; flex-direction: column; gap: 10px;
}
.signin-email input {
    width: 100%; height: 48px; padding: 0 16px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 12px; color: var(--text-primary); font-size: 14px;
    box-sizing: border-box; outline: none;
    transition: border-color 0.15s;
}
.signin-email input:focus {
    border-color: var(--accent);
}
.signin-email input::placeholder {
    color: var(--text-muted);
}
.signin-email-btn {
    width: 100%; height: 48px; border: none; border-radius: 12px;
    background: var(--accent); color: white;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.signin-email-btn:hover {
    background: var(--accent-hover);
}
.signin-email-btn:disabled {
    opacity: 0.5; cursor: not-allowed;
}
.signin-status {
    margin-top: 12px; font-size: 13px; color: var(--text-secondary);
    min-height: 20px;
}
.signin-status.success { color: #34d399; }
.signin-status.error { color: #f87171; }

/* ── Cloud Badge ──────────────────────────────── */
.account-cloud-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 11px; font-weight: 500;
    color: var(--text-muted);
}
.account-cloud-badge.connected {
    color: #34d399;
}
.account-cloud-badge svg {
    width: 14px; height: 14px;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}
.sidebar.collapsed { width: 0; min-width: 0; border-right: none; }

.sidebar-header {
    height: 44px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-title {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
}
.sidebar-header-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); padding: 4px 6px; border-radius: 4px;
    font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.sidebar-header-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.sidebar-list {
    flex: 1; overflow-y: auto; padding: 8px;
    display: flex; flex-direction: column; gap: 2px;
}
.sidebar-list::-webkit-scrollbar { width: 6px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-signal-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    cursor: pointer; transition: background 0.15s;
    color: var(--text-primary);
}
.sidebar-signal-card:hover { background: var(--bg-hover); }
.sidebar-signal-card.active { background: var(--bg-surface); }
.sidebar-signal-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.sidebar-signal-info { flex: 1; min-width: 0; }
.sidebar-signal-name {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-signal-meta {
    font-size: 11px; color: var(--text-muted);
    display: flex; gap: 6px; margin-top: 1px;
}

/* Sidebar context menu */
.sidebar-context-menu {
    position: fixed;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 500; padding: 4px 0; min-width: 160px;
}
.sidebar-context-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; font-size: 13px;
    color: var(--text-primary); cursor: pointer;
    transition: background 0.1s;
}
.sidebar-context-item:hover { background: var(--bg-hover); }
.sidebar-context-item.danger { color: #e55; }
.sidebar-context-item.danger:hover { background: rgba(200,50,50,0.15); }

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
    flex-shrink: 0;
}
.sidebar-footer-row {
    display: flex; gap: 6px; align-items: center;
}
.sidebar-new-btn {
    flex: 1; padding: 8px 12px;
    background: var(--bg-surface); border: 1px dashed var(--border);
    border-radius: 6px; color: var(--text-secondary);
    cursor: pointer; font-size: 13px;
    transition: border-color 0.15s, color 0.15s;
}
.sidebar-new-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.sidebar-gallery-btn {
    background: none; border: 1px solid var(--border);
    border-radius: 6px; padding: 7px 10px;
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s, color 0.15s;
}
.sidebar-gallery-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.sidebar-version {
    font-size: 11px; color: var(--text-muted);
    font-family: 'SF Mono','Consolas','Monaco',monospace;
    text-align: center;
}

/* ── Sidebar collapse button ──────────────────── */
.sidebar-collapse-btn {
    margin-left: auto;
}

/* ── Signal sidebar expand (left edge of content area) ── */
.signal-sidebar-expand {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.signal-sidebar-expand:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--accent);
}
.signal-sidebar-expand.hidden { display: none; }

/* ── Signal home/gallery view ────────────────── */
.signal-home {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
}
.signal-home-toolbar {
    margin-bottom: 20px;
    flex-shrink: 0;
}
.signal-home-search-wrap {
    position: relative;
    max-width: 360px;
}
.signal-home-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.signal-home-search {
    width: 100%;
    padding: 9px 12px 9px 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.signal-home-search:focus {
    outline: none;
    border-color: var(--accent);
}
.signal-home-search::placeholder {
    color: var(--text-muted);
}

/* Backlink badge on gallery cards */
.signal-backlink-badge {
    display: inline-block;
    font-size: 10px;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    padding: 1px 6px;
    border-radius: 3px;
    margin-top: 2px;
}

/* ── Backlinks popover ───────────────────────── */
.signal-backlinks-popover {
    position: fixed;
    bottom: 32px;
    right: 16px;
    width: 300px;
    max-height: 360px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 600;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.signal-backlinks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.signal-backlinks-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    border-radius: 4px;
}
.signal-backlinks-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.signal-backlinks-list {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ── Shell chat panel ──────────────────────────── */
.shell-chat-panel {
    width: 380px;
    min-width: 380px;
    height: 100%;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease, min-width 0.2s ease, opacity 0.15s ease;
    overflow: hidden;
}
.shell-chat-panel.collapsed {
    width: 0;
    min-width: 0;
    opacity: 0;
    border-right: none;
}
.shell-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.shell-chat-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.shell-chat-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 18px;
    cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.shell-chat-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.shell-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.shell-chat-msg {
    max-width: 90%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}
.shell-chat-msg--user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-radius: 12px 12px 4px 12px;
}
.shell-chat-msg--assistant {
    align-self: flex-start;
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 12px 12px 12px 4px;
}
.shell-chat-msg--assistant code {
    background: var(--bg-primary);
    padding: 1px 4px; border-radius: 3px; font-size: 12px;
}
.shell-chat-msg--assistant pre {
    background: var(--bg-primary);
    padding: 8px; border-radius: 6px;
    overflow-x: auto; margin: 4px 0;
}
.shell-chat-msg--system {
    align-self: center;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}
.shell-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.shell-chat-input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
    min-height: 36px;
    max-height: 120px;
    font-family: inherit;
}
.shell-chat-input:focus { border-color: var(--accent); outline: none; }
.shell-chat-send {
    background: var(--accent);
    border: none; border-radius: 8px;
    padding: 8px; cursor: pointer;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.shell-chat-send:hover { opacity: 0.9; }
/* Docked mode tabs */
.usearch-docked-tabs {
    display: flex; gap: 2px;
}
.usearch-dtab {
    padding: 4px 14px; border: none; border-radius: 6px;
    background: none; color: var(--text-muted);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.1s;
}
.usearch-dtab:hover { color: var(--text-primary); }
.usearch-dtab.active { background: var(--bg-surface); color: var(--text-primary); }
.usearch-docked-search, .usearch-docked-chat {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.usearch-docked-search .usearch-results { flex: 1; overflow-y: auto; }
.hidden { display: none !important; }
.usearch-dock-btn {
    background: none; border: 1px solid var(--border);
    color: var(--text-muted); padding: 4px 6px; border-radius: 6px;
    cursor: pointer; display: flex; align-items: center;
    transition: all 0.15s;
}
.usearch-dock-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── App container ──────────────────────────────── */
.app-container {
    flex: 1;
    display: flex;
    min-width: 0;
    height: 100%;
    position: relative;
}

.app-frame {
    flex: 1;
    display: flex;
    min-width: 0;
    height: 100%;
}

/* ── Model badge (legacy, kept for kanban.html compat) ── */
.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    font-family: 'SF Mono','Consolas','Monaco',monospace;
}
.model-badge:hover { border-color: var(--accent); color: var(--text-primary); }
.model-badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #22c55e;
}

/* ── Toast notifications (shell-level) ───────────── */
.lani-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 13px;
    z-index: 99999;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
    max-width: 420px;
    text-align: center;
}
.lani-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.lani-toast a { color: var(--link); text-decoration: underline; }
.lani-toast .toast-actions { margin-top: 6px; display: flex; gap: 8px; justify-content: center; }
.lani-toast .toast-actions button {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.lani-toast .toast-actions button:hover { background: var(--accent); }

/* ── Workspace switcher ───────────────────────────── */
.rail-workspace-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: 1px solid transparent;
    border-radius: 8px; padding: 6px 10px;
    color: var(--text-secondary); cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    width: calc(var(--rail-width) - 12px);
    font-size: 11px; white-space: nowrap;
    overflow: hidden;
}
.rail-workspace-btn:hover {
    color: var(--text-primary); background: var(--bg-hover);
    border-color: var(--border);
}
.rail-workspace-label {
    flex: 1; overflow: hidden; text-overflow: ellipsis;
    text-align: left; font-size: 10px; line-height: 1.2;
    display: none; /* Hidden when rail is narrow */
}
.rail-workspace-chevron {
    flex-shrink: 0; opacity: 0.5;
    display: none; /* Hidden when rail is narrow */
}

/* Workspace popup menu */
.workspace-menu {
    display: none;
    position: fixed;
    bottom: 52px;
    left: calc(var(--rail-width) + 8px);
    width: 260px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    z-index: 600;
    padding: 6px;
    animation: account-menu-in 0.15s ease-out;
    max-height: 400px;
    overflow-y: auto;
}
.workspace-menu.open { display: block; }
.workspace-menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 6px;
    cursor: pointer; transition: background 0.15s;
    color: var(--text-primary); font-size: 13px;
}
.workspace-menu-item:hover { background: var(--bg-hover); }
.workspace-menu-item.active { background: var(--bg-surface); }
.workspace-menu-dot {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; color: var(--accent);
}
.workspace-menu-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.workspace-menu-delete {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.workspace-menu-item:hover .workspace-menu-delete { opacity: 1; }
.workspace-menu-delete:hover { color: #e55; background: rgba(200,50,50,0.15); }
.workspace-menu-sep {
    height: 1px; background: var(--border); margin: 4px 6px;
}
.workspace-menu-new { color: var(--accent); }
.workspace-menu-new .workspace-menu-dot { color: var(--accent); }

/* Workspace new dialog */
.workspace-dialog-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
}
.workspace-dialog-panel {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; width: 400px; max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.workspace-dialog-panel h3 { margin: 0 0 4px; font-size: 16px; color: var(--text-primary); }
.workspace-dialog-subtitle { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; }
.workspace-dialog-panel label {
    display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px;
}
.workspace-dialog-type-label { margin-top: 12px; }
.workspace-dialog-panel input {
    width: 100%; padding: 8px 12px; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-primary); font-size: 14px;
    box-sizing: border-box;
}
.workspace-dialog-panel input:focus { outline: none; border-color: var(--accent); }
.workspace-type-cards {
    display: flex; gap: 10px; margin-top: 6px;
}
.workspace-type-card {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 10px; border-radius: 8px;
    border: 2px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer; transition: border-color 0.15s;
    font-size: 12px; color: var(--text-secondary);
}
.workspace-type-card.selected {
    border-color: var(--accent); color: var(--text-primary);
}
.workspace-type-card.disabled {
    opacity: 0.5; cursor: not-allowed;
}
.workspace-type-soon {
    font-size: 10px; color: var(--text-muted);
    background: var(--bg-hover); padding: 1px 6px; border-radius: 4px;
}
.workspace-dialog-actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px;
}
.workspace-dialog-actions button {
    padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; border: none;
}
.workspace-dialog-actions .ws-cancel {
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary);
}
.workspace-dialog-actions .ws-create {
    background: var(--accent); color: white; font-weight: 600;
}

/* ── Runtime switch loader ────────────────────────── */
.runtime-switch-loader {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary); z-index: 100;
}
.runtime-switch-text {
    color: var(--text-secondary); font-size: 14px;
}

/* ── Status bar ──────────────────────────────────── */
.status-bar {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 0 10px;
    flex-shrink: 0;
    font-size: 11px;
    font-family: 'SF Mono','Consolas','Monaco',monospace;
    color: var(--text-muted);
    z-index: 50;
    gap: 4px;
}
.status-bar-left, .status-bar-right {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}
.status-bar-right { margin-left: auto; }
.status-bar-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 7px;
    height: 22px;
    border-radius: 3px;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.status-bar-item:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
/* Connectivity dot inside status bar items */
.status-bar-item .sb-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.sb-dot.full     { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.sb-dot.partial  { background: #eab308; box-shadow: 0 0 4px rgba(234,179,8,0.4); }
.sb-dot.local    { background: #3b82f6; box-shadow: 0 0 4px rgba(59,130,246,0.4); }
.sb-dot.offline  { background: #555; box-shadow: none; }
.sb-dot.checking { background: #888; animation: sb-pulse 1.2s ease-in-out infinite; }
@keyframes sb-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}
.sb-provider { color: var(--text-secondary); }
.sb-auto-badge {
    font-size: 9px;
    padding: 0 4px;
    border-radius: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 14px;
}

/* ── Home view ───────────────────────────────────── */
.home-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 40px;
    width: 100%;
    overflow-y: auto;
}
.home-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 36px;
    color: var(--text-primary);
}
.home-header svg {
    opacity: 0.8;
    margin-bottom: 4px;
}
.home-header h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
}
.home-header p {
    font-size: 14px;
    color: var(--text-secondary);
}
.home-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 560px;
    width: 100%;
}
.home-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--card-accent);
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    text-align: left;
    width: 100%;
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
}
.home-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    border-color: var(--card-accent);
}
.home-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: color-mix(in srgb, var(--card-accent) 15%, transparent);
    color: var(--card-accent);
    flex-shrink: 0;
}
.home-card-body {
    flex: 1;
    min-width: 0;
}
.home-card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.home-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Hidden utility ───────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet Breakpoints
   ══════════════════════════════════════════════════════ */

/* ── Mobile: < 768px ──────────────────────────────── */
@media (max-width: 767px) {
    .app-shell { flex-direction: column; }

    /* Icon rail → bottom tab bar */
    .icon-rail {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        min-width: 0 !important;
        height: 56px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 4px 8px;
        z-index: 500;
        justify-content: center;
        gap: 4px;
    }
    .icon-rail-top { flex-direction: row; gap: 4px; }
    .icon-rail-bottom { flex-direction: row; gap: 4px; }
    .icon-rail-bottom .rail-label { display: block; }
    #icon-rail-bottom-apps { display: contents; }
    .rail-logo { display: none; }
    .rail-separator { display: none; }
    .rail-btn { width: auto; padding: 6px 12px; flex-direction: column; gap: 1px; }
    .rail-label { font-size: 9px; }

    /* Content area fills remaining space; top bar + status bar keep their height */
    .app-shell-content {
        flex: 1; width: 100%; min-height: 0;
        padding-bottom: 56px;
    }
    .shell-top-bar { flex: none !important; }
    .status-bar { flex: none !important; }
    .account-menu { bottom: 64px; left: 8px; }
}

/* ── Sidebar dual-mode: home vs detail ────────────── */

/* Sidebar content containers */
.sidebar-home-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.sidebar-home-content.hidden { display: none; }

.sidebar-chat-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}
.sidebar-chat-content.hidden { display: none; }

/* ChatWidget fills the sidebar chat content area */
#sidebar-chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Sidebar back button (detail mode header) */
.sidebar-back-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 5px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.sidebar-back-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Signal name shown in the detail mode header */
.sidebar-detail-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    margin-left: 4px;
}

/* Sidebar search bar */
.sidebar-search-wrap {
    position: relative;
    margin: 10px 10px 4px;
    flex-shrink: 0;
}
.sidebar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.sidebar-search {
    width: 100%;
    padding: 7px 10px 7px 30px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}
.sidebar-search:focus { border-color: var(--accent); }
.sidebar-search::placeholder { color: var(--text-muted); }

/* Sidebar section label */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 10px 14px 4px;
    flex-shrink: 0;
}

/* Signal-type category rows */
.sidebar-category-list {
    flex: 1;
    overflow-y: auto;
    padding: 2px 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sidebar-category-list::-webkit-scrollbar { width: 4px; }
.sidebar-category-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-category-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-category-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.12s, color 0.12s;
    user-select: none;
}
.sidebar-category-row:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-category-row.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-category-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; display: flex; align-items: center; justify-content: center; }
.sidebar-category-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-category-count {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ── App connecting indicator ────────────────────── */
/* Shown inside an app container while its WASM runtime boots in the background. */
.app-connecting-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--font-family, system-ui, sans-serif);
}
.app-connecting-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border, #333);
    border-top-color: var(--accent, #6c8aff);
    border-radius: 50%;
    animation: app-connect-spin 0.8s linear infinite;
}
@keyframes app-connect-spin {
    to { transform: rotate(360deg); }
}

/* ── Tablet: 768-1023px ──────────────────────────── */
@media (max-width: 1023px) and (min-width: 768px) {
    .icon-rail { width: 48px; min-width: 48px; }
    .rail-label { font-size: 9px; }
    .rail-btn { width: 40px; padding: 6px 2px; }
}

/* ── Toast notifications ─────────────────────── */
.lani-toast-container {
    position: fixed;
    bottom: 36px; /* above status bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}
.lani-toast {
    background: var(--surface-3, #2a2a2a);
    color: var(--text-1, #e0e0e0);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.lani-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Write button loading state ──────────────── */
[data-requires-runtime][disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}
