:root {
  color-scheme: light;
  --ink: #1f2528;
  --muted: #647076;
  --line: #d9e0df;
  --paper: #f7f4ee;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b4f4a;
  --warning: #9f3a38;
  --shadow: 0 18px 40px rgba(39, 48, 52, 0.12);
  --mobile-shadow: 0 10px 24px rgba(39, 48, 52, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
audio,
video {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 520px);
  gap: 18px;
  height: 100vh;
  padding: 18px;
}

.mobile-switch {
  display: none;
}

.form-pane,
.listening-pane {
  min-height: 0;
}

.form-pane {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.listening-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.playlist-pane {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  gap: 14px;
}

.player-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2.8vw, 2rem);
  line-height: 1.12;
}

h2 {
  font-size: 1.1rem;
}

audio,
video {
  width: 100%;
}

video {
  aspect-ratio: 16 / 9;
  background: #151a1c;
  border-radius: 6px;
}

.player-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf4f3;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: #dcecea;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.playlist-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px;
}

.playlist-header p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.track-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 0 3px 3px;
  overflow: auto;
  list-style: none;
}

.track-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.track-button:hover {
  background: #f0f8f6;
}

.track-button.is-active {
  border-color: var(--accent);
  background: #e7f4f1;
}

.track-button.is-missing {
  color: var(--warning);
}

.track-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #eceded;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.track-title {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-type {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.empty-state {
  margin: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .form-pane {
    min-height: 72vh;
  }

  .listening-pane {
    min-height: 78vh;
  }
}

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  body {
    background: #f4efe7;
  }

  .app-shell {
    grid-template-areas:
      "player"
      "switch"
      "stage";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 8px;
    height: 100svh;
    height: 100dvh;
    min-height: 0;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .mobile-switch {
    display: grid;
    grid-area: switch;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    min-height: 38px;
    padding: 3px;
    background: #e7e0d5;
    border: 1px solid #d4ccc0;
    border-radius: 8px;
  }

  .mobile-switch button {
    min-height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
  }

  body[data-mobile-view="form"] #form-tab,
  body[data-mobile-view="tracks"] #tracks-tab {
    background: var(--panel);
    color: var(--accent-strong);
    box-shadow: 0 2px 8px rgba(39, 48, 52, 0.11);
  }

  .form-pane {
    grid-area: stage;
    min-height: 0;
    border-radius: 8px;
    box-shadow: none;
  }

  .listening-pane {
    display: contents;
  }

  .player-card {
    position: relative;
    z-index: 2;
    grid-area: player;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    box-shadow: var(--mobile-shadow);
  }

  .player-copy {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .player-card .eyebrow {
    margin: 0;
    font-size: 0.68rem;
    white-space: nowrap;
  }

  h1 {
    overflow: hidden;
    font-size: 1.03rem;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  h2 {
    font-size: 0.98rem;
  }

  audio {
    height: 34px;
  }

  video {
    max-height: 25svh;
    border-radius: 6px;
  }

  .player-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .player-actions button {
    min-height: 34px;
    font-size: 0.86rem;
  }

  .playlist-pane {
    grid-area: stage;
    gap: 8px;
    overflow: hidden;
  }

  body[data-mobile-view="form"] .playlist-pane {
    display: none;
  }

  body[data-mobile-view="tracks"] .form-pane {
    display: none;
  }

  .playlist-header {
    align-items: center;
    padding: 2px 2px 0;
  }

  .playlist-header .eyebrow {
    display: none;
  }

  .playlist-header p:last-child {
    font-size: 0.82rem;
  }

  .track-list {
    gap: 5px;
    padding: 0 1px 4px;
    scrollbar-width: thin;
  }

  .track-button {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 43px;
    padding: 5px 8px;
    border-radius: 7px;
  }

  .track-number {
    width: 25px;
    height: 25px;
    font-size: 0.72rem;
  }

  .track-title {
    font-size: 0.91rem;
  }

  .track-type {
    font-size: 0.68rem;
  }
}

@media (max-width: 420px) {
  .track-button {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .track-type {
    display: none;
  }
}
