/* ==========================================================================
   Bedrock Remote Connect - UI foundation
   Shared by every page. Page-specific rules stay inline in each page.
   Colours and the grid background are carried over from the previous design.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Public+Sans:wght@400;500;600;700&display=swap');

@font-face {
    font-family: "Conthrax";
    src: url("fonts/Conthrax-SemiBold.otf") format("opentype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    color-scheme: dark;

    --bg-deep: #070b12;
    --bg-sidebar: rgba(10, 15, 24, 0.94);
    --bg-panel: #0f1623;
    --bg-card: #151f30;
    --bg-input: #111a29;
    --bg-hover: rgba(159, 176, 201, 0.07);
    --bg-active: rgba(34, 211, 238, 0.10);

    --accent-primary: #22d3ee;
    --accent-secondary: #38bdf8;
    --accent-ink: #032530;
    --accent-soft: rgba(34, 211, 238, 0.12);
    --accent-success: #34d399;
    --accent-warning: #fbbf24;
    --accent-error: #f87171;
    --success-soft: rgba(52, 211, 153, 0.12);
    --warning-soft: rgba(251, 191, 36, 0.12);
    --error-soft: rgba(248, 113, 113, 0.10);

    --text-primary: #e6edf6;
    --text-secondary: #9fb0c9;
    --text-muted: #6c7b95;

    --border-subtle: rgba(159, 176, 201, 0.13);
    --border-strong: rgba(159, 176, 201, 0.24);
    --shadow-color: rgba(0, 0, 0, 0.45);
    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 18px 40px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-subtle);
    --header-bg: rgba(7, 11, 18, 0.88);
    --grid-overlay: rgba(2, 8, 16, 0.58);

    --radius-sm: 6px;
    --radius: 6px;
    --radius-lg: 12px;
    --radius-xl: 12px;
    --sidebar-w: 252px;
    --rail-w: 72px;
    --topbar-h: 56px;

    --font-sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

[data-theme="light"] {
    color-scheme: light;

    --bg-deep: #eef3fb;
    --bg-sidebar: rgba(255, 255, 255, 0.96);
    --bg-panel: #ffffff;
    --bg-card: #f4f7fc;
    --bg-input: #ffffff;
    --bg-hover: rgba(19, 32, 51, 0.05);
    --bg-active: rgba(2, 132, 199, 0.09);

    --accent-primary: #0284c7;
    --accent-secondary: #0369a1;
    --accent-ink: #ffffff;
    --accent-soft: rgba(2, 132, 199, 0.10);
    --accent-success: #059669;
    --accent-warning: #d97706;
    --accent-error: #dc2626;
    --success-soft: rgba(5, 150, 105, 0.10);
    --warning-soft: rgba(217, 119, 6, 0.10);
    --error-soft: rgba(220, 38, 38, 0.08);

    --text-primary: #132033;
    --text-secondary: #415168;
    --text-muted: #74839b;

    --border-subtle: rgba(19, 32, 51, 0.10);
    --border-strong: rgba(19, 32, 51, 0.18);
    --shadow-color: rgba(0, 0, 0, 0.16);
    --shadow-card: 0 1px 2px rgba(19, 32, 51, 0.06), 0 1px 3px rgba(19, 32, 51, 0.04);
    --shadow-pop: 0 18px 40px -12px rgba(19, 32, 51, 0.25), 0 0 0 1px var(--border-subtle);
    --header-bg: rgba(255, 255, 255, 0.95);
    --grid-overlay: rgba(255, 255, 255, 0.56);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }

body {
    background-color: var(--bg-deep);
    background-image: linear-gradient(var(--grid-overlay), var(--grid-overlay)), url('grid.png');
    background-repeat: repeat, repeat;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .25s, color .25s;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; border-radius: 6px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

/* Theme-dependent images */
.only-light { display: none !important; }
[data-theme="light"] .only-light { display: block !important; }
[data-theme="light"] .only-dark { display: none !important; }

/* ── App shell ──────────────────────────────────────────────────────────── */
body.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    overflow: hidden;
}
body.app.rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    padding: 18px 14px 14px;
    gap: 6px;
    z-index: 60;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    color: inherit;
    text-decoration: none !important;
}
.brand img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-family: "Conthrax", var(--font-sans); font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.brand-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 14px 10px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 38px;
    padding: 0 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none !important;
    transition: background-color .15s, color .15s;
    white-space: nowrap;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--bg-active); color: var(--accent-primary); }
.nav-item .ext { margin-left: auto; width: 14px; height: 14px; opacity: .55; }

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* User menu (ids used by every page script: userMenu, userMenuBtn, headerEmail, logoutBtn) */
.user-menu { position: relative; flex: 1; min-width: 0; }
.user-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    cursor: pointer;
    text-align: left;
}
.user-trigger:hover, .user-menu.open .user-trigger { background: var(--bg-hover); }
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid; place-items: center;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent-primary);
    font-size: 13px; font-weight: 600;
    text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.user-meta .email { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 12px; color: var(--text-muted); }
.user-trigger > svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

.user-dropdown, .menu-pop {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    min-width: 210px;
    width: 100%;
    background: var(--bg-panel);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    padding: 6px;
    display: none;
    z-index: 80;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    text-decoration: none !important;
    font-size: 13.5px;
    cursor: pointer;
    text-align: left;
}
.user-dropdown svg { width: 16px; height: 16px; color: var(--text-muted); }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-hover); }
.user-dropdown button { color: var(--accent-error); }
.user-dropdown button svg { color: currentColor; }
.user-dropdown hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 6px 4px; }

.theme-toggle {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun-icon { display: none; }
[data-theme="light"] .theme-toggle .sun-icon { display: block; }
[data-theme="light"] .theme-toggle .moon-icon { display: none; }

/* Compact rail (display + files pages, where the workspace needs the width) */
@media (min-width: 900px) {
    body.rail .sidebar { padding: 18px 10px 12px; align-items: center; }
    body.rail .brand { padding: 4px 0 18px; justify-content: center; }
    body.rail .brand-text,
    body.rail .nav-label,
    body.rail .nav-item span,
    body.rail .nav-item .ext,
    body.rail .user-meta,
    body.rail .user-trigger > svg { display: none; }
    body.rail .nav { align-items: center; }
    body.rail .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; }
    body.rail .nav-sep { width: 28px; height: 1px; background: var(--border-subtle); margin: 10px 0; }
    body.rail .sidebar-footer { flex-direction: column-reverse; gap: 8px; width: 100%; }
    body.rail .user-menu { flex: none; }
    body.rail .user-trigger { padding: 4px; }
    body.rail .user-dropdown { left: calc(100% + 10px); bottom: 0; width: 220px; }
}
.nav-sep { display: none; }

/* Main column */
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.app-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

/* Mobile top bar */
.topbar {
    display: none;
    align-items: center;
    gap: 8px;
    height: var(--topbar-h);
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    position: relative;
    z-index: 40;
}
.topbar-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.topbar-title img { width: 24px; height: 24px; object-fit: contain; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
    width: 40px; height: 40px;
    display: inline-grid; place-items: center;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn svg { width: 20px; height: 20px; }

.scrim {
    position: fixed; inset: 0;
    background: rgba(2, 6, 12, 0.55);
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
    z-index: 55;
}

@media (max-width: 899.98px) {
    body.app, body.app.rail { grid-template-columns: minmax(0, 1fr); }
    .topbar { display: flex; }
    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: min(84vw, 300px);
        transform: translateX(-100%);
        transition: transform .22s ease;
        background: var(--bg-panel);
        padding-top: calc(18px + env(safe-area-inset-top, 0));
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
    }
    body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
    body.nav-open .scrim { opacity: 1; pointer-events: auto; }
}

/* ── Page scaffolding ───────────────────────────────────────────────────── */
.page {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 36px 56px;
}
.page.narrow { max-width: 960px; }
@media (max-width: 899.98px) { .page { padding: 20px 16px 40px; } }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.page-head p { color: var(--text-secondary); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 899.98px) {
    .page-head { margin-bottom: 18px; }
    .page-head h1 { font-size: 22px; }
}

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.crumbs a { color: var(--text-secondary); }
.crumbs svg { width: 14px; height: 14px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 600; }
.card-head p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent-primary); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent-primary); filter: brightness(1.08); border-color: transparent; }
.btn-secondary { background: var(--bg-card); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--accent-error); border-color: rgba(248, 113, 113, 0.30); }
.btn-danger:hover { background: var(--error-soft); border-color: rgba(248, 113, 113, 0.5); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }

.spinner-sm {
    width: 15px; height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
    opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Badges / status ────────────────────────────────────────────────────── */
.status-badge, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--bg-card);
    color: var(--text-secondary);
}
.status-badge .dot, .badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-badge.online { background: var(--success-soft); color: var(--accent-success); }
.status-badge.active, .status-badge.waiting { background: var(--warning-soft); color: var(--accent-warning); }
.status-badge.offline { background: var(--bg-card); color: var(--text-muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label, .form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-hint { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.form-group input, .field {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input::placeholder, .field::placeholder { color: var(--text-muted); }
.form-group input:focus, .field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-mono { font-family: var(--font-mono); font-size: 13.5px !important; letter-spacing: .02em; }

/* ── Inline messages ────────────────────────────────────────────────────── */
.message, .msg {
    display: none;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.message.error, .msg.err { display: block; background: var(--error-soft); color: var(--accent-error); border-color: rgba(248, 113, 113, 0.25); }
.message.success, .msg.ok { display: block; background: var(--success-soft); color: var(--accent-success); border-color: rgba(52, 211, 153, 0.25); }
.message.info { display: block; background: var(--accent-soft); color: var(--accent-primary); border-color: rgba(34, 211, 238, 0.22); }

/* ── Segmented control ──────────────────────────────────────────────────── */
.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}
.segmented button {
    height: 30px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.active { background: var(--bg-panel); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 0 0 1px var(--border-subtle); }
.segmented .count { color: var(--text-muted); margin-left: 4px; font-weight: 400; }

/* ── Key/value rows ─────────────────────────────────────────────────────── */
.kv { display: flex; flex-direction: column; }
.kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 46px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .label { color: var(--text-secondary); font-size: 13.5px; }
.kv-row .value { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state .empty-icon {
    width: 48px; height: 48px;
    margin: 0 auto 14px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--bg-card);
    color: var(--text-muted);
}
.empty-state .empty-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.empty-state p { max-width: 360px; margin: 0 auto; font-size: 13.5px; }

/* ── Pre-auth pages (login, claim) ──────────────────────────────────────── */
body.plain { display: flex; flex-direction: column; min-height: 100%; overflow-y: auto; }
.plain-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    padding-top: calc(16px + env(safe-area-inset-top, 0));
}
.plain-top .theme-toggle { border: 1px solid var(--border-subtle); background: var(--bg-panel); }
.plain-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 16px 48px; }
.plain-foot { text-align: center; padding: 0 16px 24px; font-size: 12.5px; color: var(--text-muted); }
.plain-foot a { color: var(--text-secondary); }
.plain-foot span { margin: 0 8px; opacity: .5; }
@media (max-width: 560px) { .plain-top { padding: 12px 16px; } }

/* Signed-out visitors on public pages (privacy policy) */
.user-menu.is-anonymous { display: none; }
.signin-link { display: none; flex: 1; }
.user-menu.is-anonymous ~ .signin-link { display: inline-flex; }
@media (min-width: 900px) { body.rail .signin-link { display: none !important; } }

/* Text placed straight on the grid background (page titles, breadcrumbs, footers).
   The grid reads as mid-grey in dark mode, so these need more contrast than in-card text. */
:root { --on-bg: #f5f8fc; --on-bg-muted: rgba(240, 245, 252, 0.80); }
[data-theme="light"] { --on-bg: var(--text-primary); --on-bg-muted: var(--text-secondary); }
.page-head h1, .page-head h2 { color: var(--on-bg); }
.page-head p, .crumbs, .crumbs a, .crumbs span, .plain-foot, .plain-foot a { color: var(--on-bg-muted); }
.crumbs a:hover, .plain-foot a:hover { color: var(--on-bg); }

/* ── Workspace pages (Display, Files) ───────────────────────────────────── */
.ws-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 20px;
    padding-top: calc(10px + env(safe-area-inset-top, 0));
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    flex-shrink: 0;
    position: relative;
    z-index: 40;
}
.ws-bar .nav-toggle { display: none; margin-left: -6px; }
.ws-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.ws-title .crumbs { margin: 0; color: var(--text-muted); }
.ws-title .crumbs a, .ws-title .crumbs span { color: var(--text-secondary); }
.ws-title .crumbs .here { color: var(--text-primary); font-weight: 600; font-size: 15px; }
.ws-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
@media (max-width: 899.98px) {
    .ws-bar { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top, 0)); min-height: 56px; gap: 6px; }
    .ws-bar .nav-toggle { display: inline-grid; }
    .ws-title .crumbs > :not(.here):not(svg.keep) { display: none; }
    .ws-title .crumbs svg, .ws-title .crumbs > span:not(.here) { display: none; }
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 11px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
}
.status-pill span { overflow: hidden; text-overflow: ellipsis; }
.status-pill .dot, .status-pill .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-pill .connected { background: var(--accent-success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-pill .connecting { background: var(--accent-warning); animation: pulse 1.6s ease-in-out infinite; }
.status-pill .error { background: var(--accent-error); }

/* Device switcher list (rendered by the page scripts) */
.panel-title { font-size: 14px; font-weight: 600; }
.connect-status { color: var(--text-secondary); font-size: 13px; margin: 4px 0 12px; }
.connect-device-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.connect-device-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 12px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}
.connect-device-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.connect-device-name { font-weight: 600; color: var(--text-primary); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connect-device-name:hover { color: var(--accent-primary); text-decoration: none; }
.device-state-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.device-state-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.device-state-pill.connected { color: var(--accent-primary); }
.device-state-pill.available { color: var(--accent-success); }
.connect-device-item:has(.device-state-pill.connected) { border-color: rgba(34, 211, 238, 0.35); background: var(--accent-soft); }
.btn-connect-device {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-panel);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-connect-device:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.btn-connect-device:disabled { opacity: .5; cursor: default; }
.connect-empty { padding: 16px 4px; color: var(--text-muted); font-size: 13px; text-align: center; }

/* Resizable right panel */
.side-resizer { display: none; }
@media (min-width: 900px) {
    .side-resizer { display: block; position: relative; width: 8px; margin-left: -4px; margin-right: -4px; cursor: col-resize; z-index: 5; flex-shrink: 0; }
    .side-resizer::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
    .side-resizer:hover::before, .side-resizer.dragging::before { background: var(--accent-primary); }
}

/* Phone tab bar + pull-up panel */
.mobile-bottom-container {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
}
@media (min-width: 900px) { .mobile-bottom-container { display: none; } }
.mobile-panel-content {
    display: none;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, .35);
    padding: 18px 16px 16px;
    overflow-y: auto;
}
.mobile-panel-content::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: -8px auto 12px; }
.mobile-panel-content.active { display: block; }
.mobile-bottom-bar {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0));
    background: var(--bg-panel);
    border-top: 1px solid var(--border-subtle);
}
.bottom-btn {
    flex: 1;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.bottom-btn svg { width: 22px; height: 22px; }
.bottom-btn span { font-size: 11.5px; font-weight: 500; }
.bottom-btn.active { color: var(--accent-primary); background: var(--accent-soft); }

/* ── Brand title font on page titles ── */
.page-head h1, .ws-title .crumbs .here, .topbar-title span, .auth-card h1, .claim-card .card-title, .policy h1 {
    font-family: "Conthrax", var(--font-sans);
    font-weight: 600;
    letter-spacing: .01em;
}
.page-head h1 { font-size: 24px; }
.ws-title .crumbs .here { font-size: 14px; }
@media (max-width: 899.98px) { .page-head h1 { font-size: 20px; } }

/* Disabled primary: solid neutral, not a faded accent */
.btn-primary:disabled, .btn-primary[aria-disabled="true"] {
    opacity: 1;
    background: var(--bg-card);
    color: var(--text-muted);
    border-color: var(--border-subtle);
    filter: none;
}

/* Product glyphs (AM100 meter, TalkBox speaker). Two layers:
   ::after  the line drawing, tinted by currentColor (as the tile sets it)
   ::before the device shell under it, in the model colour. The screen window
            and everything around the device stay transparent. */
:root { --shell-am100: #8b95a5; --shell-i10: #2f6bff; }
.dev-glyph {
    display: block;
    position: relative;
    width: 26px; height: 26px;
}
.dev-glyph::before,
.dev-glyph::after {
    content: "";
    position: absolute;
    inset: 0;
}
.dev-glyph::before {
    background-color: var(--shell-color, transparent);
    -webkit-mask: var(--shell, none) center / contain no-repeat;
    mask: var(--shell, none) center / contain no-repeat;
}
.dev-glyph::after {
    background-color: currentColor;
    -webkit-mask: var(--glyph) center / contain no-repeat;
    mask: var(--glyph) center / contain no-repeat;
}
.dev-glyph.am100 { --glyph: url('icons/am100.png'); --shell: url('icons/am100-shell.png'); --shell-color: var(--shell-am100); }
/* i10: the AM100 with a blue shell */
.dev-glyph.i10 { --glyph: url('icons/am100.png'); --shell: url('icons/am100-shell.png'); --shell-color: var(--shell-i10); }
.dev-glyph.talkbox { --glyph: url('icons/talkbox.png'); }
