:root {
  color-scheme: dark;
  --bg: #0a0d11;
  --panel: #121821;
  --panel-2: #171f2c;
  --line: #273247;
  --text: #edf3ff;
  --muted: #95a4ba;
  --green: #44d16d;
  --green-soft: rgba(68, 209, 109, 0.12);
  --amber: #f5c24d;
  --shadow: 0 20px 52px rgba(0, 0, 0, 0.36);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(68, 209, 109, 0.12), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(245, 194, 77, 0.09), transparent 26rem),
    var(--bg);
  font: 14px/1.45 "Segoe UI", "Aptos", "Helvetica Neue", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 0.72rem 0.9rem;
  cursor: pointer;
}

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

button.primary {
  background: rgba(68, 209, 109, 0.18);
  border-color: rgba(68, 209, 109, 0.55);
}

button.secondary {
  background: rgba(255, 255, 255, 0.03);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem 0.82rem;
}

audio {
  display: none;
}

.app-shell {
  min-height: 100vh;
  padding: 1rem;
}

.access-panel,
.dashboard-shell,
.sidebar,
.content,
.now-panel,
.queue-panel,
.now-card {
  background: rgba(18, 24, 33, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.access-panel {
  width: min(640px, 100%);
  margin: clamp(1.5rem, 9vh, 6rem) auto 0;
  padding: 1.25rem;
  border-radius: 18px;
}

.dashboard-shell {
  margin-top: 1rem;
  border-radius: 18px;
  padding: 1rem;
  overflow-x: auto;
}

.panel-header,
.topbar,
.content-head,
.panel-title-row,
.access-foot,
.player-buttons,
.progress-meta,
.topbar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.eyebrow,
.meta-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.74rem;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  font-size: 0.98rem;
}

.lede {
  margin: 1rem 0 1.1rem;
  color: var(--muted);
  max-width: 56ch;
}

.access-form {
  display: grid;
  gap: 0.8rem;
}

.access-form label,
.field-stack label {
  display: grid;
  gap: 0.4rem;
}

.access-form span,
.field-stack span {
  color: var(--muted);
  font-size: 0.8rem;
}

.access-message {
  min-height: 1.2rem;
  margin-top: 0.75rem;
  color: var(--amber);
  font-size: 0.9rem;
}

.access-foot {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 1rem;
}

.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 0.34rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
}

.status-pill {
  color: var(--green);
  border-color: rgba(68, 209, 109, 0.45);
  background: rgba(68, 209, 109, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 340px;
  gap: 1rem;
  margin-top: 1rem;
}

body:not(.mobile-docked) .workspace {
  min-width: 980px;
}

.sidebar,
.content,
.player-column > section {
  border-radius: 16px;
}

.sidebar,
.content,
.player-column > section {
  padding: 0.95rem;
}

.sidebar,
.content,
.player-column {
  min-height: 420px;
}

body.mobile-docked {
  padding-bottom: calc(20rem + env(safe-area-inset-bottom, 0px));
}

body.mobile-docked .app-shell {
  padding: 0.55rem;
}

body.mobile-docked .dashboard-shell,
body.mobile-docked .access-panel {
  width: 100%;
  padding: 0.8rem;
}

body.mobile-docked .workspace {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

body.mobile-docked .sidebar {
  display: contents;
}

body.mobile-docked .field-stack {
  order: 1;
}

body.mobile-docked .control-stack {
  order: 2;
}

body.mobile-docked .folder-box {
  order: 3;
}

body.mobile-docked .content {
  order: 4;
}

body.mobile-docked .player-column {
  order: 5;
  position: fixed;
  left: 0.55rem;
  right: 0.55rem;
  bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  padding: 0;
  max-height: 18.5rem;
  overflow: auto;
  border-top: 0;
  background: transparent;
  box-shadow: none;
  min-height: auto;
  width: auto;
}

body.mobile-docked .library-box {
  order: 6;
}

body.mobile-docked .playlist-box {
  order: 7;
}

body.mobile-docked .sidebar,
body.mobile-docked .content,
body.mobile-docked .player-column {
  border-radius: 14px;
  min-height: auto;
  width: 100%;
}

body.mobile-docked .player-column {
  width: auto;
}

body.mobile-docked .field-stack,
body.mobile-docked .control-stack,
body.mobile-docked .folder-box,
body.mobile-docked .library-box,
body.mobile-docked .playlist-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 24, 33, 0.94);
  box-shadow: var(--shadow);
  padding: 0.75rem;
}

body.mobile-docked .control-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

body.mobile-docked .field-stack {
  grid-template-columns: 1fr;
}

body.mobile-docked .folder-heading {
  display: none;
}

body.mobile-docked .folder-toggle {
  display: flex;
}

body.mobile-docked .folder-panel {
  display: none;
  margin-top: 0.65rem;
}

body.mobile-docked .folder-box.open .folder-panel {
  display: block;
}

body.mobile-docked .folder-list {
  max-height: 14rem;
}

body.mobile-docked .meta-box {
  margin-top: 0;
  padding-top: 0.75rem;
  border-top: 0;
}

.field-stack,
.control-stack,
.list-stack,
.playlist-form {
  display: grid;
  gap: 0.7rem;
}

.control-stack {
  margin: 1rem 0;
}

.meta-box {
  margin-top: 1rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}

.meta-line {
  color: var(--muted);
  margin-top: 0.25rem;
}

.content-head {
  margin-bottom: 0.85rem;
}

.dashboard-message {
  min-height: 1.2rem;
  margin-top: 0.65rem;
  color: var(--amber);
  font-size: 0.88rem;
}

.dashboard-message.error {
  color: #ffb3a8;
}

.content-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.track-table,
.list-stack.compact,
.folder-list {
  display: grid;
  gap: 0.55rem;
}

.folder-list {
  max-height: 21rem;
  overflow: auto;
  padding-right: 0.1rem;
}

.folder-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
}

.folder-panel {
  display: block;
}

.view-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.track-row,
.list-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  padding: 0.8rem 0.85rem;
}

.track-row {
  align-items: start;
}

.list-row.queue-empty,
.list-row.empty-state {
  grid-template-columns: 1fr;
}

.list-row.queue-empty .track-main,
.list-row.empty-state .track-main {
  grid-column: 1 / -1;
}

.track-row.active,
.list-row.active {
  border-color: rgba(68, 209, 109, 0.5);
  background: var(--green-soft);
}

.track-art {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 55%),
    linear-gradient(160deg, var(--swatch-1), var(--swatch-2));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.track-main {
  min-width: 0;
}

.track-title {
  font-weight: 650;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-meta,
.list-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-row .list-meta {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.track-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  align-self: start;
}

.track-actions button {
  padding: 0.44rem 0.58rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.genre-editor {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
}

.genre-editor input {
  min-width: 0;
  padding: 0.52rem 0.7rem;
  border-radius: 10px;
}

.genre-editor button {
  padding: 0.52rem 0.7rem;
  border-radius: 10px;
}

.track-source {
  color: rgba(149, 164, 186, 0.78);
}

.now-panel {
  border-radius: 16px;
}

.now-card {
  border-radius: 14px;
  padding: 0.9rem;
}

.now-title {
  font-weight: 650;
  font-size: 1.03rem;
}

.now-meta {
  margin-top: 0.3rem;
  color: var(--muted);
}

.progress {
  padding: 0.85rem 0 0.35rem;
}

.seek-bar {
  width: 100%;
  margin: 0;
  accent-color: var(--green);
}

.progress-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.4rem;
}

.player-buttons {
  flex-wrap: wrap;
}

.player-buttons.two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.queue-panel {
  margin-top: 1rem;
}

.queue-panel .list-row {
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
}

.queue-panel .track-title,
.queue-panel .list-meta {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.queue-panel .track-actions {
  grid-column: 1 / -1;
  align-self: start;
  justify-content: flex-start;
}

.playlist-item,
.folder-item {
  display: grid;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  padding: 0.7rem 0.8rem;
}

.playlist-item.active,
.folder-item.active {
  border-color: rgba(68, 209, 109, 0.5);
  background: var(--green-soft);
}

.playlist-actions,
.folder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.playlist-actions button,
.folder-actions button {
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  font-size: 0.8rem;
}

.folder-item .list-meta,
.playlist-item .list-meta {
  white-space: normal;
}

.folder-item .genre-editor {
  margin-top: 0.15rem;
}

.folder-item .genre-editor input,
.track-actions .genre-editor input {
  background: rgba(255, 255, 255, 0.03);
}

.folder-item .genre-editor button,
.track-actions .genre-editor button {
  white-space: nowrap;
}

#dashboardShell[hidden],
#accessPanel[hidden] {
  display: none;
}

@media (max-width: 840px) and (hover: none) and (pointer: coarse) {
  html {
    font-size: 17px;
  }

  body {
    font-size: 16px;
    line-height: 1.55;
    padding-bottom: 0;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    padding: 0.8rem;
  }

  .access-panel,
  .dashboard-shell {
    width: 100%;
    padding: 1rem;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
  }

  .content {
    order: 1;
  }

  .player-column {
    order: 2;
  }

  .sidebar {
    order: 3;
  }

  .panel-header,
  .topbar,
  .content-head,
  .panel-title-row,
  .topbar-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .eyebrow,
  .meta-title {
    font-size: 0.82rem;
  }

  h1 {
    font-size: 2.15rem;
  }

  h2 {
    font-size: 1.22rem;
  }

  h3 {
    font-size: 1.04rem;
  }

  .lede {
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .access-form span,
  .field-stack span,
  .content-meta,
  .meta-line,
  .track-meta,
  .list-meta,
  .now-meta,
  .progress-meta,
  .chip,
  .status-pill {
    font-size: 0.93rem;
  }

  button,
  input,
  select {
    font-size: 1rem;
    min-height: 48px;
    padding: 0.85rem 0.95rem;
  }

  .player-column {
    position: static;
    z-index: auto;
    padding: 0;
    max-height: none;
    overflow: visible;
    border-top: 0;
    background: transparent;
    box-shadow: none;
  }

  .sidebar,
  .content,
  .player-column {
    min-height: auto;
    width: 100%;
  }

  .player-buttons.two-up {
    grid-template-columns: 1fr;
  }

  .track-row,
  .list-row {
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 0.9rem 0.9rem;
  }

  .track-art {
    width: 40px;
    height: 40px;
  }

  .track-title,
  .list-title {
    font-size: 1.02rem;
    line-height: 1.3;
    white-space: normal;
  }

  .track-meta,
  .list-meta {
    line-height: 1.38;
    white-space: normal;
  }

  .track-actions,
  .playlist-actions,
  .folder-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .list-row.queue-empty,
  .list-row.empty-state {
    grid-template-columns: 1fr;
  }

  .track-actions button,
  .playlist-actions button,
  .folder-actions button {
    font-size: 0.95rem;
    padding: 0.58rem 0.72rem;
    min-height: 42px;
  }

  .genre-editor {
    grid-template-columns: 1fr;
  }

  .genre-editor button {
    width: 100%;
  }

  .now-title {
    font-size: 1.15rem;
    line-height: 1.25;
  }

  .progress-meta {
    font-size: 0.88rem;
  }

  .player-buttons button {
    font-size: 1rem;
    padding: 0.8rem 0.95rem;
    min-height: 46px;
  }

  .playlist-item,
  .folder-item {
    padding: 0.85rem 0.9rem;
  }

  .queue-panel {
    margin-top: 0.9rem;
  }
}

@media (max-width: 520px) and (hover: none) and (pointer: coarse) {
  body {
    padding-bottom: calc(20rem + env(safe-area-inset-bottom, 0px));
  }

  .app-shell {
    padding: 0.55rem;
  }

  .dashboard-shell,
  .access-panel {
    padding: 0.8rem;
    border-radius: 16px;
  }

  .workspace {
    gap: 0.7rem;
  }

  .sidebar,
  .content,
  .player-column {
    border-radius: 14px;
  }

  .player-column {
    position: fixed;
    left: 0.55rem;
    right: 0.55rem;
    bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    padding: 0;
    max-height: 18.5rem;
    overflow: auto;
    border-top: 0;
    background: transparent;
    box-shadow: none;
  }

  .field-stack,
  .control-stack,
  .meta-box,
  .playlist-form,
  .player-buttons,
  .queue-panel,
  .now-panel {
    gap: 0.65rem;
  }

  .meta-box {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
  }

  .track-row,
  .list-row {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }

  .track-art {
    display: none;
  }

  .track-main {
    grid-column: 1 / -1;
  }

  .track-actions,
  .playlist-actions,
  .folder-actions {
    gap: 0.5rem;
  }

  .track-actions button,
  .playlist-actions button,
  .folder-actions button {
    flex: 1 1 30%;
  }

  .track-title {
    font-size: 1rem;
    line-height: 1.28;
  }

  .track-row .track-meta + .track-meta,
  .list-row .list-meta + .list-meta {
    display: none;
  }

  .track-meta,
  .list-meta,
  .now-meta,
  .content-meta,
  .meta-line,
  .progress-meta {
    font-size: 0.88rem;
    line-height: 1.45;
  }

  .topbar-meta {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
  }

  .topbar-meta .chip,
  .topbar-meta button {
    width: auto;
  }

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

  .player-buttons button {
    width: 100%;
  }

  .player-buttons.two-up {
    grid-template-columns: 1fr 1fr;
  }

  .queue-panel .list-row {
    grid-template-columns: 1fr;
  }

  .queue-panel .track-title,
  .queue-panel .list-meta {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .queue-panel .track-actions {
    justify-content: flex-start;
  }

  .queue-panel .track-actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  .playlist-actions button,
  .folder-actions button {
    flex: 1 1 calc(50% - 0.25rem);
  }
}
