:root {
  color-scheme: dark;
  --bg: #090c0b;
  --surface: #111614;
  --surface-2: #171d1a;
  --line: #27302c;
  --text: #f3f7f4;
  --muted: #8f9a94;
  --mint: #72f3bd;
  --mint-deep: #39c98d;
  --lime: #cef56c;
  --danger: #ff847c;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% -10%, rgba(114, 243, 189, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.42; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(23, 29, 26, 0.98), rgba(14, 18, 16, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--mint);
  color: #07120d;
  font-weight: 900;
  font-size: 24px;
  transform: rotate(-5deg);
  box-shadow: 8px 8px 0 rgba(206, 245, 108, 0.24);
}

.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; box-shadow: none; }
.eyebrow, .panel-kicker { margin: 22px 0 8px; color: var(--mint); font-size: 11px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.login-card h1 { margin: 0; font-size: clamp(36px, 7vw, 58px); line-height: 0.98; letter-spacing: -0.055em; }
.login-card h1 span { color: var(--muted); }
.login-copy { margin: 22px 0 28px; color: var(--muted); }
.login-card label, .field-label { display: block; margin-bottom: 8px; color: #c6cec9; font-size: 13px; font-weight: 700; }
.login-row { display: flex; gap: 10px; }

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  background: #0c100e;
  color: var(--text);
  padding: 0 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus, select:focus { border-color: var(--mint-deep); box-shadow: 0 0 0 3px rgba(114, 243, 189, 0.11); }

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.button.primary { background: var(--mint); color: #07120d; }
.button.primary:hover { background: var(--lime); }
.button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.button.ghost:hover { border-color: #536159; }
.form-message { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1320px) / 2)); border-bottom: 1px solid var(--line); background: rgba(9, 12, 11, 0.78); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 5; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 16px; letter-spacing: -0.02em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; color: #cfd7d2; font-size: 12px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.icon-button, .text-button { border: 0; background: transparent; color: var(--muted); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 11px; font-size: 20px; }
.icon-button:hover, .text-button:hover { color: var(--text); }
.text-button { padding: 8px; font-size: 13px; font-weight: 700; }
.text-button.danger:hover { color: var(--danger); }

main { width: min(1320px, calc(100% - 48px)); margin: 0 auto; padding: 46px 0 70px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.page-heading .eyebrow { margin-top: 0; }
.page-heading h1 { margin: 0; font-size: clamp(32px, 5vw, 56px); letter-spacing: -0.055em; line-height: 1; }
.select-label { width: min(320px, 100%); color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.select-label span { display: block; margin-bottom: 8px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 0.82fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(19, 25, 22, 0.97), rgba(14, 18, 16, 0.97)); overflow: hidden; }
.panel h2 { margin: 0; font-size: 24px; letter-spacing: -0.035em; }
.panel-kicker { margin: 0 0 8px; }
.muted, .hint { color: var(--muted); }
.hint { margin: 12px 0 0; font-size: 12px; line-height: 1.5; }

.now-playing { min-height: 365px; display: grid; grid-template-columns: minmax(250px, 38%) 1fr; }
.artwork-wrap { position: relative; min-height: 100%; background: #1c2420; overflow: hidden; }
.artwork-wrap::after { content: ""; position: absolute; inset: auto 0 0; height: 45%; background: linear-gradient(transparent, rgba(5, 8, 6, 0.64)); }
.artwork { display: block; width: 100%; height: 100%; object-fit: cover; }
.artwork-placeholder { width: 100%; height: 100%; min-height: 365px; display: grid; place-items: center; color: rgba(114, 243, 189, 0.72); font-size: 92px; background: radial-gradient(circle at 35% 32%, #314a3e, #14211b 46%, #0d1210); }
.playing-indicator { position: absolute; z-index: 1; left: 18px; bottom: 18px; height: 28px; display: flex; align-items: end; gap: 4px; padding: 7px 9px; border-radius: 9px; background: rgba(5, 8, 6, 0.72); backdrop-filter: blur(8px); }
.playing-indicator i { width: 3px; height: 12px; border-radius: 2px; background: var(--mint); animation: equalize 0.8s ease-in-out infinite alternate; }
.playing-indicator i:nth-child(2) { height: 7px; animation-delay: -0.4s; }
.playing-indicator i:nth-child(3) { height: 17px; animation-delay: -0.2s; }
.playing-indicator.paused i { animation-play-state: paused; height: 4px; }
@keyframes equalize { to { height: 4px; } }
.player-content { display: flex; flex-direction: column; justify-content: center; padding: clamp(24px, 4vw, 48px); min-width: 0; }
.player-content h2 { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(26px, 3.2vw, 43px); }
.player-content > .muted { margin: 8px 0 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-row { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.progress { position: relative; height: 18px; border: 0; padding: 0; background: transparent; }
.progress::before, .progress span { content: ""; position: absolute; left: 0; top: 8px; height: 3px; border-radius: 3px; }
.progress::before { width: 100%; background: #35403a; }
.progress span { width: 0; background: var(--mint); }
.transport { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 27px 0 24px; }
.control-button { display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--text); }
.control-button.secondary { width: 44px; height: 44px; background: var(--surface-2); font-size: 21px; }
.control-button.main { width: 64px; height: 64px; background: var(--text); color: var(--bg); font-size: 22px; font-weight: 900; }
.control-button:hover { transform: translateY(-1px); }
.utility-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: #b5beb9; font-size: 11px; font-weight: 700; }
.chip:hover, .chip.active { border-color: var(--mint-deep); color: var(--mint); }
.volume-control { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.volume-control input { min-height: auto; width: 86px; padding: 0; accent-color: var(--mint); }
.volume-control output { width: 34px; }

.connection-panel, .add-panel, .queue-panel { padding: 26px; }
.connection-panel { display: flex; flex-direction: column; }
.connection-panel .muted { margin: 8px 0 28px; }
.connection-panel .field-label { margin-top: auto; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.add-panel { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(190px, 0.65fr) minmax(300px, 1.35fr); gap: 28px; align-items: center; }
.add-form { display: flex; gap: 10px; }
.add-panel .hint { grid-column: 2; margin-top: -18px; }
.queue-panel { grid-column: 1 / -1; }
.queue-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.queue-heading h2 span { display: inline-grid; place-items: center; min-width: 28px; height: 28px; margin-left: 5px; padding: 0 7px; border-radius: 9px; background: rgba(114, 243, 189, 0.11); color: var(--mint); font-size: 13px; vertical-align: 3px; }
.queue-list { list-style: none; margin: 0; padding: 0; }
.queue-item { display: grid; grid-template-columns: 28px 48px minmax(0, 1fr) auto auto; gap: 13px; align-items: center; padding: 12px 8px; border-top: 1px solid var(--line); }
.queue-number { color: var(--muted); font-size: 12px; text-align: center; }
.queue-cover { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.queue-meta { min-width: 0; }
.queue-meta strong, .queue-meta span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-meta strong { font-size: 14px; }
.queue-meta span, .queue-duration { margin-top: 4px; color: var(--muted); font-size: 11px; }
.remove-button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 17px; }
.remove-button:hover { background: rgba(255, 132, 124, 0.1); color: var(--danger); }
.empty-state { display: grid; justify-items: center; padding: 42px 20px 34px; border-top: 1px solid var(--line); color: var(--muted); text-align: center; }
.empty-state > span { font-size: 34px; color: var(--mint); }
.empty-state strong { margin-top: 10px; color: var(--text); }
.empty-state p { margin: 6px 0 0; font-size: 13px; }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; background: #18201c; color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.36); font-size: 13px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 132, 124, 0.48); }

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .now-playing, .connection-panel, .add-panel, .queue-panel { grid-column: 1; }
  .connection-panel { min-height: 280px; }
  .add-panel { grid-template-columns: 1fr; }
  .add-panel .hint { grid-column: 1; margin-top: -18px; }
}

@media (max-width: 650px) {
  .topbar { padding: 0 16px; }
  .status-pill, .topbar .text-button { display: none; }
  main { width: min(100% - 28px, 1320px); padding-top: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .now-playing { grid-template-columns: 1fr; }
  .artwork-wrap, .artwork-placeholder { min-height: 270px; }
  .artwork-wrap { aspect-ratio: 16 / 10; }
  .player-content { padding: 24px 20px; }
  .utility-controls { justify-content: center; }
  .volume-control { width: 100%; justify-content: center; margin: 10px 0 0; }
  .add-form, .login-row { flex-direction: column; }
  .queue-item { grid-template-columns: 24px 42px minmax(0, 1fr) auto; gap: 9px; }
  .queue-cover { width: 42px; height: 42px; }
  .queue-duration { display: none; }
  .connection-panel, .add-panel, .queue-panel { padding: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
