:root {
  --bg: #0e0f13;
  --panel: #191b22;
  --panel2: #20232c;
  --line: #2a2e39;
  --text: #e9e6e1;
  --muted: #8b8f9c;
  --accent: #ff7a2f;
  --accent2: #ffc24a;
  --good: #57d68d;
  --warn: #f2c14e;
  --bad: #ff5d5d;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: radial-gradient(700px 360px at 20% -8%, #2a1710 0%, transparent 65%), var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding: 0 0 calc(env(safe-area-inset-bottom) + 16px);
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* icons: one line style, coloured by the text */
.ic {
  width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ic.inline { width: 14px; height: 14px; vertical-align: -2px; color: var(--text); }

/* ---------- top ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  /* the status bar (clock, Dynamic Island) is drawn over the page — the sticky header keeps below it */
  padding: calc(env(safe-area-inset-top) + 8px) 16px 10px; position: sticky; top: 0; z-index: 5;
  background: rgba(14,15,19,.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 7px; }
.logo { width: 24px; height: 24px; }
.brand .name { font-weight: 700; font-size: 19px; }
.brand .tag { color: var(--muted); font-size: 13px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.net { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.net i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.net.on i { background: var(--good); }
.net.off i { background: var(--warn); }
.icon {
  display: inline-grid; place-items: center; flex: none;
  background: transparent; border: 0; width: 38px; height: 38px; border-radius: 10px;
  color: var(--muted); cursor: pointer;
}
.icon .ic { width: 20px; height: 20px; }
.icon:active { background: var(--panel2); color: var(--text); }

main { padding: 4px 16px 0; display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.badge {
  background: linear-gradient(90deg, #ff3d2e, #ffc24a); color: #1a0d05; font-weight: 700;
  border-radius: 6px; padding: 1px 7px; font-size: 11px; letter-spacing: .4px;
}
.flag { margin-left: auto; display: inline-grid; place-items: center; width: 32px; height: 28px; margin-right: -6px; background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer; }
.flag .ic { width: 17px; height: 17px; }
.flag:active { color: var(--accent); background: var(--panel2); }
.label .badge { margin-left: auto; }
.label .badge + .flag { margin-left: 8px; }
.sheet textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 16px; margin-bottom: 10px;
}
.flag-cats .setting { margin: 8px 0; }
.chip { display: inline-block; min-width: 34px; text-align: center; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; color: #111; background: #666; }

/* ---------- now playing ---------- */
.now .title { font-size: 21px; font-weight: 700; margin-top: 4px; line-height: 1.2; overflow-wrap: anywhere; }
.now .artist { color: var(--muted); min-height: 1.4em; }
.now .wave { width: 100%; height: 64px; display: block; margin: 10px 0 8px; border-radius: 8px; background: #121318;
  touch-action: pan-y; cursor: pointer; }   /* по горизонтали — перемотка, по вертикали — прокрутка страницы */
.now .meta { display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.now .meta .time { margin-left: auto; color: var(--text); }

.controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.play {
  width: 74px; height: 74px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #ff8a3f, #ff5a1e); box-shadow: 0 6px 24px rgba(255,106,36,.35);
  display: grid; place-items: center;
}
.play svg { width: 34px; height: 34px; fill: #1a0d05; }
.play .i-pause { display: none; }
.play.on .i-play { display: none; }
.play.on .i-pause { display: block; }
.play:active { transform: scale(.96); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 42px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 11px;
  padding: 0 14px; cursor: pointer; white-space: nowrap;
}
.btn .ic { color: var(--muted); }
.btn:active { background: #2a2e3a; }
.btn:disabled { opacity: .45; }
.btn.primary { background: linear-gradient(180deg, #ff8a3f, #ff6a24); border-color: #ff7a2f; color: #1a0d05; font-weight: 600; }
.btn.primary .ic { color: currentColor; }
.btn.small { height: 34px; padding: 0 11px; font-size: 14px; gap: 6px; }
.btn.small .ic { width: 16px; height: 16px; }
/* "mix now": accent outline and the crossfade icon */
.btn.mix { border-color: rgba(255,122,47,.55); background: rgba(255,122,47,.08); color: #ffd9bf; font-weight: 600; }
.btn.mix .ic { width: 20px; height: 20px; color: var(--accent); }
.btn.mix:active { background: rgba(255,122,47,.2); }
.btn.mix:disabled { border-color: var(--line); background: var(--panel2); color: var(--muted); opacity: 1; }
.btn.mix:disabled .ic { color: var(--muted); }
.status { text-align: center; color: var(--muted); font-size: 14px; min-height: 2.6em; }
.status b { color: var(--text); }

.next .row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.grow { flex: 1; min-width: 0; }
.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- offline readiness ---------- */
.prep-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 5px 9px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel2); color: var(--text); font-weight: 600; }
.bar { height: 6px; background: #121318; border-radius: 3px; margin: 10px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff3d2e, #ffc24a); transition: width .4s; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- queue ---------- */
.queue-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.queue-head h2 { font-size: 17px; margin: 6px 0; }
.queue-head > div { display: flex; gap: 8px; }
.count { color: var(--muted); font-weight: 400; font-size: 13px; }
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.queue li {
  display: grid; grid-template-columns: 22px 1fr auto auto; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 8px 6px 8px 10px;
}
.queue li.unready { opacity: .55; }
.queue .idx { color: var(--muted); font-size: 12px; }
.queue .right { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue .acts { display: flex; }
.queue .acts button { display: inline-grid; place-items: center; background: transparent; border: 0; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.queue .acts button:active { background: var(--panel2); color: var(--text); }
.dl { font-size: 12px; min-width: 30px; display: inline-flex; justify-content: flex-end; align-items: center; color: var(--muted); }
.dl .ic { width: 15px; height: 15px; }
.dl.ok { color: var(--good); }
.dl.err { color: var(--bad); }
.empty { color: var(--muted); text-align: center; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; }
.sheet-body {
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px);
  max-width: 560px; margin: 0 auto;
}
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; position: sticky; top: -12px; background: var(--bg); padding: 4px 0; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
.sheet-head input { flex: 1; }
input[type=search], input[type=url], select {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
  font-size: 16px; /* 16px — иначе Safari приближает страницу при вводе */
}
.results { list-style: none; margin: 0; padding: 0; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.results .acts { display: flex; gap: 6px; align-items: center; }
.results .acts button { display: inline-grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; height: 36px; width: 40px; color: var(--muted); cursor: pointer; }
.results .acts button:active { color: var(--text); background: #2a2e3a; }
.results .acts .ic { width: 17px; height: 17px; }
.setting { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.setting.check { flex-direction: row; align-items: center; gap: 10px; }
.setting.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.help { margin-top: 18px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.help b { color: var(--text); }

/* ---------- setup ---------- */
.setup { padding: 24px 20px; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.setup h1 { margin: 8px 0 0; font-size: 26px; }
.setup p { margin: 0; }
.err { color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translateX(-50%);
  background: #262a35; border: 1px solid #3a3f4d; border-radius: 12px; padding: 10px 14px; z-index: 30;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.4); font-size: 14px;
}
