:root {
  color-scheme: dark;
  --bg: #090d0b;
  --surface: rgba(20, 27, 23, 0.88);
  --surface-strong: #171e1a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7f5;
  --muted: #9aa69f;
  --green: #1ed760;
  --green-soft: #83f2aa;
  --mint: #91e9d0;
  --amber: #f2c879;
  --danger: #ff8f8f;
  --radius: 24px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -8%, rgba(30, 215, 96, 0.12), transparent 34rem),
    linear-gradient(180deg, #0b100d 0%, #080b09 100%);
  color: var(--text);
  overflow-x: hidden;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.ambient { position: fixed; border-radius: 50%; filter: blur(90px); pointer-events: none; opacity: .12; }
.ambient-one { width: 280px; height: 280px; background: var(--green); top: 28%; left: -180px; }
.ambient-two { width: 220px; height: 220px; background: #4da6ff; bottom: 5%; right: -150px; }

.app-shell { width: min(100%, 760px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px calc(40px + env(safe-area-inset-bottom)); position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-size: .82rem; font-weight: 760; letter-spacing: .13em; text-transform: uppercase; }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--green); display: grid; place-content: center; gap: 3px; }
.brand-mark span { display: block; width: 17px; height: 2px; border-radius: 8px; background: #071108; transform: rotate(7deg); }
.brand-mark span:nth-child(2) { width: 14px; }
.brand-mark span:nth-child(3) { width: 11px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.035); color: var(--muted); cursor: pointer; }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero-card, .section-card, .login-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(27,36,31,.95), rgba(15,21,18,.92)); box-shadow: 0 24px 60px rgba(0,0,0,.24); }
.hero-card { padding: 22px; overflow: hidden; position: relative; }
.hero-card::before { content: ""; position: absolute; width: 250px; height: 250px; background: radial-gradient(circle, rgba(30,215,96,.15), transparent 68%); top: -140px; right: -80px; pointer-events: none; }
.hero-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; }
.state-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid rgba(30,215,96,.25); color: var(--green-soft); background: rgba(30,215,96,.08); border-radius: 999px; padding: 8px 12px; font-size: .76rem; font-weight: 750; letter-spacing: .04em; }
.state-pill.idle { color: var(--mint); background: rgba(145,233,208,.07); border-color: rgba(145,233,208,.22); }
.state-pill.checking { color: var(--muted); background: rgba(255,255,255,.04); border-color: var(--line); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.last-checked { color: var(--muted); font-size: .76rem; }
.hero-main { display: grid; grid-template-columns: 112px 1fr; gap: 22px; align-items: center; margin: 28px 0; position: relative; }
.album-art { width: 112px; aspect-ratio: 1; border-radius: 20px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(145deg, #26312b, #111713); box-shadow: 0 18px 42px rgba(0,0,0,.32); }
.album-art.playing { animation: artGlow 3s ease-in-out infinite alternate; }
@keyframes artGlow { to { box-shadow: 0 18px 45px rgba(30,215,96,.18); } }
.album-art img { width: 100%; height: 100%; object-fit: cover; }
.album-art svg { width: 46px; fill: none; stroke: #718078; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { color: var(--green-soft); font-size: .68rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.track-copy h1 { font-size: clamp(1.35rem, 6vw, 2.2rem); line-height: 1.12; margin: 8px 0 6px; letter-spacing: -.035em; }
.track-copy p { color: var(--muted); margin: 0; line-height: 1.5; }
.device-strip { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; }
.device-strip span:not(.device-icon) { color: var(--muted); display: block; font-size: .72rem; margin-bottom: 3px; }
.device-strip strong { font-size: .9rem; }
.device-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.05); color: var(--green-soft); }
.device-icon svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.error-banner, .demo-banner { margin-top: 14px; border-radius: 18px; padding: 15px 17px; }
.error-banner { border: 1px solid rgba(255,143,143,.22); background: rgba(255,143,143,.07); color: #ffc1c1; font-size: .84rem; }
.demo-banner { border: 1px solid rgba(242,200,121,.18); background: rgba(242,200,121,.06); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.demo-banner strong, .demo-banner span { display: block; }
.demo-banner strong { color: var(--amber); font-size: .82rem; margin-bottom: 3px; }
.demo-banner span { color: var(--muted); font-size: .72rem; }
.secondary-button { color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: .76rem; font-weight: 700; white-space: nowrap; cursor: pointer; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.action-card { min-height: 82px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 19px; background: rgba(20,27,23,.76); color: var(--text); text-align: left; text-decoration: none; cursor: pointer; }
.action-card:hover { border-color: rgba(255,255,255,.15); background: rgba(26,35,30,.85); }
.action-card strong, .action-card small { display: block; }
.action-card strong { font-size: .88rem; margin-bottom: 4px; }
.action-card small { color: var(--muted); font-size: .7rem; }
.action-icon { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; }
.action-icon.green { background: var(--green); color: #061008; }
.action-icon.mint { background: rgba(145,233,208,.12); color: var(--mint); }
.action-icon svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.action-icon.green svg circle { fill: currentColor; stroke: none; }
.action-icon.green svg path { stroke: #071108; }
.chevron { color: #67736c; font-size: 1.5rem; }

.section-card { padding: 21px; margin-top: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-heading h2 { font-size: 1.15rem; margin: 5px 0 0; letter-spacing: -.02em; }
.soft-badge { color: var(--muted); border: 1px solid var(--line); background: rgba(255,255,255,.03); padding: 6px 9px; border-radius: 999px; font-size: .68rem; }
.section-description { color: var(--muted); font-size: .78rem; line-height: 1.6; margin: 12px 0 2px; }
.event-list, .device-list { margin-top: 16px; }
.event-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.event-item:first-child { border-top: 0; padding-top: 2px; }
.event-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--green); box-shadow: 0 0 0 5px rgba(30,215,96,.08); }
.event-dot.stopped { background: var(--mint); box-shadow: 0 0 0 5px rgba(145,233,208,.07); }
.event-dot.switched { background: var(--amber); box-shadow: 0 0 0 5px rgba(242,200,121,.07); }
.event-item strong { display: block; font-size: .84rem; margin-bottom: 4px; }
.event-item p { color: var(--muted); font-size: .73rem; line-height: 1.45; margin: 0; }
.event-item time { color: #6f7a74; font-size: .67rem; white-space: nowrap; }
.empty-state { color: #718078; font-size: .8rem; line-height: 1.6; padding: 18px 0 8px; text-align: center; }
.device-row { display: grid; grid-template-columns: 1fr minmax(115px, .65fr) auto; gap: 9px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.device-row:first-child { border-top: 0; }
.device-info strong, .device-info small { display: block; }
.device-info strong { font-size: .82rem; }
.device-info small { color: var(--muted); margin-top: 3px; font-size: .67rem; }
.device-row input, .pin-form input { width: 100%; color: var(--text); background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; outline: none; }
.device-row input:focus, .pin-form input:focus { border-color: rgba(30,215,96,.5); box-shadow: 0 0 0 3px rgba(30,215,96,.08); }
.save-button { color: var(--green-soft); background: transparent; border: 0; font-size: .73rem; font-weight: 750; cursor: pointer; }

.install-card { margin-top: 14px; padding: 17px; border: 1px dashed rgba(145,233,208,.26); border-radius: 18px; display: flex; gap: 13px; background: rgba(145,233,208,.045); }
.install-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; color: var(--mint); background: rgba(145,233,208,.1); font-weight: 800; }
.install-card strong { font-size: .83rem; }
.install-card p { color: var(--muted); font-size: .74rem; line-height: 1.55; margin: 5px 0 0; }

.login-card { margin: 15vh auto 0; max-width: 470px; padding: 30px; }
.login-card h1 { margin: 8px 0; letter-spacing: -.04em; }
.login-card > p { color: var(--muted); line-height: 1.6; font-size: .85rem; }
.pin-form { margin-top: 24px; }
.pin-form label { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 8px; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.primary-button { border: 0; border-radius: 11px; padding: 0 17px; background: var(--green); color: #071108; font-weight: 800; cursor: pointer; }
.form-error { min-height: 1.2em; color: var(--danger) !important; margin: 8px 0 0 !important; font-size: .72rem !important; }
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 120px); opacity: 0; padding: 12px 17px; border-radius: 999px; color: var(--text); background: #273029; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 14px 35px rgba(0,0,0,.35); font-size: .78rem; transition: .25s ease; z-index: 20; white-space: nowrap; max-width: calc(100vw - 36px); overflow: hidden; text-overflow: ellipsis; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 600px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .hero-card { padding: 18px; }
  .hero-main { grid-template-columns: 88px 1fr; gap: 16px; margin: 24px 0; }
  .album-art { width: 88px; border-radius: 16px; }
  .action-grid { grid-template-columns: 1fr; }
  .action-card { min-height: 72px; }
  .device-row { grid-template-columns: 1fr auto; }
  .device-row input { grid-column: 1 / -1; grid-row: 2; }
  .save-button { grid-column: 2; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

