:root {
  --bg: #ffffff;
  --bg2: #f2f2f2;
  --bg3: #e5e5e5;
  --fg: #0f0f0f;
  --fg2: #606060;
  --accent: #ff0033;
  --accent-fg: #ffffff;
  --sel: #fde8ea;
  --border: #e0e0e0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --bg2: #1f1f1f;
    --bg3: #303030;
    --fg: #f1f1f1;
    --fg2: #aaaaaa;
    --sel: #3a1d22;
    --border: #2a2a2a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  width: 400px;
  max-height: 590px;
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.notice {
  background: var(--accent);
  color: var(--accent-fg);
  padding: 6px 12px;
  font-size: 12px;
}

/* ---- now playing ---- */
.now { padding: 12px 12px 6px; border-bottom: 1px solid var(--border); flex: none; }
.now-top { display: flex; gap: 10px; align-items: flex-start; }
.np-thumb {
  width: 112px; height: 63px; border-radius: 8px; object-fit: cover;
  background: var(--bg2); flex: none;
}
.now.empty .np-thumb { visibility: hidden; width: 0; margin-right: -10px; }
.np-info { min-width: 0; flex: 1; }
.np-title {
  font-weight: 600; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.np-author { color: var(--fg2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-badges { margin-top: 4px; display: flex; gap: 4px; }
.badge {
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: var(--bg3); color: var(--fg);
}
.badge.red { background: var(--accent); color: var(--accent-fg); }
.badge.yellow { background: #f5c518; color: #000; }

.now.empty .seek-row, .now.empty .controls, .now.empty .vol-row { opacity: .4; pointer-events: none; }

.seek-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.time { font-variant-numeric: tabular-nums; color: var(--fg2); font-size: 11px; min-width: 34px; }
.time:last-child { text-align: right; }
input[type="range"] { flex: 1; accent-color: var(--accent); margin: 0; min-width: 0; }

.controls { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 4px; }
.icon {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; position: relative;
  flex: none;
}
.icon:hover { background: var(--bg2); }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
.icon svg text { fill: currentColor; }
.icon.big { width: 46px; height: 46px; background: var(--fg); color: var(--bg); }
.icon.big:hover { background: var(--fg); opacity: .85; }
.icon.big svg { width: 28px; height: 28px; }
.icon.small { width: 30px; height: 30px; }
.icon.small svg { width: 18px; height: 18px; }
.icon.toggle { color: var(--fg2); }
.icon.toggle.on { color: var(--accent); background: var(--sel); }
.loop-one {
  position: absolute; right: 3px; bottom: 2px; font-size: 9px; font-weight: 800; color: var(--accent);
}

.vol-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.vol-row input { max-width: 200px; }
#rate {
  margin-left: auto; background: var(--bg2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 4px; font: inherit; font-size: 12px;
}

/* ---- tabs ---- */
.tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.tab {
  flex: 1; background: transparent; border: 0; padding: 9px 0; font-weight: 600; color: var(--fg2);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--fg); border-bottom-color: var(--fg); }

.pane { flex: 1; min-height: 160px; overflow-y: auto; padding: 8px 0; }
.empty-msg { color: var(--fg2); padding: 14px 16px; text-align: center; }

/* ---- playlist ---- */
.pl-head { display: flex; align-items: center; gap: 4px; padding: 0 10px 6px 14px; }
.pl-titles { flex: 1; min-width: 0; }
.pl-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-pos { color: var(--fg2); font-size: 12px; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 10px; padding: 6px 12px; cursor: pointer; align-items: center;
}
.item:hover { background: var(--bg2); }
.item.selected { background: var(--sel); }
.item .idx { width: 22px; text-align: center; color: var(--fg2); font-size: 11px; flex: none; }
.item.selected .idx { color: var(--accent); }
.thumb {
  position: relative; width: 96px; height: 54px; flex: none; border-radius: 6px; overflow: hidden; background: var(--bg2);
}
.list.compact .thumb { width: 72px; height: 40px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .dur {
  position: absolute; right: 3px; bottom: 3px; background: rgba(0, 0, 0, .8); color: #fff;
  font-size: 10px; font-weight: 600; padding: 0 4px; border-radius: 3px;
}
.thumb .stack {
  position: absolute; inset: 0 0 0 auto; width: 40%; background: rgba(0, 0, 0, .7); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; gap: 1px;
  text-align: center; line-height: 1.1;
}
.thumb .stack svg { width: 16px; height: 16px; fill: #fff; }
.meta { min-width: 0; flex: 1; }
.meta .t {
  font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta .s { color: var(--fg2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.kind { font-size: 9.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }

/* ---- search ---- */
.search-form { display: flex; gap: 6px; padding: 2px 12px 8px; }
#q {
  flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  border-radius: 18px; padding: 7px 12px; font: inherit; outline: none;
}
#q:focus { border-color: #3ea6ff; }
.primary {
  border: 0; border-radius: 18px; padding: 0 14px; background: var(--fg); color: var(--bg); font-weight: 600;
}
.filters { display: flex; gap: 6px; padding: 0 12px 8px; }
.chip {
  border: 0; background: var(--bg2); border-radius: 8px; padding: 4px 10px; font-weight: 500; font-size: 12px;
}
.chip.active { background: var(--fg); color: var(--bg); }
.more {
  display: block; margin: 8px auto 4px; border: 1px solid var(--border); background: transparent;
  border-radius: 16px; padding: 5px 16px; font-weight: 600;
}

/* ---- remote status footer ---- */
.remote {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-top: 1px solid var(--border); font-size: 11.5px; color: var(--fg2);
}
.remote a { margin-left: auto; color: var(--fg2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #888; flex: none; }
.dot.connected { background: #2ba640; }
.dot.connecting { background: #f5a623; }
.dot.disconnected { background: var(--accent); }

/* =========================================================
   Web app overrides (popup.css above is shared styling)
   ========================================================= */
body {
  width: auto; max-height: none; min-height: 100vh; min-height: 100dvh;
  max-width: 640px; margin: 0 auto; overflow: visible;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
@media (max-width: 640px) { body { border: 0; } }

.top {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.brand { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.brand img { width: 20px; height: 20px; }
#agent {
  min-width: 0; max-width: 45%; background: var(--bg2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 6px; font: inherit;
}
.top .grow { flex: 1; }
.conn { font-size: 12px; color: var(--fg2); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.top form { margin: 0; }
.linkish { background: none; border: 0; color: var(--fg2); font-size: 12px; padding: 4px; }
.linkish:hover { color: var(--fg); text-decoration: underline; }

.now { position: sticky; top: 51px; background: var(--bg); z-index: 1; }
.np-thumb { width: 144px; height: 81px; }
@media (max-width: 420px) { .np-thumb { width: 112px; height: 63px; } }
.vol-row input { max-width: none; }

.tabs { position: sticky; z-index: 1; background: var(--bg); }
.pane { overflow: visible; min-height: 50vh; }
.item { padding: 8px 12px; }
.thumb { width: 128px; height: 72px; }
.list.compact .thumb { width: 96px; height: 54px; }

.machine-msg { padding: 32px 16px; text-align: center; color: var(--fg2); }
.machine-msg button { margin-top: 12px; }
.tab-info { font-size: 11.5px; color: var(--fg2); padding: 6px 12px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; border: 0; }
.login {
  width: 100%; max-width: 320px; padding: 24px; display: flex; flex-direction: column; gap: 4px;
}
.login h1 { font-size: 22px; margin: 0 0 12px; }
.login label { font-weight: 600; margin-top: 8px; }
.login input {
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); border-radius: 8px;
  padding: 9px 10px; font: inherit;
}
.login button { margin-top: 16px; padding: 10px; }
.login-error { background: var(--sel); color: var(--accent); padding: 8px 10px; border-radius: 8px; font-weight: 600; }
