:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d1b18;
  --muted: #6f6a61;
  --line: #e4dfd5;
  --accent: #d9442b;
  --accent-ink: #ffffff;
  --active: #fff1db;
  --good: #2e7d4f;
  --bad: #c0392b;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* tēma: pēc noklusējuma gaišā; tumšā tikai ar pārslēgu (data-theme="dark" uz <html>) */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15140f; --card: #1f1d18; --ink: #f1ede4; --muted: #a39d91; --line: #34312a;
  --accent: #ff6a4d; --active: #3a2a14; --good: #5ccf8c; --bad: #ff7b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: inherit; }
code { background: var(--line); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* galvene */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.top nav { display: flex; gap: 4px; align-items: center; }
/* EN / LV: vienkāršs uzraksts bez fona; ieslēgts = tumšs treknāks, izslēgts = blāvs */
.lang-btn { display: none; }
body[data-view="song"] .lang-btn { display: inline-block; }
.top .lang-btn.btn, .top .lang-btn.btn[aria-pressed="true"] { background: none; border: 0; min-height: 0; padding: 4px 5px; border-radius: 4px;
  font: 600 13px var(--font); letter-spacing: .04em; color: var(--ink); }
.top .lang-btn.btn[aria-pressed="false"] { color: var(--muted); font-weight: 500; opacity: .6; }
.top .lang-btn.btn:hover { background: none; color: var(--ink); opacity: 1; }
.theme-btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; font-size: 16px; line-height: 1; margin-right: 6px; }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.top nav a { white-space: nowrap; text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.top nav a.on { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.wrap { max-width: 860px; margin: 0 auto; padding: 28px 16px 64px; }
h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; }

/* dziesmu saraksts */
.songs { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.songs a { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .15s, box-shadow .15s; }
.songs a:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgb(0 0 0 / .08); }
.songs img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--line); }
.songs .info { padding: 12px 14px 14px; }
.songs .t { font-weight: 700; }
.songs .a, .songs .n { font-size: 14px; color: var(--muted); }
.songs .n { margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--active); color: var(--ink); }

/* dziesma */
.song { max-width: 1180px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.video { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.video iframe, .video #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-hit { display: none; position: absolute; inset: 0; z-index: 1; width: 100%; padding: 0; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, 0.28); -webkit-tap-highlight-color: transparent; }
.video-hit::after { content: "▶"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 30px; text-shadow: 0 1px 6px rgba(0,0,0,.5); }
/* atskaņošanas sākumā logs ir tumšs un ~5 s laikā pakāpeniski kļūst caurspīdīgs (animācija sākas no jauna pie katra play) */
.video.is-playing .video-hit { background: transparent; animation: unveil 5s ease-out; }
@keyframes unveil { 0%, 20% { background-color: rgba(0, 0, 0, 0.92); } 100% { background-color: rgba(0, 0, 0, 0); } }
.video.is-playing .video-hit::after { content: ""; }
.video .err { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; gap: 12px; text-align: center; padding: 16px; color: #fff; background: #111; }
.video .err a { color: #fff; font-weight: 700; }
.meta { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin: 12px 2px 4px; }
.meta h1 { font-size: 22px; margin: 0; }
.warn { font-size: 12px; white-space: nowrap; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); font-weight: 600; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 600 14px var(--font);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; min-height: 38px; }
.btn:hover { border-color: var(--muted); }
.btn.icon { width: 42px; padding: 0; font-size: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* rindas */
.lines { list-style: none; margin: 0; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); scroll-behavior: smooth; }
.line { position: relative; padding: 10px 56px 10px 12px; border-radius: 10px; cursor: pointer; transition: background .2s, opacity .2s; }
.line + .line { margin-top: 2px; }
.line:hover { background: color-mix(in srgb, var(--active) 60%, transparent); }
.line.past { opacity: .55; }
.line.on { background: var(--active); opacity: 1; }
.line .en { font-size: 19px; font-weight: 700; line-height: 1.35; }
.line .lv { color: var(--muted); font-size: 15px; margin-top: 2px; }
.line .tm { position: absolute; right: 12px; top: 13px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hide-en .line .en { display: none; }
.hide-lv .line .lv { display: none; }


/* tukšs saraksts */
.empty { margin-top: 24px; }

/* video kļūst par mazu logu kreisajā pusē, pielipis augšā; zem tā ir vairāk vietas tekstam (visos platumos — arī datorā ir telefona kolonna) */
@media all {
  .song { padding-top: 0; gap: 8px; }
  .stage { position: sticky; top: 55px; z-index: 15; display: grid; grid-template-columns: 176px minmax(0, 1fr);
    grid-template-areas: "video meta" "controls controls"; gap: 4px 12px; align-content: start;
    padding: 8px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
  .stage .video { grid-area: video; border-radius: 10px; align-self: start; }
  .stage .meta { grid-area: meta; margin: 0; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
  .stage .meta h1 { font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .stage .artist { font-size: 12px; }
  .stage .warn { font-size: 11px; padding: 2px 8px; white-space: normal; }
  /* caurspīdīga poga virs video: spiež tikai to, nevis YouTube iekšējās pogas; atskaņo / pauzē */
  .video-hit { display: block; }
  .stage .controls { grid-area: controls; margin: 0; padding: 8px 16px; }
}
@media (max-width: 560px) {
  .top { padding: 10px 12px; }
  .top nav a { padding: 6px 9px; }
  .line .en { font-size: 17px; }
  .sep { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------- player josla (gaišā / tumšā tēma: krāsas no --card / --ink) ---------- */
.controls { margin-top: 10px; padding: 12px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); max-width: 520px; }
.pl-row { display: flex; align-items: center; justify-content: space-between; }
.pl-btn { appearance: none; border: 0; background: none; color: var(--ink); width: 40px; height: 40px; display: grid; place-items: center;
  cursor: pointer; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.play-btn { appearance: none; border: 0; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--ink); color: var(--card); -webkit-tap-highlight-color: transparent; }
.play-btn svg, .pl-btn svg { display: block; }
.pl-btn:focus-visible, .play-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* datorā: telefona "logs" ekrāna vidū uz mīkstas fona krāsas (kā app3 paraugā) */
@media (min-width: 720px) {
  html { background: #e9e5dc; overflow-y: auto; } /* neļauj body overflow:clip pārnest uz logu (citādi datorā nevar ritināt) */
  html[data-theme="dark"] { background: #0b0a07; }
  body { width: 520px; max-width: 520px; min-height: calc(100vh - 24px); margin: 24px auto 0; border-radius: 28px 28px 0 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); overflow: clip; }
  .top { border-radius: 28px 28px 0 0; }
}

/* kļūdas paziņojums mazajā video logā (176 px) — mazāks teksts, lai ietilpst */
.stage .video .err { font-size: 11px; line-height: 1.3; gap: 4px; padding: 6px; }
.stage .video .err a { font-size: 11px; }

/* izvēlne: dziesmu saraksts no apakšas */
body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .25s; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column;
  background: var(--card); color: var(--ink); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.3);
  transform: translateY(100%); transition: transform .25s ease; padding-bottom: env(safe-area-inset-bottom); }
.sheet.open .sheet-back { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 10px auto 6px; flex: none; touch-action: none; }
.sheet-head { padding: 4px 20px 12px; flex: none; line-height: 1.3; }
.sheet-head .muted { font-size: 13px; }
.sheet-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-list a { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; text-decoration: none; }
.sheet-list a:hover { background: var(--bg); }
.sheet-list a.on { background: var(--active); }
.sheet-list img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; background: var(--line); }
.sheet-list .info { min-width: 0; }
.sheet-list .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-list .a { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
