:root {
  color-scheme: dark;
  --bg: #11110f;
  --bg-raised: #1c1b17;
  --line: #3a372f;
  --text: #f6f3ea;
  --muted: #c4bcae;
  --accent: #ff8a3d;
  --accent-ink: #1a1008;
  --toast: #2a2118;
  --focus: #ffe1c4;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  padding:
    calc(20px + var(--safe-top))
    calc(16px + var(--safe-right))
    calc(28px + var(--safe-bottom))
    calc(16px + var(--safe-left));
  touch-action: manipulation;
  overscroll-behavior-y: contain;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.app {
  width: min(100%, 28rem);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tagline {
  margin: 6px 0 0;
  color: var(--muted);
}

.file-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 1.0625rem;
  text-align: center;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

body.has-file .file-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stage-empty,
.art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.stage-empty {
  margin: 0;
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

.art {
  color: var(--accent);
  background:
    radial-gradient(circle at 50% 45%, #2a241c 0%, #0c0c0a 70%);
}

.art svg {
  width: min(46%, 140px);
  height: auto;
}

.art.is-playing .ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stage video[hidden],
.art[hidden],
.stage-empty[hidden],
.toast[hidden] {
  display: none !important;
}

.meta { display: flex; flex-direction: column; gap: 4px; }

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.filename {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kind {
  flex: none;
  margin-top: 3px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
}

.kind:empty { display: none; }

.status {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.875rem;
  min-width: 2.8em;
}

.time:last-child { text-align: right; }

.transport {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.btn {
  min-height: 56px;
  border-radius: 14px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.ghost {
  background: var(--bg-raised);
  color: var(--text);
  border-color: var(--line);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.volume {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 8px;
}

.volume-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.volume-row label {
  font-weight: 700;
}

.volume-row span {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  font-size: 16px;
}

input[type="range"]:disabled { opacity: 0.38; }

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 / var(--pct, 0%) 100% no-repeat,
    #2e2c26;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.18);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: #2e2c26;
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.18);
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.toast {
  position: fixed;
  z-index: 5;
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  width: min(28rem, calc(100% - 32px - var(--safe-left) - var(--safe-right)));
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--toast);
  color: var(--text);
  border: 1px solid var(--accent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

#audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.noscript {
  width: min(100%, 28rem);
  margin: 16px auto;
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .art.is-playing .ring { animation: none; }
  .btn:active:not(:disabled) { transform: none; }
}

@media (min-width: 720px) {
  body { padding-top: calc(40px + var(--safe-top)); }
}

/* Keep transport and the background note reachable on short phones. */
@media (max-height: 740px) {
  body {
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .app { gap: 8px; }

  .header h1 { font-size: 1.5rem; }

  .tagline { margin-top: 2px; }

  .stage { aspect-ratio: 16 / 7.5; }

  .volume {
    padding-top: 8px;
    padding-bottom: 2px;
  }

  .note {
    font-size: 0.875rem;
    line-height: 1.35;
  }
}
