:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --panel-2: #181c26;
  --panel-3: #1f2430;
  --line: #252b38;
  --ink: #eef1f6;
  --muted: #8b93a5;
  --faint: #5d6576;
  --accent: #5b8cff;
  --accent-2: #3f6fe6;
  --accent-soft: rgba(91, 140, 255, .14);
  --ok: #3ecf8e;
  --warn: #f5a524;
  --danger: #ff5b5b;
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.side { display: none; }
.main { padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px); max-width: 1280px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 52px; margin-bottom: 8px; }
.topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; flex: 1; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.conn.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(62, 207, 142, .15); }

.tabbar {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: rgba(14, 16, 22, .86);
  backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px); border-top: 1px solid var(--line);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--faint); font-size: 11px; font-weight: 500; cursor: pointer; }
.tab svg.i { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .side { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--panel); }
  .side .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 10px 22px; }
  .side .logo img { width: 28px; height: 28px; border-radius: 8px; }
  .side .tab { flex: none; flex-direction: row; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14.5px; color: var(--muted); }
  .side .tab:hover { background: var(--panel-2); color: var(--ink); }
  .side .tab.on { background: var(--accent-soft); color: var(--ink); }
  .side .tab.on svg { color: var(--accent); }
  .side .spacer { flex: 1; }
  .tabbar { display: none; }
  .main { padding: 24px 32px 120px; width: 100%; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-weight: 600; font-size: 14.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); outline: none; font-size: 16px;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.4; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 12.5px; color: var(--faint); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.seg { display: flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1; min-width: max-content; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--panel-3); color: var(--ink); }
.seg svg.i { width: 17px; height: 17px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--panel-2); cursor: pointer; font-size: 18px; }
.stepper output { min-width: 40px; text-align: center; font-weight: 600; }

/* ---------- screens ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid rgba(91, 140, 255, .3); margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.card { position: relative; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .thumb { position: relative; aspect-ratio: 16 / 9; background: #07080b; display: grid; place-items: center; overflow: hidden; cursor: pointer; }
.card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .thumb .glyph { display: grid; justify-items: center; gap: 6px; color: var(--faint); font-size: 12.5px; text-align: center; padding: 0 14px; }
.card .thumb .glyph svg.i { width: 30px; height: 30px; }
.card .thumb.off::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.card .body { display: flex; align-items: center; gap: 10px; padding: 11px 12px 12px 14px; }
.card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .now { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); }
.check {
  position: absolute; z-index: 2; top: 10px; left: 10px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; border: 2px solid rgba(255, 255, 255, .75); background: rgba(0, 0, 0, .35); color: #fff; cursor: pointer;
  backdrop-filter: blur(6px);
}
.check svg.i { width: 16px; height: 16px; stroke-width: 3; opacity: 0; }
.sel .check { background: var(--accent); border-color: var(--accent); }
.sel .check svg.i { opacity: 1; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: var(--panel-3); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.badge.live { background: rgba(255, 91, 91, .16); color: #ff8a8a; }
.tag-wall { position: absolute; z-index: 2; top: 10px; right: 10px; }

.actionbar {
  position: fixed; z-index: 45; left: 12px; right: 12px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 10px);
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-radius: 16px;
  background: rgba(31, 36, 48, .94); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: rise .2s ease;
}
@media (min-width: 900px) { .actionbar { left: calc(232px + 32px); right: 32px; bottom: 24px; max-width: 760px; margin: 0 auto; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

.sharing {
  position: fixed; z-index: 46; top: calc(env(safe-area-inset-top) + 10px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 99px;
  background: #2a1416; border: 1px solid rgba(255, 91, 91, .45); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: 13.5px; font-weight: 600;
}
.sharing .rec { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- walls ---------- */
.wall-grid { display: grid; gap: 4px; padding: 4px; border-radius: 12px; background: #07080b; }
.wall-cell { aspect-ratio: 16 / 9; border-radius: 6px; background: var(--panel-2); display: grid; place-items: center; text-align: center; padding: 4px; font-size: 11.5px; color: var(--muted); overflow: hidden; }
.wall-cell.set { background: var(--accent-soft); color: var(--ink); border: 1px solid rgba(91, 140, 255, .35); }
button.wall-cell { border: 1px dashed var(--line); cursor: pointer; font-size: 12.5px; }
button.wall-cell.set { border-style: solid; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- library ---------- */
.media-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(46%, 170px), 1fr)); }
.media { position: relative; border-radius: 12px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-align: left; padding: 0; }
.media .mthumb { aspect-ratio: 16 / 10; background: #07080b; display: grid; place-items: center; color: var(--faint); }
.media .mthumb img, .media .mthumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media .mname { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media .mname small { display: block; color: var(--faint); }
.media.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.media .order { position: absolute; top: 8px; left: 8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.media .kind { position: absolute; top: 8px; right: 8px; }
.uploads { display: grid; gap: 8px; margin-bottom: 14px; }
.upload { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.bar { height: 4px; border-radius: 4px; background: var(--panel-3); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* ---------- lists ---------- */
.list { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.item .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-3); display: grid; place-items: center; color: var(--muted); flex: none; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty svg.i { width: 36px; height: 36px; color: var(--faint); margin-bottom: 8px; }
.empty p { margin: 6px 0 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; margin: 22px 0 10px; }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .5); animation: up .25s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 19px; flex: 1; letter-spacing: -.01em; }
.sheet-body { padding: 8px 20px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px calc(env(safe-area-inset-bottom) + 14px); border-top: 1px solid var(--line); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(640px, calc(100vw - 48px)); max-height: 86dvh; border-radius: 20px; border-bottom: 1px solid var(--line); animation: pop .2s ease; }
  @keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }
}
.targets { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); margin-bottom: 14px; font-size: 13.5px; }
.targets b { font-weight: 600; }
.pick { display: grid; gap: 8px; }
.pick label { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.pick input { width: 20px; height: 20px; accent-color: var(--accent); }

.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; padding: 10px 12px; border-radius: 10px; background: #07080b; border: 1px solid var(--line); word-break: break-all; user-select: all; }
.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin-bottom: 8px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); text-align: center; }
.login-card img { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }

#toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 84px); transform: translateX(-50%) translateY(20px);
  padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }
@media (min-width: 900px) { #toast { bottom: 100px; } }

/* ---------- now playing ---------- */
.np-list { display: grid; gap: 10px; margin-bottom: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.np { padding: 14px; border-radius: var(--radius); background: linear-gradient(180deg, #161b28, var(--panel)); border: 1px solid var(--line); }
.np .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.np-bar { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.np-range { flex: 1; min-width: 0; height: 28px; accent-color: var(--accent); background: transparent; }
.np-btns { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 4px; }
.np-btns .icon-btn { color: var(--ink); }
.np-play { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; cursor: pointer; }
.np-play svg.i { width: 22px; height: 22px; fill: currentColor; }
.np-play:active { transform: scale(.95); }
