:root {
  color-scheme: dark;
  --bg: #07131f;
  --panel: #102234;
  --panel-strong: #17324b;
  --line: rgba(202, 236, 255, 0.14);
  --text: #f5fbff;
  --muted: #a7c4d8;
  --subtle: #78a0b8;
  --accent: #7edcff;
  --accent-2: #8ff0d2;
  --accent-3: #b9d8ff;
  --danger: #ff7e9e;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 16px calc(104px + var(--safe-bottom));
  background:
    radial-gradient(circle at 18% -12%, rgba(126, 220, 255, 0.28), transparent 27rem),
    radial-gradient(circle at 100% 2%, rgba(143, 240, 210, 0.18), transparent 24rem),
    linear-gradient(180deg, #0b2235 0%, var(--bg) 42%);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto 28px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(126, 220, 255, 0.18);
}

.auth-locked {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100dvh;
}

.auth-locked .topbar,
.auth-locked .main-content {
  width: 100%;
  max-width: 760px;
}

.auth-locked .topbar {
  margin: 0 auto 24px;
}

.auth-locked .brand-lockup {
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.auth-locked .brand-logo {
  width: 88px;
  height: 88px;
  border-radius: 24px;
}

.auth-locked .main-content {
  margin: 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 720;
}

.motto {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 520;
}

h2 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 700;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 6px;
}

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

.main-content {
  max-width: 760px;
  margin: 0 auto;
}

.cloud-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(190, 229, 255, 0.075);
}

.auth-locked .cloud-panel {
  margin-bottom: 0;
}

.cloud-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cloud-copy strong,
.cloud-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-copy span {
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  outline: none;
}

.auth-actions,
.signed-in-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.auth-actions .text-button,
.auth-actions .ghost-button,
.approval-button {
  min-height: 42px;
  min-width: 112px;
  padding-inline: 18px;
  font-size: 15px;
  font-weight: 650;
}

.auth-actions .text-button {
  background: rgba(126, 220, 255, 0.9);
}

.auth-actions .ghost-button {
  background: rgba(190, 229, 255, 0.11);
  color: #deeffa;
}

.approval-button {
  border: 0;
  border-radius: 999px;
  background: rgba(190, 229, 255, 0.1);
  color: var(--muted);
  cursor: default;
}

.compact {
  min-height: 40px;
  min-width: 72px;
  padding-inline: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  min-height: 46px;
}

.icon-button,
.text-button,
.ghost-button,
.play-button {
  border: 0;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--text);
  flex: 0 0 auto;
}

.icon-button svg,
.tab svg,
.play-button svg,
.search-wrap svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-button.small {
  min-width: 40px;
  min-height: 40px;
}

.icon-button.active,
.tab.active {
  color: var(--accent);
}

.text-button {
  display: inline-flex;
  justify-content: center;
  min-width: 76px;
  min-height: 46px;
  padding: 0 17px;
  background: var(--accent);
  color: #062334;
  font-weight: 720;
}

.ghost-button {
  display: inline-flex;
  justify-content: center;
  min-width: 76px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 650;
}

.import-button {
  position: relative;
  overflow: hidden;
  background: var(--accent);
  color: #062334;
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
}

.import-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  display: none;
}

.import-button svg {
  width: 25px;
  height: 25px;
  display: block;
  fill: currentColor;
  pointer-events: none;
}

.auth-locked .import-button,
.auth-locked #libraryView,
.auth-locked #playlistsView,
.auth-locked #playerView,
.auth-locked .tabbar,
.auth-locked .mini-player {
  display: none !important;
}

.auth-footer {
  display: none;
}

.auth-locked .auth-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 28px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.auth-footer strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 620;
}

.auth-footer small {
  color: var(--subtle);
}

.auth-footer span::before,
.auth-footer small::before {
  content: "\2022";
  margin-right: 9px;
  color: rgba(167, 196, 216, 0.55);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(190, 229, 255, 0.075);
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.track-list {
  display: grid;
  gap: 8px;
  contain: layout paint;
}

.track-row,
.playlist-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-areas:
    "art meta"
    "actions actions";
  align-items: center;
  gap: 10px 12px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(190, 229, 255, 0.055);
  contain: layout paint;
  content-visibility: auto;
  contain-intrinsic-size: 88px;
}

.track-row.playing {
  border-color: rgba(126, 220, 255, 0.6);
  background: rgba(126, 220, 255, 0.12);
}

.art {
  grid-area: art;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2), var(--accent-3));
  color: #062334;
  font-weight: 760;
}

.track-meta,
.playlist-meta {
  grid-area: meta;
  min-width: 0;
}

.track-meta strong,
.playlist-meta strong,
.mini-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-meta small,
.playlist-meta small,
.mini-info small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-meta small.status-ok {
  color: #8ff0d2;
}

.track-meta small.status-pending {
  color: #b9d8ff;
}

.track-meta small.status-warn {
  color: #ffd98f;
}

.track-meta small.status-error {
  color: var(--danger);
}

.row-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-top: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.row-actions::-webkit-scrollbar {
  display: none;
}

.row-action {
  min-width: max-content;
  height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.row-action.synced {
  color: var(--accent);
}

.danger {
  color: var(--danger);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.playlist-grid {
  display: grid;
  gap: 10px;
}

.playlist-detail {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.playlist-detail-head {
  align-items: flex-start;
}

.playlist-detail-head > div:first-child {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.back-button {
  justify-self: start;
  min-height: 36px;
}

@media (max-width: 420px) {
  .playlist-detail-head {
    display: grid;
    gap: 14px;
  }

  .detail-actions {
    justify-content: flex-start;
  }
}

.player-view {
  text-align: center;
  padding-top: 8px;
}

.player-art {
  width: min(68vw, 280px);
  aspect-ratio: 1;
  margin: 14px auto 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgba(126, 220, 255, 0.98), rgba(143, 240, 210, 0.95), rgba(185, 216, 255, 0.92)),
    #111;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.disc {
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, #05060a 0 13%, rgba(5, 6, 10, 0.38) 14% 29%, #05060a 30% 100%);
}

.disc span {
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
}

.progress-wrap {
  margin: 30px 0 22px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--subtle);
  font-size: 12px;
  margin-top: 4px;
}

.mode-row,
.transport-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 16px;
}

.transport-row {
  gap: 28px;
}

.transport {
  width: 56px;
  height: 56px;
}

.play-button {
  width: 76px;
  height: 76px;
  background: var(--text);
  color: #06080b;
}

.play-button svg {
  width: 34px;
  height: 34px;
}

.mini-player {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 31, 47, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  contain: layout paint;
}

.mini-info {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
}

.mini-art {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2), var(--accent-3));
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(7, 19, 31, 0.94);
  backdrop-filter: blur(10px);
  contain: layout paint;
}

.tab {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.modal {
  width: min(92vw, 420px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal form {
  display: grid;
  gap: 16px;
}

.modal label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.modal input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(190, 229, 255, 0.075);
  color: var(--text);
  outline: none;
}

.modal menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
}

.error-details {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 13, 22, 0.5);
  color: var(--muted);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.dialog-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.choice-file-button {
  position: relative;
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(190, 229, 255, 0.075);
  color: var(--text);
  font-weight: 650;
  overflow: hidden;
}

.choice-file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.choice-list button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(190, 229, 255, 0.075);
  color: var(--text);
  text-align: left;
  padding: 0 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(142px + var(--safe-bottom));
  z-index: 40;
  translate: -50% 18px;
  opacity: 0;
  pointer-events: none;
  max-width: min(88vw, 420px);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #07131f;
  font-weight: 720;
  transition: opacity 160ms ease, translate 160ms ease;
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
}

#mediaPlayer {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 720px) {
  .app-shell {
    padding-inline: 24px;
  }

  .track-list,
  .playlist-grid {
    gap: 10px;
  }

  .track-row,
  .playlist-row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    grid-template-areas: "art meta actions";
  }

  .row-actions {
    justify-content: flex-end;
    overflow: visible;
    padding-top: 0;
  }

  .cloud-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .auth-form {
    grid-template-columns: 170px 170px auto;
    align-items: center;
  }
}
