/*
 * Copyright 2026 LabRat contributors
 * SPDX-License-Identifier: Apache-2.0
 *
 * LabRat's shared visual styles.
 *
 * HOW TO CUSTOMIZE THIS FILE
 * --------------------------
 * 1. Start in Section 01 to change the colors, spacing, or overall width.
 * 2. Each section is named for the part of the UI it controls.
 * 3. Selectors use the same descriptive class names found in the HTML files.
 * 4. Keep one property per line so changes are easy to compare in Git.
 * 5. The last section contains small-screen layout adjustments.
 *
 * No CSS framework, build step, or generated/minified output is required.
 *
 * Used by: every page.
 */


/* ========================================================================== */
/* 00. SELF-HOSTED FONTS                                                      */
/* ========================================================================== */

/*
 * Both faces are variable fonts under the SIL Open Font License; the license
 * texts sit next to the files in static/fonts/. They are served locally so
 * LabRat never calls out to a font CDN.
 */
@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/SpaceGrotesk-Variable.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/JetBrainsMono-Variable.woff2") format("woff2");
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}


/* ========================================================================== */
/* 01. COLORS AND SHARED SETTINGS                                             */
/* ========================================================================== */

:root {
    /*
     * Surfaces, from darkest to lightest. Change these first when creating
     * a new theme. Page stylesheets should not introduce their own shades.
     */
    --color-surface-sunken: #020506;
    --color-brand-plate: var(--color-surface-sunken);
    /* Its border, a step toward the strong border (owner); themes follow. */
    --color-brand-plate-border: color-mix(in srgb, var(--color-border), var(--color-border-strong) 45%);
    --color-page-background: #04080a;
    --color-field-background: #071013;
    --color-panel-background-deep: #0a1216;
    --color-panel-background: #0e1a1f;
    --color-surface-raised: #15242a;
    --color-surface-hover: #1d3037;

    /* Borders, from barely visible to high contrast. */
    --color-border-subtle: #1a272d;
    --color-border: #2f3e46;
    --color-border-strong: #4a5d66;
    --color-border-bright: #7f959d;

    /* Text colors. Keep enough contrast for comfortable reading. */
    --color-text-primary: #e4eee9;
    --color-text-secondary: #b2c4bc;
    --color-text-muted: #8fa49b;
    --color-text-faint: #5f746b;

    /*
     * Accent colors used for buttons, links, focus, and selection: the
     * console's phosphor green (the control-room look, used on every page).
     */
    --color-accent: #7dffb2;
    --color-accent-strong: #b9ffd6;
    --color-accent-muted: #3c8460;
    --color-accent-surface: #10291c;
    --color-accent-dark: #06170e;
    --color-accent-soft: #7dffb21f;
    --color-success: #69d5a5;
    --color-error: #f19a93;
    --color-error-background: #372127;

    /*
     * Status colors. Each one always means the same thing on every page:
     * ok = up or confirmed, warning = inferred or needs a look,
     * tentative = ambiguous, error = failed or down.
     */
    --color-status-ok: var(--color-success);
    --color-status-ok-surface: #17382e;
    --color-status-warning: #f2c46d;
    --color-status-warning-surface: #3a3122;
    --color-status-tentative: var(--color-text-muted);
    --color-status-error: var(--color-error);
    --color-status-error-surface: #3a2429;

    /*
     * Lamps keep their colors in every theme (owner's choice), apart from
     * the accent: lamp-on is a lamp that means online, live, or all clear;
     * lamp-port a lit network port, NIC, or the port-state ring.
     */
    --color-lamp-on: var(--color-phosphor);
    --color-lamp-port: var(--color-signal-network);

    /* Port lights. A lit port uses --color-status-ok. */
    --color-led-off: #59636b;
    --color-led-off-edge: #82909a;

    /* Port connector types shown in Rack View port details. */
    --color-connector-rj45: #f0bd72;
    --color-connector-sfp: #8f9dff;
    --color-connector-combo: #72d6c1;

    /* Observed cables between ports (Discovery map and port details). */
    --color-cable: #6090ad;
    --color-cable-tentative: #8b9299;

    /*
     * Cable media, after real-world jacket colors so a drawn cable reads like
     * the one in the rack. Single-mode yellow is brighter than the AP amber.
     */
    --color-cable-copper: #6f9cf2;
    --color-cable-dac: #c9d1dc;
    --color-cable-fiber-mm: #3fd3e0;
    /* Violet, well apart from the UPS/USB yellow and the lavender router type (owner). */
    --color-cable-fiber-sm: #a66cff;
    --color-cable-fiber: #9fe0c9;
    --color-cable-unknown: #7a8698;
    /* Wi-Fi links (Equipment): a darker green than status, a medium like the cables. */
    --color-cable-wifi: #2f9a5a;

    /*
     * Device types. Every view that colors a device by type uses these, so
     * a switch is the same green on the map, in a rack, and in a room.
     */
    --color-type-server: #83b7e1;
    --color-type-server-surface: #213850;
    --color-type-switch: #54c6aa;
    --color-type-switch-surface: #1e3841;
    --color-type-router: #bd8cf0;
    --color-type-router-surface: #352b48;
    --color-type-firewall: #f18c80;
    --color-type-firewall-surface: #452d32;
    --color-type-ap: #e1bf71;
    --color-type-ap-surface: #3a3424;
    --color-type-ups: #d6d268;
    --color-type-ups-surface: #393925;
    --color-type-modem: #55d8e8;
    --color-type-modem-surface: #173a43;

    /*
     * Furniture: things that hold equipment rather than equipment itself.
     * "Mount" covers shelves and rack tops (bronze); racks are teal.
     */
    --color-furniture-mount: #a98655;
    --color-furniture-mount-surface: #3a3124;
    --color-furniture-mount-text: #f0d598;
    --color-furniture-rack: #66adb7;
    --color-furniture-rack-surface: #1b3a45;

    /*
     * Control-room console (room Equipment view): instrument panels,
     * phosphor readouts, and annunciator lamps. Alarm is red, warning amber,
     * advisory blue; unlit lamps are near-black with engraved-looking text.
     */
    --color-console-background: var(--color-page-background);
    --color-console-panel: var(--color-panel-background-deep);
    --color-console-panel-raised: var(--color-panel-background);
    --color-console-bezel: #18232a;
    --color-console-bezel-edge: var(--color-border);
    --color-console-bezel-highlight: var(--color-border-strong);
    --color-phosphor: var(--color-accent);
    --color-phosphor-soft: var(--color-accent-strong);
    --color-phosphor-dim: var(--color-accent-muted);
    --color-phosphor-faint: #7dffb21a;
    --color-console-alarm: #ff5b4d;
    --color-console-alarm-dim: #4a1a16;
    --color-console-warning: #ffb547;
    --color-console-warning-dim: #47320f;
    --color-console-advisory: #7cc8ff;
    --color-console-advisory-dim: #15324a;
    /* Recessed wells inside a console panel (meters, port strips). */
    --color-console-recess: color-mix(in srgb, var(--color-console-panel) 60%, black);
    /* An empty rack bay, between the unit lines. */
    --color-rack-bay: color-mix(in srgb, var(--color-console-panel) 70%, black);
    --color-annunciator-off: #0d1418;
    --color-annunciator-off-text: #43535b;
    /*
     * Signal-domain hues (Observations): each kind of signal keeps one hue,
     * so a panel is recognizable by color. Green stays reserved for healthy,
     * amber for warnings, and red for alarms, so a problem never hides among
     * decorative hues.
     */
    --color-signal-internet: #46d9ee;
    --color-signal-internet-tx: #9db4ff;
    --color-signal-vpn: #c39bff;
    --color-signal-compute: #7fb0ff;
    --color-signal-network: #3fd1b8;
    --color-signal-neutral: #a9bccb;
    --color-signal-power: #f07ad8;
    /*
     * Effects. Disco is the only theme with decorative glow and scanlines;
     * Dark and Light turn these off (section 01b). Lamps that mean "on"
     * keep their glow in every theme.
     *   --console-glow     Soft phosphor glow on lit titles and readouts.
     *   --effect-scanline  The faint CRT lines on panels and drawers.
     *   --color-shadow     What shadows and dark mixes are made of.
     *   --color-lift       What "lighter" mixes move toward: white on dark
     *                      themes, dark ink on Light, so tinted text stays
     *                      readable.
     *   --color-shade      What surfaces darken toward for depth.
     */
    --console-glow: 0 0 6px color-mix(in srgb, var(--color-phosphor) 55%, transparent);
    --effect-scanline: color-mix(in srgb, black 14%, transparent);
    --effect-scanline-soft: color-mix(in srgb, black 10%, transparent);
    --effect-scanline-strong: color-mix(in srgb, black 18%, transparent);
    --color-shadow: black;
    --color-lift: white;
    /* What a surface darkens toward for depth (gradients, meter starts). */
    --color-shade: black;

    /* Shadows. */
    --shadow-raised: 0 10px 26px color-mix(in srgb, var(--color-shadow) 45%, transparent);
    --shadow-overlay: 0 22px 65px color-mix(in srgb, var(--color-shadow) 35%, transparent);

    /*
     * Type families.
     *   --font-display  Headings, brand, and navigation.
     *   --font-sans     Body text.
     *   --font-mono     Data: IDs, U numbers, MACs, speeds, counts, sources.
     * Display and mono faces are self-hosted (see section 00); each stack
     * falls back to system fonts if the files are missing.
     */
    --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas,
        "Liberation Mono", monospace;

    /*
     * Action color: the one solid button per page. Deliberately orange so it
     * never reads as a status (warning yellow) or a device type (AP amber).
     */
    --color-action: #f5a35c;
    --color-action-strong: #ffbd85;
    --color-action-ink: #2a1505;

    /* Type scale. Pick the nearest step instead of a one-off size. */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: clamp(1.75rem, 3.5vw, 2.5rem);
    --text-3xl: clamp(2rem, 5vw, 3.4rem);

    /* Spacing scale for gaps, padding, and margins. */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;

    /* Corner radii. Cards, controls, small chips, and fully round pills. */
    --radius-card: 16px;
    --radius-control: 10px;
    --radius-small: 6px;
    --radius-pill: 999px;

    /* Page widths. Reading pages use --width-page; workspaces go wider. */
    --width-page: 1100px;
    --width-workspace: 1600px;
    --width-form: 620px;
    --space-page-gutter: 1.5rem;

    /*
     * Theme previews on the Settings page: a background, a panel, and an
     * accent per theme, so each choice shows a miniature of itself before
     * it is picked. Keep them in step with each theme's own tokens.
     */
    --theme-preview-disco-page: #04080a;
    --theme-preview-disco-panel: #0e1a1f;
    --theme-preview-disco-line: #2f3e46;
    --theme-preview-disco-accent: #7dffb2;
    --theme-preview-disco-glow: #55d8e8;
    --theme-preview-dark-page: #16181c;
    --theme-preview-dark-panel: #22252b;
    --theme-preview-dark-line: #3a3f47;
    --theme-preview-dark-accent: var(--accent-choice-blue-dark);
    --theme-preview-dark-glow: var(--accent-choice-blue-dark);
    --theme-preview-light-page: #f4f5f7;
    --theme-preview-light-panel: #ffffff;
    --theme-preview-light-line: #d5d9e0;
    --theme-preview-light-accent: var(--accent-choice-blue-light);
    --theme-preview-light-glow: var(--accent-choice-blue-light);

    /*
     * Accent choices for Dark and Light (Settings; data-accent). Each has a
     * Light and a Dark shade, checked for at least 4.5:1 contrast as text on
     * the theme's page, panel, hover, and accent surfaces, and under text on
     * a solid accent fill. Section 01b builds the full accent from them.
     */
    --accent-choice-blue-light: #2560c4;
    --accent-choice-blue-dark: #8ab4f8;
    --accent-choice-red-light: #c42a3c;
    --accent-choice-red-dark: #f58b94;
    --accent-choice-purple-light: #7547d1;
    --accent-choice-purple-dark: #b9a1ff;
    --accent-choice-pink-light: #c21f6a;
    --accent-choice-pink-dark: #f48fbf;

    color-scheme: dark;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.55;

    background-color: var(--color-page-background);
    color: var(--color-text-primary);
}


/* ========================================================================== */
/* 01b. DARK AND LIGHT THEMES                                                 */
/* ========================================================================== */

/*
 * :root above is Disco, the control-room look and the default. Dark and
 * Light are calmer, neutral themes; "Match my system" (data-theme="system")
 * picks between them from the device setting. labrat/themes.py writes the
 * browser's choice to <html data-theme>.
 *
 * Each token below gives its Light value first and its Dark value second
 * through light-dark(), which follows color-scheme: Dark sets "dark", Light
 * "light", and system "light dark". Tokens not listed keep Disco's value.
 * Status, device-type, and signal colors keep Disco's hues on Dark and get
 * deeper versions on Light so they stay readable on white.
 */
:root[data-theme="dark"] {
    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="system"] {
    color-scheme: light dark;
}

:root:is([data-theme="dark"], [data-theme="light"], [data-theme="system"]) {
    /* Surfaces, darkest (Light: lightest) first. */
    --color-surface-sunken: light-dark(#e9ecf0, #101215);
    /*
     * The header logo's pill stands off the page (owner): Light's is 5%
     * darker than the sunken surface, Dark's lighter than the page.
     */
    --color-brand-plate: light-dark(#dde0e4, #272b32);
    --color-page-background: light-dark(#f4f5f7, #16181c);
    --color-field-background: light-dark(#ffffff, #1b1e23);
    --color-panel-background-deep: light-dark(#ffffff, #1d2025);
    --color-panel-background: light-dark(#f8f9fb, #22252b);
    --color-surface-raised: light-dark(#ffffff, #2a2e35);
    --color-surface-hover: light-dark(#eef1f5, #30353d);

    --color-border-subtle: light-dark(#e6e9ee, #2a2e35);
    --color-border: light-dark(#d5d9e0, #3a3f47);
    --color-border-strong: light-dark(#b4bbc6, #4f5661);
    --color-border-bright: light-dark(#7d8796, #7b8491);

    --color-text-primary: light-dark(#1c2330, #e6e8eb);
    --color-text-secondary: light-dark(#465061, #b9bec7);
    --color-text-muted: light-dark(#5f6b7c, #959ca8);
    --color-text-faint: light-dark(#8a94a3, #6b727d);

    /*
     * The accent: blue unless data-accent picks another (blocks below).
     * Soft and faint tints follow whichever accent is chosen.
     */
    --color-accent: light-dark(var(--accent-choice-blue-light), var(--accent-choice-blue-dark));
    --color-accent-strong: light-dark(#1b4ea6, #b3cdfb);
    --color-accent-muted: light-dark(#9dbcef, #4d6c9c);
    --color-accent-surface: light-dark(#e7effc, #22304a);
    --color-accent-dark: light-dark(#ffffff, #0e1a2e);
    --color-accent-soft: color-mix(in srgb, var(--color-accent) 12%, transparent);
    --color-success: light-dark(#1f8a5b, #6cc9a1);
    --color-error: light-dark(#c4372b, #f19a93);
    --color-error-background: light-dark(#fbe9e7, #3a2429);

    --color-status-ok-surface: light-dark(#e3f4ec, #1e3a30);
    --color-status-warning: light-dark(#a86a00, #f2c46d);
    --color-status-warning-surface: light-dark(#fbf1dc, #3a3122);
    --color-status-error-surface: light-dark(#fbe9e7, #3a2429);

    --color-lamp-on: var(--color-status-ok);
    --color-lamp-port: light-dark(#138f7a, #3fd1b8);
    --color-led-off: light-dark(#b7bec8, #59636b);
    --color-led-off-edge: light-dark(#8d96a3, #82909a);

    --color-connector-rj45: light-dark(#b7741a, #f0bd72);
    --color-connector-sfp: light-dark(#5561d6, #8f9dff);
    --color-connector-combo: light-dark(#1f9a85, #72d6c1);

    --color-cable: light-dark(#3f7598, #6090ad);
    --color-cable-tentative: light-dark(#8b9299, #8b9299);
    --color-cable-copper: light-dark(#3567c9, #6f9cf2);
    --color-cable-dac: light-dark(#7d8794, #c9d1dc);
    --color-cable-fiber-mm: light-dark(#0e9fb0, #3fd3e0);
    --color-cable-fiber-sm: light-dark(#7b3fe0, #a66cff);
    --color-cable-fiber: light-dark(#2e9a78, #9fe0c9);
    --color-cable-unknown: light-dark(#8a94a3, #7a8698);
    --color-cable-wifi: light-dark(#1f7a43, #2f9a5a);

    --color-type-server: light-dark(#2f72b0, #83b7e1);
    --color-type-server-surface: light-dark(#e3eef8, #213850);
    --color-type-switch: light-dark(#148a6e, #54c6aa);
    --color-type-switch-surface: light-dark(#ddf3ec, #1e3841);
    --color-type-router: light-dark(#8250c4, #bd8cf0);
    --color-type-router-surface: light-dark(#efe6fa, #352b48);
    --color-type-firewall: light-dark(#c24a3b, #f18c80);
    --color-type-firewall-surface: light-dark(#fbe6e3, #452d32);
    --color-type-ap: light-dark(#a8761a, #e1bf71);
    --color-type-ap-surface: light-dark(#f8eedb, #3a3424);
    --color-type-ups: light-dark(#8f8a12, #d6d268);
    --color-type-ups-surface: light-dark(#f3f2d6, #393925);
    --color-type-modem: light-dark(#0f8fa3, #55d8e8);
    --color-type-modem-surface: light-dark(#dcf3f6, #173a43);

    --color-furniture-mount: light-dark(#9a7542, #a98655);
    --color-furniture-mount-surface: light-dark(#f3ece0, #3a3124);
    --color-furniture-mount-text: light-dark(#6f5428, #f0d598);
    --color-furniture-rack: light-dark(#2f8590, #66adb7);
    --color-furniture-rack-surface: light-dark(#ddeef0, #1b3a45);

    /* The console keeps its layout; its finish becomes plain panels. */
    --color-console-bezel: light-dark(#e6e9ee, #262a31);
    --color-phosphor-faint: color-mix(in srgb, var(--color-accent) 10%, transparent);
    --color-console-alarm: light-dark(#d7372a, #ff5b4d);
    --color-console-alarm-dim: light-dark(#fbe3e0, #4a1a16);
    --color-console-warning: light-dark(#c77a00, #ffb547);
    --color-console-warning-dim: light-dark(#fcefd7, #47320f);
    --color-console-advisory: light-dark(#2a7fd0, #7cc8ff);
    --color-console-advisory-dim: light-dark(#e1eefb, #15324a);
    --color-console-recess: light-dark(#eceff3, #15171b);
    --color-rack-bay: light-dark(#eef0f3, #17191d);
    --color-annunciator-off: light-dark(#eef1f5, #1b1e23);
    --color-annunciator-off-text: light-dark(#a0a9b6, #4d5560);

    /*
     * One palette, by the owner's choice: Disco gives each signal domain its
     * own hue, but Dark and Light use the accent for every domain, so Home,
     * Observations, and the landing page read as one family. Upload and
     * transmit lines keep a quiet steel tone so charts still show two
     * series. Status colors still say ok, warning, and alarm.
     */
    --color-signal-internet: var(--color-accent);
    --color-signal-internet-tx: light-dark(#7f93b4, #a7b4c8);
    --color-signal-vpn: var(--color-accent);
    --color-signal-compute: var(--color-accent);
    --color-signal-network: var(--color-accent);
    --color-signal-neutral: light-dark(#5f7385, #a9bccb);
    --color-signal-power: var(--color-accent);

    --color-action: light-dark(#d9701f, #f5a35c);
    --color-action-strong: light-dark(#c25f12, #ffbd85);
    --color-action-ink: light-dark(#ffffff, #2a1505);

    /* No decorative glow or scanlines; softer shadows on Light. */
    --console-glow: none;
    --effect-scanline: transparent;
    --effect-scanline-soft: transparent;
    --effect-scanline-strong: transparent;
    /* Translucent on Light, so every shadow and vignette scales down. */
    --color-shadow: light-dark(#3b465640, black);
    --color-lift: light-dark(#1c2330, white);
    --color-shade: light-dark(#aab2be, black);
}


/*
 * Accent choices: the shades that go with each base color. Strong is the
 * hover and pressed text, muted a border tint, surface a pale (Light) or
 * deep (Dark) fill under accent text, dark the ink on a solid accent fill.
 */
:root:is([data-theme="dark"], [data-theme="light"], [data-theme="system"])[data-accent="red"] {
    --color-accent: light-dark(var(--accent-choice-red-light), var(--accent-choice-red-dark));
    --color-accent-strong: light-dark(#a01d2e, #ffb8be);
    --color-accent-muted: light-dark(#eba3ad, #8c4a52);
    --color-accent-surface: light-dark(#fce8eb, #3d2329);
    --color-accent-dark: light-dark(#ffffff, #2a0d11);
}

:root:is([data-theme="dark"], [data-theme="light"], [data-theme="system"])[data-accent="purple"] {
    --color-accent: light-dark(var(--accent-choice-purple-light), var(--accent-choice-purple-dark));
    --color-accent-strong: light-dark(#5a32ad, #d6c9ff);
    --color-accent-muted: light-dark(#c4b0ef, #6a5a9c);
    --color-accent-surface: light-dark(#f1ebfc, #2e2944);
    --color-accent-dark: light-dark(#ffffff, #1b1433);
}

:root:is([data-theme="dark"], [data-theme="light"], [data-theme="system"])[data-accent="pink"] {
    --color-accent: light-dark(var(--accent-choice-pink-light), var(--accent-choice-pink-dark));
    --color-accent-strong: light-dark(#9c1655, #f9bcd9);
    --color-accent-muted: light-dark(#eeaac6, #8c4d6b);
    --color-accent-surface: light-dark(#fce7f0, #3b2533);
    --color-accent-dark: light-dark(#ffffff, #2a0f1d);
}


/*
 * Glowing text is Disco's alone. It is decorative everywhere (titles,
 * readouts, alarms whose color already says it all), and many components
 * set their own glow, so Dark and Light switch it off here in one place.
 * Lamp glows (box-shadow) stay: a lit lamp means something is on.
 */
:root:is([data-theme="dark"], [data-theme="light"], [data-theme="system"]) body * {
    text-shadow: none !important;
}


/* ========================================================================== */
/* 02. PAGE BASICS AND ACCESSIBILITY                                          */
/* ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

a {
    color: var(--color-accent);
}

/* Keyboard users should see where focus is as they tab through the page. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

/*
 * Text fields, number fields, search boxes, and dropdowns share one look on
 * every page. Page stylesheets only set layout (width, flex), not colors.
 * :where() keeps this at zero specificity so any page rule can override it.
 */
:where(
    input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="range"]),
    select,
    textarea
) {
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background-color: var(--color-field-background);
    color: var(--color-text-primary);
    font: inherit;
}

:where(input, select, textarea):hover:not(:disabled) {
    border-color: var(--color-border-strong);
}

:where(input, select, textarea):focus-visible {
    border-color: var(--color-accent);
    outline-offset: 1px;
}

:where(input, select, textarea):disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

::placeholder {
    color: var(--color-text-muted);
    opacity: 0.8;
}

/* Checkboxes and radio buttons pick up the accent color. */
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--color-accent);
}

/* Text for screen readers only, such as a fieldset legend shown as a heading. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    /* Above the header's layer (section 03), which it appears over. */
    z-index: 55;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-control);
    background-color: var(--color-accent);
    color: var(--color-accent-dark);
}

.skip-link:focus {
    top: 0.75rem;
}

h1 {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

/* Section and panel titles share the display face with page titles. */
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 650;
    letter-spacing: -0.015em;
}

/*
 * Readouts: any number or identifier a person might compare or copy, such
 * as counts, U positions, MACs, port speeds, and source names.
 */
.readout,
code,
kbd,
samp {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums slashed-zero;
}


/* ========================================================================== */
/* 03. HEADER, LOGO, AND NAVIGATION                                           */
/* ========================================================================== */

.site-header {
    /*
     * Its own layer, above the page and below drawers (60), so its dropdowns
     * overlap content and the Locations panel can tuck behind the nav pill.
     */
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    /*
     * The header always lines up with the widest (workspace) layout, so the
     * logo and navigation stay in the same place on every page.
     */
    padding: 1.25rem max(
        var(--space-page-gutter),
        calc((100% - var(--width-workspace)) / 2 + var(--space-page-gutter))
    );
    border-bottom: 1px solid var(--color-border);
}

/*
 * The logo: the wordmark on a pill (the nav track's look) with the mascot
 * hiding behind it, as on the landing page's rack (landing.css 02b), but
 * facing right: his head (rat-peek-right.svg) peeks out past the right
 * end, a paw (rat-paw-right.svg) grips that edge in front, and his tail
 * (rat-tail-wiggle.svg) leaves the left end low down and wiggles along
 * under the pill. Every size is in em of .brand, so the
 * phone layout scales the whole logo with one font size (section 08).
 * The padding leaves room for the head and tail, which are positioned
 * over it; nothing here changes the header's height.
 */
.brand {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0 1.875em 0 0.4em;
    color: var(--color-text-primary);
    font-family: var(--font-display);
    font-size: 1rem;
    text-decoration: none;
    white-space: nowrap;
}

/* Without the mascot (the landing page), the pill needs no room beside it. */
.brand:not(:has(.brand-rat-head)) {
    padding: 0;
}

/*
 * The pill, 2.5em of .brand tall (as tall as the nav track), with the
 * wordmark in secondary text so it does not shout (owner). "Lab" is light
 * and "Rat" bold, with a hair of space between, so it reads as two words,
 * not "laBrat". Sizes inside are in its own 1.5em font size.
 */
.brand-name {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    height: calc(2.5em / 1.5);
    padding: 0 calc(0.875em / 1.5);
    border: 1px solid var(--color-brand-plate-border);
    border-radius: var(--radius-pill);
    background: var(--color-brand-plate);
    color: var(--color-text-secondary);
    font-size: 1.5em;
    line-height: 1;
    letter-spacing: -0.02em;
}

.brand-name-lab {
    font-weight: 400;
}

.brand-name-rat {
    margin-left: 0.06em;
    font-weight: 650;
}

.brand-rat-head,
.brand-rat-tail,
.brand-rat-paw {
    position: absolute;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px color-mix(in srgb, var(--color-shadow) 55%, transparent));
}

/* About two thirds of the head shows right of the pill. */
.brand-rat-head {
    z-index: 0;
    top: calc(50% - 1.21875em);
    right: 0;
    width: 3em;
    animation: brand-rat-peek 9s ease-in-out infinite;
}

/* In front of the pill, fingers over its right end. */
.brand-rat-paw {
    z-index: 2;
    top: calc(50% + 0.0625em);
    right: 1.5625em;
    width: 0.6875em;
}

/*
 * Its base hides behind the pill's left end, low down; it bends round the
 * end and runs about halfway along just under the pill. The image is drawn
 * in the pill's units (rat-tail-wiggle.svg): its x 22 is the pill's left
 * edge and its y 6 the pill's middle, hence the offsets. It sways only a
 * little about its base so it stays against the pill.
 */
.brand-rat-tail {
    z-index: 0;
    top: calc(50% - 0.375em);
    left: calc(0.4em - 1.375em);
    width: 6em;
    transform-origin: 35% 33%;
    animation: brand-rat-tail 5s ease-in-out infinite;
}

/* A glimmer sweeps his sunglasses as he leans out (as landing.css 02b). */
.brand-rat-glint {
    filter: none;
    opacity: 0;
    -webkit-mask-image: linear-gradient(105deg, transparent 46%, #000 49.5%, #000 50.5%, transparent 54%);
    mask-image: linear-gradient(105deg, transparent 46%, #000 49.5%, #000 50.5%, transparent 54%);
    -webkit-mask-size: 300% 100%;
    mask-size: 300% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    animation:
        brand-rat-peek 9s ease-in-out infinite,
        brand-rat-glint 9s ease-in-out infinite;
}

@keyframes brand-rat-peek {
    0%, 70%, 100% { transform: translateX(0); }
    78%, 88% { transform: translateX(0.25em) rotate(3deg); }
}

@keyframes brand-rat-glint {
    0%, 75% { opacity: 0; -webkit-mask-position: 100% 0; mask-position: 100% 0; }
    78% { opacity: 1; }
    85% { opacity: 1; -webkit-mask-position: 0% 0; mask-position: 0% 0; }
    89%, 100% { opacity: 0; -webkit-mask-position: 0% 0; mask-position: 0% 0; }
}

@keyframes brand-rat-tail {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(1deg); }
}

@media (prefers-reduced-motion: reduce) {
    .brand-rat-head,
    .brand-rat-tail {
        animation: none;
    }

    .brand-rat-glint {
        display: none;
    }
}

.site-navigation {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.navigation-link {
    color: var(--color-text-primary);
    text-decoration: none;
}

.navigation-link:hover {
    text-decoration: underline;
}

/* The current page in the phone ☰ column; wider screens light its tab. */
.navigation-link[aria-current="page"] {
    color: var(--color-accent);
}

.navigation-form {
    margin: 0;
}

/* Inline page links on wide screens; a ☰ panel on phones (section 08). */
.site-navigation-links {
    display: contents;
}

/*
 * Wider screens: the page links sit in one pill track, a header-sized take
 * on the view switch (view-switch.css), as tall as the account pill beside
 * it (owner). The current page's tab is lit in the accent, which also marks
 * Locations on location and room pages; nothing is underlined (owner).
 */
@media (min-width: 861px) {
    .site-navigation-links {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        padding: 3px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-pill);
        background: var(--color-surface-sunken);
    }

    .site-navigation-links .navigation-link,
    .site-navigation-links .nav-menu-button {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        min-height: 2rem;
        padding: 0 var(--space-4);
        border-radius: var(--radius-pill);
        color: var(--color-text-secondary);
        font-size: var(--text-sm);
        font-weight: 600;
        text-decoration: none;
        transition: background-color 120ms ease, color 120ms ease;
    }

    .site-navigation-links .nav-menu-button {
        padding-right: var(--space-3);
    }

    .site-navigation-links .navigation-link:hover,
    .site-navigation-links .nav-menu-button:hover,
    .site-navigation-links .nav-menu[open] > .nav-menu-button {
        background: var(--color-surface-hover);
        color: var(--color-text-primary);
    }

    .site-navigation-links .navigation-link:focus-visible {
        outline: 2px solid var(--color-accent);
        outline-offset: 2px;
    }

    /* Medium screens: tighter tabs, so the header stays on one row longer. */
    @media (max-width: 900px) {
        .site-navigation-links .navigation-link,
        .site-navigation-links .nav-menu-button {
            padding-inline: var(--space-3);
        }

        .site-navigation-links .nav-menu-button {
            padding-right: var(--space-2);
        }
    }

    /* The current page: the view switch's lit tab. */
    .site-navigation-links .navigation-link[aria-current="page"],
    .site-navigation-links .nav-menu-button.is-current {
        background: var(--color-accent-surface);
        color: var(--color-accent-strong);
        box-shadow: 0 0 0 1px var(--color-accent-muted) inset;
    }
}

.site-menu-toggle {
    display: none;
}

/*
 * Header dropdowns (base.html): the Locations menu and the account menu.
 * Each is a <details> disclosure that works without scripts; main.js closes
 * it on Escape, an outside click, or focus leaving it.
 */
.nav-menu {
    position: relative;
}

.nav-menu > summary {
    cursor: pointer;
    list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
    display: none;
}

.nav-menu > summary:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Locations: reads like the other header links, with a chevron. */
.nav-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: var(--radius-small);
    color: var(--color-text-primary);
}

.nav-menu-button:hover,
.nav-menu[open] > .nav-menu-button {
    color: var(--color-accent-strong);
}

/*
 * On a location or room page, Locations reads as the current section: a lit
 * tab on wider screens (above), accent text in the phone ☰ panel. Never an
 * underline (owner).
 */
.nav-menu-button.is-current {
    color: var(--color-accent);
}

.nav-menu-chevron,
.account-menu-chevron {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 120ms ease;
}

.nav-menu[open] > summary .nav-menu-chevron,
.nav-menu[open] > summary .account-menu-chevron {
    transform: rotate(180deg);
}

.nav-menu-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 50;
    display: grid;
    min-width: 11rem;
    margin: 0;
    padding: var(--space-1);
    border: 1px solid var(--color-border-strong);
    border-radius: 0 0 var(--radius-control) var(--radius-control);
    background: var(--color-surface-raised);
    box-shadow: var(--shadow-overlay);
    transform-origin: top right;
    list-style: none;
}

.nav-menu-item {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 0;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--color-text-primary);
    cursor: pointer;
    font: inherit;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}

.nav-menu-item:hover,
.nav-menu-item:focus-visible {
    background: var(--color-surface-hover);
    color: var(--color-accent-strong);
    outline: none;
}

/* The current page reads by its accent color alone; no dot (owner). */
.nav-menu-item[aria-current="page"] {
    color: var(--color-accent);
}



/* Account menu: Profile, Settings, and Sign out under the viewer's name. */
.account-menu-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.3rem 0.6rem 0.3rem 0.3rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    color: var(--color-text-primary);
}

.account-menu-button:hover,
.account-menu[open] > .account-menu-button {
    border-color: var(--color-accent-muted);
    background: var(--color-surface-hover);
}

/* On Profile or Settings, the menu reads as the current section. */
.account-menu-button.is-current {
    border-color: var(--color-accent-muted);
}

.account-menu-avatar {
    display: inline-grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-accent-surface);
    color: var(--color-accent-strong);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 700;
}

.account-menu-name {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Just above the ☰ fold, a long name ellipsizes sooner so the row fits. */
@media (min-width: 861px) and (max-width: 1000px) {
    .account-menu-name {
        max-width: 6rem;
    }
}

/* Compact account actions align their text and trailing icons to the right. */
.account-menu .nav-menu-panel {
    width: max-content;
    min-width: 0;
    padding: 1px;
}

.account-menu .nav-menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-inline: 12px;
    text-align: right;
}

.account-menu .account-menu-icon {
    width: 1rem;
    height: 1rem;
}

/* Sign out sits below a rule, apart from the pages. */
.account-menu .nav-menu-panel li:last-child {
    margin-top: var(--space-1);
    padding-top: var(--space-1);
    border-top: 1px solid var(--color-border);
}

/*
 * Wider screens: the account panel slides out from behind the name button
 * (owner). The pill keeps its full shape and accent outline while open; the
 * panel, with its own neutral outline and a shade darker, matches the pill's
 * width and starts at its middle. main.js slides it down from behind the
 * pill, masked so it never shows above that line. The button keeps a
 * minimum width so the actions always fit beneath it. Phones show only the
 * avatar, so their panel stays a separate dropdown.
 */
@media (min-width: 861px) {
    .account-menu-button {
        position: relative;
        z-index: 51;
        min-width: 7.5rem;
    }

    /* Opaque while open, so the sliding panel passes behind it. */
    .account-menu[open] > .account-menu-button {
        background: var(--color-surface-hover);
    }

    /*
     * Like the Locations panel, it starts at the pill's vertical middle, the
     * outer point of both round ends, with no top border, so its sides flow
     * straight down out of the curves (owner). It sits under the opaque open
     * pill (z-index 50 against 51); its top padding clears the pill's lower
     * half. main.js slides it down from behind, clipped at this top.
     */
    .account-menu .nav-menu-panel {
        /* Half the 40 px pill, in px because main.js reads it as a number. */
        --slide-offset: -20px;
        top: calc(100% + var(--slide-offset));
        right: 0;
        left: 0;
        width: auto;
        padding-top: calc(20px + var(--space-1));
        border-top: 0;
        /* One shade darker than the open pill (owner), in every theme. */
        background: color-mix(in srgb, var(--color-surface-hover) 82%, var(--color-shade));
        transform-origin: top center;
    }
}


/*
 * Locations menu: one scrolling panel, with a divider before each location
 * and its rooms in a sunken well underneath. Long names ellipsize.
 */
.locations-menu-panel {
    width: max-content;
    min-width: 0;
    max-width: min(20rem, calc(100vw - 2rem));
    max-height: min(32rem, 70vh);
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Compact rows: less top and bottom padding than the account actions. */
.locations-menu-panel .nav-menu-item {
    padding: 0.35rem 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.locations-menu-site {
    min-width: 0;
    margin-top: var(--space-1);
    padding-top: var(--space-1);
    border-top: 1px solid var(--color-border);
}

/* Bound unusually long location headings without widening the dropdown. */
.locations-menu-site > .nav-menu-item {
    max-width: calc(12ch + 25px);
}

/*
 * The room well runs to the panel's outer border, with no side or bottom
 * border of its own, and reads as sunk (owner): a shadow falls inside its
 * top edge and a faint highlight catches its bottom, the reverse of a
 * raised surface.
 */
.locations-menu-rooms {
    margin: 0;
    padding: 2px 0;
    border: 0;
    background: var(--color-console-recess);
    box-shadow:
        inset 0 4px 5px -3px var(--color-shadow),
        inset 0 -1px 0 color-mix(in srgb, var(--color-lift) 7%, transparent);
    list-style: none;
}

/*
 * Room links sit a step below their location (owner): 2 px smaller, 10%
 * lighter, in readable grey rather than full white, packed closer together,
 * with square hover highlights that match the square-edged well.
 */
.locations-menu-rooms .nav-menu-item {
    padding-block: 0.2rem;
    border-radius: 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 360;
}

/* Keep the shared hover and current-room colors over that grey. */
.locations-menu-rooms .nav-menu-item:hover,
.locations-menu-rooms .nav-menu-item:focus-visible {
    color: var(--color-accent-strong);
}

.locations-menu-rooms /* The current page reads by its accent color alone; no dot (owner). */
.nav-menu-item[aria-current="page"] {
    color: var(--color-accent);
}

/*
 * Wider screens: the panel slides out from behind the nav pill like the
 * account menu (owner). It starts at the pill's vertical middle, the outer
 * point of its right-hand curve, with no top border, so its right edge
 * flows straight down out of the curve (owner). A negative z-index puts it
 * under the pill's opaque track in the header's layer, so only the part
 * outside the pill shows; its top padding clears the pill's lower half.
 * It aligns to the track's right edge. Items are right-justified under the right-justified tab with
 * 30 px on their left (owner), so the menu is always 30 px wider than its
 * longest item.
 */
@media (min-width: 861px) {
    .locations-menu-panel {
        /* From the tab's bottom up to the track's middle: half the 32 px tab
           (px, because main.js reads it as a number). */
        --slide-offset: -16px;
        top: calc(100% + var(--slide-offset));
        right: -4px;
        left: auto;
        z-index: -1;
        /* The pill's lower half (half the tab plus the track's 4 px) and a gap. */
        padding-top: calc(1rem + 4px + var(--space-1));
        border-top: 0;
        background: color-mix(in srgb, var(--color-surface-hover) 82%, var(--color-shade));
        transform-origin: top right;
    }

    .locations-menu-panel .nav-menu-item {
        padding-left: 30px;
        text-align: right;
    }

    .locations-menu-site > .nav-menu-item {
        max-width: calc(12ch + 42px);
        margin-left: auto;
    }
}

.header-note {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}


/* ========================================================================== */
/* 04. MAIN PAGE, PANELS, AND SHARED TEXT                                      */
/* ========================================================================== */

/*
 * Content starts at the top of the page and grows to push the footer down.
 * (A plain "margin: auto" here used to center short pages vertically.)
 */
.page-content {
    flex: 1 0 auto;
    width: min(100%, var(--width-page));
    margin-inline: auto;
    padding: 2.5rem var(--space-page-gutter) 4rem;
}

/* Signed-in pages and the landing page use the wide layout, matching the
   header's width; only the narrow forms (sign-in, setup) stay at the
   reading width. */
.workspace-body .page-content {
    width: min(100%, var(--width-workspace));
    padding-top: 2rem;
}


/* -------------------------------------------------------------------------- */
/* Shared page heading: eyebrow, title, lede on the left; actions on the right */
/* -------------------------------------------------------------------------- */

.page-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4) var(--space-5);
    margin-bottom: var(--space-5);
}

/* The title block takes the free space so the actions stay on the right. */
.page-heading > :first-child {
    flex: 1 1 28rem;
    min-width: 0;
}

.page-heading .eyebrow {
    margin: 0;
}

.page-heading h1 {
    margin: var(--space-2) 0;
    font-size: var(--text-2xl);
}

.page-heading-lede {
    max-width: 46rem;
    margin: 0;
    color: var(--color-text-secondary);
}

.page-heading-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}


/* -------------------------------------------------------------------------- */
/* Room headings (frame: view-frame.css; tabs: view-switch.css)             */
/* -------------------------------------------------------------------------- */

/*
 * Room heading inside the view frame (_room_header.html, view-frame.css):
 * one line, "Locations / location / room", in the frame heading's mono face.
 * The room name is the page title; a long one ellipsizes, and so does the
 * breadcrumb before it when space runs out.
 */
.room-heading-path {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
    min-width: 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.room-breadcrumbs {
    display: flex;
    flex: 0 1 auto;
    gap: var(--space-1);
    min-width: 0;
    overflow: hidden;
    color: var(--color-text-muted);
    text-overflow: ellipsis;
}

.room-breadcrumbs a {
    overflow: hidden;
    color: var(--color-text-secondary);
    text-decoration: none;
    text-overflow: ellipsis;
}

.room-breadcrumbs a:hover,
.room-breadcrumbs a:focus-visible {
    color: var(--color-accent);
}

/*
 * Room frames keep a wider side gutter than Discovery's: Equipment routes
 * cables to "Around the room" cards up to 16 px outside its columns, which
 * used to run in the page gutter and must stay inside the frame.
 */
.view-frame.room-frame {
    padding-inline: var(--space-5);
}

/* Phones scroll rack faces inside their block, so the narrow gutter is enough. */
@media (max-width: 640px) {
    .view-frame.room-frame {
        padding-inline: var(--space-2);
    }
}

/* Diagram's own tools (racks.html): part of the tool row, hidden elsewhere. */
.room-diagram-tools {
    display: contents;
}

.room-diagram-tools[hidden] {
    display: none;
}

.room-heading-path h1 {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compact icon controls shared by the view frame (rooms, Discovery) and Settings. */
.room-wiring .room-icon-button,
.view-heading .room-icon-button,
.device-drawer-bar .room-icon-button,
.settings-body .room-icon-button {
    position: relative;
    display: grid;
    place-items: center;
    padding: var(--space-2);
    width: 40px;
    height: 40px;
}

.view-heading .room-icon-button[hidden] {
    display: none;
}

/* Icon tools highlight by the icon alone, in the theme's accent: no
   background shape (owner). Keyboard focus keeps its outline. */
.button.room-icon-button:hover:not(:disabled) {
    background-color: transparent;
    color: var(--color-accent);
}

.room-wiring .room-icon-button svg,
.view-heading .room-icon-button svg,
.device-drawer-bar .room-icon-button svg,
.settings-body .room-icon-button svg {
    flex: none;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.room-icon-button:hover::after,
.room-icon-button:focus-visible::after,
.room-icon-button:has(:focus-visible)::after {
    content: attr(data-tooltip);
    white-space: nowrap;
    pointer-events: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-small);
    background: var(--color-surface-raised);
    color: var(--color-text-primary);
    font-size: var(--text-xs);
}


.form-card {
    padding: clamp(2rem, 5vw, 4rem);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: linear-gradient(
        150deg,
        var(--color-panel-background),
        var(--color-panel-background-deep)
    );
    box-shadow: var(--shadow-overlay);
}

.form-card {
    max-width: var(--width-form);
}

/*
 * Eyebrows read like the printed labels on a rack panel: small, mono, and
 * quiet, with a short accent tick so they still scan as section markers.
 */
.eyebrow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 0.9rem;
    height: 2px;
    flex: 0 0 auto;
    border-radius: var(--radius-pill);
    background-color: var(--color-accent);
}

.intro {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    line-height: 1.65;
}

.footnote {
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-page-gutter);
    border-top: 1px solid var(--color-border-subtle);
    color: var(--color-text-faint);
    font-size: var(--text-xs);
}

.site-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}


/* ========================================================================== */
/* 05. BUTTONS AND LINKS THAT LOOK LIKE BUTTONS                               */
/* ========================================================================== */

.button-row,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1.2rem;
    border: 1px solid var(--color-action);
    border-radius: var(--radius-control);
    background-color: var(--color-action);
    color: var(--color-action-ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

/*
 * Three levels of emphasis. Use them so each page has one obvious main action:
 *   .button                   Primary: solid. The main thing to do here.
 *   .button.button-secondary  Secondary: outlined. Other real actions.
 *   .button.button-quiet      Quiet: no border. Utilities such as Refresh,
 *                             Reset layout, or Back links.
 */
.button {
    transition:
        background-color 120ms ease,
        border-color 120ms ease,
        color 120ms ease,
        filter 120ms ease;
}

.button:hover {
    filter: brightness(1.08);
}

.button:disabled {
    cursor: not-allowed;
    filter: none;
    opacity: 0.5;
}

.button-secondary {
    border-color: var(--color-accent-muted);
    background-color: transparent;
    color: var(--color-accent);
}

.button-secondary:hover:not(:disabled) {
    background-color: var(--color-accent-soft);
    filter: none;
}

.button-quiet {
    border-color: transparent;
    background-color: transparent;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.button-quiet:hover:not(:disabled) {
    background-color: var(--color-accent-soft);
    color: var(--color-text-primary);
    filter: none;
}


/* ========================================================================== */
/* 05b. DELETE CONFIRMATION DIALOG (remove-dialog.js)                         */
/* ========================================================================== */

/*
 * Shared by Locations and the Equipment view. The confirm button is the
 * normal primary (action orange); red stays reserved for alarms.
 */
.remove-dialog {
    width: min(30rem, calc(100vw - 2rem));
    padding: var(--space-6);
    border: 1px solid var(--color-border-strong);
    border-top: 2px solid var(--color-action);
    border-radius: var(--radius-card);
    background: var(--color-panel-background);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-overlay);
}

.remove-dialog::backdrop {
    background: color-mix(in srgb, var(--color-shadow) 60%, transparent);
}

.remove-dialog h2 {
    margin: 0 0 var(--space-3);
    font-size: var(--text-xl);
    overflow-wrap: anywhere;
}

.remove-dialog p {
    margin: 0 0 var(--space-2);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.remove-dialog .remove-dialog-error {
    color: var(--color-status-error);
}

.remove-dialog .button-row {
    justify-content: flex-end;
    margin-top: var(--space-5);
}


/* ========================================================================== */
/* 06. SIGN-IN AND FIRST-RUN SETUP FORMS                                      */
/* ========================================================================== */

.form-fields {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    margin-top: 2rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-field label {
    font-weight: 700;
}

/* Sign-in and setup fields are larger touch targets than in-app fields. */
.form-field input {
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 0.9rem;
}

.field-help {
    margin-top: 0;
    margin-bottom: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.form-error {
    padding: 0.9rem 1rem;
    border: 1px solid var(--color-error);
    border-radius: var(--radius-control);
    background-color: var(--color-error-background);
    color: var(--color-text-primary);
}

/* The form itself provides the spacing; its action row needs no extra margin. */
.form-fields .form-actions {
    margin-top: 0.25rem;
}


/* ========================================================================== */
/* 07. STATUS INDICATORS AND PROFILE DETAILS                                  */
/* ========================================================================== */

.status-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: fit-content;
    margin-top: 2rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-control);
    background-color: var(--color-field-background);
}


/* -------------------------------------------------------------------------- */
/* Status lights (LEDs)                                                        */
/*   .led.led-ready     green: last collection succeeded                       */
/*   .led.led-error     red: last attempt failed                               */
/*   .led.led-waiting   grey: never collected                                  */
/*   .led.led-warning   amber: degraded, such as a WAN running on its backup     */
/*   .is-fresh          adds a slow pulse when data is recent                  */
/* -------------------------------------------------------------------------- */

.led {
    --led-color: var(--color-led-off);
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background-color: var(--led-color);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--led-color) 45%, black),
        0 0 6px color-mix(in srgb, var(--led-color) 55%, transparent);
}

.led-ready {
    --led-color: var(--color-status-ok);
}

.led-error {
    --led-color: var(--color-status-error);
}

.led-warning {
    --led-color: var(--color-console-warning);
}

.led-waiting {
    --led-color: var(--color-led-off);
    box-shadow: 0 0 0 1px var(--color-led-off-edge);
}

.led.is-fresh {
    animation: led-pulse 2.4s ease-in-out infinite;
}

@keyframes led-pulse {
    50% {
        box-shadow:
            0 0 0 1px color-mix(in srgb, var(--led-color) 45%, black),
            0 0 12px 2px color-mix(in srgb, var(--led-color) 70%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .led.is-fresh {
        animation: none;
    }
}


/* -------------------------------------------------------------------------- */
/* Source status strip under the header (signed-in pages)                      */
/* -------------------------------------------------------------------------- */

/*
 * Always one line: one light per endpoint with a short name. When there are
 * more lights than fit, the window swipes sideways rather than wrapping, and
 * main.js (bindSourceTicker) turns the list into a slow ticker that pauses
 * under the pointer or keyboard focus. Reduced motion keeps the swipe.
 */
.source-strip {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-2) max(
        var(--space-page-gutter),
        calc((100% - var(--width-workspace)) / 2 + var(--space-page-gutter))
    );
    border-bottom: 1px solid var(--color-border-subtle);
    background-color: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.source-strip-label {
    font-family: var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* The clipping window; min-width: 0 lets it scroll instead of widening the page. */
.source-strip-window {
    flex: 1 1 0;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.source-strip-window:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.source-strip-list {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--space-2) var(--space-5);
    width: max-content;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
}

.source-strip-label {
    flex: none;
}

/*
 * Ticker: script repeats the lights once (aria-hidden copies) and sets
 * --ticker-distance (one set plus a gap) and --ticker-duration (a slow,
 * readable pace), so sliding one set left loops without a seam. The edges
 * fade so lights glide in and out rather than being cut off.
 */
.source-strip-window.is-ticking {
    overflow-x: hidden;
    mask-image: linear-gradient(
        to right,
        transparent,
        #000 var(--space-5),
        #000 calc(100% - var(--space-5)),
        transparent
    );
}

.source-strip-window.is-ticking .source-strip-list {
    animation: source-ticker var(--ticker-duration, 30s) linear infinite;
}

/* Hold still while the user reads a tooltip, focuses, or taps the strip. */
.source-strip-window.is-ticking:hover .source-strip-list,
.source-strip-window.is-ticking:focus-within .source-strip-list,
.source-strip-window.is-ticking:active .source-strip-list {
    animation-play-state: paused;
}

@keyframes source-ticker {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc(-1 * var(--ticker-distance, 0px)));
    }
}

@media (prefers-reduced-motion: reduce) {
    .source-strip-window.is-ticking .source-strip-list {
        animation: none;
    }
}

.source-strip-item {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: var(--space-2);
}

.source-strip-item .readout {
    color: var(--color-text-secondary);
}


/* -------------------------------------------------------------------------- */
/* Panel finish: a faint top highlight, like light catching a metal edge, and */
/* optional rack-ear screws in the four corners (.panel-screws).               */
/* -------------------------------------------------------------------------- */

.form-card,
.panel-screws {
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, white 6%, transparent),
        var(--shadow-overlay);
}

/* Blueprint grid behind the Discovery map and Room View canvases. */
.blueprint-grid {
    --blueprint-minor: color-mix(in srgb, var(--color-accent) 5%, transparent);
    --blueprint-major: color-mix(in srgb, var(--color-accent) 11%, transparent);
    background-image:
        linear-gradient(var(--blueprint-major) 1px, transparent 1px),
        linear-gradient(90deg, var(--blueprint-major) 1px, transparent 1px),
        linear-gradient(var(--blueprint-minor) 1px, transparent 1px),
        linear-gradient(90deg, var(--blueprint-minor) 1px, transparent 1px);
    background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
    background-position: -1px -1px;
}

.panel-screws {
    position: relative;
}

/* Drawn on top of the panel's own background, never replacing it. */
.panel-screws::after {
    --screw: radial-gradient(
        circle,
        var(--color-border-bright) 0 1.5px,
        var(--color-border-strong) 1.5px 3px,
        transparent 3.5px
    );
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background-image: var(--screw), var(--screw), var(--screw), var(--screw);
    background-position:
        top 10px left 10px,
        top 10px right 10px,
        bottom 10px left 10px,
        bottom 10px right 10px;
    background-size: 8px 8px;
    background-repeat: no-repeat;
    pointer-events: none;
}

.account-details {
    display: grid;
    grid-template-columns: minmax(7rem, auto) 1fr;
    column-gap: 1.5rem;
    row-gap: 1rem;
    margin-top: 2rem;
}

.account-details dt {
    color: var(--color-text-muted);
}

.account-details dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}


/* ========================================================================== */
/* 07b. SIGNAL HUES AND PAGE ICONS                                            */
/* ========================================================================== */

/*
 * data-hue gives an element one domain color as --hue, from the same
 * --color-signal-* tokens Observations uses (data-signal there): internet
 * cyan, VPN violet, compute blue, physical-network teal, power magenta.
 * Home and the landing page tint cards, rules, and icons with it. Never use
 * the status colors (green, amber, red) as a hue.
 */
[data-hue="internet"] { --hue: var(--color-signal-internet); }
[data-hue="vpn"] { --hue: var(--color-signal-vpn); }
[data-hue="compute"] { --hue: var(--color-signal-compute); }
[data-hue="network"] { --hue: var(--color-signal-network); }
[data-hue="power"] { --hue: var(--color-signal-power); }

/* Line icons from templates/_icons.html: stroked in the current color. */
.page-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ========================================================================== */
/* 08. SMALL SCREENS: PHONE AND NARROW BROWSER WINDOWS                        */
/* ========================================================================== */

/*
 * The header folds behind ☰ at 860 px and under, below the width its one
 * row needs with a scrollbar (owner: never wrap the account pill to a
 * second row). One row:
 * logo, the account avatar, and ☰; the page links open as a column under
 * it. main.js (bindSiteMenu, the account slide) uses the same 860 px line.
 */
@media (max-width: 860px) {
    .site-header {
        flex-wrap: wrap;
        gap: 0.5rem 0.75rem;
    }

    .site-navigation {
        display: contents;
    }

    .account-menu {
        margin-left: auto;
    }

    .account-menu-name {
        display: none;
    }

    .site-menu-toggle {
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-control);
        background: transparent;
        color: var(--color-text-primary);
        cursor: pointer;
    }

    .site-menu-toggle svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
    }

    .site-header[data-menu-open] .site-menu-toggle {
        border-color: var(--color-accent);
        color: var(--color-accent);
    }

    .site-navigation-links {
        display: none;
    }

    /* Under the logo row, though the links come first in the markup. */
    .site-header[data-menu-open] .site-navigation-links {
        order: 5;
        display: flex;
        flex: 1 1 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.9rem;
        padding: 0.75rem 0 0.25rem;
        border-top: 1px solid var(--color-border-subtle);
    }

    /* Locations sits at the left of its ☰ panel, so it opens from its left
       edge; the account menu stays at the right of the logo row. */
    .nav-menu-panel {
        right: auto;
        left: 0;
        transform-origin: top left;
    }

    .account-menu .nav-menu-panel {
        right: 0;
        left: auto;
        transform-origin: top right;
    }

    /* Left-justified here, so the 30 px of extra room mirrors to the right. */
    .locations-menu-panel .nav-menu-item {
        padding-right: 30px;
    }
}

@media (max-width: 600px) {
    /* The source strip keeps lights and names only (section 07). */
    .source-strip-label,
    .source-strip-detail {
        display: none;
    }

    .source-strip {
        padding-inline: 1rem;
    }

    /*
     * Phones: a smaller logo (section 03 sizes it all in em, so one font
     * size scales the pill and the rat) and tighter header padding. The
     * ☰ fold itself starts wider (the 860 px block above).
     */
    .site-header {
        padding: 0.75rem 1rem;
    }

    .brand {
        font-size: 0.8rem;
    }

    .header-note {
        display: none;
    }

    .page-content {
        padding: 2rem 1rem;
    }

    .form-card {
        padding: 1.5rem;
    }

    .account-details {
        grid-template-columns: 1fr;
        row-gap: 0.25rem;
    }

    .account-details dd {
        margin-bottom: 0.8rem;
    }
}
