/* ══════════════════════════════════════════════════════════════════
   F.R.A.N.K. — New Shell (Apr 28, 2026)
   Three-pane layout, galaxy background, modern glass aesthetic.
   Loaded AFTER frank-webui.css so its rules win.
   ══════════════════════════════════════════════════════════════════ */

:root {
    /* Mockup-exact palette — deep navy + electric blue→violet→magenta gradient */
    --shell-bg: #060a1f;
    --shell-fog: rgba(6, 10, 31, 0.55);
    --panel-bg: rgba(13, 17, 36, 0.66);
    --panel-bg-strong: rgba(17, 22, 44, 0.82);
    --panel-border: rgba(255, 255, 255, 0.06);
    --panel-border-bright: rgba(255, 255, 255, 0.12);
    --panel-radius: 18px;
    --row-radius: 14px;

    --shell-text: #e8ecf5;
    --shell-text-dim: rgba(232, 236, 245, 0.62);
    --shell-text-faint: rgba(232, 236, 245, 0.36);

    /* Brand gradient — blue → violet → magenta (matches mockup Home pill) */
    --shell-accent-blue: #3D6FFF;
    --shell-accent-violet: #8B5CF6;
    --shell-accent-magenta: #EC4899;
    --shell-accent-cyan: #00B7FF;     /* FRANK + ONLINE + [SCREEN] */
    --shell-accent-pink: #FF4DBF;     /* [ÜBER MICH] */

    --shell-grad: linear-gradient(135deg, #3D6FFF 0%, #8B5CF6 50%, #EC4899 100%);
    --shell-grad-soft: linear-gradient(135deg, rgba(61,111,255,0.22) 0%, rgba(139,92,246,0.24) 50%, rgba(236,72,153,0.22) 100%);
    --shell-grad-strong: linear-gradient(135deg, #4F7FFF 0%, #9D6BFF 50%, #FF5CB0 100%);

    --row-active-bg: linear-gradient(135deg, rgba(61,111,255,0.30) 0%, rgba(139,92,246,0.32) 50%, rgba(236,72,153,0.28) 100%);
}

/* ── Galaxy background + fog ───────────────────────────────────── */
body.frank-shell-active {
    background:
        linear-gradient(180deg, rgba(6,10,31,0.42) 0%, rgba(6,10,31,0.55) 100%),
        radial-gradient(1200px 800px at 18% 20%, rgba(61,111,255,0.14), transparent 65%),
        radial-gradient(1000px 700px at 82% 78%, rgba(236,72,153,0.12), transparent 65%),
        url('/static/assets/galaxy-bg.jpg') center/cover no-repeat fixed,
        var(--shell-bg) !important;
}
html { background: var(--shell-bg); }

/* Kill the old GoL canvas + scanlines + aurora — leave everywhere */
.frank-hub > #gol-bg,
.frank-hub > .scanlines,
.frank-hub > .aurora-container,
canvas#gol-bg,
.scanlines,
.aurora-container { display: none !important; }

/* App container fills the viewport without hub padding */
.frank-hub {
    background: transparent !important;
    min-height: 100vh;
}
.page-container {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 100vh;
    height: 100vh;
}
.page { background: transparent !important; }

/* Hide the global app nav-bar on dashboard — full-screen shell instead */
body.frank-shell-active #nav,
body.frank-shell-active .af-nav,
body.frank-shell-active .af-mobile-menu { display: none !important; }
body.frank-shell-active main#app {
    padding-top: 0 !important; margin-top: 0 !important;
    height: 100vh; width: 100vw; overflow: hidden;
}

/* ── Three-pane shell ──────────────────────────────────────────── */
.fk-shell {
    display: grid;
    grid-template-columns: 260px 320px 1fr;
    gap: 16px;
    padding: 16px;
    height: 100vh;
    width: 100vw;
    box-sizing: border-box;
    color: var(--shell-text);
    font-family: 'Inter', system-ui, -apple-system, 'SF Pro Display', sans-serif;
    overflow: hidden;
}

.fk-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Sidebar (left) ───────────────────────────────────────────── */
.fk-sidebar { padding: 18px 14px; }

.fk-brand {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 6px 18px 6px;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 14px;
}
.fk-brand-mark {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; letter-spacing: 0.08em; font-size: 15px;
    color: #fff;
}
.fk-brand-logo {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--shell-grad);
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(111,140,255,0.32);
}
.fk-brand-logo svg { width: 16px; height: 16px; color: #0a0e1f; }
.fk-brand-collapse {
    width: 30px; height: 30px; border-radius: 8px;
    background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border);
    display: grid; place-items: center; cursor: pointer; color: var(--shell-text-dim);
}
.fk-brand-collapse:hover { background: rgba(255,255,255,0.08); color: #fff; }

.fk-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.fk-nav::-webkit-scrollbar { width: 4px; }
.fk-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.fk-nav-row {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--row-radius);
    color: var(--shell-text-dim);
    font-size: 13px; font-weight: 500;
    cursor: pointer; user-select: none;
    transition: background 0.18s, color 0.18s;
    background: transparent;
    border: 1px solid transparent;
}
.fk-nav-row:hover {
    background: rgba(255,255,255,0.04);
    color: var(--shell-text);
}
.fk-nav-row.active {
    background:
        linear-gradient(135deg, rgba(79,143,255,0.85) 0%, rgba(155,108,255,0.78) 50%, rgba(255,92,176,0.70) 100%);
    color: #fff;
    border-color: rgba(255,255,255,0.22);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.10) inset,
        0 1px 0 rgba(255,255,255,0.22) inset,
        0 10px 32px rgba(139,92,246,0.55),
        0 0 48px rgba(236,72,153,0.32);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    font-weight: 600;
}
.fk-nav-row.active::before {
    content: '';
    position: absolute; left: -1px; top: 4px; bottom: 4px; width: 3px;
    background: linear-gradient(180deg, #4F8FFF 0%, #B66CFF 50%, #FF5CB0 100%);
    border-radius: 3px;
    box-shadow: 0 0 14px rgba(139,92,246,0.85), 0 0 22px rgba(236,72,153,0.5);
}
.fk-nav-row.active::after {
    /* Outer halo so the row "floats" like in the mockup */
    content: '';
    position: absolute; inset: -2px;
    border-radius: inherit;
    background:
        radial-gradient(60% 90% at 30% 50%, rgba(61,111,255,0.18), transparent 70%),
        radial-gradient(60% 90% at 80% 50%, rgba(236,72,153,0.18), transparent 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(6px);
}
.fk-nav-row.active svg { color: #fff; filter: drop-shadow(0 0 6px rgba(255,255,255,0.4)); }
.fk-nav-row svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; color: currentColor; }
.fk-nav-row .fk-nav-chev {
    margin-left: auto; width: 14px; height: 14px;
    transition: transform 0.18s; opacity: 0.6;
}
.fk-nav-row.expanded .fk-nav-chev { transform: rotate(90deg); opacity: 1; }

/* Expandable Projekte sub-list */
.fk-nav-children {
    margin: 4px 0 8px 28px;
    display: none;
    flex-direction: column; gap: 2px;
    border-left: 1px solid var(--panel-border);
    padding-left: 10px;
    max-height: 320px; overflow-y: auto;
}
.fk-nav-row.expanded + .fk-nav-children { display: flex; }
.fk-nav-children::-webkit-scrollbar { width: 3px; }
.fk-nav-children::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

.fk-nav-child {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px; color: var(--shell-text-dim);
    cursor: pointer;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.fk-nav-child:hover { background: rgba(255,255,255,0.04); color: var(--shell-text); }
.fk-nav-child.active { background: rgba(111,140,255,0.16); color: #fff; }
.fk-nav-child-empty { padding: 8px 10px; font-size: 11px; color: var(--shell-text-faint); font-style: italic; }

/* ── Token usage card ──────────────────────────────────────── */
.fk-token-card {
    margin-top: 12px;
    padding: 14px 14px 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
}
.fk-token-label {
    font-size: 10px; letter-spacing: 0.18em;
    color: var(--shell-text-faint); font-weight: 700;
    margin-bottom: 6px;
}
.fk-token-value {
    font-size: 22px; font-weight: 700;
    background: var(--shell-grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
    letter-spacing: -0.01em;
}
.fk-token-percent { font-size: 11px; color: var(--shell-text-faint); margin-top: 2px; }
.fk-token-spark {
    margin-top: 8px;
    height: 28px;
    display: flex; align-items: end; gap: 3px;
    overflow: hidden;
}
.fk-token-spark .fk-spark-bar {
    flex: 1;
    background: var(--shell-grad);
    border-radius: 2px 2px 0 0;
    opacity: 0.55;
    min-height: 2px;
    transition: opacity 0.2s;
}
.fk-token-spark .fk-spark-bar:hover { opacity: 1; }

/* ── User card — mockup #9 ─────────────────────────────────── */
.fk-user-card {
    margin-top: 10px;
    padding: 12px 14px;
    background: rgba(13, 17, 36, 0.6);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 16px;
    display: flex; align-items: center; gap: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    backdrop-filter: blur(14px);
}
.fk-user-card:hover {
    background: rgba(20,24,48,0.72);
    border-color: rgba(255,255,255,0.12);
}
.fk-user-avatar {
    position: relative;
    width: 42px; height: 42px; border-radius: 50%;
    background:
        #b4bedf
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><path fill='%23ffffff' d='M32 9c-7 0-12 5.5-12 12.5S25 34 32 34s12-5.5 12-12.5S39 9 32 9zm0 28c-9 0-22 4-22 13v3c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2v-3c0-9-13-13-22-13z'/></svg>")
        center/cover no-repeat;
    color: transparent; font-size: 0;          /* hide initials */
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.10), 0 4px 12px rgba(0,0,0,0.5);
}
/* Online status dot (mockup shows a small blue/cyan dot bottom-right of avatar) */
.fk-user-avatar::after {
    content: '';
    position: absolute;
    width: 10px; height: 10px;
    bottom: 0; right: 0;
    background: #38BDF8;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(13,17,36,0.95), 0 0 8px rgba(56,189,248,0.7);
}
.fk-user-info { flex: 1; min-width: 0; }
.fk-user-name {
    font-size: 14px; color: #fff;
    font-weight: 700; line-height: 1.15;
    font-family: 'Inter', system-ui, sans-serif;
}
.fk-user-role {
    font-size: 11px; color: var(--shell-text-dim);
    margin-top: 2px;
    letter-spacing: 0.01em;
    font-family: 'Inter', system-ui, sans-serif;
}
.fk-user-chev {
    width: 16px; height: 16px;
    color: var(--shell-text-faint);
    flex-shrink: 0;
}

/* ── Middle pane (chats list) ─────────────────────────────── */
.fk-chats { padding: 18px 14px 14px 14px; }
.fk-chats-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 4px 14px 4px;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 12px;
}
.fk-chats-title {
    font-size: 13px; font-weight: 800;
    letter-spacing: 0.18em; color: #fff;
}
.fk-chats-new {
    display: flex; align-items: center; gap: 6px;
    background: var(--shell-grad);
    border: none; border-radius: 10px;
    padding: 7px 12px;
    color: #0a0e1f; font-weight: 700; font-size: 12px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(111,140,255,0.34);
    transition: transform 0.15s, box-shadow 0.15s;
}
.fk-chats-new:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(111,140,255,0.50); }
.fk-chats-new svg { width: 14px; height: 14px; }

.fk-chats-search {
    position: relative; margin-bottom: 10px;
}
.fk-chats-search input {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 11px 14px 11px 14px;
    color: #fff; font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.18s, background 0.18s;
}
.fk-chats-search input::placeholder { color: var(--shell-text-faint); }
.fk-chats-search input:focus { border-color: rgba(111,140,255,0.45); background: rgba(255,255,255,0.06); }

.fk-chats-list {
    flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px;
    padding-right: 2px;
}
.fk-chats-list::-webkit-scrollbar { width: 4px; }
.fk-chats-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.fk-chat-item {
    position: relative;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.fk-chat-item:hover { background: rgba(255,255,255,0.06); border-color: var(--panel-border-bright); }
.fk-chat-item.active {
    background: var(--shell-grad-soft);
    border-color: rgba(111,140,255,0.32);
}
.fk-chat-item.active::before {
    content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
    width: 3px; background: var(--shell-grad); border-radius: 0 3px 3px 0;
}
.fk-chat-item-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px;
}
.fk-chat-item-title {
    font-size: 13px; font-weight: 600; color: #fff;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.fk-chat-item-time { font-size: 10px; color: var(--shell-text-faint); flex-shrink: 0; margin-left: 8px; }
.fk-chat-item-preview {
    font-size: 11px; color: var(--shell-text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.4;
}
.fk-chat-item-unread-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--shell-accent-3);
    box-shadow: 0 0 10px rgba(77,214,255,0.6);
    flex-shrink: 0; margin-left: 6px;
}

.fk-chats-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--shell-text-faint);
    font-size: 12px;
    line-height: 1.6;
}

/* ── Right pane (chat thread) ─────────────────────────────── */
.fk-main { padding: 0; }
.fk-main-inner { display: flex; flex-direction: column; height: 100%; }
.fk-main-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--panel-border);
}
.fk-main-titlebar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.fk-main-title-block { display: flex; align-items: center; gap: 10px; }
.fk-main-title {
    font-size: 15px; font-weight: 800; color: var(--shell-accent-cyan);
    letter-spacing: 0.06em;
}
.fk-status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: var(--shell-accent-cyan);
    padding: 3px 10px;
    background: transparent;
    border: none;
    border-radius: 999px;
    font-weight: 700; letter-spacing: 0.12em;
}
.fk-status-pill .fk-pulse {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--shell-accent-cyan);
    box-shadow: 0 0 10px var(--shell-accent-cyan);
    animation: fk-pulse 2s ease-in-out infinite;
}
@keyframes fk-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.fk-main-tabs { display: flex; gap: 14px; margin-left: 8px; }
.fk-main-tab {
    font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
    color: var(--shell-text-faint); cursor: pointer;
    padding: 4px 0;
    transition: color 0.18s;
    background: none; border: none; font-family: inherit;
}
.fk-main-tab:hover { color: var(--shell-text); }
.fk-main-tab.active {
    background: var(--shell-grad);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.fk-main-tools { display: flex; gap: 6px; }
.fk-main-icon-btn {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border);
    color: var(--shell-text-dim); cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.fk-main-icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.fk-main-icon-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }

.fk-main-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 24px 22px;
    display: flex; flex-direction: column; gap: 18px;
}
.fk-main-body::-webkit-scrollbar { width: 6px; }
.fk-main-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* Welcome / empty state inside main */
.fk-welcome {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 32px; text-align: center;
}
.fk-welcome-mark {
    width: 88px; height: 88px; border-radius: 22px;
    background: var(--shell-grad);
    display: grid; place-items: center; color: #0a0e1f;
    box-shadow: 0 14px 50px rgba(111,140,255,0.5);
    margin-bottom: 24px;
}
.fk-welcome-mark svg { width: 44px; height: 44px; stroke-width: 1.8; }
.fk-welcome-title {
    font-size: 28px; font-weight: 700; color: #fff;
    margin-bottom: 8px; letter-spacing: -0.01em;
}
.fk-welcome-sub {
    font-size: 14px; color: var(--shell-text-dim);
    max-width: 460px; line-height: 1.55;
}
.fk-welcome-actions {
    margin-top: 26px;
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.fk-welcome-action {
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border-bright);
    border-radius: 12px;
    color: var(--shell-text);
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    display: flex; align-items: center; gap: 8px;
}
.fk-welcome-action:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }
.fk-welcome-action svg { width: 14px; height: 14px; }

/* ── Composer (bottom of main) — mockup-exact glassy bar with magenta glow ── */
.fk-composer-wrap {
    padding: 14px 22px 18px;
    border-top: 1px solid var(--panel-border);
    position: relative;
}
.fk-composer {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    background: rgba(8, 10, 24, 0.78);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 18px;
    padding: 8px 10px 8px 14px;
    transition: border-color 0.18s, box-shadow 0.18s;
    overflow: hidden;
}
/* Magenta→violet glow blob baked into the right side */
.fk-composer::before {
    content: '';
    position: absolute;
    top: -10px; right: -40px; bottom: -10px; width: 55%;
    background:
        radial-gradient(70% 100% at 70% 50%, rgba(236,72,153,0.55) 0%, transparent 65%),
        radial-gradient(50% 80% at 95% 60%, rgba(139,92,246,0.50) 0%, transparent 60%),
        radial-gradient(60% 110% at 50% 60%, rgba(61,111,255,0.30) 0%, transparent 70%);
    filter: blur(20px);
    pointer-events: none;
    z-index: 0;
}
.fk-composer > * { position: relative; z-index: 1; }
.fk-composer:focus-within {
    border-color: rgba(139,92,246,0.55);
    box-shadow: 0 0 0 4px rgba(139,92,246,0.10);
}
.fk-composer-attach {
    width: 34px; height: 34px; border-radius: 10px;
    background: transparent; border: none; color: var(--shell-text-dim);
    display: grid; place-items: center; cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.fk-composer-attach:hover { color: #fff; background: rgba(255,255,255,0.06); }
.fk-composer-input {
    flex: 1; background: transparent; border: none;
    color: #fff; font-size: 13px; padding: 10px 4px;
    font-family: inherit; outline: none;
    resize: none; min-height: 22px; max-height: 200px;
    line-height: 1.5;
}
.fk-composer-input::placeholder { color: rgba(232,236,245,0.55); }
.fk-composer-send {
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(8, 10, 24, 0.6);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.18);
    color: #cfd7ff;
    display: grid; place-items: center; cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, color 0.15s;
}
.fk-composer-send:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.32);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.10), 0 6px 20px rgba(236,72,153,0.35);
    transform: translateY(-1px);
}
.fk-composer-send:active { transform: translateY(0); }
.fk-composer-send svg { width: 18px; height: 18px; stroke-width: 1.8; }

/* Admin-Log pill (bottom-right floating) — match mockup glassy purple-tinted card */
body.frank-shell-active #admin-log-btn {
    display: inline-flex !important; align-items: center; gap: 8px !important;
    bottom: 24px !important; right: 24px !important;
    padding: 8px 14px !important;
    background: rgba(20, 16, 40, 0.85) !important;
    backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(192, 140, 255, 0.30) !important;
    border-radius: 12px !important;
    color: #d8c8ff !important;
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset !important;
}

/* ── Mobile collapse ──────────────────────────────────────── */
@media (max-width: 1100px) {
    .fk-shell { grid-template-columns: 240px 1fr; padding: 12px; gap: 12px; }
    .fk-chats { display: none; }
    .fk-shell.show-chats .fk-chats { display: flex; }
    .fk-shell.show-chats .fk-main { display: none; }
}
@media (max-width: 720px) {
    .fk-shell { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
    .fk-sidebar { display: none; }
    .fk-shell.show-sidebar .fk-sidebar { display: flex; position: fixed; left: 8px; right: 8px; top: 8px; bottom: 8px; z-index: 50; }
}

/* ── Embedding existing pages inside fk-main-body ──────────── */
/* Many sub-pages render with their own backgrounds — strip them */
.fk-main-body .proj-page,
.fk-main-body .page,
.fk-main-body .frank-hub { background: transparent !important; }

/* Hide the OLD inline sidebar (proj-sidebar) when new shell active */
body.frank-shell-active .proj-sidebar,
body.frank-shell-active .proj-sidebar-overlay,
body.frank-shell-active #admin-log-btn { display: none !important; }
body.frank-shell-active .proj-page { display: block !important; height: 100% !important; }
body.frank-shell-active .proj-main { padding: 0 !important; height: 100% !important; }

/* ── Cards rendered inside fk-main-body inherit lighter look ── */
.fk-main-body .frank-card,
.fk-main-body .proj-onboard-card { background: rgba(20,24,48,0.78); }

/* ── Re-style projects.js #proj-list rows when inside fk-chats ── */
body.frank-shell-active #proj-list { padding: 0; }
body.frank-shell-active #proj-list .proj-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; margin-bottom: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-left: none;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}
body.frank-shell-active #proj-list .proj-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--panel-border-bright);
}
body.frank-shell-active #proj-list .proj-item.active {
    background: var(--shell-grad-soft);
    border-color: rgba(111,140,255,0.32);
    box-shadow: 0 4px 14px rgba(111,140,255,0.18);
}
body.frank-shell-active #proj-list .proj-item.active::before {
    content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
    width: 3px; background: var(--shell-grad); border-radius: 0 3px 3px 0;
}
body.frank-shell-active #proj-list .proj-item-dot {
    width: 6px; height: 6px; margin-top: 6px; flex-shrink: 0;
    background: var(--shell-text-faint);
    box-shadow: none;
}
body.frank-shell-active #proj-list .proj-item.active .proj-item-dot {
    background: var(--shell-accent-3);
    box-shadow: 0 0 10px rgba(77,214,255,0.6);
}
body.frank-shell-active #proj-list .proj-item-name {
    font-size: 13px; font-weight: 600; color: #fff;
    font-family: 'Inter', system-ui, sans-serif;
    letter-spacing: 0;
}
body.frank-shell-active #proj-list .proj-item-meta {
    font-size: 11px; color: var(--shell-text-dim);
    margin-top: 3px; line-height: 1.4;
    font-family: 'Inter', system-ui, sans-serif;
}
body.frank-shell-active #proj-list .proj-item.active .proj-item-name { color: #fff; }
body.frank-shell-active #proj-list .proj-progress-bar {
    background: rgba(255,255,255,0.06);
    margin-top: 6px;
}
body.frank-shell-active #proj-list .proj-progress-fill {
    background: var(--shell-grad) !important;
}
body.frank-shell-active #proj-list .proj-empty-list {
    color: var(--shell-text-faint);
    font-size: 12px;
    padding: 24px 12px; text-align: center;
}

/* Hide the OLD project-credit-/key-status block since we have token-card now */
body.frank-shell-active .proj-key-status,
body.frank-shell-active #proj-key-status { display: none !important; }
body.frank-shell-active #proj-token-bar-section { display: none !important; }

/* Inline render of mail/welcome inside the new shell — strip its own padding */
body.frank-shell-active #proj-main .proj-welcome,
body.frank-shell-active #proj-main .proj-onboard,
body.frank-shell-active #proj-main .proj-workspace { background: transparent !important; }
body.frank-shell-active #proj-main { padding: 0 !important; }

/* Master-Frank chat view inside shell — keep messages readable */
body.frank-shell-active #proj-main .proj-msg,
body.frank-shell-active #proj-main .frank-msg { font-family: 'Inter', system-ui, sans-serif; }

/* ── Chat avatars — circular profile photos (mockup #10, #11) ── */
body.frank-shell-active #proj-main .proj-msg-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    overflow: hidden;
    background: rgba(255,255,255,0.06);
    font-size: 0 !important;            /* hide ●/◇/etc text content */
    color: transparent !important;
    border: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
/* Frank avatar (assistant) — circular mascot photo */
body.frank-shell-active #proj-main .proj-msg-assistant .proj-msg-avatar {
    background-image: url('/static/assets/mascot.jpg');
    background-color: #1a1f2e;
}
/* User avatar — light-violet silhouette (matches mockup #12/#13) */
body.frank-shell-active #proj-main .proj-msg-user .proj-msg-avatar {
    background-color: #b4bedf;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><path fill='%23ffffff' d='M32 9c-7 0-12 5.5-12 12.5S25 34 32 34s12-5.5 12-12.5S39 9 32 9zm0 28c-9 0-22 4-22 13v3c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2v-3c0-9-13-13-22-13z'/></svg>");
}
/* Generic message rows that aren't role-tagged: still show the FRANK photo */
body.frank-shell-active #proj-main .proj-msg-avatar:not([class*="user"]):not([class*="file"]) {
    background-image: url('/static/assets/mascot.jpg');
}

/* Bubble polish to match mockup #11 — beat all legacy assistant/user rules */
body.frank-shell-active .proj-msg-body,
body.frank-shell-active .proj-msg-user .proj-msg-body,
body.frank-shell-active .proj-msg-assistant .proj-msg-body,
body.frank-shell-active .proj-msg-file .proj-msg-body {
    background: rgba(13, 17, 36, 0.72) !important;
    border: 1px solid rgba(255,255,255,0.07) !important;
    border-radius: 16px !important;
    padding: 14px 18px !important;
    max-width: 720px !important;
    backdrop-filter: blur(10px);
    line-height: 1.55;
    color: #e8ecf5 !important;
}
body.frank-shell-active .proj-msg-user .proj-msg-body {
    background: rgba(13, 17, 36, 0.55) !important;
    border-radius: 16px 16px 4px 16px !important;
}
body.frank-shell-active .proj-msg-role {
    color: var(--shell-accent-cyan) !important;
    font-weight: 800 !important;
    letter-spacing: 0.06em !important;
    font-size: 12px !important;
    margin-bottom: 4px !important;
}
body.frank-shell-active .proj-msg-user .proj-msg-role { color: #fff !important; }
body.frank-shell-active .proj-msg-text,
body.frank-shell-active .proj-msg-text * {
    color: #e8ecf5 !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    font-family: 'Inter', system-ui, sans-serif !important;
}
body.frank-shell-active .proj-msg-text a { color: var(--shell-accent-cyan) !important; }

/* Compose: scrollbars in the main pane should match the shell */
body.frank-shell-active #proj-main::-webkit-scrollbar { width: 6px; }
body.frank-shell-active #proj-main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* When projects.js renders the welcome (master-frank chat), it injects
   its own mobile bar — hide it inside our shell since we have the
   header. */
body.frank-shell-active .proj-mobile-welcome-bar { display: none !important; }

/* Old per-page sidebars/menus rendered inline (settings, mail) — fit them */
body.frank-shell-active .proj-settings-page,
body.frank-shell-active .proj-mail-page { background: transparent !important; }

/* Restyle `.proj-onboard-card` and templates picker so it works on dark glass bg */
body.frank-shell-active .proj-onboard-card {
    background: rgba(20,24,48,0.85) !important;
    border-color: rgba(255,255,255,0.08) !important;
    border-radius: 18px;
}

/* Lighten emojis used in cards if they show up in the chat — give them
   a subtle backdrop so they're not jarring */
body.frank-shell-active .frank-tools-block { background: rgba(255,255,255,0.03); border-color: var(--panel-border); }

/* The "Du / Administrator" inside our user-card already shows the role,
   so kill the duplicate user plan-pill at the top right (legacy nav). */
body.frank-shell-active .af-user-plan,
body.frank-shell-active #nav-user { display: none !important; }

