: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; }

/* ---------- apmaksa: 45 s priekšskatījums + Stripe popup (pay.js) ---------- */
/* rinda ar slēdzeni saraksta beigās */
.lock-row { margin-top: 6px; padding: 14px 12px; border-radius: 10px; cursor: pointer; text-align: center;
  border: 1px dashed var(--line); background: color-mix(in srgb, var(--active) 50%, transparent); }
.lock-row:hover { border-color: var(--accent); }
.lock-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lock-t { font-weight: 700; }
.lock-s { color: var(--muted); font-size: 14px; margin-top: 2px; }
/* video "iesaldēts" pie 45 s */
.video.pw-frozen .video-hit { background: rgba(0, 0, 0, 0.6); animation: none; }
.video.pw-frozen .video-hit::after { content: "🔒"; font-size: 24px; }

body.pw-open { overflow: hidden; }
.pw-overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.pw-overlay.open { opacity: 1; pointer-events: auto; }
.pw-terms-overlay { z-index: 210; }
.pw-modal { background: var(--card); color: var(--ink); width: 100%; max-width: 480px;
  border-top: 3px solid var(--accent); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.3);
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  transform: translateY(22px); opacity: 0; transition: transform .28s cubic-bezier(.22,.61,.36,1), opacity .22s ease; }
.pw-overlay.open .pw-modal { transform: none; opacity: 1; }
.pw-terms-modal { max-width: 620px; }
@media (min-width: 560px) {
  .pw-overlay { align-items: center; padding: 20px; }
  .pw-modal { border-radius: var(--radius); padding: 24px; }
}
.pw-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pw-head h2 { margin: 0; font-size: 20px; line-height: 1.25; letter-spacing: -.015em; }
.pw-x { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--muted); width: 34px; height: 34px;
  flex: none; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.pw-x:hover { color: var(--ink); border-color: var(--muted); }
.pw-x:disabled { opacity: .4; cursor: not-allowed; }
.pw-x:focus-visible, .pw-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-lead { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.pw-price-row { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 4px; flex-wrap: wrap; }
.pw-price { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.pw-price-note { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.pw-includes { list-style: none; margin: 12px 0 16px; padding: 0; font-size: 14px; }
.pw-includes li { display: flex; gap: 9px; padding: 3px 0; }
.pw-includes li::before { content: "✓"; color: var(--accent); font-weight: 700; flex: none; }
.pw-consent { display: flex; gap: 11px; align-items: flex-start; margin: 4px 0 14px; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.pw-consent.err { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.pw-consent input { flex: none; width: 21px; height: 21px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.pw-consent-txt { font-size: 14.5px; line-height: 1.5; }
.pw-consent label { cursor: pointer; }
.pw-link { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.pw-consent-err { display: none; margin: -8px 0 14px; color: var(--bad); font-size: 13px; }
.pw-consent-err.show { display: block; }
.pw-locked { border: 1px dashed var(--line); border-radius: 10px; padding: 18px 14px; text-align: center;
  color: var(--muted); background: var(--bg); font-size: 13.5px; }
.pw-wallets { margin: 0 0 14px; }
.pw-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 11px;
  font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pw-sep::before, .pw-sep::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.pw-pay { width: 100%; margin-top: 16px; min-height: 48px; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.pw-pay:disabled { opacity: .5; cursor: not-allowed; }
.pw-msg { display: none; margin: 12px 0 0; font-size: 13.5px; padding: 11px 12px; border-radius: 10px; }
.pw-msg.err { display: block; background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pw-msg.info { display: block; background: var(--active); color: var(--ink); }
.pw-msg .pw-spin { display: inline-block; vertical-align: -3px; margin-right: 8px; }
.pw-secure { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.pw-skeleton { height: 92px; border-radius: 10px; background: linear-gradient(90deg, var(--bg) 25%, var(--card) 50%, var(--bg) 75%);
  background-size: 200% 100%; animation: pw-sk 1.3s ease-in-out infinite; }
@keyframes pw-sk { to { background-position: -200% 0; } }
.pw-spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%;
  animation: pw-rot .7s linear infinite; }
.pw-spin.dark { border-color: color-mix(in srgb, var(--ink) 20%, transparent); border-top-color: var(--ink); }
@keyframes pw-rot { to { transform: rotate(360deg); } }
.pw-terms-body h3 { margin: 18px 0 6px; font-size: 15px; }
.pw-terms-body p, .pw-terms-body ul { margin: 0 0 9px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.pw-terms-body ul { padding-left: 19px; }
.pw-terms-body section.imp { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; }
.pw-terms-draft { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad) !important; }
.pw-terms-meta { font-size: 12px !important; margin-top: 16px !important; }
.pw-terms-ok { width: 100%; margin-top: 16px; }
