:root {
  --bg: #fffeed;
  --accent: #ff6600;
  --accent-ink: #ffffff;
  --ink: #1b1b1b;
  --muted: #6b6b63;
  --card: #ffffff;
  --line: #ece9d6;
  --ok: #1f9d55;
  --err: #d1443b;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0,0,0,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: contain;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen { flex: 1; display: flex; flex-direction: column; animation: fade .28s ease; }
.screen-center { align-items: center; justify-content: center; padding: 24px; text-align: center; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- code entry ---- */
.card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 30px 24px 26px;
}
.brand { font-weight: 800; letter-spacing: .14em; font-size: .82rem; color: var(--muted); }
.brand span { color: var(--accent); }
h1 { font-size: 1.7rem; margin: .5rem 0 .35rem; }
.sub { color: var(--muted); margin: 0 0 1.25rem; line-height: 1.45; }

#code-form { display: flex; flex-direction: column; gap: 12px; }
.code-input {
  font-size: 1.7rem; text-align: center; letter-spacing: .35em;
  padding: 14px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); outline: none; transition: border-color .15s;
}
.code-input::placeholder { letter-spacing: .1em; color: #c9c6b5; }
.code-input:focus { border-color: var(--accent); }

.btn {
  font-size: 1.05rem; font-weight: 700; padding: 14px 18px;
  border: none; border-radius: 12px; cursor: pointer;
  transition: transform .08s ease, filter .15s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.03); }

/* Center via a WRAPPER — never style the .cf-turnstile element itself, or its
   injected iframe collapses to 0 width and the challenge never runs. */
.ts-wrap { display: flex; justify-content: center; min-height: 65px; margin: 4px 0 2px; }
.error { color: var(--err); font-size: .95rem; margin: .9rem 0 0; }
.foot { margin-top: 22px; color: var(--muted); font-size: .78rem; opacity: .8; }
.logo { width: 62px; height: 62px; border-radius: 16px; display: block; margin: 2px auto 14px; box-shadow: 0 5px 16px rgba(255,102,0,.28); }

.topbar-brand { font-weight: 800; letter-spacing: .03em; font-size: 1.02rem; color: #fff; }
.topbar-brand span { color: #ffe4cc; }
.search-help { margin: 9px 6px 0; color: var(--muted); font-size: .82rem; text-align: center; line-height: 1.4; }
.plus-hint { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: var(--accent); color: #fff; border-radius: 50%; font-size: .85rem; vertical-align: -4px; }

/* ---- search ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  background: var(--accent); color: var(--accent-ink);
}
.topbar-title { font-weight: 800; font-size: 1.15rem; }
.quota { font-size: .82rem; font-weight: 600; opacity: .95; }

.search-wrap { padding: 14px 16px 8px; position: sticky; top: 0; background: var(--bg); }
.search-input {
  width: 100%; font-size: 1.05rem; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
  color: var(--ink); outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }

.results { list-style: none; margin: 0; padding: 4px 12px 40px; }
.result {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 14px; background: #fff;
  border: 1px solid var(--line); margin-bottom: 10px;
  animation: fade .2s ease;
}
.result .art {
  width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  background: #eee; flex: none;
}
.result .meta { flex: 1; min-width: 0; }
.result .title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .artist { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .badge-e { font-size: .62rem; font-weight: 700; color: #999; border: 1px solid #ccc; border-radius: 3px; padding: 0 3px; margin-left: 6px; vertical-align: middle; }
.add-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; font-size: 1.6rem; line-height: 1;
  cursor: pointer; transition: transform .08s, filter .15s;
}
.add-btn:active { transform: scale(.9); }
.add-btn:disabled { background: var(--ok); }

.hint, .empty { text-align: center; color: var(--muted); padding: 40px 24px; line-height: 1.5; }

/* ---- search dropdown (overlays the board while typing) ---- */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--bg); border-top: 1px solid var(--line);
  max-height: 66vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-shadow: 0 14px 22px rgba(0,0,0,.14);
  animation: fade .16s ease;
}
.search-dropdown .results { padding: 8px 12px 14px; }

/* ---- always-on board: now playing + up next ---- */
.feed { padding: 12px 16px calc(env(safe-area-inset-bottom) + 40px); }
.feed-now {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.fn-art { width: 62px; height: 62px; border-radius: 10px; object-fit: cover; background: #eee; flex: none; }
.fn-meta { min-width: 0; }
.fn-label { font-size: .66rem; font-weight: 800; letter-spacing: .1em; color: var(--accent); text-transform: uppercase; }
.fn-name { font-weight: 800; font-size: 1.1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.fn-artist { color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-h { font-weight: 800; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 4px 10px; }
.feed-next { list-style: none; margin: 0; padding: 0; }
.fnx { display: flex; align-items: center; gap: 12px; padding: 7px 4px; animation: fade .2s ease; }
.fnx-num { width: 18px; text-align: center; font-weight: 800; color: var(--accent); flex: none; font-size: .9rem; }
.fnx-art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #eee; flex: none; }
.fnx-meta { min-width: 0; }
.fnx-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fnx-artist { color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%); z-index: 50;
  max-width: 90%; padding: 13px 20px; border-radius: 999px;
  font-weight: 600; color: #fff; box-shadow: var(--shadow);
  animation: pop .25s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.info { background: #333; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- queue button + overlay ---- */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.queue-btn {
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.55);
  font-weight: 700; font-size: .9rem; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: background .15s, transform .08s;
}
.queue-btn:active { transform: scale(.96); }
.queue-btn:hover { background: rgba(255,255,255,.28); }

.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 82dvh;
  background: var(--bg); border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.22);
  display: flex; flex-direction: column;
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  animation: slideup .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px;
}
.sheet-title { font-weight: 800; font-size: 1.2rem; }
.close-btn {
  background: none; border: none; font-size: 1.2rem; color: var(--muted);
  cursor: pointer; padding: 6px 10px; border-radius: 8px; line-height: 1;
}
.close-btn:active { background: rgba(0,0,0,.06); }
.sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: 4px; }

.nowplaying {
  display: flex; align-items: center; gap: 12px;
  margin: 2px 16px 6px; padding: 12px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line);
}
.nowplaying .np-art { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: #eee; flex: none; }
.nowplaying .meta { min-width: 0; }
.np-label { font-size: .68rem; font-weight: 800; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
.np-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-num { flex: none; width: 24px; text-align: center; font-weight: 800; color: var(--accent); }
.q-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-weight: 600; padding: 48px 24px; }
.spin-dark { display: inline-block; width: 22px; height: 22px; border: 3px solid rgba(0,0,0,.12); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; }

/* spinner */
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ===== Manager / DJ console ===== */
.mgr-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; }
.mgr-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.mgr-h { font-weight: 800; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }

.nowcard { display: flex; flex-direction: column; text-align: center; }
.np-big-art { width: 168px; height: 168px; border-radius: 14px; object-fit: cover; background: #eee; margin: 4px auto 14px; box-shadow: 0 6px 20px rgba(0,0,0,.14); }
.np-big-name { font-weight: 800; font-size: 1.25rem; line-height: 1.2; }
.np-big-artist { color: var(--muted); margin-top: 3px; }
.np-context { color: var(--accent); font-size: .8rem; font-weight: 700; margin-top: 6px; min-height: 1em; }

.scrub-row { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; }
.scrub-time { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; }
.seek { flex: 1; accent-color: var(--accent); height: 22px; }

.transport { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 4px; }
.tp-btn { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 1.25rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform .08s, background .15s; }
.tp-btn:active { transform: scale(.92); }
.tp-btn.active { background: #fff2e8; border-color: var(--accent); }
.tp-play { width: 66px; height: 66px; background: var(--accent); color: #fff; border: none; font-size: 1.5rem; }

.vol-row { display: flex; align-items: center; gap: 8px; margin: 14px auto 0; max-width: 250px; }
.vol-ico { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 4px; width: 30px; line-height: 1; transition: transform .08s; }
.vol-ico:active { transform: scale(.88); }
.seek.vol { height: 14px; }
.vol-val { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #fff2e8; color: #b34700; border: 1px solid #ffd9bd; border-radius: 999px; padding: 9px 14px; font-weight: 700; font-size: .9rem; cursor: pointer; transition: transform .08s, background .15s; }
.chip:active { transform: scale(.96); }
.chip:hover { background: #ffe4cc; }

.results.tight { padding: 0; margin-top: 4px; }
.results.tight .result { margin-bottom: 8px; }
.m-actions { display: flex; gap: 6px; flex: none; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 11px; font-weight: 700; font-size: .82rem; cursor: pointer; color: var(--ink); transition: transform .08s, background .15s; }
.mini-btn:active { transform: scale(.95); }
.mini-btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }

.mgr-devices { display: flex; flex-direction: column; gap: 8px; }
.device { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; text-align: left; transition: background .15s; }
.device.active { border-color: var(--accent); background: #fff2e8; cursor: default; }
.device .badge { font-size: .68rem; font-weight: 800; color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 9px; }

.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.admin-row:first-of-type { border-top: none; }
.admin-right { display: flex; align-items: center; gap: 10px; }
.code-pill { font-size: 1.15rem; letter-spacing: .12em; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

.toggle { position: relative; width: 52px; height: 30px; border-radius: 999px; border: none; background: #d8d5c4; cursor: pointer; transition: background .18s; flex: none; }
.toggle.on { background: var(--accent); }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle.on .knob { transform: translateX(22px); }

.hint.small { padding: 8px 0; font-size: .85rem; text-align: left; }
