:root {
  --bg: #121212;
  --sidebar: #000;
  --panel: #181818;
  --hover: #282828;
  --ink: #fff;
  --muted: #b3b3b3;
  --faint: #6a6a6a;
  --green: #1ed760;
  --green-hover: #3be477;
  --line: #282828;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--green);
  color: #000;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  z-index: 5;
}

.skip-link:focus { left: 0.75rem; top: 0.75rem; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.library {
  background: var(--sidebar);
  padding: 1rem 0.75rem 0.5rem;
}

.brand {
  margin: 0 0.5rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.search { position: relative; margin: 0 0.25rem 0.75rem; }

#q {
  width: 100%;
  background: #242424;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
}

#q::placeholder { color: var(--muted); }

#hits {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--hover);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  max-height: 18rem;
  overflow: auto;
}

#hits button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}

#hits button:hover { background: #3e3e3e; }

#routes {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 40vh;
  overflow: auto;
  padding-bottom: 0.75rem;
}

#routes button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}

#routes button:hover { background: #1a1a1a; color: var(--ink); }

#routes button.is-current {
  background: var(--hover);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--green);
}

main {
  flex: 1;
  padding: 1.25rem 1rem 5.5rem;
}

.status { color: var(--muted); margin: 2rem 0; }

#stop {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#stop[hidden] { display: none; }

.progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.route-title {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-weight: 600;
}

h1 {
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.meta { margin: 0 0 0.65rem; color: var(--muted); }

.stage { margin: 0 0 0.5rem; }

.stage > p {
  margin: 0;
  padding: 2rem 1rem;
  background: var(--panel);
  border-radius: 12px;
  color: var(--muted);
}

.frame {
  position: relative;
  width: min(100%, 480px, calc(32vh * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.track { margin: 0 0 0.75rem; color: var(--ink); font-weight: 600; }

.track a { color: var(--muted); font-weight: 400; }

.alts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.85rem; }

.alts button {
  background: var(--panel);
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.alts button[aria-pressed="true"] { background: var(--hover); color: var(--ink); }

.transport {
  display: flex;
  gap: 0.6rem;
  position: sticky;
  bottom: 0;
  padding: 0.75rem 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(18, 18, 18, 0));
}

#prev, #next {
  border-radius: 999px;
  padding: 0.85rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
}

#prev {
  background: transparent;
  color: var(--ink);
  border: 1px solid #727272;
}

#next {
  flex: 1;
  background: var(--green);
  color: #000;
  border: 0;
}

#next:hover:not(:disabled) { background: var(--green-hover); }

#prev:hover:not(:disabled) { border-color: var(--ink); }

#prev:disabled, #next:disabled {
  background: var(--hover);
  color: var(--faint);
  border-color: transparent;
  cursor: default;
}

.note, .summary, .blurb { margin: 0 0 0.75rem; color: var(--muted); }

.summary { color: var(--ink); }

.queue-panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 1rem 0.75rem 0.5rem;
}

.queue-panel h2 {
  margin: 0 0.5rem 0.35rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.blurb { margin: 0 0.5rem 0.75rem; font-size: 0.92rem; }

#queue {
  list-style: none;
  margin: 0;
  padding: 0;
}

#queue button {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0.55rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
}

#queue button:hover { background: #222; color: var(--ink); }

#queue button.is-current {
  background: var(--hover);
  color: var(--green);
}

#queue .num {
  width: 1.4rem;
  flex: none;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

#queue button.is-current .num { color: var(--green); }

#queue .stop-name { font-weight: 600; }

details {
  margin: 0.5rem 0 1rem;
  background: var(--panel);
  border-radius: 12px;
  padding: 0.15rem 1rem;
}

summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.85rem 0;
}

#more-body h3 {
  margin: 0.9rem 0 0.3rem;
  font-size: 0.95rem;
}

#more-body p { margin: 0 0 0.65rem; color: var(--muted); }

#more-body a, .track a { color: var(--ink); }

#more-body ul { margin: 0 0 0.8rem; padding-left: 1.1rem; }

#more-body button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
}

button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

#next:focus-visible { outline-color: #000; }

@media (min-width: 960px) {
  .app {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    height: 100dvh;
    overflow: hidden;
  }

  .library {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-top: 1.25rem;
  }

  #routes {
    flex: 1;
    max-height: none;
    min-height: 0;
  }

  main {
    overflow: auto;
    padding: 1.75rem 1.75rem 2.5rem;
  }

  #stop {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(16rem, 0.85fr);
    gap: 1.25rem;
    align-items: start;
  }

  #stop[hidden] { display: none; }

  .queue-panel { position: sticky; top: 0; }

  .transport { position: static; background: none; padding-top: 0.25rem; }
}

@media (max-width: 959px) {
  main { order: -1; }

  .transport {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
