:root {
  --bg: #fff8f5;
  --surface: #ffefe9;
  --text: #2a1f1c;
  --muted: #7d6d67;
  --border: rgba(0, 0, 0, 0.1);
  --accent: #e2552f;
  --accent-bg: #ffe6dd;
  --accent-text: #9a3414;
  --thumb: #ffc9b6;
  --on-accent: #ffffff;
  --danger: #a32d2d;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1412;
    --surface: #241b18;
    --text: #f6eeea;
    --muted: #a8978f;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #ff7f5c;
    --accent-bg: #3a1b10;
    --accent-text: #ffc9b6;
    --thumb: #5a2a19;
    --on-accent: #2b0e05;
    --danger: #f09595;
  }
}

/* `manipulation` mantém rolar e tocar, mas tira o zoom de duplo toque do iOS. */
* { box-sizing: border-box; touch-action: manipulation; }
/* A página não rola nem "estica" no iOS: o body fica preso na tela e só o <main> rola. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 8px 16px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

.view { padding: 0 0 16px; min-height: 100%; }
header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.section { padding: 20px 16px 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.icon-btn { padding: 10px; border-radius: 50%; color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn[data-mode="one"]::after { content: "1"; position: absolute; font-size: 9px; font-weight: 700; margin: -2px 0 0 -9px; }
.icon-btn { position: relative; }

.btn { background: var(--surface); border: 0.5px solid var(--border); border-radius: 10px; padding: 11px 16px; font-weight: 500; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.ghost { color: var(--accent); padding: 8px 10px; font-weight: 500; }

.notice { margin: 8px 16px; padding: 10px 12px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-text); font-size: 14px; }
.notice.error { background: transparent; color: var(--danger); border: 0.5px solid var(--danger); }

.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--muted); margin: 0; }
button:disabled { opacity: 0.6; cursor: default; }
.empty { text-align: center; padding: 72px 32px; color: var(--muted); }
.empty h2 { color: var(--text); }
.empty .btn { margin-top: 16px; }

.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-bottom: 0.5px solid var(--border); }
.row.playing { background: var(--accent-bg); }
.row.playing .row-title { color: var(--accent-text); }
.row.playing .thumb.note { background: var(--accent); color: var(--on-accent); }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 2px 0; }
.thumb { width: 44px; height: 44px; border-radius: 8px; background: var(--thumb); flex: none; object-fit: cover; }
.thumb.wide { width: 80px; height: 45px; }
.thumb.note { display: flex; align-items: center; justify-content: center; color: var(--accent-text); }
.thumb.note svg { width: 22px; height: 22px; }
#cover-note { color: var(--accent); }
#cover-note svg { width: 72px; height: 72px; stroke-width: 1.5; }
#results { margin-top: 12px; }
.row-text { min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.error { color: var(--danger); }
.row .icon-btn { color: var(--muted); }
.bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -35%; } to { margin-left: 100%; } }

#add-form { padding: 0 16px; }
.field { display: flex; align-items: center; border: 0.5px solid var(--border); border-radius: 10px; background: var(--surface); padding-right: 4px; }
.field:focus-within { border-color: var(--accent); }
.field input { flex: 1; min-width: 0; border: 0; background: none; color: inherit; font: inherit; padding: 12px; outline: none; }
#add-form .notice { margin: 10px 0; }
#add-submit { width: 100%; margin-top: 12px; }

.player-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 0 16px; }
.cover { margin: 12px 28px; aspect-ratio: 1; max-height: 42vh; margin-inline: auto; border-radius: 14px; background: var(--accent-bg); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover img[hidden] { display: none; }
.now { padding: 8px 28px 0; display: flex; flex-direction: column; }
.now strong { font-size: 18px; font-weight: 600; }
.seek { padding: 12px 28px 0; }
.times { display: flex; justify-content: space-between; margin-top: 2px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--progress, 0%), var(--border) var(--progress, 0%)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); margin-top: -6px; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); }
.controls { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 12px 16px; }
.play-btn { width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.play-btn svg { width: 28px; height: 28px; fill: currentColor; stroke: none; }
.queue { margin-top: 8px; border-top: 0.5px solid var(--border); }

.tabs { position: relative; display: flex; border-top: 0.5px solid var(--border); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 9px 0 6px; font-size: 11px; color: var(--muted); }
.tabs button.on { color: var(--accent); }
/* Barrinha no topo da aba selecionada: um elemento só, que desliza de uma aba pra outra. */
.tab-indicator { position: absolute; top: -0.5px; left: 0; width: calc(100% / 3); height: 3px; display: flex; justify-content: center; pointer-events: none; transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
.tab-indicator::before { content: ""; width: 32px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .tab-indicator { transition: none; } }
.tabs svg { width: 22px; height: 22px; }

dialog { border: 0.5px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text); width: min(92vw, 420px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog label { display: block; margin-top: 12px; font-size: 14px; color: var(--muted); }
dialog label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; }
dialog label.check input { width: auto; margin: 0; }
dialog input[type="text"], dialog input[type="url"], dialog input[type="password"] { display: block; width: 100%; margin-top: 4px; padding: 11px; border: 0.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.top-actions { display: flex; align-items: center; }
/* O espaço da prévia já fica reservado (9:16), então nada pula quando a imagem chega ou é trocada. */
#share-img { display: block; aspect-ratio: 9 / 16; height: 58vh; width: auto; max-width: 100%; object-fit: contain; margin: 12px auto 0; border-radius: 12px; background: var(--surface); }
dialog:focus { outline: none; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog .notice { margin: 8px 0 0; }
