:root {
  color-scheme: dark;
  --page: #0b1220;
  --panel: #151e2d;
  --panel-2: #202b3b;
  --text: #f8fafc;
  --muted: #9ba9bb;
  --line: rgba(159, 176, 198, 0.24);
  --accent: #10bce7;
  --accent-strong: #0284c7;
  --danger: #fb7185;
  --ok: #22c55e;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(max(24px, env(safe-area-inset-bottom)) + 78px);
}

.topbar {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 8px 0 18px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.1;
}

.topbar p,
.track-panel p,
.compatibility-panel p {
  color: var(--muted);
}

.topbar p {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  margin-top: 7px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  background: rgba(8, 14, 25, 0.72);
}

.connection-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.connection-state.connected {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.38);
  background: rgba(34, 197, 94, 0.12);
}

.connection-state.connected::before {
  background: var(--ok);
}

.connection-state.checking {
  color: #bae6fd;
  border-color: rgba(16, 188, 231, 0.38);
  background: rgba(16, 188, 231, 0.12);
}

.connection-state.checking::before {
  background: var(--accent);
}

.connection-state.offline {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(251, 113, 133, 0.12);
}

.connection-state.offline::before {
  background: var(--danger);
}

.panel,
.track-panel,
.playlist-panel,
.compatibility-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view[hidden] {
  display: none;
}

.config-panel {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr 0.7fr;
  gap: 12px;
  padding: 14px;
}

.host-field {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #080e19;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.config-actions {
  display: grid;
  grid-column: span 2;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-self: end;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.secondary-button,
.install-button {
  min-height: 44px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 700;
}

.install-button {
  min-height: 38px;
  color: #041923;
  background: var(--accent);
  border-color: transparent;
}

.track-panel {
  margin-top: 14px;
  padding: 16px;
}

.track-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.eyebrow {
  color: var(--accent) !important;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.text-button {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  padding: 6px 0;
}

.track-panel h2 {
  font-size: 22px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

#currentMeta {
  display: none;
}

.track-neighbors {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.track-neighbor {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(8, 14, 25, 0.54);
}

.track-neighbor span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.track-neighbor strong {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.playlist-panel {
  padding: 16px;
}

.playlist-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.playlist-heading h2 {
  font-size: 22px;
  line-height: 1.18;
}

.playlist-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
}

.playlist-add-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
}

.playlist-add-panel[hidden] {
  display: none;
}

.playlist-add-actions {
  display: grid;
  grid-template-columns: 104px 104px;
  gap: 8px;
}

.playlist-subtitle,
.empty-state {
  color: var(--muted);
}

.playlist-subtitle {
  margin-top: 12px;
  overflow-wrap: anywhere;
}

.playlist-import-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.playlist-import-panel[hidden] {
  display: none;
}

.playlist-import-panel textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #080e19;
  color: var(--text);
  outline: none;
}

.playlist-import-panel textarea:focus {
  border-color: var(--accent);
}

.playlist-import-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.playlist-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.empty-state {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.playlist-song {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  text-align: left;
}

.song-position {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #041923;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.song-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.song-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
}

.control-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 78px;
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  text-align: center;
}

.control-symbol {
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  color: currentColor;
  font-family: Consolas, monospace;
  font-size: 20px;
  font-weight: 900;
}

.control-symbol.square::before {
  width: 16px;
  height: 16px;
  background: currentColor;
  content: "";
}

.control-button strong {
  overflow-wrap: anywhere;
}

.control-button.primary {
  background: var(--accent-strong);
  color: #ffffff;
  border-color: transparent;
}

.compatibility-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
}

.compatibility-panel[hidden] {
  display: none;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(21, 30, 45, 0.94);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

.bottom-tab {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

.bottom-tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-tab.is-active {
  color: #041923;
  background: var(--accent);
  border-color: transparent;
}

@media (max-width: 620px) {
  .topbar {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }

  .install-button {
    grid-column: 1 / -1;
  }

  .config-panel {
    grid-template-columns: 0.8fr 1.2fr;
  }

  .host-field {
    grid-column: 1 / -1;
  }

  .password-field {
    grid-column: 1 / -1;
  }

  .config-actions {
    grid-column: 1 / -1;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .playlist-add-panel,
  .playlist-add-actions {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 380px) {
  .config-panel,
  .config-actions {
    grid-template-columns: 1fr;
  }

  .config-panel > *,
  .config-actions {
    grid-column: 1;
  }
}
