/* open-peripherie: design system "open-peripherie" v2 (https://claude.ai/artifact/Smrf5sM2mRo4FjwydcNAyi).
   Tokens first, then the op- components (the system's bundle.css), then the app's page layout.
   Components use only these variables (docs/guidelines.md). */

@font-face {
    font-family: "Inter";
    src: url("../fonts/InterVariable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root, [data-theme="light"] {
  --bg: #ecebe7;
  --dot: #cfcdc6;
  --bg-panel: #ffffff;
  --bg-raised: #f6f5f2;
  --bg-hover: #efeee9;
  --border: #e3e1db;
  --border-strong: #c9c6bd;
  --ink: #1d1d1f;
  --text: var(--ink);
  --text-muted: #66666d;
  --text-faint: #a6a5ad;
  --on-ink: #ffffff;
  --accent: #e0263c;
  --accent-soft: #ffe0e4;
  --mint: #cdeedd;
  --sky: #d6e8ff;
  --lavender: #e4defc;
  --peach: #ffe4cf;
  --lemon: #fff3b8;
  --ok: #1a7f45;
  --warn: #a35f00;
  --error: #c62828;
  --cap: #ffffff;
  --cap-mod: #f4f3ef;
  --press: var(--ok);
  --press-fill: var(--mint);
  --gauge-track: #e6e4de;
  --gauge-depth: var(--ink);
  --mark-actuation: var(--accent);
  --mark-reset: #7fb2ff;
  --shadow-card: 0 1px 2px #1d1d1f0f, 0 4px 16px #1d1d1f0a;
  --shadow-cap: inset 0 -2px 0 #1d1d1f1a;
  --shadow-float: 0 8px 28px #1d1d1f26;
  --shadow-press: 0 0 0 2px #1a7f45;
}
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 26px;
  --radius-pill: 999px;
  --duration-fast: 120ms;
  --duration-slow: 240ms;
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}


.op-root {
    background-color: var(--bg);
    background-image: radial-gradient(var(--dot) 1px, transparent 1.4px);
    background-size: 16px 16px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 20px;
    font-feature-settings: "cv11" 1;
    -webkit-font-smoothing: antialiased;
}

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

.op-muted { color: var(--text-muted); }
.op-mono { font-family: var(--font-mono); font-size: 12px; }
.op-overline { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }

.op-icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Button */
.op-button {
    display: inline-flex; align-items: center; gap: var(--space-2);
    height: 36px; padding: 0 var(--space-4);
    border-radius: var(--radius-sm); border: 1.5px solid transparent;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast);
}
.op-button.primary { background: var(--ink); color: var(--on-ink); }
.op-button.primary:hover { background: #33333a; }
.op-button.outline { background: var(--bg-panel); color: var(--text); border-color: var(--border-strong); }
.op-button.outline:hover { border-color: var(--ink); }
.op-button.ghost { background: transparent; color: var(--text-muted); padding: 0 var(--space-3); }
.op-button.ghost:hover { color: var(--text); background: var(--bg-hover); }
.op-button.small { height: 30px; padding: 0 var(--space-3); font-size: 12px; }
.op-button:active { transform: translateY(1px); }
.op-button:disabled { opacity: 0.45; cursor: default; transform: none; }
.op-button:focus-visible, .op-segment button:focus-visible, .op-key:focus-visible, .op-tile:focus-visible, .op-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Chip */
.op-chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 11px; border-radius: var(--radius-pill);
    background: var(--bg-panel); border: 1px solid var(--border);
    font-size: 12px; white-space: nowrap;
}
.op-chip .label { color: var(--text-muted); }
.op-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.op-chip.ok { background: var(--mint); border-color: transparent; }
.op-chip.ok .dot { background: var(--ok); }
.op-chip.warn { background: var(--peach); border-color: transparent; }
.op-chip.warn .dot { background: var(--warn); }
.op-chip.error { background: var(--accent-soft); border-color: transparent; }
.op-chip.error .dot { background: var(--error); }
.op-chip.sky { background: var(--sky); border-color: transparent; }
.op-chip.lavender { background: var(--lavender); border-color: transparent; }

/* Segmented choice: the selected option is an ink pill */
.op-segment {
    display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px;
    background: var(--bg-panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.op-segment button {
    height: 28px; padding: 0 var(--space-3); border: none; border-radius: 6px;
    background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.op-segment button:hover { color: var(--text); background: var(--bg-hover); }
.op-segment button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.op-segment.locked button { cursor: default; }
.op-segment.locked button:not([aria-pressed="true"]) { opacity: 0.4; }
.op-segment.locked button[aria-pressed="true"] { background: var(--text-muted); }

/* Toggle */
.op-toggle { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.op-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.op-toggle .track {
    width: 40px; height: 22px; border-radius: var(--radius-pill); position: relative;
    background: var(--bg-hover); border: 1.5px solid var(--border-strong); transition: background var(--duration-fast);
}
.op-toggle .track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
    background: var(--bg-panel); box-shadow: 0 1px 2px #1d1d1f33; transition: left var(--duration-fast);
}
.op-toggle input:checked + .track { background: var(--ok); border-color: var(--ok); }
.op-toggle input:checked + .track::after { left: 20px; }
.op-toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Slider with value field */
.op-slider { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.op-slider input[type=range] { flex: 1; min-width: 80px; accent-color: var(--ink); height: 20px; }
.op-slider input[type=range]:disabled { opacity: 0.35; }
.op-slider .value {
    display: inline-flex; gap: 4px; align-items: center;
    flex: none; width: 104px; height: 34px; padding: 0 10px; white-space: nowrap;
    background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
}
.op-slider .value input { width: 100%; min-width: 0; background: none; border: none; color: var(--text); font: inherit; font-weight: 600; text-align: right; padding: 0; }
.op-slider .value .unit { color: var(--text-muted); font-size: 12px; }
.op-slider .ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

/* Travel gauge */
.op-gauge { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-3); align-items: center; }
.op-gauge .bar { position: relative; width: 28px; height: 120px; border-radius: var(--radius-pill); background: var(--gauge-track); border: 1.5px solid var(--ink); overflow: hidden; }
.op-gauge .depth { position: absolute; left: 0; right: 0; top: 0; background: var(--gauge-depth); opacity: 0.8; }
.op-gauge .mark { position: absolute; left: -4px; right: -4px; height: 3px; border-radius: 2px; }
.op-gauge .mark.actuation { background: var(--mark-actuation); }
.op-gauge .mark.reset { background: var(--mark-reset); }
.op-gauge .legend { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.op-gauge .legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.op-gauge .legend .a::before { background: var(--mark-actuation); }
.op-gauge .legend .r::before { background: var(--mark-reset); }
.op-gauge .legend .d::before { background: var(--gauge-depth); }
.op-gauge.horizontal .bar { width: 100%; height: 12px; }
.op-gauge.horizontal .depth { top: 0; bottom: 0; left: 0; right: auto; }
.op-gauge.horizontal .mark { top: -4px; bottom: -4px; left: auto; right: auto; width: 3px; height: auto; }

/* Card and setting rows */
.op-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); min-width: 0; }
.op-card > header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.op-card > header h2 { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; }
.op-card > header .spacer { flex: 1; }
.op-card > .body { padding: var(--space-2) var(--space-5); }
.op-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(200px, 2fr); gap: var(--space-4); align-items: center; padding: var(--space-3) 0; }
.op-row + .op-row { border-top: 1px solid var(--border); }
.op-row .name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.op-row .hint { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: 2px; }
.op-row.dimmed .name { color: var(--text-muted); }
.op-row .state { font-size: 12px; color: var(--text-muted); }
.op-row .state.saved { color: var(--ok); }
.op-row .state.error { color: var(--error); }
.op-info { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: none; color: var(--text-muted); font: 700 11px/1 var(--font-sans); cursor: help; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* Notice: one condition said once, with its action */
.op-notice {
    display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
    background: var(--peach); border: 1px solid transparent;
}
.op-notice .op-icon { color: var(--warn); }
.op-notice.info { background: var(--sky); }
.op-notice.info .op-icon { color: var(--ink); }
.op-notice.error { background: var(--accent-soft); }
.op-notice.error .op-icon { color: var(--error); }
.op-notice .text { flex: 1; min-width: 200px; }
.op-notice .text strong { font-weight: 600; }
.op-notice .text div { font-size: 12px; color: var(--text); opacity: 0.8; }

/* Toast */
.op-toast {
    display: inline-flex; align-items: center; gap: var(--space-3);
    padding: 10px var(--space-4); border-radius: var(--radius-md);
    background: var(--bg-panel); border: 1px solid var(--border); box-shadow: var(--shadow-float);
    font-size: 13px; font-weight: 500;
}
.op-toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.op-toast.ok .dot { background: var(--ok); }
.op-toast.error { background: var(--accent-soft); border-color: transparent; }
.op-toast.error .dot { background: var(--error); }

/* Topbar with device tabs */
.op-topbar {
    display: flex; align-items: center; gap: var(--space-4); height: 56px; padding: 0 var(--space-5);
    background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.op-topbar .brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; white-space: nowrap; }
.op-topbar .devices { display: flex; gap: 4px; min-width: 0; overflow-x: auto; flex: 1; }
.op-topbar .device {
    display: flex; align-items: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-3);
    color: var(--text-muted); text-decoration: none; border-radius: var(--radius-pill); white-space: nowrap; font-size: 13px; font-weight: 600;
}
.op-topbar .device:hover { color: var(--text); background: var(--bg-hover); }
.op-topbar .device[aria-current="page"], .op-topbar .device.current { color: var(--on-ink); background: var(--ink); }
.op-topbar .battery { font-size: 11px; font-variant-numeric: tabular-nums; }
.op-topbar .battery.ok { color: var(--ok); }
.op-topbar .device[aria-current="page"] .battery.ok { color: var(--mint); }
.op-topbar .battery.warn { color: var(--warn); }
.op-topbar .battery.error { color: var(--error); }

/* Device tile */
.op-tile {
    display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5);
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card);
    color: var(--text); text-decoration: none; transition: border-color var(--duration-fast);
}
.op-tile:hover { border-color: var(--ink); }
.op-tile .art { width: 56px; height: 56px; flex: none; color: var(--ink); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); background: var(--sky); }
.op-tile .art.keyboard { background: var(--lavender); }
.op-tile .art svg { width: 30px; height: 30px; }
.op-tile .body { flex: 1; min-width: 0; }
.op-tile .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-tile .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--space-2); }

/* Key caps: white caps outlined in ink, legends centred */
.op-key {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    padding: 4px; min-width: 0; height: 100%; width: 100%;
    background: var(--cap); color: var(--ink); border: 1.5px solid var(--ink); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-cap); font: inherit; cursor: pointer; text-align: center; overflow: hidden;
    transition: background var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}
.op-key:hover { background: var(--bg-hover); }
.op-key.mod { background: var(--cap-mod); }
.op-key .shift { font-size: 11px; line-height: 12px; font-weight: 600; color: var(--text-muted); }
.op-key .main { font-size: 14px; line-height: 16px; font-weight: 600; }
.op-key.word .main { font-size: 11px; line-height: 13px; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.op-key.transparent { border-style: dashed; border-color: var(--border-strong); }
.op-key.transparent .main, .op-key.transparent .shift { color: var(--text-faint); }
.op-key.off { background: transparent; border-style: dashed; border-color: var(--border-strong); box-shadow: none; }
.op-key.changed { background: var(--peach); }
.op-key.selected { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.op-key.tested { background: var(--mint); border-color: var(--ok); }
.op-key.pressed { background: var(--press-fill); border-color: var(--press); box-shadow: var(--shadow-press); transform: translateY(1px); }
.op-key .travel { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--gauge-track); overflow: hidden; }
.op-key .travel i { display: block; height: 100%; background: var(--gauge-depth); }

/* Keyboard case: white body, thick ink outline */
.op-board { background: var(--bg-panel); border: 3px solid var(--ink); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-card); }
.op-board .plate { position: relative; }
/* each cap sits in an absolutely placed slot (left, top, width, height in px from key units) */
.op-board .plate > .slot { position: absolute; }

/* Mouse drawing: top view in ink outline, buttons are real buttons */
.op-mouse { position: relative; width: 180px; height: 300px; }
.op-mouse svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.op-mouse .shell { fill: var(--bg-panel); stroke: var(--ink); stroke-width: 3; }
.op-mouse .split { stroke: var(--ink); stroke-width: 2; }
.op-mouse .btn {
    position: absolute; border: 1.5px solid transparent; background: transparent; color: var(--text-muted);
    font: 700 11px/1 var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; border-radius: 6px;
}
.op-mouse .btn:hover { color: var(--text); background: var(--bg-hover); }
.op-mouse .btn.selected { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.op-mouse .btn.pressed { color: var(--text); border-color: var(--press); background: var(--press-fill); box-shadow: var(--shadow-press); }
.op-mouse .btn.left { left: 12px; top: 12px; width: 74px; height: 118px; border-top-left-radius: 78px; }
.op-mouse .btn.right { right: 12px; top: 12px; width: 74px; height: 118px; border-top-right-radius: 78px; }
.op-mouse .btn.wheel { left: 80px; top: 40px; width: 20px; height: 46px; border-radius: 10px; border-color: var(--ink); background: var(--cap-mod); }
.op-mouse .btn.side4 { left: -7px; top: 150px; width: 16px; height: 34px; border-color: var(--ink); background: var(--cap-mod); }
.op-mouse .btn.side5 { left: -7px; top: 190px; width: 16px; height: 34px; border-color: var(--ink); background: var(--cap-mod); }

/* Lighting swatches */
.op-swatches { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.op-swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--bg-panel); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.op-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 4px var(--ink); }

/* Tool tabs under the device drawing */
.op-tabs { display: flex; gap: var(--space-1); overflow-x: auto; }
.op-tabs button {
    height: 40px; padding: 0 var(--space-4); border: none; background: none; color: var(--text-muted);
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0; white-space: nowrap;
}
.op-tabs button:hover { color: var(--text); }
.op-tabs button[aria-selected="true"] { color: var(--text); background: var(--bg-panel); box-shadow: inset 0 -3px 0 var(--accent); }
.op-tabpanel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md); box-shadow: var(--shadow-card); padding: var(--space-5); }

/* Lighting: zones, effect tiles */
.op-effects { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: var(--space-2); }
.op-effect {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px;
    background: var(--bg-raised); border: 1.5px solid transparent; border-radius: var(--radius-sm);
    color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.op-effect:hover { color: var(--text); background: var(--bg-hover); }
.op-effect[aria-pressed="true"] { color: var(--on-ink); background: var(--ink); }
.op-effect .op-icon { width: 20px; height: 20px; }
.op-zone {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
    background: var(--bg-raised); border: 1.5px solid transparent; border-radius: var(--radius-md); cursor: pointer;
}
.op-zone.back { background: var(--sky); }
.op-zone.side { background: var(--lemon); }
.op-zone[aria-current="true"] { border-color: var(--ink); }
.op-zone .text { flex: 1; }
.op-zone .text div { font-size: 12px; color: var(--text-muted); }

/* Loading screen */
.op-boot { min-height: 100%; display: flex; align-items: center; justify-content: center; }
.op-boot .stack { width: min(360px, 80%); display: flex; flex-direction: column; align-items: center; gap: var(--space-5); text-align: center; padding: var(--space-6); background: var(--bg-panel); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.op-boot .mark { width: 64px; height: 64px; }
.op-boot .name { font-size: 20px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; }
.op-boot .progress { width: 100%; height: 6px; border-radius: var(--radius-pill); background: var(--gauge-track); overflow: hidden; }
.op-boot .progress i { display: block; height: 100%; background: var(--ink); border-radius: inherit; transition: width var(--duration-slow); }
.op-boot .status { display: flex; justify-content: space-between; width: 100%; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------------------------
   App shell and pages
   --------------------------------------------------------------------------------------------- */

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    /* an app, not a document: double clicks and drags do not select text (fields still do) */
    user-select: none;
    -webkit-user-select: none;
    background-color: var(--bg);
    background-image: radial-gradient(var(--dot) 1px, transparent 1.4px);
    background-size: 16px 16px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 20px;
    font-feature-settings: "cv11" 1;
    -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; }

h1, h2, h3 { margin: 0; }

input, select, button { font: inherit; }

input, textarea, [contenteditable], .op-mono { user-select: text; -webkit-user-select: text; }

select {
    height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
    background: var(--bg-panel); color: var(--text); border: 1px solid var(--border-strong);
}

.op-display { font-size: 28px; line-height: 34px; font-weight: 650; letter-spacing: -0.02em; }

/* Boot screen in index.html: Blazor sets --blazor-load-percentage on the document while it loads */
.op-boot { min-height: 100vh; }
.op-boot .progress i { width: var(--blazor-load-percentage, 0%); }
.op-boot .status .percent::after { content: var(--blazor-load-percentage-text, ""); }

#blazor-error-ui {
    display: none;
    position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    padding: 10px 16px; border-radius: var(--radius-md);
    background: var(--accent-soft); color: var(--text); box-shadow: var(--shadow-float);
    z-index: 1000;
}
#blazor-error-ui .reload { margin-left: 8px; font-weight: 600; }
