:root {
  --bg: #f6f1e8;
  --bg-elev: #fffdf8;
  --bg-soft: #efe7d8;
  --text: #1c150c;
  --muted: #6a5c48;
  --line: #e2d6c2;
  --accent: #8a5a12;
  --accent-strong: #6e450b;
  --gold: #c4922a;
  --danger: #8a2f1a;
  --shadow: 0 8px 28px rgba(60, 40, 10, .08);
  --radius: 14px;
  --topbar: 64px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #12100c;
  --bg-elev: #1c1913;
  --bg-soft: #262119;
  --text: #f3ead9;
  --muted: #b3a48c;
  --line: #3a3328;
  --accent: #e8b84a;
  --accent-strong: #f0c96a;
  --gold: #e8b84a;
  --danger: #e08a72;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--gold); }
button, input { font: inherit; color: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -3rem; background: var(--accent);
  color: #1c150c; padding: .5rem .8rem; border-radius: 8px; z-index: 20;
}
.skip-link:focus { top: .6rem; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar);
  display: grid;
  grid-template-columns: auto minmax(0, 720px) auto;
  gap: 1rem;
  align-items: center;
  padding: 0 1.1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo {
  display: flex; align-items: center; gap: .55rem;
  color: var(--text); text-decoration: none; font-weight: 700;
  letter-spacing: -.03em; font-size: 1.25rem;
}
.logo-mark { color: var(--gold); display: flex; }
.search {
  display: flex; align-items: stretch;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  min-width: 0;
}
.search input {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  padding: .55rem 1rem .55rem 1.1rem;
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search-btn, .theme-toggle {
  border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  width: 44px; height: 40px;
}
.search-btn { border-left: 1px solid var(--line); }
.search-btn:hover, .theme-toggle:hover { color: var(--text); background: var(--bg-soft); }
.theme-toggle { border: 1px solid var(--line); border-radius: 999px; width: 42px; height: 42px; background: var(--bg-elev); }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark, :root:not([data-theme]) .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light, :root:not([data-theme]) .theme-icon-light { display: inline-flex; }
[data-theme="dark"] .theme-icon-dark { display: inline-flex; }

/* Home */
.home { max-width: 1400px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.watch { max-width: 1400px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.home-intro h1 {
  font-size: clamp(1.5rem, 2.4vw, 2.05rem);
  letter-spacing: -.03em; margin: 0 0 .4rem; font-weight: 700;
}
.lede { margin: 0 0 .35rem; color: var(--muted); max-width: 62ch; }
.count { margin: 0 0 1.2rem; color: var(--muted); font-size: .92rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.15rem 1rem;
}
.card {
  color: inherit; text-decoration: none;
  display: flex; flex-direction: column; gap: .55rem;
  border-radius: 12px;
}
.card:hover .thumb img { transform: scale(1.03); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.thumb {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}
.thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .35s ease;
}
.duration {
  position: absolute; right: .4rem; bottom: .4rem;
  background: rgba(0,0,0,.82); color: #fff;
  font-size: .72rem; font-weight: 600;
  padding: .12rem .35rem; border-radius: 4px;
}
.badge {
  position: absolute; left: .4rem; top: .4rem;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  color: var(--accent-strong);
  font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15rem .4rem; border-radius: 999px;
  border: 1px solid var(--line);
}
.card-title {
  margin: 0; font-size: 1rem; font-weight: 600;
  letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin: 0; color: var(--muted); font-size: .86rem; }
.empty { padding: 3rem 0; color: var(--muted); text-align: center; }

/* Watch layout */
.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas:
    "player lyrics"
    "meta   lyrics"
    "upnext lyrics";
  gap: 1rem 1.2rem;
  align-items: start;
}
/* Desktop watch: equal, tighter side margins (aligned with the top bar),
   video at 95% of its previous width, and all recovered space given to lyrics.
   Font size on .lyrics-scroll is unchanged. Mobile (max-width: 1100px) is untouched. */
@media (min-width: 1101px) {
  .watch {
    max-width: none;
    width: 100%;
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }
  /* Previous video width was (layout - 340px - 1.2rem gap), with 1.2rem page padding
     and a 1400px cap. Keep that historical size, then take 95% of it. */
  .watch-layout {
    grid-template-columns: minmax(0, calc(0.95 * (100% - 340px - 1.4rem))) minmax(0, 1fr);
  }
}
@media (min-width: 1400px) {
  /* Historical video width capped at 1400px - 2.4rem padding - 1.2rem gap - 340px. */
  .watch-layout {
    grid-template-columns: calc(0.95 * (1400px - 3.6rem - 340px)) minmax(0, 1fr);
  }
}
.player-wrap { grid-area: player; }
.song-meta { grid-area: meta; }
.lyrics-panel { grid-area: lyrics; }
.up-next { grid-area: upnext; }
.player {
  position: relative; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.song-meta h1 {
  margin: 0 0 .25rem; font-size: clamp(1.25rem, 2vw, 1.7rem);
  letter-spacing: -.03em;
}
.song-meta .byline { margin: 0 0 .7rem; color: var(--muted); }
.song-meta .note { margin: .4rem 0 0; color: var(--muted); max-width: 70ch; }
.meta-row { display: flex; flex-wrap: wrap; gap: .45rem .8rem; font-size: .9rem; color: var(--muted); }

.lyrics-panel, .up-next-list {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lyrics-panel {
  position: sticky; top: calc(var(--topbar) + .75rem);
  max-height: calc(100vh - var(--topbar) - 1.5rem);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel-head {
  padding: .85rem 1.1rem .7rem;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; justify-content: space-between; gap: .6rem;
}
.panel-head h2 { margin: 0; font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.lyrics-scroll {
  overflow: auto; padding: 1.15rem 1.2rem 1.6rem;
  font-family: var(--serif);
  font-size: 1.14rem; line-height: 1.7;
}
.verse { margin: 0 0 1.2rem; }
.verse-label {
  font-family: var(--font);
  font-size: .72rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 .25rem;
}
.verse p { margin: 0; }
.lyrics-placeholder {
  font-family: var(--font);
  color: var(--muted);
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 1.1rem 1rem;
}
.lyrics-placeholder strong { display: block; color: var(--text); margin-bottom: .35rem; font-family: var(--font); }

.mobile-tabs { display: none; }
.up-next h2 {
  margin: 1.1rem 0 .7rem; font-size: .95rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.up-item {
  display: grid; grid-template-columns: 154px minmax(0, 1fr);
  gap: .7rem; color: inherit; text-decoration: none;
  padding: .45rem; border-radius: 10px;
}
.up-item:hover { background: var(--bg-soft); }
.up-item .thumb { border-radius: 8px; box-shadow: none; }
.up-item .card-title { font-size: .92rem; }
.watch-loading, .watch-error { padding: 3rem 0; color: var(--muted); }

.site-foot {
  border-top: 1px solid var(--line);
  padding: 1.2rem 1.2rem 2rem;
  color: var(--muted); font-size: .88rem; text-align: center;
}
.site-foot p { margin: 0 auto; max-width: 70ch; }

@media (max-width: 1100px) {
  .watch-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "player"
      "meta"
      "tabs"
      "panel";
  }
  .lyrics-panel { position: static; max-height: none; }
  .mobile-tabs {
    display: flex; grid-area: tabs; gap: .4rem;
    background: var(--bg-soft); padding: .3rem; border-radius: 999px; width: max-content;
  }
  .mobile-tabs button {
    border: 0; background: transparent; color: var(--muted);
    padding: .4rem .95rem; border-radius: 999px; cursor: pointer; font-weight: 600;
  }
  .mobile-tabs button[aria-selected="true"] {
    background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
  }
  .tab-panel[hidden] { display: none; }
  .watch-layout .lyrics-panel, .watch-layout .up-next { grid-area: panel; }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto; padding: .55rem .8rem .7rem;
  }
  .logo { grid-column: 1; grid-row: 1; }
  .theme-toggle { grid-column: 2; grid-row: 1; justify-self: end; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .home, .watch { padding: 1rem .8rem 2.5rem; }
  .up-item { grid-template-columns: 128px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card .thumb img { transition: none; }
}
