:root {
  color-scheme: dark;
  --bg: #0e1219;
  --panel: #171e2b;
  --line: #2c3a52;
  --text: #e8edf7;
  --muted: #9aabc4;
  --accent: #4d6fff;
  --accent-2: #2a3750;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { margin: 0 0 8px; }
h2 { font-size: 26px; margin: 0 0 6px; }
h3 { margin: 20px 0 10px; font-size: 16px; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
a { color: inherit; }
.lede a, article a { color: #8eb4ff; }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.auth-card form, .auth-card details { margin-top: 16px; }
summary { cursor: pointer; color: var(--muted); }

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
  grid-template-rows: 1fr auto;
}

aside {
  grid-row: 1 / 3;
  background: #121826;
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand strong { display: block; font-size: 22px; }
.brand span { display: block; font-size: 13px; margin-top: 4px; }
nav.tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
nav.tabs a {
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
}
nav.tabs a[aria-current="page"] {
  background: var(--accent-2);
  border-color: var(--accent);
}
#logout { margin-top: auto; }

main { padding: 24px 24px 16px; overflow: auto; }
#status {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.5em;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #151c28;
}

.page-head { margin-bottom: 16px; }
.lede { margin: 0; color: var(--muted); max-width: 68ch; }
.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.card-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

section[data-page], article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin: 0 0 14px;
}
section[data-page] { padding: 22px; }
article, .media-card {
  background: #121a27;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.media-card h3 { margin-top: 0; }
.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  background: #0b1018;
  margin-bottom: 10px;
}
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: #121a27;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

input, button, select, textarea {
  font: inherit;
  color: inherit;
  border-radius: 8px;
  border: 1px solid #485875;
  padding: 10px;
}
input, select, textarea {
  width: 100%;
  background: #101826;
}
button, .button-link {
  background: var(--accent);
  color: white;
  cursor: pointer;
  border: 0;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 8px;
}
button.secondary, .button-link { background: var(--accent-2); }
button:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input, .row select, .row textarea { flex: 1 1 220px; }
.badge {
  display: inline-block;
  margin-left: 6px;
  background: #8a5a16;
  color: #ffe7b3;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 12px;
}

#player-dock {
  grid-column: 2;
  border-top: 1px solid var(--line);
  background: #10151f;
  padding: 12px 20px 16px;
}
#player-dock video, #player-dock audio, #yt-host {
  width: 100%;
  max-height: 280px;
  margin-top: 8px;
  background: #000;
  border-radius: 10px;
}
#yt-host { min-height: 220px; }
body.route-watch #yt-host { max-height: 420px; min-height: 280px; }
#now-playing { font-size: 14px; }

@media (max-width: 860px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  aside {
    grid-row: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  nav.tabs { flex-direction: row; flex-wrap: wrap; }
  #logout { margin-top: 0; }
  #player-dock { grid-column: 1; }
  .card-grid { grid-template-columns: 1fr; }
}
