/* Lenskit — MIT License — see LICENSE
   Chrome components. The canvas is the show; everything here should read as instrument glass laid
   over it. Colours, fonts and sizes come from styles/tokens.css only. */

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--vacuum);
  color: var(--text);
  color-scheme: dark;
  overscroll-behavior: none;
}

body {
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

.lk-app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--vacuum);
  color: var(--text);
  font-family: var(--f-ui);
  isolation: isolate;
}

/* :where() keeps this reset at element specificity so component rules (.btn-primary …) win */
:where(.lk-app) button, :where(.lk-app) input, :where(.lk-app) select { font: inherit; color: inherit; }
.lk-app button { cursor: pointer; }
.lk-app button:disabled { cursor: not-allowed; }
.lk-app kbd {
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  display: inline-block;
  min-width: 1.75em;
  padding: 1px 5px;
  border: 1px solid var(--hair-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--text);
  background: rgba(255, 255, 255, .03);
  text-align: center;
  line-height: 1.5;
}
.lk-app ::selection { background: rgba(var(--accent-rgb), .3); }

/* `hidden` must win over component display rules (.btn is inline-flex, .card flex …), or
   handle.setVisible(false) on a button in a row silently does nothing. The caption animates its
   own hidden state. */
.lk-app [hidden]:not(.caption) { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lk-app :focus { outline: none; }
.lk-app :focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.noscript {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  background: var(--vacuum);
  color: var(--text-2);
  font-family: var(--f-quote);
  font-style: italic;
  font-size: 19px;
  text-align: center;
}

/* ---------- stage layers ---------- */

.scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
/* canvas pixels paint over an inset box-shadow, so the view's focus ring is an inset outline */
.scene:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .6); outline-offset: -2px; box-shadow: none; }

.vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, var(--vignette) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--vacuum) 55%, transparent) 0%, transparent 16%, transparent 78%, color-mix(in srgb, var(--vacuum) 60%, transparent) 100%);
  z-index: 1;
}
.grain {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

/* Cross-fade curtain: sits over the scene but under the chrome, so only the world dissolves. */
.veil {
  position: absolute; inset: 0;
  z-index: 2;
  background: var(--vacuum);
  opacity: 0;
  pointer-events: none;
  transition: opacity 380ms var(--ease-io);
}
.veil.is-on { opacity: 1; }

.chrome {
  position: absolute; inset: 0;
  z-index: 10;
  pointer-events: none;
  transition: visibility 0s linear 0s;
}
.chrome > * { pointer-events: auto; }
/* Fade the glass leaves, never a wrapper: an ancestor with opacity < 1 becomes the backdrop root,
   and every backdrop-filter inside it stops blurring the scene until the fade ends (then snaps). */
.lk-app.ui-hidden .chrome {
  visibility: hidden;
  transition: visibility 0s linear 420ms;
}
.lk-app.ui-hidden :is(.wordmark, .tagline, .lens-switch, .hud-item, .icon-btn, .panel, .caption, .timeline) { opacity: 0; }

/* ---------- glass ---------- */

.glass, .panel, .caption, .timeline, .toast, .error-card, .modal-card, .hud-item, .lens-switch, .icon-btn, .show-ui {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--hair);
}

/* ---------- brand, top-left ---------- */

.brand {
  position: absolute;
  top: calc(var(--gutter) + var(--sat));
  left: calc(var(--gutter) + var(--sal));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  pointer-events: none;
}
.brand > * { pointer-events: auto; }

.wordmark {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: .46em;
  margin-right: -.46em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 22px color-mix(in srgb, var(--now) 25%, transparent);
  position: relative;
  padding-bottom: 9px;
  user-select: none;
  transition: opacity 420ms var(--ease);
}
.wordmark::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: calc(100% - .46em);
  height: 1px;
  background: var(--chrono);
  opacity: .75;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), .45);
  transform-origin: left center;
}
.tagline {
  margin: 8px 0 14px;
  font-family: var(--f-quote);
  font-style: italic;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .01em;
  transition: opacity 420ms var(--ease);
}

.lens-switch {
  display: inline-flex;
  flex-wrap: wrap;                  /* many lenses wrap onto a second row instead of running under the panel */
  max-width: calc(100vw - var(--panel-w) - var(--gutter) * 3 - var(--sal) - var(--sar));
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  transition: opacity 420ms var(--ease);
}
.lens-btn {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas: "name kbd" "sub sub";
  align-items: baseline;
  column-gap: 10px;
  row-gap: 1px;
  min-width: 124px;
  padding: 8px 12px 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  color: var(--muted);
  transition: background 220ms var(--ease), color 220ms var(--ease);
}
.lens-btn:hover { color: var(--text); background: var(--chip); }
.lens-btn[aria-pressed="true"] {
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .025));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), 0 6px 22px -10px rgba(var(--accent-rgb), .45);
}
.lens-btn[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 3px;
  height: 1px;
  border-radius: 1px;
  background: var(--chrono);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), .6);
}
.lens-btn[aria-pressed="true"]:focus-visible { box-shadow: var(--ring); }
.lens-name {
  grid-area: name;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.lens-sub {
  grid-area: sub;
  font-family: var(--f-quote);
  font-style: italic;
  font-size: 13px;
  color: var(--muted);
}
.lens-kbd {
  grid-area: kbd;
  justify-self: end;
  opacity: .55;
  transform: scale(.9);
}
.lens-btn[aria-pressed="true"] .lens-kbd { opacity: .9; }

/* ---------- top-right: HUD + icon bar ---------- */

.topright {
  position: absolute;
  top: calc(var(--gutter) + var(--sat));
  right: calc(var(--gutter) + var(--sar));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
.topright > * { pointer-events: auto; }

.hud {
  display: flex;
  gap: 6px;
  margin: 0;
  pointer-events: none;
}
.hud-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 82px;
  padding: 7px 11px 8px;
  border-radius: 10px;
  pointer-events: none;
  transition: opacity 420ms var(--ease);
}
.hud-item[hidden] { display: none; }
.hud-label {
  margin: 0;
  font-family: var(--f-ui);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.hud-value {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.iconbar {
  display: flex;
  gap: 6px;
}
.icon-btn {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 11px;
  color: var(--muted);
  transition: color 180ms var(--ease), border-color 180ms var(--ease), background 180ms var(--ease), transform 180ms var(--ease), opacity 420ms var(--ease);
}
.icon-btn svg {
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn:hover { color: var(--text); border-color: var(--hair-2); background: var(--glass-2); }
.icon-btn:active { transform: scale(.95); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: rgba(var(--accent-rgb), .35); }

/* ---------- control panel ---------- */

.panel {
  position: absolute;
  /* clears the HUD row (≈53px tall) with a hairline of air */
  top: calc(var(--gutter) + var(--sat) + 66px);
  right: calc(var(--gutter) + var(--sar));
  width: var(--panel-w);
  max-height: calc(100% - var(--gutter) * 2 - var(--sat) - var(--sab) - 66px - var(--tl-h) - 14px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .035);
  overflow: hidden;
  transition: opacity 420ms var(--ease);
}
/* a lens that builds no controls gets no panel (and no view offset) */
.panel.is-empty { display: none; }
.panel-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 12px 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--hair);
  background: transparent;
  text-align: left;
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel-head:hover .chev { color: var(--text); background: var(--chip-hover); }
.panel-head:focus-visible { box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .85); }
.grab { display: none; }
.panel-heading { flex: 1; display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.panel-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text);
}
.panel-sub {
  font-family: var(--f-quote);
  font-style: italic;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chev {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  transition: transform 300ms var(--ease), color 180ms, background 180ms;
}
.chev svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chev { transform: rotate(180deg); }
.panel.is-collapsed .chev { transform: none; }
.panel.is-collapsed .panel-head { border-bottom-color: transparent; border-radius: var(--radius); }

.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  padding: 4px 0 10px;
  transition: opacity 260ms var(--ease);
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.panel.is-collapsed .panel-body { display: none; }

/* sections */
.ps { border-top: 1px solid var(--hair); }
.ps:first-child { border-top: 0; }
.ps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.ps-head:hover { color: var(--text); }
.ps-head:focus-visible { box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .8); border-radius: 6px; }
.ps-title {
  font-family: var(--f-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.ps-chev { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 260ms var(--ease); }
.ps.is-collapsed .ps-chev { transform: rotate(-90deg); }
.ps-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 16px 16px;
}
.ps.is-collapsed .ps-body { display: none; }

/* control rows */
.ctl { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ctl[hidden] { display: none !important; }
.ctl.is-disabled { opacity: .42; }
.ctl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.ctl-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .005em;
}
.ctl-val {
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}
.ctl-hint, .ctl-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}
.ctl-note { padding: 1px 0; }
.ctl-note:empty { display: none; }

/* range slider: thin track, glowing thumb */
.range {
  --p: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.range:disabled { cursor: not-allowed; }
.range::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), .95) 0, rgba(var(--accent-rgb), .95) var(--p), var(--track) var(--p), var(--track) 100%);
}
.range::-moz-range-track { height: 2px; border-radius: 2px; background: var(--track); }
.range::-moz-range-progress { height: 2px; border-radius: 2px; background: rgba(var(--accent-rgb), .95); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  border: 0;
  background: var(--now);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18), 0 0 14px rgba(var(--accent-rgb), .75);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease);
}
.range::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 0;
  background: var(--now);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18), 0 0 14px rgba(var(--accent-rgb), .75);
}
.range:hover::-webkit-slider-thumb { transform: scale(1.15); }
.range:active::-webkit-slider-thumb { transform: scale(1.25); box-shadow: 0 0 0 5px rgba(var(--accent-rgb), .2), 0 0 20px rgba(var(--accent-rgb), .9); }
.range:focus-visible { box-shadow: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.range:focus-visible::-moz-range-thumb { box-shadow: var(--ring); }

/* select */
.select-wrap { position: relative; }
.select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--hair-2);
  border-radius: var(--radius-s);
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.select:hover { background: var(--chip-hover); }
.select option { background: var(--option-bg); color: var(--text); }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* segmented */
.seg {
  display: flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  background: rgba(0, 0, 0, .18);
}
.seg-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 200ms var(--ease), color 200ms var(--ease), box-shadow 200ms var(--ease);
}
/* long labels (ui.js adds .seg-fit): size each segment to its label so none is cut off */
.seg-fit > .seg-btn { flex: 1 1 auto; padding: 0 6px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-checked="true"] {
  color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), #FFFFFF 44%), var(--accent));
  box-shadow: 0 0 16px -2px rgba(var(--accent-rgb), .55);
}
.seg-btn[aria-checked="true"]:focus-visible { box-shadow: var(--ring); }

/* toggle switch */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 3px 0;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 6px;
}
.toggle .ctl-label { flex: 1; }
.sw {
  position: relative;
  flex: none;
  width: 34px; height: 20px;
  border-radius: 20px;
  background: var(--switch-bg);
  box-shadow: inset 0 0 0 1px var(--hair-2);
  transition: background 220ms var(--ease), box-shadow 220ms var(--ease);
}
.knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--knob);
  transition: transform 240ms var(--ease), background 220ms var(--ease), box-shadow 220ms var(--ease);
}
.toggle[aria-checked="true"] .sw { background: rgba(var(--accent-rgb), .22); box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .55); }
.toggle[aria-checked="true"] .knob { transform: translateX(14px); background: var(--now); box-shadow: 0 0 10px rgba(var(--accent-rgb), .85); }
.toggle:hover .knob { background: var(--knob-hover); }
.toggle[aria-checked="true"]:hover .knob { background: #FFFFFF; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--hair-2);
  border-radius: var(--radius-s);
  background: var(--chip);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), color 180ms, transform 120ms var(--ease), box-shadow 180ms;
}
.btn:hover { background: var(--chip-hover); border-color: var(--edge-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; transform: none; }
.btn-primary {
  border-color: transparent;
  color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), #FFFFFF 48%), var(--accent));
  box-shadow: 0 8px 24px -12px rgba(var(--accent-rgb), .9);
}
.btn-primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), #FFFFFF 62%), color-mix(in srgb, var(--accent), #FFFFFF 15%));
  border-color: transparent;
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--chip); }
.btn.is-on, .btn.is-active, .btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), .45);
  background: rgba(var(--accent-rgb), .08);
  box-shadow: inset 0 0 12px -4px rgba(var(--accent-rgb), .4);
}
/* a pressed primary stays a solid accent chip with dark text (the generic pressed tint would put
   accent text on the accent gradient) */
.btn-primary.is-on, .btn-primary.is-active, .btn-primary[aria-pressed="true"] {
  color: var(--on-accent);
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), #FFFFFF 48%), var(--accent));
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .55), 0 8px 24px -12px rgba(var(--accent-rgb), .9);
}
.ctl-btn .btn { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-row .btn { flex: 1 1 auto; padding: 0 10px; }

/* file drop-zone */
.drop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 11px;
  border: 1px dashed var(--drop-edge);
  background: rgba(255, 255, 255, .018);
  cursor: pointer;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), box-shadow 200ms var(--ease);
}
.drop:hover { border-color: var(--drop-edge-hover); background: rgba(255, 255, 255, .035); }
.drop:focus-within { border-color: rgba(var(--accent-rgb), .8); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
.drop.is-over {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), .08);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .12), 0 0 30px -6px rgba(var(--accent-rgb), .55);
}
.drop.is-reject { border-color: var(--reject); animation: shake 360ms var(--ease); }
.drop.is-disabled { pointer-events: none; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-icon {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(var(--accent-rgb), .08);
  color: var(--accent);
}
.drop-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drop-title { font-size: 13px; font-weight: 600; color: var(--text); }
.drop-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes shake { 20%, 60% { transform: translateX(-3px); } 40%, 80% { transform: translateX(3px); } }

/* swatches: gradient pills */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.swatch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 6px 6px 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--chip);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  text-align: center;
  transition: border-color 200ms var(--ease), color 200ms, background 200ms;
}
.swatch:hover { color: var(--text); background: var(--chip-hover); }
.swatch-pill {
  display: block;
  height: 10px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.swatch[aria-checked="true"] { color: var(--text); border-color: rgba(var(--accent-rgb), .55); background: rgba(var(--accent-rgb), .06); }
.swatch[aria-checked="true"] .swatch-pill { box-shadow: 0 0 14px -2px rgba(var(--accent-rgb), .6), inset 0 0 0 1px rgba(255, 255, 255, .18); }

/* cards: subjects / shapes / presets */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 58px;
  padding: 10px 11px 11px;
  border: 1px solid var(--hair);
  border-radius: 11px;
  background: var(--chip);
  text-align: left;
  overflow: hidden;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), transform 160ms var(--ease);
}
.card:hover { background: var(--chip-hover); border-color: var(--hair-2); }
.card:active { transform: scale(.985); }
.card-label { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.25; }
.card-sub { font-size: 11px; line-height: 1.35; color: var(--muted); }
.card::after {
  content: "";
  position: absolute;
  left: 11px; right: 11px; bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--chrono);
  opacity: 0;
  transform: scaleX(.4);
  transition: opacity 240ms var(--ease), transform 320ms var(--ease);
}
.card[aria-checked="true"] {
  border-color: rgba(var(--accent-rgb), .5);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), .09), rgba(var(--accent-rgb), .025));
  box-shadow: 0 10px 26px -18px rgba(var(--accent-rgb), .9);
}
.card[aria-checked="true"]::after { opacity: 1; transform: scaleX(1); box-shadow: 0 0 10px rgba(var(--accent-rgb), .7); }
.card[aria-checked="true"] .card-sub { color: var(--card-sub-on); }
.card:disabled, .swatch:disabled, .seg-btn:disabled { opacity: .45; }

/* ---------- caption card ---------- */

.caption {
  position: absolute;
  left: calc(var(--gutter) + var(--sal));
  bottom: calc(var(--gutter) + var(--sab) + var(--tl-h) + 12px);
  width: max-content;
  max-width: min(420px, calc(100% - var(--panel-w) - var(--gutter) * 3 - var(--sal) - var(--sar)));
  padding: 16px 44px 16px 18px;
  border-radius: var(--radius);
  box-shadow: 0 24px 50px -28px rgba(0, 0, 0, .9);
  transition: opacity 360ms var(--ease), transform 360ms var(--ease), visibility 0s linear 0s;
}
.caption[hidden] { display: block; opacity: 0; transform: translateY(8px); visibility: hidden; pointer-events: none; transition: opacity 280ms var(--ease), transform 280ms var(--ease), visibility 0s linear 280ms; }
/* Artifact hosts ship [hidden]{display:none!important}; keep the caption laid out so it can fade. */
.lk-app .caption[hidden] { display: block !important; }
.caption::before {
  content: "";
  position: absolute;
  left: 18px; top: 0;
  width: 44px; height: 1px;
  background: var(--chrono);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), .6);
}
.cap-eyebrow {
  margin: 0 0 7px;
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}
.cap-title {
  margin: 0 0 6px;
  font-family: var(--f-quote);
  font-style: italic;
  font-weight: 400;
  font-size: 25px;
  line-height: 1.12;
  letter-spacing: -.005em;
  color: var(--now);
  text-shadow: 0 0 26px color-mix(in srgb, var(--now) 18%, transparent);
}
.cap-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--body);
  max-width: 44ch;
}
.cap-credit {
  margin: 10px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--hair);
  font-family: var(--f-mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .02em;
  color: var(--faint);
}
.cap-eyebrow:empty, .cap-title:empty, .cap-body:empty, .cap-credit:empty { display: none; }
.caption.is-compact { cursor: pointer; padding-block: 11px 12px; }
.caption.is-compact .cap-body, .caption.is-compact .cap-credit { display: none; }
.caption.is-compact .cap-eyebrow { margin-bottom: 4px; }
.caption.is-compact .cap-title { display: inline; margin: 0; font-size: 19px; }
/* the disclosure sits on the title's line */
.cap-more {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 4px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-family: var(--f-mono);
  font-style: normal;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: 3px;
  transition: color 160ms;
}
.caption.is-compact:hover .cap-more, .cap-more:hover { color: var(--accent); }
.cap-more:focus-visible { color: var(--accent); box-shadow: var(--ring); }
.caption-x {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  transition: color 160ms, background 160ms;
}
.caption-x:hover { color: var(--text); background: var(--chip-hover); }
.caption-x svg, .modal-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

/* ---------- chronometer timeline ---------- */

.timeline {
  position: absolute;
  left: calc(var(--gutter) + var(--sal));
  right: calc(var(--gutter) + var(--sar));
  bottom: calc(var(--gutter) + var(--sab));
  height: var(--tl-h);
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "play label track readout";
  align-items: center;
  column-gap: 14px;
  padding: 0 18px 0 8px;
  border-radius: 16px;
  box-shadow: 0 20px 50px -28px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .03);
  transition: opacity 320ms var(--ease), transform 320ms var(--ease), visibility 0s linear 0s;
}
.timeline.is-hidden { opacity: 0; transform: translateY(10px); visibility: hidden; pointer-events: none; transition: opacity 260ms var(--ease), transform 260ms var(--ease), visibility 0s linear 260ms; }
.timeline.no-play {
  padding-left: 18px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "label track readout";
}

.tl-play {
  grid-area: play;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid var(--hair-2);
  border-radius: 11px;
  background: rgba(255, 255, 255, .03);
  color: var(--now);
  transition: background 180ms, border-color 180ms, transform 120ms, box-shadow 180ms;
}
.tl-play:hover { background: rgba(var(--accent-rgb), .1); border-color: rgba(var(--accent-rgb), .4); box-shadow: 0 0 18px -6px rgba(var(--accent-rgb), .7); }
.tl-play:active { transform: scale(.94); }
.tl-play svg { width: 16px; height: 16px; fill: currentColor; grid-area: 1 / 1; transition: opacity 160ms, transform 200ms var(--ease); }
.tl-play .i-play { opacity: 0; transform: scale(.6); }
.tl-play.is-paused .i-play { opacity: 1; transform: none; }
.tl-play.is-paused .i-pause { opacity: 0; transform: scale(.6); }
.tl-play[hidden] { display: none; }

.tl-label {
  grid-area: label;
  font-family: var(--f-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.tl-label:empty { display: none; }

.tl-track {
  --p: 0%;
  grid-area: track;
  position: relative;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tl-track:focus-visible { box-shadow: var(--ring); }
.tl-rail {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 3px;
  background: var(--tl-grad, var(--chrono));
  opacity: .9;
  box-shadow: 0 0 14px -2px rgba(var(--accent-rgb), .28);
  transition: height 180ms var(--ease), margin 180ms var(--ease);
}
/* the default rail is the chronometer: past cools behind the needle, future warms ahead of it */
.tl-track.is-chrono .tl-rail {
  background: linear-gradient(90deg,
    var(--rail-0) 0%,
    var(--rail-1) calc(var(--p) * .55),
    var(--rail-2) calc(var(--p) * .9),
    var(--now) var(--p),
    var(--rail-4) calc(var(--p) + (100% - var(--p)) * .25),
    var(--future) calc(var(--p) + (100% - var(--p)) * .7),
    var(--rail-6) 100%);
}
.tl-track:hover .tl-rail, .tl-track.is-scrubbing .tl-rail { height: 5px; margin-top: -2.5px; }
.tl-ticks {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 11px;
  margin-top: -5.5px;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--text) 16%, transparent) 0 1px, transparent 1px calc(100% / 24));
  -webkit-mask: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.tl-needle {
  position: absolute;
  top: 3px; bottom: 3px;
  left: var(--p);
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--now);
  box-shadow: 0 0 6px var(--now), 0 0 16px var(--needle-glow), 0 0 34px var(--needle-glow-2);
  pointer-events: none;
}
.tl-halo {
  position: absolute;
  left: 50%; top: 50%;
  width: 26px; height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--now) 55%, transparent) 0%, rgba(var(--accent-rgb), .18) 38%, transparent 70%);
  transition: transform 200ms var(--ease);
}
.tl-track:hover .tl-halo, .tl-track.is-scrubbing .tl-halo, .tl-track:focus-visible .tl-halo { transform: scale(1.35); }

.tl-readout {
  grid-area: readout;
  min-width: 8ch;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}

/* no timeline (features.timeline: false): the caption and panel take its room (phones: see below) */
@media (min-width: 721px) {
  .lk-app.no-timeline .caption { bottom: calc(var(--gutter) + var(--sab)); }
  .lk-app.no-timeline .panel { max-height: calc(100% - var(--gutter) * 2 - var(--sat) - var(--sab) - 66px); }
}

/* ---------- toasts ---------- */

.toasts {
  position: absolute;
  left: 50%;
  bottom: calc(var(--gutter) + var(--sab) + var(--tl-h) + 14px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 32px);
  pointer-events: none;
  z-index: 15;
}
.lk-app.ui-hidden .toasts { bottom: calc(var(--gutter) + var(--sab) + 8px); }
.toast {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .9);
  animation: toast-in 320ms var(--ease) both;
  text-align: center;
}
.toast.is-leaving { animation: toast-out 260ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
/* Desktop: the caption owns the bottom-left, so notes float under the brand, centred on the canvas
   left of the panel. In ui-hidden mode (no caption) they keep the bottom-centre placement. */
@media (min-width: 721px) {
  .lk-app:not(.ui-hidden) .toasts {
    top: calc(var(--gutter) + var(--sat) + 142px);   /* under wordmark + tagline + lens switch (~145px) */
    bottom: auto;
    left: calc(var(--sal) + (100% - var(--sal) - var(--sar) - var(--gutter) - var(--panel-w)) / 2);  /* centre of the canvas left of the panel; translateX(-50%) is kept */
    max-width: calc(100% - var(--sal) - var(--sar) - var(--gutter) * 3 - var(--panel-w));            /* never reaches under the panel; long notes wrap */
  }
}
@media (min-width: 721px) and (max-height: 600px) {
  .lk-app:not(.ui-hidden) .toasts { top: calc(var(--gutter) + var(--sat) + 106px); }  /* tagline hidden: brand ends ~115px */
}

/* ---------- hide-UI pill ---------- */

.show-ui {
  position: absolute;
  top: calc(var(--gutter) + var(--sat));
  right: calc(var(--gutter) + var(--sar));
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  opacity: .9; /* the only way back to the UI (no hover on touch): keep its text ≥ 4.5:1 */
  transition: opacity 200ms, color 200ms;
  animation: fade-in 400ms var(--ease) 200ms backwards;
}
.show-ui:hover, .show-ui:focus-visible { opacity: 1; color: var(--text); }
.show-ui[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- loader ---------- */

.loader {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  transition: opacity 600ms var(--ease), visibility 0s linear 0s;
}
.loader.is-done { opacity: 0; visibility: hidden; transition: opacity 600ms var(--ease), visibility 0s linear 600ms; }
.loader-text {
  font-family: var(--f-quote);
  font-style: italic;
  font-size: 19px;
  color: var(--text-2);
  letter-spacing: .01em;
}
.loader-line {
  position: relative;
  width: 160px; height: 1px;
  overflow: hidden;
  background: color-mix(in srgb, var(--text) 10%, transparent);
}
.loader-line::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 60%;
  background: var(--chrono);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), .8);
  animation: sweep 1.6s var(--ease-io) infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(170%); } }

/* ---------- error / fallback ---------- */

.error-card {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  width: min(440px, calc(100% - 32px));
  padding: 22px 22px 18px;
  border-radius: 16px;
  border-color: var(--error-edge);
  background: var(--error-bg);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .95);
  animation: pop 320ms var(--ease) both;
}
.error-card[hidden] { display: none; }
.error-eyebrow { margin: 0 0 6px; font-family: var(--f-mono); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--error); }
.error-title { margin: 0 0 10px; font-family: var(--f-display); font-weight: 400; font-size: 16px; letter-spacing: .02em; line-height: 1.3; }
.error-msg {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--hair);
  background: rgba(0, 0, 0, .3);
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--error-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 180px;
  overflow: auto;
}
.error-msg:empty { display: none; }
.error-actions { display: flex; gap: 8px; justify-content: flex-end; }
.error-actions .btn[hidden] { display: none; }

/* ---------- dialogs ---------- */

.modal {
  padding: 0;
  margin: auto;
  border: 0;
  background: transparent;
  color: var(--text);
  width: min(680px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100% - 32px);
  overflow: visible;
}
/* ::backdrop only inherits custom properties in recent engines: keep the literal as the fallback */
.modal::backdrop {
  background: var(--backdrop, rgba(3, 4, 9, .62));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal[open] .modal-card { animation: pop 340ms var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-card {
  position: relative;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 26px 28px 24px;
  border-radius: 18px;
  background: var(--modal-bg);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .95), inset 0 1px 0 rgba(255, 255, 255, .04);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}
.modal-x {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}
.modal-x:hover { color: var(--text); background: var(--chip-hover); }
.modal-eyebrow { margin: 0 0 8px; font-family: var(--f-mono); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.modal-title { margin: 0 0 6px; font-family: var(--f-display); font-weight: 400; font-size: 20px; letter-spacing: .12em; text-transform: uppercase; }
.about-lede { margin: 0 0 18px; font-family: var(--f-quote); font-style: italic; font-size: 17px; color: var(--text-2); }
.about-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.about-section { padding: 14px 16px; border: 1px solid var(--hair); border-radius: 12px; background: rgba(255, 255, 255, .02); }
.about-section h3 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-family: var(--f-display); font-weight: 500; font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; }
.about-section h3 em { font-family: var(--f-quote); font-weight: 400; font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--muted); }
.about-section p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--body); }
/* section dots: the first carries the whole chrono gradient, the rest one chrono colour each (--dot) */
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
  align-self: center;
  background: var(--dot, var(--past));
  box-shadow: 0 0 10px color-mix(in srgb, var(--dot, var(--past)) 90%, transparent);
}
.dot.is-chrono { background: linear-gradient(90deg, var(--past), var(--now), var(--future)); box-shadow: 0 0 10px rgba(var(--accent-rgb), .8); }
.about-h { margin: 0 0 8px; font-family: var(--f-display); font-weight: 500; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 18px; }
.keys.is-single { grid-template-columns: 1fr; }
.keys table { width: 100%; border-collapse: collapse; }
.keys td { padding: 6px 0; border-bottom: 1px solid var(--hair); font-size: 12.5px; color: var(--cell); vertical-align: middle; }
.keys td:first-child { width: 1%; padding-right: 14px; white-space: nowrap; color: var(--muted); font-size: 11px; }
.k-tag { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-right: 6px; }
.about-credit { margin: 0; padding-top: 14px; border-top: 1px solid var(--hair); font-family: var(--f-quote); font-style: italic; font-size: 14px; line-height: 1.5; color: var(--muted); }

.capture { width: min(920px, calc(100% - 32px)); }
.capture-frame {
  margin: 14px 0 12px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--hair);
  background: var(--vacuum);
  line-height: 0;
}
.capture-frame img { display: block; width: 100%; height: auto; max-height: calc(100dvh - 240px); object-fit: contain; }
.capture-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.capture-hint { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- entrance ---------- */

/* Entrance animates the leaves (see the backdrop-root note at .chrome), staggered. */
.lk-app.is-booting .chrome { visibility: hidden; transition: none; }
.lk-app.is-live .wordmark { animation: rise 900ms var(--ease) 40ms backwards; }
.lk-app.is-live .tagline { animation: rise 900ms var(--ease) 90ms backwards; }
.lk-app.is-live .lens-switch { animation: rise 900ms var(--ease) 140ms backwards; }
.lk-app.is-live .wordmark::after { animation: draw 1400ms var(--ease) 220ms backwards; }
.lk-app.is-live .hud-item,
.lk-app.is-live .icon-btn { animation: rise 900ms var(--ease) 140ms backwards; }
.lk-app.is-live .panel { animation: slide-in 900ms var(--ease) 220ms backwards; }
.lk-app.is-live .timeline { animation: rise 900ms var(--ease) 300ms backwards; }
.lk-app.is-live .caption:not([hidden]) { animation: rise 900ms var(--ease) 420ms backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(14px); } }
@keyframes draw { from { transform: scaleX(0); opacity: 0; } }

/* ---------- mid widths: HUD compacts, then drops under the icon bar ---------- */

@media (max-width: 1140px) and (min-width: 721px) {
  .hud-item { min-width: 0; padding: 6px 9px 7px; }
  .hud-value { font-size: 12px; }
}
@media (max-width: 980px) and (min-width: 721px) {
  .topright { flex-direction: column; align-items: flex-end; gap: 8px; }
  .hud { order: 2; }
  .panel {
    top: calc(var(--gutter) + var(--sat) + 108px);
    max-height: calc(100% - var(--gutter) * 2 - var(--sat) - var(--sab) - 108px - var(--tl-h) - 14px);
  }
  .lk-app.no-timeline .panel { max-height: calc(100% - var(--gutter) * 2 - var(--sat) - var(--sab) - 108px); }
}

/* ---------- short windows (laptop splits, phones on their side): keep the caption clear of the brand ---------- */

@media (max-height: 600px) and (min-width: 721px) {
  .tagline { display: none; }
  .lens-switch { margin-top: 12px; }
  .cap-title { font-size: 20px; }
  .cap-body {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .cap-credit { display: none; }
}

/* ---------- phones: bottom sheet ---------- */

@media (max-width: 720px) {
  .lk-app { --gutter: 16px; --sheet-head: 52px; --tl-h: 58px; }

  .brand { padding-top: 10px; }
  /* The wordmark shares the top row with the icon bar (chrome.js sets --icons; --icon-slot is one
     button plus its gap): a long app name ends in an ellipsis rather than running under the buttons.
     Padding offset by negative margins keeps the text and underline glows inside the clip without
     moving anything. */
  .lk-app { --icon-slot: 41px; --icon-gap: 5px; }
  .wordmark {
    max-width: calc(100vw - var(--gutter) * 2 - var(--sal) - var(--sar) - var(--icons, 4) * var(--icon-slot) + var(--icon-gap) + 8px - 4px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px; letter-spacing: .38em; margin-right: -.38em;
    padding: 8px 0 13px 8px;
    margin-top: -8px; margin-bottom: -6px; margin-left: -8px;
  }
  .wordmark::after { left: 8px; bottom: 6px; width: calc(100% - 8px - .38em); }
  .tagline { display: none; }
  .lens-switch { margin-top: 12px; max-width: calc(100vw - var(--gutter) * 2 - var(--sal) - var(--sar)); }
  .lens-btn { min-width: 0; padding: 6px 12px 7px; column-gap: 6px; }
  .lens-name { font-size: 11px; }
  .lens-sub { font-size: 12px; }
  .lens-kbd { display: none; }

  .topright { left: calc(var(--gutter) + var(--sal)); justify-content: flex-end; }
  .iconbar { gap: 5px; }
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .hud {
    position: absolute;
    top: 100px; left: 0; right: 0;
    gap: 16px;
    overflow: hidden;
  }
  .hud-item {
    padding: 0;
    min-width: 0;
    gap: 1px;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
  }
  .hud-label { font-size: 8.5px; letter-spacing: .14em; }
  .hud-value { font-size: 11px; }

  .panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto;
    max-height: 55%;
    border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    padding-bottom: var(--sab);
    background: var(--sheet-bg);
    box-shadow: 0 -24px 60px -24px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .04);
    transition: max-height 380ms var(--ease), opacity 420ms var(--ease);
    z-index: 3;
  }
  .panel.is-collapsed { max-height: calc(var(--sheet-head) + var(--sab)); }
  .panel.is-collapsed .panel-body { display: block; visibility: hidden; transition: opacity 200ms, visibility 0s linear 380ms; opacity: 0; }
  .panel-head, .panel.is-collapsed .panel-head { min-height: var(--sheet-head); padding: 18px 14px 10px 18px; border-radius: 18px 18px 0 0; }
  .grab {
    display: block;
    position: absolute;
    top: 7px; left: 50%;
    width: 38px; height: 4px;
    margin-left: -19px;
    border-radius: 4px;
    background: var(--grab);
  }
  .panel-head:hover .grab { background: var(--grab-hover); }
  .chev { transform: none; }
  .panel.is-collapsed .chev { transform: rotate(180deg); }

  .timeline {
    bottom: calc(var(--sheet-head) + var(--sab) + 10px);
    height: auto;
    padding: 7px 12px 5px 7px;
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-areas: "play label readout" "play track track";
    column-gap: 10px;
    row-gap: 0;
    border-radius: 14px;
  }
  .timeline.no-play {
    padding-left: 12px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "label readout" "track track";
  }
  .tl-play { width: 38px; height: 38px; }
  .tl-readout { font-size: 11px; justify-self: end; min-width: 0; }
  .tl-track { height: 26px; }

  .caption {
    left: calc(var(--gutter) + var(--sal));
    right: calc(var(--gutter) + var(--sar));
    width: auto;
    max-width: none;
    bottom: calc(var(--sheet-head) + var(--sab) + 10px + 60px + 8px);
    padding: 12px 40px 12px 14px;
  }
  .lk-app.no-timeline .caption { bottom: calc(var(--sheet-head) + var(--sab) + 10px); }
  .caption::before { left: 14px; }
  .cap-title { font-size: 19px; }
  .cap-body {
    font-size: 12.5px;
    max-width: none;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .cap-credit { display: none; }
  /* a lens without controls has no sheet: the timeline and caption drop into its place */
  .panel.is-empty ~ .timeline { bottom: calc(var(--gutter) + var(--sab)); }
  .panel.is-empty ~ .caption { bottom: calc(var(--gutter) + var(--sab) + 60px + 8px); }
  .lk-app.no-timeline .panel.is-empty ~ .caption { bottom: calc(var(--gutter) + var(--sab)); }
  .lk-app.sheet-open .caption { opacity: 0; visibility: hidden; pointer-events: none; }
  .lk-app.sheet-open .timeline { opacity: 0; visibility: hidden; pointer-events: none; }

  .lk-app:not(.sheet-open):not(.ui-hidden) .toasts { top: calc(var(--sat) + 156px); bottom: auto; }  /* below the HUD (ends ~145px + sat), clear of the caption band */
  .lk-app.sheet-open .toasts { bottom: calc(55% + 12px); } /* float above the open sheet, not over its controls */
  .lk-app.is-live .panel { animation-name: rise; }          /* a sheet rises; it doesn't slide in from the side */
  .about-sections, .keys { grid-template-columns: 1fr; }
  .modal-card { padding: 22px 18px 18px; }
  .modal-title { font-size: 16px; }
}

/* phones on their side: the caption would otherwise climb over the HUD and lens switch */
@media (max-width: 720px) and (max-height: 500px) {
  .hud { display: none; }
  .cap-body { -webkit-line-clamp: 2; }
  .lk-app:not(.sheet-open):not(.ui-hidden) .toasts { top: calc(var(--gutter) + var(--sat)); }  /* top row, between the wordmark and the icon bar */
}

@media (max-width: 380px) {
  .lens-sub { display: none; }
  .lens-btn { grid-template-areas: "name kbd"; }
  /* keep the wordmark clear of the icon bar on 320px screens */
  .wordmark { font-size: 10px; letter-spacing: .3em; margin-right: -.3em; }
  .wordmark::after { width: calc(100% - 8px - .3em); }
  .lk-app { --icon-slot: 38px; --icon-gap: 4px; }
  .iconbar { gap: 4px; }
  .icon-btn { width: 34px; height: 34px; }
}

/* Focus rings must win over the selected-state glows. */
.lk-app .card:focus-visible,
.lk-app .btn:focus-visible,
.lk-app .swatch:focus-visible,
.lk-app .toggle:focus-visible,
.lk-app .icon-btn:focus-visible,
.lk-app .tl-play:focus-visible { box-shadow: var(--ring); }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .lk-app *, .lk-app *::before, .lk-app *::after {
    animation-duration: .001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
  .veil { transition-duration: 140ms !important; }
  .loader-line::after { transform: translateX(40%); }
}

/* ---------- forced colors: box-shadow rings vanish, so draw a system-colour outline ---------- */

@media (forced-colors: active) {
  .lk-app :focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: -2px;
  }
}

/* ---------- no engine (no WebGL 2, or three.js failed to load) ---------- */

/* Nothing will ever draw: drop the lens switch, the controls a lens would fill and the capture/hide
   buttons; the wordmark, fullscreen and About stay around the error card. After
   `.lk-app .caption[hidden]` on purpose. */
.lk-app.no-engine :is(.lens-switch, .panel, .timeline, .caption, .hud, #btn-capture, #btn-hide) { display: none !important; }

/* ---------- low quality ---------- */

/* Low quality: the canvas redraws every frame, so every backdrop blur and the blended grain re-run every frame at native DPR. */
.lk-app.q-low { --glass: var(--glass-solid); --glass-2: var(--glass-2-solid); }
.lk-app.q-low .grain { display: none; }
.lk-app.q-low :is(.glass, .panel, .caption, .timeline, .toast, .hud-item, .lens-switch, .icon-btn, .show-ui) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
