@font-face {
  font-family: "Chivo Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/chivo-mono-latin.woff2") format("woff2");
}

/*
 * CS2 Crosshair Studio. A self-contained design system: nothing here reads the
 * portfolio's tokens, and nothing in the portfolio reads these. The look is a
 * small piece of hardware — a machined chassis, raised keys, recessed wells,
 * an LCD — drawn with gradients and shadows rather than images.
 */

:root {
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Chivo Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius-device: 14px;
  --radius-key: 8px;
  --radius-well: 7px;

  --ease-press: cubic-bezier(0.3, 0.7, 0.4, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-press: 90ms;
  --dur-base: 180ms;
  --dur-slow: 320ms;
  --blur-map: 14px;

  /* One appearance: the olive of Valve's old Steam client (2003). */
  --page: #3e4637;
  --chassis-top: #4c5844;
  --chassis-bottom: #46503e;
  --chassis-line: #292c21;
  --highlight: rgb(255 255 255 / 0.08);
  --shade: rgb(0 0 0 / 0.25);
  --shade-strong: rgb(0 0 0 / 0.42);

  --key-top: #5a6650;
  --key-bottom: #4c5844;
  --key-line: #292c21;
  --key-pressed: #3e4637;

  --well: #3e4637;
  --well-line: #292c21;

  --ink: #dee5d7;
  --ink-muted: #a0aa95;
  --engrave: rgb(0 0 0 / 0.35);

  --lcd: #292c21;
  --lcd-ink: #c4b550;
  --lcd-dim: #8c9284;

  --accent: #c4b550;
  --accent-ink: #292c21;
  --led-off: #5d6655;

  --bezel: #1f2219;
  --focus: #c4b550;

  color-scheme: dark;
}

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

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

body {
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  /* Whole-pixel line heights everywhere: a fractional one (12px x 1.35) leaves
     the boxes below it on a fraction of a pixel, and a browser snaps a text
     field to the pixel grid differently from a button there, so the two sit a
     pixel apart. */
  font: 500 12px/16px var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-slow) var(--ease-out);
}

button,
input,
textarea,
output {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}


/* ---------- Chassis ---------- */

.device {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(236px, 36%, 360px);
  gap: 10px;
  height: 100%;
  padding: 10px;
  background:
    linear-gradient(180deg, var(--chassis-top), var(--chassis-bottom));
  /* The outermost edge is one colour on all four sides. */
  box-shadow: inset 0 0 0 1px var(--chassis-line);
}

.deck,
.panel {
  min-width: 0;
  min-height: 0;
}

.deck {
  display: flex;
  flex-direction: column;
  gap: 8px;
  container-type: inline-size;
}

.deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  padding-left: 2px;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-muted);
  font: 750 10.5px/1 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 var(--engrave);
}

.led {
  align-self: center;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-off);
  box-shadow: inset 0 1px 1px var(--shade-strong);
  transition: background-color 60ms linear, box-shadow 60ms linear;
}

.led[data-on] {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent), inset 0 -1px 1px oklch(0 0 0 / 0.2);
}

.deck-controls {
  display: flex;
  gap: 6px;
  min-width: 0;
}

/* ---------- Screen ---------- */

.bezel {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 7px;
  border-radius: 12px;
  background: linear-gradient(180deg, oklch(from var(--bezel) calc(l + 0.06) c h), var(--bezel));
  box-shadow:
    0 1px 0 var(--highlight),
    inset 0 1px 0 oklch(1 0 0 / 0.08),
    inset 0 -1px 0 oklch(0 0 0 / 0.4),
    0 2px 6px var(--shade);
}

.screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 6px;
  background: oklch(0.15 0 0);
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.6);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

/* A map that is not the one on screen waits blurred and transparent, and the
   one on screen is blurred while the next is loading (data-loading), so a
   change of map is seen to be under way. The scale hides the soft edge a blur
   leaves. Both ways are one transition: the map leaving blurs as it fades, the
   map arriving sharpens as it appears. */
.screen-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: blur(var(--blur-map));
  scale: 1.06;
  pointer-events: none;
  -webkit-user-drag: none;
  transition:
    opacity var(--dur-slow) var(--ease-out),
    filter var(--dur-slow) var(--ease-out),
    scale var(--dur-slow) var(--ease-out);
}

.screen-map[data-shown] {
  opacity: 1;
  filter: none;
  scale: 1;
}

.screen[data-loading] .screen-map[data-shown] {
  filter: blur(var(--blur-map));
  scale: 1.06;
}

.screen[data-loading] .loupe-canvas {
  filter: blur(3px);
}

.screen-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* A faint sheen on the glass, above the picture and below the labels. */
.screen-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(160deg, oklch(1 0 0 / 0.08), transparent 38%),
    radial-gradient(120% 90% at 50% 50%, transparent 60%, oklch(0 0 0 / 0.35));
}

/* A loupe over the middle of the screen: the same pixels, each one drawn as a
   square, so a 1:1 crosshair can be read on a dense display. */
.loupe {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px;
  border-radius: 50%;
  background: linear-gradient(160deg, oklch(0.42 0.004 80), oklch(0.16 0.004 80));
  box-shadow: 0 6px 16px -4px oklch(0 0 0 / 0.6), inset 0 1px 0 oklch(1 0 0 / 0.25);
  pointer-events: none;
}

.loupe-canvas {
  display: block;
  transition: filter var(--dur-base) var(--ease-out);
  border-radius: 50%;
  background: oklch(0.15 0 0);
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.7);
  image-rendering: pixelated;
}

.loupe-tag {
  position: absolute;
  left: 50%;
  bottom: -7px;
  padding: 1px 6px;
  border-radius: 4px;
  background: oklch(0.16 0.004 80);
  color: oklch(0.92 0 0);
  font: 700 11px/1.4 var(--font-mono);
  transform: translateX(-50%);
}

.screen-tag,
.screen-hint {
  position: absolute;
  margin: 0;
  padding: 3px 7px;
  border-radius: 5px;
  background: oklch(0 0 0 / 0.55);
  color: oklch(0.95 0 0);
  font: 600 10px/1.2 var(--font-mono);
  letter-spacing: 0.04em;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.screen-tag {
  left: 8px;
  bottom: 8px;
}

.screen-hint {
  right: 8px;
  bottom: 8px;
  transition: opacity var(--dur-base) var(--ease-out);
}

.screen[data-firing] .screen-hint {
  opacity: 0;
}

/* ---------- Strip under the screen ---------- */

.strip {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.lcd {
  position: relative;
  border-radius: var(--radius-well);
  background: var(--lcd);
  box-shadow:
    inset 0 1px 3px oklch(0 0 0 / 0.6),
    inset 0 0 0 1px oklch(0 0 0 / 0.5);
}

.code-lcd {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 4px 9px;
}

.lcd-label {
  color: var(--lcd-dim);
  font: 700 8.5px/10px var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lcd-code {
  overflow: hidden;
  color: var(--lcd-ink);
  font: 600 11px/16px var(--font-mono);
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 8px oklch(from var(--lcd-ink) l c h / 0.35);
  -webkit-user-select: all;
  user-select: all;
}

/* ---------- Keys ---------- */

.key {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--radius-key);
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  /* Every shadow is inside the key: a drop shadow below it made a key read
     taller (and lower) than the field or key beside it, so the silhouette is
     exactly the box and the depth is a darker band inside the bottom edge. */
  box-shadow:
    inset 0 0 0 1px var(--key-line),
    inset 0 2px 0 var(--highlight),
    inset 0 -2px 0 oklch(0 0 0 / 0.16);
  color: var(--ink);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform var(--dur-press) var(--ease-press),
    box-shadow var(--dur-press) var(--ease-press),
    background var(--dur-base) var(--ease-out),
    filter var(--dur-base) var(--ease-out);
  -webkit-user-select: none;
  user-select: none;
}

@media (hover: hover) {
  .key:hover {
    filter: brightness(1.03);
    box-shadow:
      inset 0 0 0 1px var(--key-line),
      inset 0 2px 0 var(--highlight),
      inset 0 -2px 0 oklch(0 0 0 / 0.24);
  }
}

.key:active,
.key[data-pressed] {
  transform: translateY(1px);
  background: var(--key-pressed);
  box-shadow:
    inset 0 1px 2px var(--shade-strong),
    inset 0 0 0 1px var(--key-line);
  transition-duration: 30ms;
}

.key-accent {
  --key-top: oklch(from var(--accent) calc(l + 0.06) c h);
  --key-bottom: var(--accent);
  --key-line: oklch(from var(--accent) calc(l - 0.16) c h);
  --key-pressed: oklch(from var(--accent) calc(l - 0.05) c h);
  --highlight: oklch(1 0 0 / 0.35);
  color: var(--accent-ink);
  text-shadow: 0 -1px 0 oklch(0 0 0 / 0.2);
}

.key-icon {
  width: 30px;
  padding: 0;
}

.key-icon svg {
  width: 16px;
  height: 16px;
}

.key[aria-pressed="false"] .mute,
.key[aria-pressed="true"] .wave {
  display: inline;
}
.key[aria-pressed="true"] .mute,
.key[aria-pressed="false"] .wave {
  display: none;
}

/* A key label that changes swaps in place. */
.key [data-label] {
  display: inline-block;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}

/* ---------- Panel ---------- */

.panel {
  display: flex;
  flex-direction: column;
  border-radius: 11px;
  background: var(--well);
  /* A real border rather than an inset shadow: children (the scrollbar
     above all) paint over an inset shadow, which broke the right edge. */
  border: 1px solid var(--well-line);
  box-shadow: inset 0 1px 3px var(--shade-strong);
  overflow: hidden;
}

.panel-head {
  display: flex;
  gap: 5px;
  padding: 8px;
  border-bottom: 1px solid var(--well-line);
  box-shadow: 0 1px 0 var(--highlight);
}

/* ---------- Tabs ---------- */

.tabs {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--well-line);
}

/* One container marks the open tab and slides to the next one when the tab
   changes. The tabs are two equal columns, so it only has to travel one column
   plus the gap. .tabs::before is the container, .tabs::after the two curves
   where it meets the line under the tabs. */
.tabs {
  --tab-w: 100px;
  isolation: isolate;
}

.tabs::before,
.tabs::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 8px;
  bottom: -1px;
  left: 10px;
  width: var(--tab-w);
  pointer-events: none;
  transition: transform 340ms var(--ease-out);
}

.tabs:has(.tab:nth-child(2)[aria-selected="true"])::before {
  transform: translateX(calc(100% + 8px));
}

/* The curves are 18px wider than the container, so the same distance is the
   width of this box less those 18px, plus the 8px gap. */
.tabs:has(.tab:nth-child(2)[aria-selected="true"])::after {
  transform: translateX(calc(100% - 10px));
}

.tabs::before {
  box-sizing: border-box;
  bottom: 0;
  border: 1px solid var(--well-line);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--key-top), var(--well));
}

/* A ring in the line's colour, and under it the container's own fill, kept only
   in the corner outside the ring and across the line itself. */
.tabs::after {
  left: 2px;
  width: calc(var(--tab-w) + 18px);
  background:
    radial-gradient(circle at 0 0, transparent 8px, var(--well-line) 8px 9px, transparent 9px) left 0 bottom -1px / 10px 10px no-repeat,
    radial-gradient(circle at calc(100% - 2px) 0, transparent 8px, var(--well-line) 8px 9px, transparent 9px) right 0 bottom -1px / 11px 10px no-repeat,
    linear-gradient(180deg, var(--key-top), var(--well));
  mask:
    linear-gradient(#000, #000) 9px bottom / calc(100% - 18px) 2px no-repeat,
    radial-gradient(circle at 0 0, transparent 8px, #000 8px) left 0 bottom -1px / 10px 10px no-repeat,
    radial-gradient(circle at calc(100% - 2px) 0, transparent 8px, #000 8px) right 0 bottom -1px / 11px 10px no-repeat;
}

.tab {
  position: relative;
  z-index: 1;
  flex: none;
  width: var(--tab-w);
  min-height: 28px;
  margin-bottom: -1px;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font-weight: 650;
  cursor: pointer;
  transition: color var(--dur-base) var(--ease-out);
}

.tab[aria-selected="true"] {
  color: var(--accent);
}

@media (hover: hover) {
  .tab:hover {
    color: var(--ink);
  }
}

.panel-scroll {
  flex: 1;
  min-height: 0;
  padding: 2px 8px 10px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  /* What scrolls under the tabs, or off the foot of the panel, fades out over
     a few pixels instead of being cut off at the edge. JavaScript sets the two
     lengths from the scroll position, so nothing fades at rest. */
  --fade-top: 0px;
  --fade-bottom: 0px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
}

/* A scrollbar that is always there, drawn like the rest of the chassis: a
   recessed groove holding a raised thumb. */
.panel-scroll::-webkit-scrollbar,
.select-menu::-webkit-scrollbar {
  width: 12px;
}
.panel-scroll::-webkit-scrollbar-track,
.select-menu::-webkit-scrollbar-track {
  margin: 4px 0;
  border: 3px solid var(--well);
  border-radius: 6px;
  background: var(--chassis-line);
}
.panel-scroll::-webkit-scrollbar-thumb,
.select-menu::-webkit-scrollbar-thumb {
  border: 2px solid var(--well);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--key-top), var(--key-bottom));
  box-shadow: inset 0 0 0 1px var(--key-line);
}
.panel-scroll::-webkit-scrollbar-thumb:hover,
.select-menu::-webkit-scrollbar-thumb:hover {
  background: var(--key-top);
}
@supports not selector(::-webkit-scrollbar) {
  .panel-scroll,
  .select-menu {
    scrollbar-color: var(--key-top) var(--chassis-line);
  }
}


.group {
  margin: 0;
  padding: 8px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--well-line);
  box-shadow: 0 1px 0 var(--highlight);
  min-width: 0;
}

.group:last-child {
  border-bottom: 0;
  box-shadow: none;
}

.group[disabled] {
  opacity: 0.45;
}

.group-title {
  float: left;
  width: 100%;
  margin-bottom: 7px;
  padding: 0;
  color: var(--ink-muted);
  font: 750 9.5px/10px var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 var(--engrave);
}

.group-title + * {
  clear: both;
}

.group-unit {
  float: right;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: none;
}

.group-sub {
  display: grid;
  gap: 0;
  margin-top: 6px;
}

.group-sub[hidden] {
  display: none;
}

.note {
  margin: 6px 0 0;
  color: var(--ink-muted);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 15px;
}

.note:empty {
  display: none;
}

/* ---------- Scrubber: label, readout and a recessed track ---------- */

.scrub {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 6px;
  padding: 3px 0 4px;
}

.scrub-label {
  color: var(--ink);
  font-weight: 600;
  font-size: 11px;
}

.scrub-readout {
  display: flex;
  align-items: center;
  gap: 2px;
}

.scrub-step {
  width: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 6px;
  font: 700 12px/1 var(--font-mono);
}

.scrub-value {
  width: 46px;
  height: 20px;
  padding: 0 5px;
  border: 0;
  border-radius: 5px;
  background: var(--lcd);
  box-shadow: inset 0 1px 2px oklch(0 0 0 / 0.6);
  color: var(--lcd-ink);
  font: 600 11px/20px var(--font-mono);
  text-align: right;
  cursor: ew-resize;
  font-variant-numeric: tabular-nums;
}

.scrub-value:focus {
  cursor: text;
}

.scrub-track {
  --t: 0;
  --thumb: 18px;
  --track: 18px;
  position: relative;
  grid-column: 1 / -1;
  height: var(--track);
  cursor: pointer;
  touch-action: none;
}

.scrub-track::before {
  /* The groove. */
  content: "";
  position: absolute;
  inset: calc(var(--track) / 2 - 3px) 0;
  border-radius: 4px;
  background: var(--page);
  box-shadow: inset 0 1px 2px var(--shade-strong), 0 1px 0 var(--highlight);
}

.scrub-fill {
  position: absolute;
  top: calc(var(--track) / 2 - 3px);
  bottom: calc(var(--track) / 2 - 3px);
  left: 0;
  width: calc(var(--t) * (100% - var(--thumb)) + var(--thumb) / 2);
  border-radius: 4px;
  background: var(--fill, oklch(from var(--accent) l c h / 0.85));
  box-shadow: inset 0 1px 1px oklch(0 0 0 / 0.25);
}

.scrub[data-tint="red"] { --fill: oklch(0.62 0.2 27); }
.scrub[data-tint="green"] { --fill: oklch(0.7 0.18 145); }
.scrub[data-tint="blue"] { --fill: oklch(0.58 0.18 260); }

.scrub-thumb {
  position: absolute;
  top: calc((var(--track) - var(--thumb)) / 2);
  left: calc(var(--t) * (100% - var(--thumb)));
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 35%, var(--key-top), var(--key-bottom) 70%);
  box-shadow:
    inset 0 1px 0 var(--highlight),
    inset 0 0 0 1px var(--key-line),
    0 1px 2px var(--shade-strong),
    0 3px 6px -2px var(--shade-strong);
  transition: transform var(--dur-press) var(--ease-press), box-shadow var(--dur-base) var(--ease-out);
}

.scrub-thumb::after {
  /* The grip: a small dimple in the cap. */
  content: "";
  position: absolute;
  inset: calc(var(--thumb) / 3);
  border-radius: 50%;
  background: var(--key-bottom);
  box-shadow: inset 0 1px 1.5px var(--shade-strong), 0 1px 0 var(--highlight);
}

@media (hover: hover) {
  .scrub-track:hover .scrub-thumb {
    transform: scale(1.08);
  }
}

.scrub-track[data-dragging] .scrub-thumb {
  transform: scale(0.94);
  box-shadow:
    inset 0 1px 0 var(--highlight),
    inset 0 0 0 1px var(--key-line),
    0 1px 1px var(--shade-strong);
}

/* ---------- Select ---------- */

.select {
  min-width: 0;
}

.select-wide {
  flex: 1;
}

.select-trigger {
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  padding: 0 8px 0 10px;
  font-weight: 600;
}

.deck-controls .select-trigger {
  max-width: 150px;
}

/* A narrow deck (the gallery tile): the name takes its own line, so the three
   selects keep their whole labels. */
@container (max-width: 520px) {
  .deck-bar {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .brand {
    width: 100%;
    padding-top: 2px;
  }
  .deck-controls {
    width: 100%;
  }
  .deck-controls .select {
    flex: 1;
  }
  .deck-controls .select-trigger {
    max-width: none;
  }
}

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-chevron {
  flex: none;
  width: 12px;
  height: 12px;
  color: var(--ink-muted);
  transition: transform var(--dur-base) var(--ease-out);
}

.select-trigger[aria-expanded="true"] .select-chevron {
  transform: rotate(180deg);
}

.select-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  max-height: min(300px, calc(100vh - 16px));
  padding: 4px;
  overflow-y: auto;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--key-top), var(--key-bottom));
  box-shadow:
    inset 0 1px 0 var(--highlight),
    inset 0 0 0 1px var(--key-line),
    0 12px 28px -8px var(--shade-strong),
    0 2px 6px var(--shade);
  color: var(--ink);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out),
    display var(--dur-base) allow-discrete,
    overlay var(--dur-base) allow-discrete;
}

.select-menu:popover-open {
  opacity: 1;
  transform: none;
}

@starting-style {
  .select-menu:popover-open {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

.select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}

.select-option[data-active] {
  background: var(--well);
  box-shadow: inset 0 1px 2px var(--shade), inset 0 0 0 1px var(--well-line);
}

.select-option[aria-selected="true"]::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
}

.option-meta {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
}

.option-rank {
  min-width: 18px;
  color: var(--ink-muted);
  font: 600 10px/1 var(--font-mono);
}

/* ---------- Switch ---------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-weight: 600;
  font-size: 11px;
}

.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: var(--page);
  box-shadow: inset 0 1px 3px var(--shade-strong), inset 0 0 0 1px var(--well-line), 0 1px 0 var(--highlight);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out);
}

.switch[aria-checked="true"] {
  background: oklch(from var(--accent) l c h / 0.9);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  background: radial-gradient(circle at 50% 35%, var(--key-top), var(--key-bottom) 75%);
  box-shadow: inset 0 1px 0 var(--highlight), inset 0 0 0 1px var(--key-line), 0 1px 2px var(--shade-strong);
  transition: transform var(--dur-base) var(--ease-out), width var(--dur-press) var(--ease-press);
}

.switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

.switch:active::after {
  width: 21px;
}
.switch[aria-checked="true"]:active::after {
  transform: translateX(13px);
}

/* ---------- Swatches ---------- */

.swatches {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}

.swatch {
  position: relative;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow:
    inset 0 1px 1px oklch(1 0 0 / 0.45),
    inset 0 -1px 2px oklch(0 0 0 / 0.25),
    0 0 0 1px oklch(0 0 0 / 0.25),
    0 1px 2px var(--shade-strong);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-press);
}

@media (hover: hover) {
  .swatch:hover {
    transform: translateY(-1px) scale(1.06);
  }
}

.swatch:active {
  transform: scale(0.92);
}

.swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--accent);
}

/* ---------- Import sheet ---------- */

.sheet {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--chassis-top), var(--chassis-bottom));
  box-shadow:
    inset 0 1px 0 var(--highlight),
    inset 0 0 0 1px var(--chassis-line),
    0 24px 60px -12px oklch(0 0 0 / 0.5);
  color: var(--ink);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out),
    display var(--dur-base) allow-discrete,
    overlay var(--dur-base) allow-discrete;
}

.sheet[open] {
  opacity: 1;
  transform: none;
}

@starting-style {
  .sheet[open] {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.sheet::backdrop {
  background: oklch(0 0 0 / 0);
  transition: background-color var(--dur-base) var(--ease-out), display var(--dur-base) allow-discrete, overlay var(--dur-base) allow-discrete;
}

.sheet[open]::backdrop {
  background: oklch(0 0 0 / 0.35);
}

@starting-style {
  .sheet[open]::backdrop {
    background: oklch(0 0 0 / 0);
  }
}

.sheet-body {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.sheet-title {
  margin: 0 0 -4px;
  font-size: 14px;
  font-weight: 750;
}

.well-input {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-well);
  background: var(--lcd);
  box-shadow: inset 0 1px 3px oklch(0 0 0 / 0.6), 0 1px 0 var(--highlight);
  color: var(--lcd-ink);
  font: 600 12px/18px var(--font-mono);
  resize: none;
}

/* The error's room is kept whether or not there is one, so the dialog never
   changes height when a message arrives. */
.sheet-error {
  min-height: 15px;
  margin: 0;
  color: oklch(0.6 0.2 27);
  font-size: 11px;
  font-weight: 600;
  line-height: 15px;
}

@media (max-width: 480px) {
  .sheet-error {
    min-height: 30px;
  }
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  left: 10px;
  top: 10px;
  max-width: calc(100% - 190px);
  margin: 0;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--lcd);
  box-shadow: 0 8px 20px -6px oklch(0 0 0 / 0.5), inset 0 0 0 1px oklch(0 0 0 / 0.5);
  color: var(--lcd-ink);
  font: 600 11px/1.3 var(--font-mono);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.toast[data-shown] {
  opacity: 1;
  transform: none;
}

/* ---------- Small windows ---------- */

/* ---------- On a phone, in the gallery ---------- */

/* The preview takes the room it needs and the settings take the rest. */
html[data-touch] .device {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

html[data-touch] [data-action="copy-commands"],
html[data-touch] .brand {
  display: none;
}

/* A tile is a display: the preview and nothing else, no controls anywhere. */
html[data-mode="tile"] .device {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 0;
  row-gap: 0;
}

html[data-mode="tile"] .panel {
  visibility: hidden;
}

/* A tile shows the preview and nothing else. What it hides closes up rather
   than switching off, so opening the project grows the controls in. */
.deck-bar,
.strip {
  overflow: clip;
  overflow-clip-margin: 4px;
  max-height: 120px;
  transition:
    max-height var(--dur-slow) var(--ease-out),
    margin var(--dur-slow) var(--ease-out),
    opacity var(--dur-slow) var(--ease-out);
}

html[data-mode="tile"] .deck-bar {
  max-height: 0;
  margin-bottom: -8px;
  opacity: 0;
  pointer-events: none;
}

html[data-mode="tile"] .strip {
  max-height: 0;
  margin-top: -8px;
  opacity: 0;
  pointer-events: none;
}

html[data-mode="tile"] .screen-hint,
html[data-mode="tile"] .screen-tag {
  opacity: 0;
}

html:not([data-closable]) [data-action="close"] {
  display: none;
}


@media (max-height: 360px) {
  .strip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
  }
}

/* On a phone the colour presets are big enough to hit with a thumb, and sit
   side by side rather than spread across the row. */
html[data-touch] .swatches {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}
html[data-touch] .swatch {
  width: 34px;
  height: 34px;
}

/* On a phone every control is a size a thumb can hit: keys, selects, number
   fields, sliders, switches, tabs and the rows of an open list. */
html[data-touch] .key {
  min-height: 38px;
  padding: 0 14px;
}
html[data-touch] .key-icon {
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
}
html[data-touch] .key-icon svg {
  width: 18px;
  height: 18px;
}
html[data-touch] .tab {
  min-height: 38px;
}
html[data-touch] .scrub {
  padding: 5px 0 6px;
}
html[data-touch] .scrub-label,
html[data-touch] .switch-row {
  font-size: 12px;
}
html[data-touch] .scrub-step {
  width: 32px;
  min-height: 32px;
}
html[data-touch] .scrub-value {
  width: 56px;
  height: 32px;
  font: 600 16px/32px var(--font-mono);
}
html[data-touch] .scrub-track {
  --thumb: 28px;
  --track: 32px;
}
html[data-touch] .switch-row {
  padding: 6px 0;
}
html[data-touch] .switch {
  width: 50px;
  height: 30px;
  border-radius: 15px;
}
html[data-touch] .switch::after {
  width: 26px;
  height: 26px;
}
html[data-touch] .switch[aria-checked="true"]::after {
  transform: translateX(20px);
}
html[data-touch] .switch:active::after {
  width: 30px;
}
html[data-touch] .switch[aria-checked="true"]:active::after {
  transform: translateX(16px);
}
html[data-touch] .select-option {
  padding: 11px 10px;
}

/* The list is drawn on a key's face, so its groove is the well and the
   borders are left clear instead of the well colour. */
.select-menu::-webkit-scrollbar-track {
  border-color: transparent;
  background: var(--well);
  background-clip: padding-box;
}
.select-menu::-webkit-scrollbar-thumb {
  border-color: transparent;
  background-clip: padding-box;
}

/* A number that changes by itself rolls: the old reading leaves and the new one
   comes in. The input holds the real value and stays still underneath. */
.scrub-box {
  position: relative;
  display: inline-flex;
}

.scrub-roll {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.scrub-roll {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.scrub-col {
  position: relative;
  display: inline-block;
  white-space: pre;
}

.scrub-gone {
  position: absolute;
  top: 0;
  right: 0;
}

.scrub[data-rolling] .scrub-value {
  color: transparent;
}

/* On a tablet the close button sits at the right edge of the bar. */
.deck-controls [data-action="close"] {
  margin-left: auto;
}

html[data-touch] .deck-controls {
  width: 100%;
}

/* The description sits close under the title and a little away from the field. */
.sheet-body .note {
  margin: 0 0 4px;
}

/* In a rounded window the chassis takes the window's corners, so its outline
   runs round the curve instead of being cut off by it. */
html[data-windowed] .device {
  border-radius: 18px;
}

@media (max-width: 699px) {
  html[data-windowed][data-touch] .device {
    border-radius: 0;
  }
}

/* The window wrapper only exists for the legacy look. */
.window {
  display: contents;
}

/* A static select keeps the width of its widest option. */
.deck-controls .select[data-static] .select-trigger {
  width: var(--static-w, 100%);
  max-width: none;
}

@container (max-width: 520px) {
  .deck-controls .select[data-static] .select-trigger {
    width: 100%;
  }
}

/* The zoom reading rolls when it changes. */
.loupe-tag {
  overflow: hidden;
}

.loupe-num {
  display: inline-block;
}

.loupe-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

/* On a touch layout the selects always fill the row, whatever its width. */
html[data-touch] .deck-controls {
  width: 100%;
}

html[data-touch] .deck-controls .select {
  flex: 1;
}

html[data-touch] .deck-controls .select[data-static] .select-trigger {
  width: 100%;
  max-width: none;
}

/* The loupe's size is set by the script in whole device pixels; the frame is
   only scaled while it changes, about its top right corner. */
.loupe {
  transform-origin: top right;
}

@media (prefers-reduced-motion: reduce) {
  .screen-map,
  .loupe-canvas {
    transition: none;
  }
  .tabs::before,
  .tabs::after {
    transition: none;
  }
}

/* On a touch screen a long press holds or drags; it does not select text or
   open the callout. Fields keep their selection, and the share code stays
   selectable. */
html[data-touch] body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html[data-touch] input,
html[data-touch] textarea,
html[data-touch] .lcd-code {
  -webkit-user-select: text;
  user-select: text;
}

/* ---------- The zoomed preview on a phone ---------- */

/* The preview is wide rather than tall, so the settings keep their room, and it
   shows the zoomed view alone: the loupe fills the screen and the map and the
   crosshair at their own size are drawn under it, unseen. */
.zoom {
  display: none;
}

html[data-touch]:not([data-mode="tile"]) .deck {
  min-height: 0;
}

html[data-touch]:not([data-mode="tile"]) .bezel {
  flex: none;
}

html[data-touch]:not([data-mode="tile"]) .screen {
  height: auto;
  aspect-ratio: 16 / 9;
}

html[data-touch]:not([data-mode="tile"]) .screen-map,
html[data-touch]:not([data-mode="tile"]) .screen-canvas,
html[data-touch]:not([data-mode="tile"]) .screen-glass,
html[data-touch]:not([data-mode="tile"]) .loupe-tag {
  visibility: hidden;
}

html[data-touch]:not([data-mode="tile"]) .loupe {
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

html[data-touch]:not([data-mode="tile"]) .loupe-canvas {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transition: filter var(--dur-slow, 200ms) ease-out, scale var(--dur-slow, 200ms) ease-out;
}

html[data-touch]:not([data-mode="tile"]) .screen[data-loading] .loupe-canvas {
  filter: blur(14px);
  scale: 1.06;
}

html[data-touch]:not([data-mode="tile"]) .zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
}

.zoom-reading {
  border-radius: 5px;
  min-width: 38px;
  padding: 3px 7px;
  background: oklch(0 0 0 / 0.55);
  color: oklch(0.95 0 0);
  font: 600 11px/1.2 var(--font-mono);
  letter-spacing: 0.04em;
  text-align: center;
}

.zoom .key:disabled {
  color: color-mix(in oklch, var(--ink) 38%, var(--key-bottom));
  transform: none;
  filter: none;
}

.zoom .key {
  touch-action: manipulation;
}

@media (prefers-reduced-motion: reduce) {
  html[data-touch]:not([data-mode="tile"]) .loupe-canvas {
    transition: none;
  }
}

/* A finger takes hold of the slider's thumb and nothing else on the track: the
   thumb's touch area reaches a little past the cap, and the rest of the track
   leaves vertical scrolling to the page. */
html[data-touch] .scrub-track {
  touch-action: pan-y;
}

html[data-touch] .scrub-thumb {
  touch-action: none;
}

html[data-touch] .scrub-thumb::before {
  content: "";
  position: absolute;
  inset: -8px;
}

/* On a touch screen the settings scroll like any other page there: the system's
   own overlay scrollbar instead of a 12px drawn one (which showed as a lighter
   strip with an outline down the right edge and shifted the content off
   centre), and no edge fade, because a mask on a scrolling box is composited
   as its own layer on iOS and shows as a tinted band down the sides. */
html[data-touch] .panel-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  mask-image: none;
  scrollbar-width: none;
}

html[data-touch] .panel-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* iOS Safari zooms the whole page in when a field under 16px is focused, and
   leaves it zoomed and panned afterwards: the page then shows a different
   colour down the left edge and the backdrop down the right and bottom edges.
   So fields are 16px on touch, and the document itself cannot be panned (the
   panel is the only thing that scrolls). */
html[data-touch] input,
html[data-touch] textarea {
  font-size: 16px;
}

html[data-touch],
html[data-touch] body {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* The preview's height is a whole number of pixels: the 16:9 ratio of its width
   (the bezel's padding is 7px a side) would otherwise leave everything under it
   on a fraction of a pixel. */
html[data-touch]:not([data-mode="tile"]) .screen {
  height: round(down, calc((100cqw - 14px) * 9 / 16), 1px);
  aspect-ratio: auto;
}

/* The step buttons' − and + are drawn, not typed: a glyph sits wherever the
   font puts it (about a pixel off the middle of the box, and the − and the +
   a half pixel apart), while a 2px bar centred in an even-sized box is exact. */
.scrub-step {
  position: relative;
  font-size: 0;
  line-height: 0;
}

.scrub-step::before,
.scrub-step::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 2px;
  background: currentColor;
}

.scrub-step[data-dir="-1"]::after {
  display: none;
}

.scrub-step[data-dir="1"]::after {
  width: 2px;
  height: 8px;
}

html[data-touch] .scrub-step::before {
  width: 10px;
}

html[data-touch] .scrub-step[data-dir="1"]::after {
  height: 10px;
}

/* A digit's height is centred on the box, not the line it sits in. */
.scrub-value {
  padding-top: 2px;
}

html[data-touch] .scrub-value {
  padding-top: 1px;
}
