:root {
    --transport-height: 60px;
}

header {
    display: grid;
    grid-template-columns: var(--sidebar-width, 248px) 1fr auto auto;
    align-items: center;
    height: var(--transport-height, 60px);
    padding: 0 16px 0 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: linear-gradient(180deg,
        var(--lux-bg-1, var(--bg-color)) 0%,
        var(--lux-bg-0, var(--bg-color)) 100%);
    border-bottom: var(--lux-hairline, 1px) solid var(--lux-line-bold, var(--border-color));
}

/* Accent rule — subtle bottom glow under the transport bar.
   Uses ::before because ::after is reserved by base.css for the
   ambient-background blur overlay. */
header::before {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        color-mix(in srgb, var(--ch-signal, var(--primary-color)) 30%, transparent) 15%,
        color-mix(in srgb, var(--ch-cyan, var(--primary-color)) 25%, transparent) 50%,
        color-mix(in srgb, var(--ch-magenta, var(--primary-color)) 20%, transparent) 85%,
        transparent 100%);
    opacity: 0.8;
    pointer-events: none;
    z-index: 1;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    height: 100%;
    border-right: var(--lux-hairline, 1px) solid var(--lux-line-bold, var(--border-color));
    position: relative;
}

/* Glowing LED brand mark. Rendered as a ::before on .header-title so no
   HTML change is required. The existing #server-status pulse dot sits
   inside as the "core" of the mark (see status-badge rule below). */
/* LED brand mark — 28 px glowing square with inset dark core.
   Glow intensity pulses subtly to reinforce the "live instrument" feel. */
.header-title::before {
    content: '';
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
    background: var(--ch-signal, var(--primary-color));
    box-shadow:
        0 0 22px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 55%, transparent),
        0 0 8px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 90%, transparent),
        inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    position: relative;
    animation: brandPulse 4s ease-in-out infinite;
}
.header-title::after {
    content: '';
    position: absolute;
    left: calc(18px + 8px);
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--lux-bg-0, var(--bg-color));
    border-radius: 2px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 40%, transparent);
    pointer-events: none;
}

@keyframes brandPulse {
    0%, 100% {
        box-shadow:
            0 0 22px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 55%, transparent),
            0 0 8px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 90%, transparent),
            inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    }
    50% {
        box-shadow:
            0 0 30px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 70%, transparent),
            0 0 12px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 95%, transparent),
            inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    }
}

/* Brand stack — title on one line, version under it, no wrap. */
.brand-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    line-height: 1;
    min-width: 0;
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    white-space: nowrap;
    -webkit-text-stroke: 0.4px color-mix(in srgb, var(--primary-color) 60%, transparent);
    paint-order: stroke fill;
    background: linear-gradient(
        90deg,
        var(--lux-ink, #e6ebf2) 0%,
        var(--ch-signal, var(--primary-color)) 50%,
        var(--lux-ink, #e6ebf2) 100%
    );
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: titleShimmer 8s linear infinite;
    line-height: 1;
    margin: 0;
    filter: drop-shadow(0 0 12px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 25%, transparent));
}

.brand-stack #server-version {
    font-size: 0.6rem;
    padding: 2px 7px;
    letter-spacing: 0.25em;
    align-self: flex-start;
}

@keyframes titleShimmer {
    to { background-position: -220% 50%; }
}

/* ── Transport center: reserved area for armed-status / master-stop /
       quick-search shortcut. Populated by JS in Phase 3; empty for now. ── */
.transport-center {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    color: var(--lux-ink-dim, var(--text-secondary));
}

.transport-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    background: var(--lux-bg-2, var(--bg-secondary));
    border: var(--lux-hairline, 1px) solid var(--lux-line, var(--border-color));
    border-radius: var(--lux-r-sm, 3px);
    color: var(--lux-ink-dim, var(--text-secondary));
    font-family: var(--font-mono, inherit);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.transport-status.is-armed {
    color: var(--ch-signal, var(--primary-color));
    border-color: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 45%, transparent);
    background: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 10%, transparent);
    box-shadow:
        inset 0 0 14px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 12%, transparent),
        0 0 18px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 20%, transparent);
    text-shadow: 0 0 10px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 40%, transparent);
}

.transport-status .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor, 0 0 3px currentColor;
    animation: pulse 1.4s ease-in-out infinite;
    flex-shrink: 0;
}
.transport-status:not(.is-armed) .dot {
    background: var(--lux-ink-faint, var(--text-muted));
    box-shadow: none;
    animation: none;
}

/* Transport meta — Uptime / CPU / Mem readouts as vertical KEY/VALUE stacks */
.transport-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 6px 0 16px;
    font-family: var(--font-mono, monospace);
}

.meta-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    line-height: 1;
    min-width: 0;
}

.meta-cell .k {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--lux-ink-faint, var(--text-muted));
}

.meta-cell .v {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--lux-ink, var(--text-color));
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Interactive meta-cell — clickable variant used by the Poll control.
   Lightweight hover + focus states so it reads as actionable without
   looking like a button. */
.meta-cell-interactive {
    cursor: pointer;
    padding: 4px 8px;
    margin: 0 -2px;
    border-radius: var(--lux-r-sm, 3px);
    border: var(--lux-hairline, 1px) solid transparent;
    outline: none;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}
.meta-cell-interactive:hover {
    background: var(--lux-bg-2, var(--bg-secondary));
    border-color: var(--lux-line, var(--border-color));
}
.meta-cell-interactive:focus-visible {
    border-color: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 50%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 20%, transparent);
}
.meta-cell-interactive:active {
    transform: translateY(0.5px);
}
.meta-cell-interactive .v {
    color: var(--ch-signal, var(--primary-color));
    text-shadow: 0 0 10px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 25%, transparent);
}

.meta-sep {
    width: 1px;
    height: 24px;
    background: var(--lux-line, var(--border-color));
    flex-shrink: 0;
}

h2 {
    margin-bottom: 20px;
    color: var(--text-color);
    font-size: 1.5rem;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    padding: 0;
}

.header-toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--lux-line, var(--border-color));
    margin: 0 6px;
    flex-shrink: 0;
}

.header-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 5px;
    transition: color 0.2s, background 0.2s;
}

.header-link:hover {
    color: var(--text-color);
    background: var(--bg-secondary);
}

.header-locale {
    padding: 2px 4px;
    border: none;
    border-radius: 5px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.header-locale:hover {
    color: var(--text-color);
    background: var(--bg-secondary);
}

/* ── Header locale picker (post IconSelect enhancement) ────────────────────
   The hidden <select.header-locale> is enhanced into a trigger button at
   runtime. Inside the toolbar, re-skin it to match .header-btn so it reads
   as a peer of the icon buttons, with the 2-letter code rendered as a small
   LED-style accent badge in Orbitron — same display font as the brand mark. */
.header-toolbar .icon-select-trigger {
    width: auto;
    gap: 6px;
    padding: 3px 6px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}

.header-toolbar .icon-select-trigger:hover {
    color: var(--text-color);
    background: var(--bg-secondary);
    border-color: transparent;
}

.header-toolbar .icon-select-trigger-icon {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--primary-color);
    padding: 3px 5px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--primary-color) 14%, transparent);
    line-height: 1;
}

.header-toolbar .icon-select-trigger-icon > span {
    font-weight: inherit;
}

.header-toolbar .icon-select-trigger-label {
    flex: 0 1 auto;
    font-weight: 500;
    font-size: 0.72rem;
    letter-spacing: 0.01em;
    margin: 0;
}

.header-toolbar .icon-select-trigger-arrow {
    font-size: 0.6rem;
    opacity: 0.55;
    margin-left: 1px;
}

#server-version {
    font-family: var(--font-mono, 'Orbitron', sans-serif);
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--ch-signal, var(--primary-color));
    background: transparent;
    border: var(--lux-hairline, 1px) solid color-mix(in srgb, var(--ch-signal, var(--primary-color)) 45%, transparent);
    padding: 2px 6px;
    border-radius: 2px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: background 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

#server-version.has-update {
    background: var(--ch-signal, var(--primary-color));
    border-color: var(--ch-signal, var(--primary-color));
    color: #fff;
    cursor: pointer;
    animation: updatePulse 2s ease-in-out infinite;
}

@keyframes updatePulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ch-signal, var(--primary-color)) 40%, transparent); }
    50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 0%, transparent); }
}

/* ── Update banner ──
   Channel-signal surface: top accent stripe + hairline border tinted to
   --ch-signal so it reads as part of the same Lumenworks language as
   toasts, modals, and the bulk toolbar. Version is rendered as an
   Orbitron chip — same family as the version badge in the header. */
.update-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 8px 16px;
    background: linear-gradient(180deg,
        var(--lux-bg-1, var(--bg-secondary)) 0%,
        var(--lux-bg-2, var(--bg-secondary)) 100%);
    border-bottom: var(--lux-hairline, 1px) solid color-mix(in srgb,
        var(--ch-signal, var(--primary-color)) 35%,
        var(--lux-line-bold, var(--border-color)));
    color: var(--lux-ink, var(--text-color));
    font-size: 0.85rem;
    font-weight: var(--weight-semibold, 600);
    letter-spacing: 0.01em;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.02),
        0 0 24px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 14%, transparent);
    animation: bannerSlideDown 0.3s var(--ease-out);
}

/* Top accent stripe — matches .toast::before so the channel language
   stays consistent across every floating/notification surface. */
.update-banner::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 1.5px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--ch-signal, var(--primary-color)) 20%,
        var(--ch-signal, var(--primary-color)) 80%,
        transparent 100%);
    box-shadow: 0 0 12px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 55%, transparent);
    pointer-events: none;
}

.update-banner-text {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    color: var(--lux-ink, var(--text-color));
}

.update-banner-version {
    font-family: var(--font-brand, 'Orbitron', sans-serif);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ch-signal, var(--primary-color));
    background: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 14%, transparent);
    border: var(--lux-hairline, 1px) solid color-mix(in srgb,
        var(--ch-signal, var(--primary-color)) 45%, transparent);
    padding: 2px 8px;
    border-radius: var(--lux-r-sm, 3px);
    line-height: 1.4;
    white-space: nowrap;
}

.update-banner-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.update-banner-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    border: var(--lux-hairline, 1px) solid transparent;
    color: var(--lux-ink-dim, var(--text-secondary));
    cursor: pointer;
    border-radius: var(--lux-r-sm, var(--radius-sm));
    transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.update-banner-action:hover {
    color: var(--ch-signal, var(--primary-color));
    background: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 12%, transparent);
    border-color: color-mix(in srgb, var(--ch-signal, var(--primary-color)) 35%, transparent);
    box-shadow: 0 0 10px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 25%, transparent);
}

.update-banner-apply {
    color: var(--ch-signal, var(--primary-color));
}

/* ── Donation banner ── */
.donation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.85rem;
    animation: bannerSlideDown 0.3s var(--ease-out);
}

.donation-banner-text {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.donation-banner-text .icon {
    width: 14px;
    height: 14px;
    color: #e25555;
    flex-shrink: 0;
}

.donation-banner-action {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.donation-banner-action:hover {
    color: var(--primary-color);
    background: var(--border-color);
}

.donation-banner-donate {
    color: #e25555;
}

.donation-banner-donate:hover {
    color: #ff6b6b;
    background: rgba(226, 85, 85, 0.1);
}

@keyframes bannerSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* #server-status visual hidden — the brand mark itself carries the
   connection state. When JS adds `.offline`, the mark shifts to coral
   via the :has() modifier on .header-title below. */
.status-badge {
    display: none;
}

/* Brand mark reflects connection state. Default is the running-color
   (tracks --ch-signal / --primary-color). When the server-status element
   has `.offline`, override to coral so the header reads "disconnected"
   without needing a separate pip. */
.header-title:has(#server-status.offline)::before {
    background: var(--ch-coral, var(--danger-color));
    box-shadow:
        0 0 22px color-mix(in srgb, var(--ch-coral, var(--danger-color)) 55%, transparent),
        0 0 8px color-mix(in srgb, var(--ch-coral, var(--danger-color)) 90%, transparent),
        inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    animation: none;
}
.header-title:has(#server-status.offline)::after {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ch-coral, var(--danger-color)) 40%, transparent);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Demo mode badge (header) */
.demo-badge {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #1a1a1a;
    background: #ffb300;
    padding: 2px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    animation: demoPulse 3s ease-in-out infinite;
    white-space: nowrap;
}

@keyframes demoPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Demo mode banner (top of page) */
.demo-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 16px;
    background: linear-gradient(90deg, #ff8f00, #ffb300);
    color: #1a1a1a;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    z-index: var(--z-sticky, 100);
    position: relative;
}

.demo-banner-dismiss {
    background: none;
    border: none;
    color: #1a1a1a;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
    line-height: 1;
    flex-shrink: 0;
}

.demo-banner-dismiss:hover {
    opacity: 1;
}

/* Connection lost overlay */
.connection-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-connection);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    overflow: hidden;
}

.connection-overlay-content {
    text-align: center;
    color: #fff;
}

.connection-overlay-content h2 {
    margin: 16px 0 8px;
    font-size: 1.4rem;
}

.connection-overlay-content p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.95rem;
}

.connection-spinner-lg {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: conn-spin 0.8s linear infinite;
}

@keyframes conn-spin {
    to { transform: rotate(360deg); }
}

/* Device card ping button spinning animation */
.card-ping-btn.spinning svg {
    animation: conn-spin 0.8s linear infinite;
}

/* Visually hidden — screen readers only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* WLED device health indicator */
.health-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

.health-dot.health-online {
    background-color: var(--primary-color);
    box-shadow: 0 0 6px color-mix(in srgb, var(--primary-color) 60%, transparent); /* --primary-color glow */
}

.health-dot.health-offline {
    background-color: var(--danger-color);
    box-shadow: 0 0 6px color-mix(in srgb, var(--danger-color) 60%, transparent); /* --danger-color glow */
}

.health-dot.health-unknown {
    background-color: var(--text-secondary);
    animation: pulse 2s infinite;
}

.health-latency {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--primary-text-color);
    margin-left: auto;
    padding-left: 8px;
    opacity: 0.85;
}

.health-latency.offline {
    color: var(--danger-color);
}

/* ── Tabs (base styles; sidebar.css re-specializes for vertical rail;
       mobile.css reverts to a fixed bottom bar on phones) ── */
.tab-bar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s ease, border-color 0.25s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-color);
}

.tab-btn.active {
    color: var(--primary-text-color);
    border-bottom-color: var(--primary-color);
}

.tab-badge {
    background: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    min-width: 16px;
    text-align: center;
    line-height: 1.3;
    display: inline-block;
}

.tab-btn.active .tab-badge {
    background: var(--primary-color);
    color: var(--primary-contrast);
}

.tab-panel {
    display: none;
    position: relative;
}

.tab-panel.active {
    display: block;
    animation: tabFadeIn 0.25s ease-out;
}

@keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Thin animated bar at top of tab panel during data refresh */
.tab-panel.refreshing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 2px;
    background: var(--primary-color);
    border-radius: 1px;
    animation: tab-loading-slide 1.2s ease-in-out infinite;
    z-index: 2;
}

@keyframes tab-loading-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

/* Header toolbar buttons */
/* Header icon buttons — hairline-bordered squares with channel glow
   on hover. Mirrors the mockup's `.icon-btn` treatment. */
.header-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--lux-r-sm, 3px);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--lux-ink-dim, var(--text-secondary));
    transition: color 0.2s, background 0.2s, box-shadow 0.2s;
    display: inline-grid;
    place-items: center;
    line-height: 1;
    flex-shrink: 0;
}

.header-btn:hover {
    color: var(--lux-ink, var(--text-color));
    background: var(--lux-bg-2, var(--bg-secondary));
    box-shadow: 0 0 12px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 18%, transparent);
}

.header-btn .icon {
    width: 15px;
    height: 15px;
}

/* Reusable color picker popover */
.color-picker-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.color-picker-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.color-picker-swatch:hover {
    box-shadow: 0 0 6px var(--primary-color);
}
.color-picker-popover {
    position: absolute;
    top: calc(100% + 8px);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 8px 24px var(--shadow-color);
    z-index: 200;
    animation: color-picker-pop-in 0.15s ease-out;
}
.color-picker-popover.anchor-right { right: 0; }
.color-picker-popover.anchor-left  { left: 0; }
.color-picker-popover.cp-fixed { z-index: 1000; }
@keyframes color-picker-pop-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.color-picker-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    padding: 0;
}
.color-picker-dot:hover {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(255,255,255,0.2);
}
.color-picker-dot.active {
    border-color: var(--text-color);
    box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px var(--text-color);
}
.color-picker-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.color-picker-reset {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.color-picker-reset:hover {
    color: var(--danger-color);
}
.color-picker-custom input[type="color"] {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

/* Command Palette */
#command-palette {
    position: fixed;
    inset: 0;
    z-index: var(--z-command-palette);
    display: flex;
    justify-content: center;
    padding-top: 15vh;
}

.cp-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(1000px 600px at 50% 30%,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.8) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.15s ease-out;
}

.cp-dialog {
    position: relative;
    width: 520px;
    max-width: 90vw;
    max-height: 60vh;
    background: var(--lux-bg-1, var(--card-bg));
    border: var(--lux-hairline, 1px) solid var(--lux-line-bold, var(--border-color));
    border-radius: var(--lux-r-md, 12px);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.02),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 8px 32px var(--shadow-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-self: flex-start;
    animation: cpSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Channel-accent rule across the top edge (matches modals) */
.cp-dialog::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--ch-signal, var(--primary-color)) 20%,
        var(--ch-cyan, var(--primary-color)) 50%,
        var(--ch-magenta, var(--primary-color)) 80%,
        transparent 100%);
    opacity: 0.9;
    box-shadow: 0 0 12px color-mix(in srgb, var(--ch-signal, var(--primary-color)) 40%, transparent);
    pointer-events: none;
    z-index: 2;
}

@keyframes cpSlideDown {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cp-input {
    width: 100%;
    padding: 16px 18px 14px 18px;
    border: none;
    border-bottom: var(--lux-hairline, 1px) solid var(--lux-line, var(--border-color));
    background: transparent;
    color: var(--lux-ink, var(--text-color));
    font-family: var(--font-body, inherit);
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    letter-spacing: -0.005em;
}

.cp-input::placeholder {
    color: var(--lux-ink-mute, var(--text-secondary));
    font-family: var(--font-mono, inherit);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

.cp-results {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.cp-group-header {
    font-family: var(--font-mono, inherit);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--lux-ink-mute, var(--text-secondary));
    padding: 10px 18px 4px;
}

.cp-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
    z-index: 1;
    color: var(--lux-ink-dim, var(--text-color));
}

.cp-result:hover {
    background: var(--lux-bg-3, var(--bg-secondary));
    color: var(--lux-ink, var(--text-color));
}

.cp-result.cp-active {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--ch-signal, var(--primary-color)) 18%, transparent) 0%,
        transparent 100%);
    color: var(--lux-ink, var(--text-color));
    box-shadow: inset 2px 0 0 var(--ch-signal, var(--primary-color));
}

.cp-result.cp-active .cp-detail {
    color: var(--primary-contrast);
    opacity: 0.7;
}

.cp-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.cp-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.cp-detail {
    flex-shrink: 0;
    font-family: var(--font-mono, inherit);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: var(--lux-ink-mute, var(--text-secondary));
}

.cp-running {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    box-shadow: 0 0 4px var(--primary-color);
}

.cp-action-item .cp-icon {
    opacity: 0.85;
}

.cp-action-item .cp-detail {
    font-weight: 600;
    color: var(--primary-color);
}

.cp-action-item.cp-active .cp-detail {
    color: var(--primary-contrast);
    opacity: 0.9;
}

.cp-loading,
.cp-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.cp-footer {
    padding: 8px 18px;
    border-top: var(--lux-hairline, 1px) solid var(--lux-line, var(--border-color));
    font-family: var(--font-mono, inherit);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    color: var(--lux-ink-mute, var(--text-secondary));
    text-align: center;
    background: color-mix(in srgb, var(--lux-bg-0, transparent) 40%, transparent);
}

/* On narrow screens the brand column shrinks to just the mark; on phones
   the sidebar hides entirely and mobile.css reverts .tab-bar to a fixed
   bottom strip. */
@media (max-width: 1100px) {
    /* Keep all four header children (title | center | meta | toolbar) on one
       row. Without an explicit 4th track they wrap, doubling the header. */
    header {
        grid-template-columns: var(--sidebar-width, 56px) auto 1fr auto;
    }
    .header-title {
        padding: 0 10px;
        justify-content: center;
        gap: 0;
    }
    .header-title h1,
    #server-version,
    .header-title::after {
        display: none;
    }
    .transport-center {
        padding: 0 10px;
    }
    /* Tighter meta cluster — drop the trailing separator and shrink gaps */
    .transport-meta {
        gap: 10px;
        padding: 0 4px 0 8px;
        justify-content: flex-end;
    }
    .transport-meta .meta-sep:last-child {
        display: none;
    }
    /* Tighter toolbar so it fits beside the meta cluster */
    .header-toolbar {
        gap: 2px;
    }
    .header-toolbar-sep {
        margin: 0 2px;
    }
    /* Hide secondary header items at narrow widths to free room */
    .header-link,
    #tour-restart-btn {
        display: none;
    }

    .container {
        padding: 16px;
    }
}

/* Tablet/phone shoulder: the meta cluster still wants ~280px which collides
   with the toolbar below 900px. Drop CPU + Mem cells (Uptime + Poll stay,
   they're the most useful at-a-glance signals). */
@media (max-width: 900px) {
    #transport-cpu,
    #transport-mem {
        display: none;
    }
    .transport-meta .meta-cell:has(#transport-cpu),
    .transport-meta .meta-cell:has(#transport-mem) {
        display: none;
    }
    .transport-meta > .meta-sep:nth-of-type(1) {
        display: none;
    }
}

@media (max-width: 600px) {
    header {
        grid-template-columns: auto 1fr auto;
        padding: 0 8px 0 0;
    }
    .header-title {
        padding: 0 10px;
        border-right: none;
    }
    .transport-center {
        display: none;
    }
    /* Below the phone breakpoint the sidebar vanishes and the bottom tab
       bar takes over, so most of the meta cluster goes too. */
    .transport-meta {
        display: none;
    }
    .container {
        padding: 10px;
    }
}
