/* ============================================================
   Tesla Music — minimalist Navidrome client
   Designed for the Tesla in-car browser: big targets, few menus
   ============================================================ */

:root {
  --bg1: #44535f;
  --bg2: #232c34;
  --accent: #e9b25c;
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.55);
  --text-faint: rgba(255, 255, 255, 0.28);
  --card: rgba(255, 255, 255, 0.07);
  --card-hover: rgba(255, 255, 255, 0.13);
  --radius: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(178deg, var(--bg1) 0%, var(--bg2) 78%) fixed;
  color: var(--text);
  overflow: hidden;
  user-select: none;
  transition: background 0.9s ease;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; }

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ---------- generic icon buttons ---------- */

.icon-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex: none;
  transition: background 0.15s, transform 0.1s, color 0.2s;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.12); transform: scale(0.94); }
.icon-btn svg { width: 30px; height: 30px; fill: currentColor; }
.icon-btn.big svg { width: 36px; height: 36px; }
.icon-btn.sub { color: var(--text-dim); }
.icon-btn.sub.on { color: var(--accent); }
.icon-btn.accent { color: var(--accent); }

/* ============================================================
   LOGIN
   ============================================================ */

#login { align-items: center; justify-content: center; }

.login-card {
  width: min(460px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
  padding: 40px;
}
.login-logo { margin-bottom: 4px; }
.login-card h1 { font-size: 38px; font-weight: 600; letter-spacing: 0.5px; }
.login-sub { color: var(--text-dim); font-size: 18px; margin-bottom: 10px; }

.login-card input {
  font: inherit;
  font-size: 20px;
  color: var(--text);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px 22px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #2a2118;
  font-size: 21px;
  font-weight: 600;
  border-radius: 16px;
  padding: 18px;
  margin-top: 6px;
  transition: filter 0.15s, transform 0.1s;
}
.btn-primary:active { filter: brightness(1.1); transform: scale(0.98); }

.login-error { color: #ff9b8a; font-size: 17px; min-height: 22px; }

/* ============================================================
   HOME / LIBRARY
   ============================================================ */

.home-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 34px 44px 10px;
}
.home-header h1 { font-size: 36px; font-weight: 600; flex: none; }

.home-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: 999px;
  padding: 0 24px;
  height: 60px;
  max-width: 560px;
  margin-left: auto;
}
.home-search .search-ico { width: 24px; height: 24px; color: var(--text-dim); flex: none; }
.home-search input {
  flex: 1;
  font: inherit;
  font-size: 19px;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  height: 100%;
}
.home-search input::placeholder { color: var(--text-faint); }
.home-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.tabs {
  display: flex;
  gap: 12px;
  padding: 14px 44px 18px;
}
.tab {
  font-size: 19px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--card);
  border-radius: 999px;
  padding: 13px 30px;
  transition: background 0.15s, color 0.15s;
}
.tab.active { background: var(--accent); color: #2a2118; font-weight: 600; }

.grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 26px;
  padding: 6px 44px 140px;
  align-content: start;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  transition: background 0.15s, transform 0.1s;
}
.card:active { background: var(--card-hover); transform: scale(0.97); }
.card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
}
.card .card-name {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .card-sub {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: -6px;
}

.grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 20px;
  padding: 70px 0;
}

/* ============================================================
   DETAIL
   ============================================================ */

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 26px 36px 16px;
}
.detail-title { flex: 1; min-width: 0; }
.detail-title h2 {
  font-size: 30px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-title span { font-size: 16px; color: var(--text-dim); }

.play-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #2a2118;
  font-size: 19px;
  font-weight: 600;
  border-radius: 999px;
  padding: 0 30px;
  height: 62px;
  transition: filter 0.15s, transform 0.1s;
}
.play-pill:active { filter: brightness(1.1); transform: scale(0.97); }
.play-pill svg { width: 26px; height: 26px; fill: currentColor; }

.tracks {
  flex: 1;
  overflow-y: auto;
  padding: 6px 36px 140px;
}

.track-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 18px;
  border-radius: 18px;
  text-align: left;
  transition: background 0.15s;
}
.track-row:active { background: var(--card); }
.track-row.current { background: var(--card); }
.track-row.current .track-name { color: var(--accent); }

.track-num {
  width: 36px;
  flex: none;
  font-size: 17px;
  color: var(--text-faint);
  text-align: center;
}
.track-row img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  flex: none;
  background: rgba(0, 0, 0, 0.25);
}
.track-main { flex: 1; min-width: 0; }
.track-name {
  font-size: 19px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-dur { font-size: 16px; color: var(--text-dim); flex: none; }

.tracks-section {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 26px 18px 10px;
}

/* ============================================================
   NOW PLAYING
   ============================================================ */

.player { z-index: 30; }

.player-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 30px 30px;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.player-context {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}

/* --- artwork + progress ring --- */

.art-col {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.art-wrap {
  position: relative;
  width: min(46vh, 76vw, 470px);
  aspect-ratio: 1;
}

#ringSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 4;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 250px 250px;
}
.ring-knob { fill: var(--accent); }
.ring-hit {
  fill: none;
  stroke: rgba(0, 0, 0, 0.001);
  stroke-width: 56;
  cursor: pointer;
}

.player-art {
  position: absolute;
  inset: 7.2%;
  width: 85.6%;
  height: 85.6%;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

/* --- info + controls --- */

.info-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: min(620px, 94vw);
}

.player-title {
  font-size: 34px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.player-artist {
  font-size: 20px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: center;
}

.player-time {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 6px;
  font-size: 17px;
  letter-spacing: 0.5px;
}
.player-time .time-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.3);
}
.player-time .dim { color: var(--text-dim); }

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-top: 10px;
  width: 100%;
}

.play-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #ffffff;
  color: #1f262c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  flex: none;
  transition: transform 0.1s;
}
.play-btn:active { transform: scale(0.94); }
.play-btn svg { width: 42px; height: 42px; fill: currentColor; }

#btnStar.on { color: var(--accent); }
#btnStar.on #heartPath { fill: var(--accent); }
#heartPath { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

.player-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(440px, 86vw);
  margin-top: 14px;
}

#btnRepeat { position: relative; }
.repeat-one {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  display: none;
}
#btnRepeat.one .repeat-one { display: block; }

/* --- narrow portrait (phones): tighter control row --- */

@media (max-width: 480px) {
  .player-controls { gap: 4px; }
  .play-btn { width: 84px; height: 84px; }
  .player-controls .icon-btn { width: 56px; height: 56px; }
  .player-title { font-size: 28px; }
}

/* --- landscape: art left, controls right (Tesla) --- */

@media (orientation: landscape) and (min-width: 900px) {
  .player-content {
    flex-direction: row;
    justify-content: center;
    gap: 7vw;
  }
  .art-wrap { width: min(62vh, 34vw, 520px); }
  .player-title { font-size: 40px; }
  .player-artist { font-size: 22px; }
  .player-time { margin: 26px 0 12px; }
  .player-controls { gap: 32px; margin-top: 16px; }
  .play-btn { width: 108px; height: 108px; }
  .player-bottom { margin-top: 26px; }
}

/* ============================================================
   MINI PLAYER
   ============================================================ */

.mini {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(680px, 94vw);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(22, 28, 34, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 12px 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 20;
  overflow: hidden;
}
.mini.hidden { display: none; }

.mini img {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  object-fit: cover;
  flex: none;
  background: rgba(0, 0, 0, 0.25);
}
.mini-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.mini-info span:first-child {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-info span:last-child {
  font-size: 15px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
}
#miniBar {
  height: 100%;
  width: 0;
  background: var(--accent);
}

/* ============================================================
   SHEETS / OVERLAY / TOAST
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  opacity: 1;
  transition: opacity 0.2s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 0);
  width: min(720px, 100vw);
  max-height: 72vh;
  background: #1d242b;
  border-radius: 28px 28px 0 0;
  padding: 14px 26px 34px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}
.sheet.hidden { transform: translate(-50%, 105%); }

.sheet-handle {
  width: 52px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  margin: 4px auto 16px;
  flex: none;
}
.sheet h3 {
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 14px;
  flex: none;
}

.queue-list { overflow-y: auto; }

.sheet-item {
  font-size: 20px;
  text-align: left;
  padding: 20px 14px;
  border-radius: 14px;
  transition: background 0.15s;
}
.sheet-item:active { background: var(--card); }
.sheet-item.danger { color: #ff9b8a; }

.vol-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 16px 8px 12px;
  color: var(--text-dim);
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: rgba(20, 25, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 18px;
  padding: 14px 28px;
  border-radius: 999px;
  z-index: 60;
  transition: opacity 0.25s;
  pointer-events: none;
}
.toast.hidden { opacity: 0; }

/* ---------- scrollbars ---------- */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
