:root {
  color-scheme: dark;
  --bg: #101113;
  --surface: #181a1e;
  --surface-2: #202329;
  --line: #343842;
  --text: #f5f1e8;
  --muted: #a8adba;
  --accent: #3ddc97;
  --accent-ink: #07140f;
  --gold: #ffbe55;
  --danger: #ff6b6b;
  --blue: #57a8ff;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(61, 220, 151, 0.08), transparent 340px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
.button,
input,
select {
  font: inherit;
}

button,
.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
}

.secondary {
  background: transparent;
  border-color: var(--line);
}

.danger {
  color: #210606;
  background: var(--danger);
  font-weight: 800;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.9rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-button.main-control {
  width: 54px;
  height: 54px;
  background: var(--accent);
  color: var(--accent-ink);
}

.hidden {
  display: none !important;
}

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

.auth-panel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.95;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.topbar,
.section-heading,
.player-title-row,
.time-row,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin: 8px 0 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.status-badge.good {
  color: var(--accent);
  border-color: rgba(61, 220, 151, 0.45);
}

.player-band {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: stretch;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 26, 30, 0.88);
  box-shadow: var(--shadow);
}

.cover {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  align-self: center;
  border-radius: 8px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--surface-2), #111);
}

#playerCover {
  width: 150px;
  height: 150px;
  justify-self: center;
}

.player-main {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 12px;
}

.player-title-row h2 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 1.35rem;
}

.progress-wrap {
  display: grid;
  gap: 5px;
}

progress {
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.time-row {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.controls {
  display: grid;
  grid-template-columns: 42px 54px 42px minmax(100px, 1fr);
  align-items: center;
  gap: 10px;
}

.volume {
  width: 100%;
  accent-color: var(--accent);
}

.device-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #121418;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stack {
  display: grid;
  gap: 14px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 17, 19, 0.9);
  backdrop-filter: blur(12px);
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.active {
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 800;
}

.view-section {
  display: grid;
  gap: 16px;
}

.section-heading {
  margin-top: 4px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.5rem;
}

.section-heading.compact {
  margin-top: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.session-card,
.result-row,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.session-card {
  min-height: 280px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.session-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}

.card-body {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.card-body h3,
.result-main h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.meta,
.muted {
  color: var(--muted);
}

.meta {
  margin: 0;
  font-size: 0.88rem;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.type-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.type-row label {
  min-height: 34px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  white-space: nowrap;
}

.type-row input {
  width: auto;
  min-height: auto;
}

.list {
  display: grid;
  gap: 10px;
}

.list.tight {
  gap: 8px;
}

.result-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
}

.result-row img {
  width: 78px;
  height: 78px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.result-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.result-actions,
.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.panel {
  padding: 14px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.inline-form {
  margin-bottom: 12px;
}

.inline-form input,
.inline-form select {
  flex: 1 1 150px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(480px, calc(100vw - 24px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #262a31;
  box-shadow: var(--shadow);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 720px) {
  .app {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 2.35rem;
  }

  .status-badge {
    display: none;
  }

  .player-band {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
  }

  #playerCover {
    width: 92px;
    height: 92px;
  }

  .player-title-row {
    align-items: flex-start;
  }

  .player-title-row h2 {
    font-size: 1rem;
  }

  .controls {
    grid-template-columns: 42px 54px 42px;
  }

  .volume {
    grid-column: 1 / -1;
  }

  .device-row {
    grid-template-columns: 1fr;
  }

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

  .tab {
    min-height: 46px;
    padding: 0 6px;
    font-size: 0.84rem;
  }

  .search-box {
    grid-template-columns: 1fr;
  }

  .result-row {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .result-row img {
    width: 64px;
    height: 64px;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }
}
