:root {
  --ink: #0b0b0d;
  --surface: #141417;
  --surface-2: #1c1c21;
  --surface-3: #26262d;
  --outline: #34343c;
  --text: #f4f1ee;
  --muted: #a7a3a0;
  --orange: #ff5a1f;
  --red: #e3262e;
  --amber: #ffa23a;
  --ok: #4cd37a;
  --error: #ff6b6b;
  --fire: linear-gradient(100deg, var(--red), var(--orange) 60%, var(--amber));
  --radius: 20px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font: 400 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(11, 11, 13, .55), rgba(11, 11, 13, .2) 40%, rgba(11, 11, 13, .85)),
    url("/bg.webp") center / cover no-repeat;
}

h1, h2, .wordmark { font-family: Outfit, Inter, system-ui, sans-serif; letter-spacing: -.01em; }
h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.05; margin: 0 0 18px; font-weight: 800; }
h2 { font-size: 20px; margin: 0 0 16px; font-weight: 700; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.fire-text { background: var(--fire); -webkit-background-clip: text; background-clip: text; color: transparent; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.wordmark { font-size: 26px; font-weight: 800; }
.wordmark span { color: var(--orange); }
.tag {
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--amber); border: 1px solid rgba(255, 162, 58, .35); padding: 3px 9px; border-radius: 999px;
}

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 48px) 40px; }

.card {
  background: rgba(20, 20, 23, .9);
  border: 1px solid rgba(52, 52, 60, .7);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 28px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ------------------------------------------------ login */
.login { display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(24px, 5vw, 64px); align-items: center; min-height: 70vh; }
.lead { color: #d6d1cc; font-size: 17px; max-width: 540px; }
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: center; color: #e6e1dc; }
.steps span {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fire); color: #fff; font-weight: 700; font-size: 14px;
}
.login-card { border-image: none; position: relative; }
.login-card::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(130deg, rgba(255, 90, 31, .75), rgba(52, 52, 60, .6) 45%, rgba(227, 38, 46, .6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

/* ------------------------------------------------ forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field em { font-style: normal; font-weight: 400; opacity: .7; }
input, select {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--outline); border-radius: 12px; padding: 13px 14px; font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 90, 31, .18); }
input.mono { font-size: 20px; letter-spacing: .06em; text-transform: uppercase; }
input.key { color: var(--orange); letter-spacing: .3em; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  appearance: none; border: 0; cursor: pointer; font: 600 15px Inter, system-ui, sans-serif; color: #fff;
  border-radius: 14px; padding: 14px 22px; width: 100%; transition: transform .12s, filter .12s, opacity .12s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.fire { background: var(--fire); box-shadow: 0 10px 30px -12px rgba(255, 90, 31, .7); }
.btn.fire:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface-2); border: 1px solid var(--outline); width: auto; }
.btn.small { padding: 9px 16px; font-size: 14px; }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.alert { border-radius: 12px; padding: 11px 14px; font-size: 14px; margin: 4px 0 14px; }
.alert.error { background: rgba(255, 107, 107, .1); color: var(--error); border: 1px solid rgba(255, 107, 107, .3); }

/* ------------------------------------------------ dashboard */
.dashboard { display: grid; gap: 20px; }
.device { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; color: var(--amber); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.device h2 { font-size: 26px; margin: 0 0 14px; }
.device-facts { display: flex; flex-wrap: wrap; gap: 10px 32px; margin: 0; }
.device-facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.device-facts dd { margin: 2px 0 0; font-size: 17px; }
#device-key { color: var(--orange); letter-spacing: .2em; font-weight: 700; }
.status {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  background: rgba(255, 162, 58, .12); color: var(--amber);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.status.ok { background: rgba(76, 211, 122, .12); color: var(--ok); }

.grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; align-items: start; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.count { color: var(--muted); font-size: 13px; }

.playlists { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pl {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 16px; padding: 14px 14px 14px 16px;
}
.pl:hover { border-color: var(--outline); }
.pl-icon {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font: 700 12px Outfit, sans-serif;
  background: linear-gradient(135deg, rgba(227, 38, 46, .55), rgba(255, 90, 31, .35)); color: #fff; letter-spacing: .05em;
}
.pl-main { min-width: 0; }
.pl-name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); margin-right: 6px; vertical-align: 1px; }
.pill.hot { background: rgba(255, 90, 31, .16); color: var(--amber); }
.pl-actions { display: flex; gap: 6px; }
.icon-btn {
  appearance: none; border: 1px solid var(--outline); background: transparent; color: var(--muted); cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--text); border-color: #4a4a54; }
.icon-btn.danger:hover { color: var(--error); border-color: rgba(255, 107, 107, .5); }
.icon-btn svg { width: 18px; height: 18px; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px 10px; }
.empty img { opacity: .8; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 18px; }
.tab { appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 14px Inter, sans-serif; padding: 10px 6px; border-radius: 10px; cursor: pointer; }
.tab.active { background: var(--fire); color: #fff; }

.drop {
  display: grid; place-items: center; text-align: center; gap: 4px; cursor: pointer;
  border: 1.5px dashed #4a4a54; border-radius: 16px; padding: 26px 16px; margin-bottom: 14px; background: rgba(11, 11, 13, .5);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--orange); background: rgba(255, 90, 31, .06); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { font-size: 16px; }
.drop span { color: var(--muted); font-size: 13px; }
.drop.has-file strong { color: var(--amber); }

.more { margin: 2px 0 14px; color: var(--muted); }
.more summary { cursor: pointer; font-size: 14px; margin-bottom: 10px; }

.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 14px; }
.progress div { height: 100%; width: 0; background: var(--fire); transition: width .15s; }

.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid rgba(255, 90, 31, .2); border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--surface-3); border: 1px solid var(--outline); color: var(--text);
  padding: 12px 18px; border-radius: 14px; box-shadow: 0 20px 40px -12px rgba(0, 0, 0, .7); max-width: calc(100% - 32px);
}

footer { text-align: center; color: #75716e; font-size: 12px; padding: 20px 16px 28px; }

/* ------------------------------------------------ accounts + devices */
.account { display: flex; align-items: center; gap: 12px; }
.account-email { color: var(--muted); font-size: 14px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two-tabs { grid-template-columns: 1fr 1fr; }
.alert.info { background: rgba(255, 162, 58, .1); color: var(--amber); border: 1px solid rgba(255, 162, 58, .3); }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; }
.link { appearance: none; background: none; border: 0; padding: 0; color: var(--amber); font: 500 14px Inter, sans-serif; cursor: pointer; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); margin: 0 0 16px; }

.device-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.device-tabs { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.device-tab {
  appearance: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  background: rgba(20, 20, 23, .9); border: 1px solid var(--outline); color: var(--muted);
  border-radius: 14px; padding: 10px 14px; font: 600 14px Inter, sans-serif;
}
.device-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.device-tab .dot.ok { background: var(--ok); }
.device-tab.active { color: #fff; border-color: rgba(255, 90, 31, .7); background: rgba(255, 90, 31, .12); }
.device-tab:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.add-device-btn { white-space: nowrap; }
.add-device .device-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; align-items: end; }
.add-device .device-form .btn { width: auto; margin-bottom: 14px; }
.add-device .device-form .alert { grid-column: 1 / -1; }
.empty-card { text-align: center; display: grid; justify-items: center; gap: 4px; padding: 40px 20px; }
.empty-card .btn { width: auto; }
.device-side { display: grid; justify-items: end; gap: 12px; }
.device-actions { display: flex; gap: 8px; }
.btn.danger:hover { color: var(--error); border-color: rgba(255, 107, 107, .5); }
#device-panel { display: grid; gap: 20px; }
#device-panel[hidden] { display: none !important; }

@media (max-width: 900px) {
  .add-device .device-form { grid-template-columns: 1fr; }
  .add-device .device-form .btn { width: 100%; }
  .device-side { justify-items: start; }
  .login { grid-template-columns: 1fr; min-height: auto; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .account-email { display: none; }
  .two { grid-template-columns: 1fr; }
  .tag { display: none; }
  .pl { grid-template-columns: 1fr auto; }
  .pl-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.pl.editing { border-color: var(--orange); background: rgba(255, 90, 31, .08); }
