/* Neutral zinc base, one accent, hairlines instead of card boxes. */
:root {
  --bg: #09090b;
  --surface: #101012;
  --surface-high: #17171a;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #fafafa;
  --text-dim: #a1a1aa;
  --text-faint: #71717a;
  --accent: #3fbf7f;
  --accent-soft: rgba(63, 191, 127, 0.14);
  --danger: #e5705f;
  --radius: 10px;
  --radius-lg: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --speed: 0.3s;

  color: var(--text);
  background: var(--bg);
  font-family: Geist, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

/* Layout rules below set display on these elements, which would otherwise win
   over the [hidden] attribute the player toggles. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  overflow: hidden;
}

.sprite {
  display: none;
}

.mono {
  font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: currentColor;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  background-clip: content-box;
  background-color: var(--line-strong);
  border-radius: 999px;
}

/* ------------------------------------------------------------------ shell */

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 3px rgba(63, 191, 127, 0.18);
  animation: breathe 4s var(--ease) infinite;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text span {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.workspace {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr) 300px;
  min-height: 0;
}

.panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  /* Without this the column sizes to max-content and the panel overflows. */
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  background: var(--surface);
}

.panel-library {
  border-right: 1px solid var(--line);
}

.panel-settings {
  border-left: 1px solid var(--line);
}

.panel-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 24px;
}

.panel-footer {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

/* Groups are separated by a hairline and space, not by card boxes. */
.group + .group {
  border-top: 1px solid var(--line);
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.panel-library .section-label {
  margin-bottom: 14px;
}

/* Native <details> keeps keyboard and screen-reader behaviour for free. */
summary.section-label {
  position: sticky;
  top: -18px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0 12px;
  margin: 0 -2px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  transition: color var(--speed) var(--ease);
}

summary.section-label::-webkit-details-marker {
  display: none;
}

summary.section-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translate(-1px, -1px);
  transition: transform 0.25s var(--ease);
}

.group[open] > summary.section-label::before {
  transform: rotate(45deg) translate(-1px, -1px);
}

summary.section-label:hover {
  color: var(--text-dim);
}

.group-body {
  padding-bottom: 20px;
  animation: rise 0.28s var(--ease);
}

/* ----------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
    color var(--speed) var(--ease), transform 0.12s var(--ease), opacity var(--speed) var(--ease);
}

.button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button-primary {
  background: var(--accent);
  color: #04140c;
  font-weight: 600;
}

.button-primary:hover:not(:disabled) {
  background: #4ad693;
}

.button-ghost {
  background: var(--surface-high);
  border-color: var(--line);
  color: var(--text-dim);
}

.button-ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--text);
}

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

.button-outline:hover:not(:disabled) {
  background: var(--accent-soft);
}

.button-block {
  width: 100%;
}

/* Wiping the library is one click away, so it says so in red once armed. */
.button-danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.button-danger[data-armed="true"] {
  border-color: var(--danger);
  color: var(--danger);
}

.button-tiny {
  padding: 6px 10px;
  font-size: 12px;
}

/* ----------------------------------------------------------------- library */

.library-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.library-tools .field {
  margin-bottom: 0;
}

.library-list {
  display: grid;
  gap: 4px;
}

.library-group {
  padding: 12px 2px 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-group:first-child {
  padding-top: 0;
}

.library-item {
  --index: 0;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  animation: rise 0.45s var(--ease) backwards;
  animation-delay: calc(var(--index) * 55ms);
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
  /* A library of a few thousand replays put thousands of rows in the document,
     and every timecode update during playback then cost a full-page layout —
     enough to drag the preview down to single-digit fps. Rows off screen are
     skipped entirely now; the placeholder height keeps the scrollbar honest. */
  content-visibility: auto;
  contain-intrinsic-size: auto 56px;
}

.library-item:hover {
  background: var(--surface-high);
}

.library-item.is-active {
  background: var(--surface-high);
  border-color: var(--line-strong);
}

/* A human verdict is certain, so it gets a stripe down the whole row —
   readable at a glance while scrolling, not just on close inspection of the
   thumbnail corner. */
.library-item.label-gem {
  box-shadow: inset 3px 0 0 var(--accent);
}

.library-item.label-trash {
  box-shadow: inset 3px 0 0 var(--danger);
}

/* The checkbox sits on the thumbnail so the filename gets the panel's width. */
.library-item-media {
  position: relative;
  width: 62px;
  flex: none;
}

.library-item-check {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

/* Sits on the thumbnail, opposite the batch-render checkbox. Always visible
   once lit, so a liked clip is recognisable while scrolling past it. */
.library-item-like {
  position: absolute;
  top: 1px;
  right: 1px;
  padding: 0 3px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
  transition: color var(--speed) var(--ease), transform 0.12s var(--ease);
}

.library-item-like:hover {
  color: #fff;
}

.library-item-like:active {
  transform: scale(0.86);
}

.library-item-like.is-liked {
  color: #f5c518;
}

/* Same treatment as the star, moved to the bottom corners: trash trains the
   classifier's negative examples, gem its positive ones. */
.library-item-trash,
.library-item-gem {
  position: absolute;
  bottom: 1px;
  padding: 0 3px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  line-height: 1.3;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
  transition: color var(--speed) var(--ease), transform 0.12s var(--ease);
}

.library-item-trash {
  left: 1px;
}

.library-item-gem {
  right: 1px;
}

.library-item-trash:hover,
.library-item-gem:hover {
  color: #fff;
}

.library-item-trash:active,
.library-item-gem:active {
  transform: scale(0.86);
}

.library-item-trash.is-trash {
  color: var(--danger);
}

.library-item-gem.is-gem {
  color: var(--accent);
}

.library-filter {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
}

.library-filter input {
  accent-color: var(--accent);
  cursor: pointer;
}

.library-item-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  background: #000 linear-gradient(115deg, #141417, #1d1d21, #141417);
  border: 1px solid var(--line);
}

.library-item-body {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.library-item-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.library-item-meta {
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Deliberately quieter than the meta lines above it — a guess, not a
   verdict. Only shown on replays nobody has labelled by hand yet. */
.library-item-ai {
  font-size: 10.5px;
  color: var(--text-faint);
  opacity: 0.7;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-remove {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--speed) var(--ease), color var(--speed) var(--ease),
    background var(--speed) var(--ease);
}

.library-item:hover .library-item-remove,
.library-item-remove:focus-visible {
  opacity: 1;
}

.library-item-remove:hover {
  background: rgba(229, 112, 95, 0.15);
  color: var(--danger);
}

.shortcut-hint {
  margin: 0;
  padding: 0 22px 14px;
  background: var(--surface);
  color: var(--text-faint);
  font-size: 11px;
}

.shortcut-hint kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-high);
  color: var(--text-dim);
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10px;
}

.library-more {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.library-more:hover {
  border-color: var(--line-strong);
  color: var(--text-dim);
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 26px 4px;
  color: var(--text-faint);
}

.empty-state-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  opacity: 0.5;
}

.empty-state strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.empty-state span {
  font-size: 12px;
  line-height: 1.55;
}

.empty-state code {
  font-family: "Geist Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
}

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

.stage-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.stage-frame {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 22px;
}

.stage {
  position: relative;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  outline: none;
  transition: border-color var(--speed) var(--ease);
}

.stage:focus-visible,
.stage.is-dragging {
  border-color: var(--accent);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(8px);
}

.stage-overlay strong {
  font-size: 14px;
  font-weight: 500;
}

.stage-overlay span {
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 46ch;
}

/* Server chunks are tens of megabytes, so the wait needs a real read-out
   rather than a skeleton that says nothing about how long is left. */
.loading-progress {
  display: grid;
  gap: 6px;
  justify-items: center;
  width: min(320px, 70%);
  margin-top: 6px;
}

.loading-progress[hidden] {
  display: none;
}

.loading-bar {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.15s linear;
}

.loading-label {
  font-size: 11px;
  color: var(--text-dim);
}

.skeleton {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #17171a 0%, #232327 50%, #17171a 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-wide {
  width: min(280px, 46%);
}

.skeleton-narrow {
  width: min(170px, 28%);
}

.export-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(9, 9, 11, 0.92) 45%);
}

.export-progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12.5px;
}

.export-progress-copy strong {
  font-weight: 500;
}

.export-progress-copy span {
  color: var(--accent);
}

.progress-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}

/* --------------------------------------------------------------- transport */

.transport {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.play-button {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #04140c;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background var(--speed) var(--ease),
    opacity var(--speed) var(--ease);
}

.play-button .icon {
  width: 20px;
  height: 20px;
}

.play-button:hover:not(:disabled) {
  background: #4ad693;
}

.play-button:active:not(:disabled) {
  transform: scale(0.93);
}

.play-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.time-label {
  font-size: 12px;
  flex: none;
}

.time-label-dim {
  color: var(--text-faint);
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 12px;
  color: var(--text-faint);
}

/* ----------------------------------------------------------------- inputs */

input[type="range"] {
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  transition: transform 0.18s var(--ease);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.25);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.1);
}

input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.timeline-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  /* Room for the mass curve behind the scrubber */
  min-height: 34px;
}

/* Where the followed player had mass, and how much. Sits behind the scrubber so
   a flat stretch reads as "nothing here" before you drag into it. */
.timeline-graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.timeline {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

/* Ticks sit under the cursor-transparent layer so scrubbing still works. */
.timeline-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.timeline-marks span {
  position: absolute;
  top: 50%;
  width: 2px;
  height: 11px;
  margin-left: -1px;
  border-radius: 1px;
  transform: translateY(-50%);
  background: var(--text-dim);
}

.timeline-marks span[data-kind="death"] {
  background: var(--danger);
}

.timeline-marks span[data-kind="kill"],
.timeline-marks span[data-kind="surge"] {
  background: var(--accent);
}

.highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 22px 16px;
  background: var(--surface);
  /* A busy half-hour session yields hundreds of markers, which used to push the
     player clean off the screen. About four rows, then scroll. */
  max-height: 132px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.highlights:empty {
  display: none;
}

/* Ad slot. The height is reserved up front so a filled unit does not shove the
   player up the page, and the label sits above the unit because AdSense allows
   only wording like "Advertisement" next to it. */
.ad-slot {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 0 22px 16px;
  background: var(--surface);
}

.ad-slot-label {
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ad-slot .adsbygoogle {
  width: 100%;
  max-width: 970px;
  min-height: 90px;
}

.highlight-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-high);
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease),
    transform 0.12s var(--ease);
}

.highlight-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.highlight-chip:active {
  transform: translateY(1px) scale(0.985);
}

.highlight-jump {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 4px 2px 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.highlight-jump::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.highlight-act {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.highlight-act:hover {
  background: var(--surface);
  color: var(--text);
}

/* The marker carrying the author card. */
.highlight-act[data-on="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Confirmed reads solid, rejected fades out but stays clickable to restore. */
.highlight-chip[data-state="kept"] {
  border-color: var(--accent);
  color: var(--text);
}

.highlight-chip[data-state="dropped"] {
  opacity: 0.4;
}

.highlight-chip[data-state="dropped"] .highlight-jump {
  text-decoration: line-through;
}

.highlight-add {
  color: var(--text-faint);
  border-style: dashed;
  padding: 5px 10px;
  cursor: pointer;
}

.timeline-marks span[data-state="kept"] {
  height: 15px;
}

.highlight-chip[data-kind="death"] .highlight-jump::before {
  background: var(--danger);
}

.highlight-chip[data-kind="manual"] .highlight-jump::before {
  background: var(--text-dim);
}

.highlight-chip time {
  font-family: "Geist Mono", monospace;
  color: var(--text-faint);
}

.preset-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.preset-tools + .preset-tools {
  margin-top: 8px;
}

.theme-fields {
  margin-top: 14px;
}

.theme-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 12px;
}

.theme-row + .theme-row {
  border-top: 1px solid var(--line);
}

.theme-row span {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A swatch, not a chrome-styled colour widget. */
.theme-row input[type="color"] {
  width: 100%;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.theme-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.theme-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.theme-row .theme-percent {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.theme-row output {
  font-family: "Geist Mono", monospace;
  font-size: 10.5px;
  text-align: right;
  color: var(--accent);
}

select,
input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-high);
  font-size: 12.5px;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

select:hover,
input[type="text"]:hover,
input[type="url"]:hover {
  border-color: var(--line-strong);
}

select:focus-visible,
input[type="text"]:focus-visible,
input[type="url"]:focus-visible {
  outline: none;
  border-color: var(--accent);
}

input::placeholder {
  color: var(--text-faint);
}

.inline-field select {
  width: auto;
  padding: 5px 8px;
}

/* Label above input, per the form pattern. */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field > span {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* A field that belongs to the toggle above it. */
.field-indent {
  margin: 2px 0 10px 12px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.row-text strong {
  font-size: 12.5px;
  font-weight: 500;
}

.row-text small {
  font-size: 11px;
  color: var(--text-faint);
}

.row-select select {
  width: 118px;
  flex: none;
}

.row-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider {
  display: grid;
  gap: 8px;
  padding: 10px 0;
}

.slider + .slider {
  border-top: 1px solid var(--line);
}

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.slider-head strong {
  font-size: 12.5px;
  font-weight: 500;
}

.slider-head output {
  font-size: 11.5px;
  color: var(--accent);
}

.slider-note {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-faint);
}

.meta-list {
  margin: 0;
  display: grid;
}

.meta-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  font-size: 12px;
}

.meta-list > div + div {
  border-top: 1px solid var(--line);
}

.meta-list dt {
  color: var(--text-faint);
}

.meta-list dd {
  margin: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-editor {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

/* With no override there is nothing to preview, so the thumbnail column goes. */
.skin-editor.is-bare {
  grid-template-columns: minmax(0, 1fr);
}

.skin-editor.is-bare .skin-preview {
  display: none;
}

.skin-preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-high);
  border: 1px solid var(--line);
}

.skin-fields .field:last-child {
  margin-bottom: 0;
}

.gallery-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
  margin: 14px 0 10px;
}

input[type="search"] {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-high);
  font-size: 12.5px;
  transition: border-color var(--speed) var(--ease);
}

input[type="search"]:focus-visible {
  outline: none;
  border-color: var(--accent);
}

/* Thumbnails load lazily, so only the visible rows hit the proxy. */
.skin-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
  max-height: 232px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
}

.skin-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-high);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--speed) var(--ease), transform 0.14s var(--ease);
}

.skin-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.skin-tile:hover {
  border-color: var(--line-strong);
  transform: scale(1.08);
}

.skin-tile:active {
  transform: scale(0.96);
}

.skin-tile.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.skin-gallery-empty {
  grid-column: 1 / -1;
  padding: 18px 2px;
  font-size: 12px;
  color: var(--text-faint);
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 10px;
}

.export-grid .field {
  margin-bottom: 0;
}

.hint {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-faint);
}

.status {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.status[data-kind="success"] {
  color: var(--accent);
}

.status[data-kind="error"] {
  color: var(--danger);
}

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

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

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: inset 0 0 0 3px rgba(63, 191, 127, 0.18);
  }
  50% {
    box-shadow: inset 0 0 0 3px rgba(63, 191, 127, 0.42);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  html,
  body {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    height: auto;
  }

  .workspace {
    display: block;
  }

  .panel {
    display: block;
    border: none;
    border-top: 1px solid var(--line);
  }

  .panel-scroll {
    max-height: 46vh;
    overflow-y: auto;
  }

  .stage-frame {
    padding: 14px;
  }
}

@media (max-width: 620px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .transport {
    flex-wrap: wrap;
    padding: 12px 14px 16px;
  }

  .timeline {
    order: 1;
    flex-basis: 100%;
  }

  .inline-field {
    display: none;
  }
}

/* Server archive search results */
.archive-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
}
/* ------------------------------------------------------ archive calendar */

.archive-calendar {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.archive-calendar[hidden] {
  display: none;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.calendar-month {
  font-size: 12.5px;
  font-weight: 500;
}

.calendar-nav {
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 3px 8px;
}

.calendar-nav:hover {
  color: inherit;
  background: rgba(255, 255, 255, 0.06);
}

.calendar-nav-wide {
  font-size: 11px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-dow {
  font-size: 10px;
  text-align: center;
  color: var(--text-faint);
  padding-bottom: 2px;
}

.calendar-day {
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  cursor: default;
  font: inherit;
  font-size: 11px;
  display: grid;
  place-items: center;
}

/* Days that hold recordings are the only ones worth reaching for */
.calendar-day[data-has="true"] {
  color: inherit;
  cursor: pointer;
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.25);
}

.calendar-day[data-has="true"]:hover {
  background: rgba(74, 222, 128, 0.22);
}

.calendar-day[data-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #08120c;
  font-weight: 500;
}

.day-scale {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--border, #333);
  padding-top: 9px;
}

.day-scale[hidden] {
  display: none;
}

.day-scale-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.day-hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 1px;
  height: 34px;
  align-items: end;
}

/* Each bar grows from the bottom by how much of that hour was played */
.day-hour {
  border: 0;
  padding: 0;
  border-radius: 2px 2px 0 0;
  background: rgba(74, 222, 128, 0.5);
  height: calc(6px + var(--fill, 0) * 28px);
  min-height: 2px;
  cursor: pointer;
}

.day-hour:disabled {
  background: rgba(255, 255, 255, 0.06);
  height: 2px;
  cursor: default;
}

.day-hour:hover:not(:disabled) {
  background: rgba(74, 222, 128, 0.8);
}

.day-hour[data-selected="true"] {
  background: var(--accent);
}

.day-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-faint);
}

.archive-hit {
  text-align: left;
  padding: 7px 9px;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  display: grid;
  gap: 2px;
}

.archive-hit strong {
  font-weight: 500;
}

.archive-hit small {
  color: var(--text-faint);
  font-size: 11px;
}

.archive-hit-track {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

/* The bars are block-drawing characters, so they only line up in a mono font */
.archive-hit-spark {
  font-family: var(--mono, ui-monospace, monospace);
  letter-spacing: -1px;
  color: var(--accent);
  opacity: 0.75;
}
.archive-hit:hover {
  background: rgba(255, 255, 255, 0.1);
}
