:root {
  color-scheme: dark;
  --bg: #0a0c11;
  --panel: #141822;
  --panel-2: #1b2130;
  --border: #252d3f;
  --border-strong: #38435c;
  --text: #e9edf5;
  --muted: #96a1b9;
  --accent: #e50914;
  --accent-hover: #ff2b36;
  --ok: #46d17f;
  --warn: #ffb020;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(900px 500px at 50% -220px, #1a2133 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(1000px, 100% - 2rem);
  margin-inline: auto;
}

a {
  color: #8ab4ff;
}

a:hover {
  color: #b7ccff;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.5rem 0.75rem;
  background: var(--panel-2);
  border-radius: 8px;
}

/* --- header ---------------------------------------------------------- */

.site-header {
  padding: 1.4rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(229, 9, 20, 0.6);
}

.auth-area {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.auth-who {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 18ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-gate {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.auth-gate p {
  margin: 0;
}

/* --- buttons & inputs ------------------------------------------------ */

input,
select,
textarea,
button,
.btn {
  font: inherit;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #0e121b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.25);
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

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

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn.ghost:hover {
  background: var(--panel-2);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.icon-btn {
  position: relative;
}

.glyph {
  font-size: 1rem;
  line-height: 1;
}

.icon-btn.attention::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

.field {
  display: block;
  margin-bottom: 0.9rem;
}

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

.field.grow {
  flex: 1 1 12rem;
  margin-bottom: 0;
}

.label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field-row.align-start {
  align-items: flex-start;
}

.field-row > textarea,
.field-row > input[type="text"] {
  flex: 1 1 14rem;
}

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

/* --- status & notices ------------------------------------------------ */

.status {
  margin: 0.6rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  min-height: 1.1em;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.error {
  color: var(--danger);
}

.notice {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(255, 176, 32, 0.35);
  background: rgba(255, 176, 32, 0.08);
  border-radius: var(--radius-sm);
  color: var(--warn);
  font-size: 0.88rem;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--warn);
  text-decoration: underline;
  cursor: pointer;
}

.badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ok);
  border: 1px solid rgba(70, 209, 127, 0.35);
  background: rgba(70, 209, 127, 0.08);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
}

/* --- browse view ----------------------------------------------------- */

.search-banner {
  padding: 1rem 0 0.5rem;
}

.search-heading {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.1rem);
  letter-spacing: -0.02em;
}

.search-sub {
  margin: 0.4rem 0 1.1rem;
  color: var(--muted);
}

.search-bar {
  position: relative;
  display: block;
}

.search-bar input {
  font-size: 1.3rem;
  padding: 1.25rem 1.2rem 1.25rem 3.6rem;
  border-radius: var(--radius);
  background: var(--panel);
}

.search-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: -5px;
  width: 10px;
  height: 2px;
  background: var(--muted);
  transform: rotate(45deg);
  border-radius: 2px;
}

.browse-heading {
  margin: 2.25rem 0 0;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.browse-empty {
  margin: 2.5rem 0;
  text-align: center;
  color: var(--muted);
}

.results {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 1.25rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
}

.result {
  min-width: 0;
}

.result-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.result-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #12161f;
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.result-card:hover .result-poster {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.result-card:focus-visible {
  outline: none;
}

.result-card:focus-visible .result-poster {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.28);
}

.result.selected .result-poster {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.result-title {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.result-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

/* --- player view ----------------------------------------------------- */

.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.player-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

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

.player-main > .panel {
  margin-top: 1.1rem;
}

.inline-fields {
  display: flex;
  gap: 0.6rem;
}

.mini {
  display: block;
}

.mini input {
  width: 4.75rem;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

/* --- sidebar (title art and essentials) ------------------------------ */

.player-sidebar {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sidebar-art {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #0b0e14;
}

.sidebar-body {
  padding: 1rem 1.1rem 1.2rem;
}

.sidebar-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.sidebar-meta {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-overview {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: #cbd3e1;
  overflow-wrap: anywhere;
}

.sidebar-link {
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-link:hover {
  text-decoration: underline;
}

/* --- collapsible panels ---------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

.panel[open] > summary::after {
  transform: rotate(90deg);
}

.panel > summary:hover {
  color: #fff;
}

.panel > summary:focus-visible {
  outline: none;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 3px rgba(229, 9, 20, 0.25);
}

.panel[open] > summary {
  border-bottom: 1px solid var(--border);
}

.panel-body {
  padding: 1.1rem 1.15rem 1.2rem;
}

.panel-body > :first-child {
  margin-top: 0;
}

/* --- settings dialog ------------------------------------------------- */

.settings {
  width: min(680px, 100% - 2rem);
  max-height: min(85vh, 100% - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  display: none;
  overflow: hidden;
}

.settings[open] {
  display: flex;
  flex-direction: column;
}

.settings::backdrop {
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(2px);
}

.settings-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.settings-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.settings-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem;
}

.settings-section + .settings-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.settings-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.option-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem 0.9rem;
  margin: 0 0 0.9rem;
}

.option-group legend {
  padding: 0 0.4rem;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.option-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.option {
  min-width: 0;
}

.option-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.option-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* --- footer ---------------------------------------------------------- */

.site-footer {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem 0 3rem;
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.85em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- browse tabs and footer ------------------------------------------ */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 2rem;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.tab[aria-pressed="true"] {
  color: #fff;
  background: var(--panel-2);
  border-color: var(--accent);
}

.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.25);
}

.browse-footer {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.id-lookup {
  margin-top: 2rem;
}

.results[aria-busy="true"] {
  opacity: 0.55;
}

/* --- player extras --------------------------------------------------- */

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

.snippet-controls {
  align-items: flex-end;
  margin-bottom: 0.9rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  white-space: nowrap;
  padding-bottom: 0.5rem;
}

.check input {
  width: auto;
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .result-poster,
  .panel > summary::after,
  .btn {
    transition: none;
  }

  .result-card:hover .result-poster {
    transform: none;
  }
}

@media (max-width: 820px) {
  .player-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .header-inner {
    flex-direction: row;
  }

  .brand span:last-child {
    display: none;
  }

  .player-actions {
    width: 100%;
  }

  .mini input {
    width: 4rem;
  }

  .results {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}
