:root {
  --bg: #10110f;
  --panel: rgba(245, 235, 215, 0.08);
  --panel-strong: rgba(245, 235, 215, 0.14);
  --text: #f7efe0;
  --muted: #b8aa92;
  --gold: #e4b45f;
  --red: #a63d2f;
  --green: #8ebf73;
  --line: rgba(247, 239, 224, 0.16);
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 12%, rgba(228, 180, 95, 0.18), transparent 28rem),
    radial-gradient(circle at 90% 8%, rgba(166, 61, 47, 0.2), transparent 32rem),
    linear-gradient(135deg, #11130f 0%, #1d1713 52%, #0b0c0c 100%);
  color: var(--text);
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: #19140d;
  cursor: pointer;
  font-weight: 800;
  padding: 0.75rem 1.1rem;
  box-shadow: 0 12px 30px var(--shadow);
}

button.secondary {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

button.compact {
  padding: 0.55rem 0.85rem;
  box-shadow: none;
  white-space: nowrap;
}

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

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  padding: 0.72rem 0.85rem;
}

main {
  padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 2.5rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  padding: clamp(1.25rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='80'%3E%3Cpath d='M0 40h160' stroke='rgba(255,255,255,0.08)'/%3E%3Cpath d='M40 0v80M80 0v80M120 0v80' stroke='rgba(255,255,255,0.05)'/%3E%3C/svg%3E");
  box-shadow: 0 30px 80px var(--shadow);
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
  margin: 0.25rem 0 1rem;
  max-width: 880px;
}

.hero p {
  color: var(--muted);
  max-width: 720px;
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.45fr) minmax(380px, 0.95fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
  align-items: start;
}

.library-panel,
.player-panel {
  border: 1px solid var(--line);
  background: rgba(11, 12, 12, 0.72);
  border-radius: 28px;
  box-shadow: 0 24px 72px var(--shadow);
}

.library-panel {
  padding: 1rem;
  min-height: min(760px, calc(100vh - 170px));
  max-height: calc(100vh - 170px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  color: var(--muted);
  margin-bottom: 1rem;
}

.movie-list {
  display: grid;
  gap: 0.75rem;
  overflow: auto;
  padding-right: 0.35rem;
}

.movie-card {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 0.85rem;
  border-radius: 20px;
  padding: 0.65rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid transparent;
  box-shadow: none;
}

.movie-card.selected {
  border-color: rgba(228, 180, 95, 0.55);
  background: rgba(228, 180, 95, 0.11);
}

.poster-fallback {
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #3c1f16, #db9a45);
  color: #1b120b;
  font-size: 2rem;
  font-weight: 1000;
}

.movie-title {
  font-weight: 900;
  letter-spacing: -0.02em;
}

.movie-meta,
.movie-path,
.mode-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.movie-path {
  overflow-wrap: anywhere;
  margin: 0.2rem 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chips span,
.technical span {
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  padding: 0.24rem 0.5rem;
  font-size: 0.74rem;
}

.chips .good {
  color: var(--green);
}

.chips .warn {
  color: var(--gold);
}

.player-panel {
  padding: clamp(1rem, 3vw, 1.6rem);
}

.player-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.player-header h2 {
  margin: 0.2rem 0 0.4rem;
  font-size: clamp(1.6rem, 3vw, 3rem);
  letter-spacing: -0.06em;
}

.player-header p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.technical {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-content: flex-start;
}

.video-shell {
  overflow: hidden;
  border-radius: 22px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.09);
}

video {
  display: block;
  width: 100%;
  max-height: 68vh;
  background: #000;
}

.playback-debug {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.24);
  padding: 0.85rem;
}

.playback-debug.has-error {
  border-color: rgba(166, 61, 47, 0.65);
  background: rgba(166, 61, 47, 0.14);
}

.playback-debug summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 900;
}

.playback-debug p {
  color: var(--muted);
  font-size: 0.85rem;
}

.debug-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.6rem 0 0.75rem;
}

.debug-toolbar p {
  flex: 1;
  margin: 0;
}

.debug-toolbar span {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
}

.playback-debug textarea {
  width: 100%;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 0.85rem;
}

.controls-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.error-banner,
.empty {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(166, 61, 47, 0.2);
  border: 1px solid rgba(166, 61, 47, 0.45);
}

.token-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.token-card {
  width: min(560px, 100%);
  border-radius: 34px;
  border: 1px solid var(--line);
  background: rgba(11, 12, 12, 0.82);
  padding: clamp(1.5rem, 5vw, 3rem);
  box-shadow: 0 30px 90px var(--shadow);
}

.token-card h1 {
  margin: 0.3rem 0 0.7rem;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: -0.07em;
  line-height: 0.94;
}

.token-card p {
  color: var(--muted);
}

.token-card code {
  color: var(--text);
}

.token-card form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.token-error {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid rgba(166, 61, 47, 0.5);
  border-radius: 14px;
  background: rgba(166, 61, 47, 0.18);
  color: #ffd6ce;
  font-weight: 700;
}

.token-footnote {
  margin-top: 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .hero,
  .player-header {
    align-items: stretch;
    flex-direction: column;
  }

  .layout,
  .controls-grid {
    grid-template-columns: 1fr;
  }

  .library-panel {
    min-height: 58vh;
    max-height: 68vh;
  }

  .debug-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .token-card form {
    grid-template-columns: 1fr;
  }
}
