:root {
  --bg: #111318; --panel: #1a1d24; --panel2: #232730; --line: #2d323d;
  --fg: #e8eaf0; --muted: #8e95a5; --accent: #ff8a1f; --accent2: #ffb366;
  --ok: #4cc38a; --warn: #f2c14e; --bad: #ef6b73; --spotify: #1db954;
  --header: rgba(17,19,24,.92); --desc: #c9ceda; --on-accent: #1a1000;
  --radius: 14px;
  color-scheme: dark;
}
/* light palette: chosen explicitly (data-theme=light), or by the system (class sys-light, set by app.js) */
:root[data-theme=light], :root:not([data-theme=dark]).sys-light {
  --bg: #f3f4f8; --panel: #ffffff; --panel2: #e9ebf1; --line: #d6dae3;
  --fg: #171a21; --muted: #5f6677; --accent: #ea7a12; --accent2: #b85a00;
  --ok: #1e9a5a; --warn: #a3720a; --bad: #cf3a44; --spotify: #169c47;
  --header: rgba(243,244,248,.92); --desc: #2a2f3a; --on-accent: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* beat .item's display:flex and friends */
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent2); text-decoration: none; }
button, input, select { font: inherit; }
header.top { position: sticky; top: 0; z-index: 5; background: var(--header); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 8px) 14px 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .3px; color: var(--fg); padding-bottom: 6px; }
.brand b { font-weight: inherit; }
.brand span { color: var(--accent); }
.brand img { width: 26px; height: 26px; border-radius: 7px; display: block; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
nav { display: flex; gap: 4px; overflow-x: auto; align-items: stretch; }
nav .grow { flex: 1; }
nav a.cog { display: flex; align-items: center; padding: 6px 8px; }
nav a.cog svg { display: block; }
nav a.cog.active { color: var(--accent2); }
nav a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
nav a.active { color: var(--fg); border-color: var(--accent); }
main { padding: 14px 14px calc(env(safe-area-inset-bottom) + 40px); max-width: 760px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: var(--fg); }
.item:active { background: var(--panel2); }
.item img, .art { width: 56px; height: 56px; border-radius: 10px; background: var(--panel2); object-fit: cover; flex: none; }
.art.big { width: 84px; height: 84px; border-radius: 14px; }
.showHead { display: flex; gap: 12px; align-items: center; margin: 4px 0 2px; }
.showHead h1 { font-size: 20px; line-height: 1.2; margin: 0 0 4px; }
.showHead p { margin: 0; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.menu button.danger { color: var(--bad); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub.wrap { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: rgba(76,195,138,.4); }
.badge.warn { color: var(--warn); border-color: rgba(242,193,78,.4); }
.badge.bad { color: var(--bad); border-color: rgba(239,107,115,.4); }
.badge.acc { color: var(--accent2); border-color: rgba(255,138,31,.5); }
.badge.spot { color: var(--spotify); border-color: rgba(29,185,84,.5); }
.badge.auto { color: var(--ok); border-color: rgba(76,195,138,.4); border-style: dashed; }
button, .btn { background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.spotify { background: var(--spotify); color: #06220f; border-color: var(--spotify); }
button.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .5; }
input[type=text], input[type=password], input[type=search], select { width: 100%; background: var(--panel); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
form.inline { display: flex; gap: 8px; }
.desc { white-space: pre-wrap; color: var(--desc); font-size: 15px; }
.ep { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.ep .t { font-weight: 650; }
.ep .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.ep .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ep .desc { margin-top: 8px; font-size: 14px; }
.ep.on { border-color: rgba(76,195,138,.5); }
.ep.done { opacity: .6; }
.epl { display: flex; gap: 10px; align-items: flex-start; }
.epl .epArt { flex: none; }
.epl .epArt img, .epl .epArt .art { width: 48px; height: 48px; border-radius: 9px; display: block; }
.epl .epShow { display: block; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.epl .epShow:hover { color: var(--accent2); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 34px; letter-spacing: 6px; text-align: center; margin: 10px 0; color: var(--accent2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--panel2); color: var(--fg); padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 20; max-width: 90vw; }
.login { max-width: 360px; margin: 60px auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.center { text-align: center; }
.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tabs button.active { border-color: var(--accent); color: var(--accent2); }

details > summary { cursor: pointer; list-style: none; margin: 22px 0 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '▸ '; color: var(--muted); }
details[open] > summary::before { content: '▾ '; }
details > summary h2 { margin: 0; }

/* sync log console */
.console { background: #0c0e12; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.console-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.console-bar .tabs { margin: 0; flex-wrap: wrap; }
.console-bar input[type=search] { flex: 1; min-width: 140px; padding: 6px 10px; font-size: 14px; }
.console-body { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; padding: 6px 0; max-height: 60vh; overflow: auto; }
.console-day { color: var(--muted); padding: 6px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.console-line { display: flex; gap: 10px; padding: 2px 12px; border-left: 3px solid transparent; }
.console-line:hover { background: rgba(255,255,255,.03); }
.console-line .t { color: var(--muted); flex: none; }
.console-line .k { flex: none; width: 52px; font-weight: 700; text-transform: uppercase; font-size: 11px; padding-top: 1px; }
.console-line .m { flex: 1; min-width: 0; color: #d7dbe5; word-break: break-word; }
.console-line .x { display: block; color: var(--muted); font-size: 11.5px; }
.console-line.sync { border-left-color: var(--accent); } .console-line.sync .k { color: var(--accent2); }
.console-line.report { border-left-color: var(--ok); } .console-line.report .k { color: var(--ok); }
.console-line.feed .k { color: #7aa2f7; }
.console-line.pair { border-left-color: var(--ok); } .console-line.pair .k { color: var(--ok); }
.console-line.bad { border-left-color: var(--bad); background: rgba(239,107,115,.06); } .console-line.bad .k, .console-line.bad .m { color: var(--bad); }
.console-line .who { color: var(--accent2); font-weight: 700; }
.console-line.download .k { color: #c3a6ff; }

.libRow { gap: 8px; position: relative; }
.libRow .item { flex: 1; min-width: 0; padding-right: 64px; }
/* small switch in the card's top-right corner, its state written underneath */
.autoSwitch { position: absolute; top: 10px; right: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 48px; }
.autoSwitch .lbl { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }
.autoSwitch.on .lbl { color: var(--ok); }
.autoSwitch.inline { position: static; flex-direction: row; gap: 8px; width: auto; }
.autoSwitch.inline .lbl { font-size: 12.5px; }
.spotMark { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--spotify); color: #fff; display: flex; align-items: center; justify-content: center; }
.switch { position: relative; width: 40px; height: 24px; padding: 0; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: left .15s, background .15s; }
.switch.on { background: rgba(76,195,138,.25); border-color: rgba(76,195,138,.6); }
.switch.on .knob { left: 18px; background: var(--ok); }
.watchToggle { flex: none; width: 68px; padding: 6px 0; font-size: 12.5px; border-radius: 8px; text-align: center; white-space: nowrap; }
.watchToggle.on { background: rgba(76,195,138,.15); color: var(--ok); border-color: rgba(76,195,138,.5); }

/* compact list toolbar: quick filter + sort + overflow menu, then one segmented filter row */
.status { margin: 4px 0 10px; line-height: 1.5; }
.help { display: inline-block; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 12px; line-height: 18px; text-align: center; color: var(--muted); vertical-align: 1px; margin-left: 4px; }
.toolbar { position: relative; display: flex; gap: 6px; align-items: center; margin: 8px 0 6px; }
.toolbar input[type=search] { flex: 1; min-width: 0; padding: 8px 12px; font-size: 14px; }
.toolbar select { width: auto; flex: none; max-width: 42vw; padding: 8px 28px 8px 10px; font-size: 13px; font-weight: 600; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238e95a5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.toolbar .icon { flex: none; width: 38px; padding: 8px 0; text-align: center; font-size: 16px; line-height: 1; border-radius: 10px; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: flex; flex-direction: column; min-width: 180px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.menu button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.menu button:hover, .menu button:active { background: var(--panel); }
.seg { display: flex; gap: 2px; padding: 3px; margin: 0 0 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-width: 0; padding: 6px 8px; font-size: 13px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); white-space: nowrap; }
.seg button b { font-weight: 600; opacity: .7; font-size: 12px; margin-left: 2px; }
.seg button.active { background: var(--panel2); color: var(--accent2); }
.seg button.active b { opacity: .9; }
.tabs .grow { flex: 1; }
.console-line.debug .k { color: #8e95a5; }
.console-line.recode .k { color: #f2c14e; }
