:root {
  --bg: #f4f5f8; --card: #ffffff; --text: #14161c; --muted: #6b7080; --line: #e3e5ec;
  --accent: #2f6df6; --accent-text: #ffffff; --good: #13783c; --warn: #8f5500; --bad: #c42d36;
  --left: #2f6df6; --right: #c42d36; --both: #8b4fd8;
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0d12; --card: #161a22; --text: #eef0f5; --muted: #9298a8; --line: #262b36;
          --accent: #5b8cff; --accent-text: #0b0d12; --warn: #f0a640; --good: #3ec77a; --bad: #ff6b73; --right: #ff6b73; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.screen { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1 { font-size: 30px; margin: 8px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
p { margin: 0; }
b { font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 1 1 180px; }
.hint, .footnote { font-size: 13px; color: var(--muted); margin-top: 10px; }
.footnote { text-align: center; padding: 0 8px; }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; }

button, .button {
  font: inherit; font-weight: 500; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  background: var(--line); color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; text-align: center;
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.big { width: 100%; padding: 15px; font-size: 17px; }
button.on { background: var(--accent); color: var(--accent-text); }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible, .button:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

input { font: inherit; color: var(--text); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .join input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
.join { display: flex; gap: 8px; }
.field input::placeholder, .join input::placeholder { color: var(--muted); opacity: 1; }
.join input { text-transform: uppercase; letter-spacing: .3em; font-weight: 600; text-align: center; font-size: 20px; }
.join button { flex: none; width: 96px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 0 12px; position: relative; }
.or::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.or span { background: var(--card); padding: 0 10px; position: relative; }

.hero { text-align: center; padding: 24px 8px 8px; }
.hero p { color: var(--muted); }
.logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo svg { width: 48px; height: 48px; --card: var(--accent); }
.how ol { margin: 0; padding-left: 20px; }
.how li { margin: 8px 0; }

.bar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 3; background: var(--bg);
       margin: calc(-12px - env(safe-area-inset-top)) -16px 0; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; }
.code-label { font-size: 12px; color: var(--muted); }
.code { font-size: 24px; font-weight: 700; letter-spacing: .12em; }
.status { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.status.ok .dot { background: var(--good); }
.status.bad .dot { background: var(--bad); }

.notice { background: color-mix(in srgb, var(--warn) 16%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }

.invite { display: flex; gap: 16px; align-items: center; }
.qr { flex: none; width: 132px; height: 132px; background: #fff; border-radius: 12px; padding: 8px; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.invite-text p { font-size: 14px; color: var(--muted); margin-bottom: 10px; word-break: break-word; }
@media (max-width: 360px) { .invite { flex-direction: column; text-align: center; } .invite .row { justify-content: center; } }

.player { text-align: center; }
.track-title { font-size: 20px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-sub { color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 0; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.transport { display: flex; justify-content: center; align-items: center; gap: 22px; margin-top: 8px; }
.round { width: 52px; height: 52px; border-radius: 50%; padding: 0; }
.round svg { width: 24px; height: 24px; fill: currentColor; }
.round.huge { width: 68px; height: 68px; }
.round.huge svg { width: 32px; height: 32px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.track { display: flex; align-items: center; gap: 10px; }
.track button.select { flex: 1; justify-content: flex-start; background: none; padding: 0; min-height: 0; text-align: left; font-weight: 500; }
.track.current button.select { color: var(--accent); font-weight: 650; }
.track .len { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.track .remove { background: none; color: var(--muted); padding: 0 6px; min-height: 32px; }
.count { color: var(--muted); font-size: 13px; }

.device-head { display: flex; align-items: center; gap: 10px; }
.device-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--line); flex: none; font-size: 18px; }
.device-name { font-weight: 600; }
.device-name small { color: var(--muted); font-weight: 400; }
.device-sub { font-size: 13px; color: var(--muted); }
.device-sub .ok { color: var(--good); }
.device.offline { opacity: .5; }
.slider { display: grid; grid-template-columns: 58px 1fr 64px; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.slider output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; margin-top: 10px; }
.seg button { flex: 1; background: transparent; padding: 6px; min-height: 34px; border-radius: 8px; font-size: 14px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.seg button.on[data-channel=left] { color: var(--left); }
.seg button.on[data-channel=right] { color: var(--right); }
.sync-status { font-size: 14px; margin-top: 10px; }
.sync-status.done { color: var(--good); }
.sync-status.warn, .sync-status.failed { color: var(--warn); }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay .card { width: min(420px, 100%); text-align: center; }
.overlay p { color: var(--muted); margin: 6px 0 16px; }
