/* ============================================================
   Material Design 3 — Lime primary (#A7C957)
   ============================================================ */

/* ---------- MD3 Tonal Palette ---------- */
:root {
  /* Primary */
  --md-primary: #6B8E23;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #E1F0A8;
  --md-on-primary-container: #1E2A00;
  /* Secondary */
  --md-secondary: #5C6247;
  --md-on-secondary: #FFFFFF;
  --md-secondary-container: #E1E7C5;
  --md-on-secondary-container: #191F09;
  /* Tertiary */
  --md-tertiary: #386669;
  --md-on-tertiary: #FFFFFF;
  --md-tertiary-container: #BBECF0;
  --md-on-tertiary-container: #002022;
  /* Surface */
  --md-surface: #FDFCF5;
  --md-surface-dim: #DDDCCF;
  --md-surface-bright: #FDFCF5;
  --md-surface-container-lowest: #FFFFFF;
  --md-surface-container-low: #F7F6E9;
  --md-surface-container: #F1F0E3;
  --md-surface-container-high: #EBEADD;
  --md-surface-container-highest: #E5E4D7;
  --md-on-surface: #1B1C17;
  --md-on-surface-variant: #43483E;
  --md-outline: #73796D;
  --md-outline-variant: #C3C8BB;
  /* Inverse */
  --md-inverse-surface: #30312B;
  --md-inverse-on-surface: #F2F1E5;
  --md-inverse-primary: #C5E87C;

  /* Shape scale */
  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-xl: 28px;
  --shape-full: 9999px;

  /* Legacy aliases */
  --accent: var(--md-primary);
  --thumb2: #B4D96F;

  color-scheme: light;
}

[data-theme="dark"] {
  --md-primary: #B4D96F;
  --md-on-primary: #2B3800;
  --md-primary-container: #3F5200;
  --md-on-primary-container: #DFF0A8;
  --md-secondary: #C4CBA9;
  --md-on-secondary: #2E341B;
  --md-secondary-container: #444B30;
  --md-on-secondary-container: #E0E7C4;
  --md-tertiary: #A0CDD2;
  --md-on-tertiary: #00363A;
  --md-tertiary-container: #1F4D51;
  --md-on-tertiary-container: #BCE9EE;
  --md-surface: #1B1C17;
  --md-surface-dim: #1B1C17;
  --md-surface-bright: #41423C;
  --md-surface-container-lowest: #161712;
  --md-surface-container-low: #24251F;
  --md-surface-container: #282923;
  --md-surface-container-high: #33342E;
  --md-surface-container-highest: #3E3F39;
  --md-on-surface: #E3E3D6;
  --md-on-surface-variant: #C3C8BB;
  --md-outline: #8D9386;
  --md-outline-variant: #43483E;
  --md-inverse-surface: #E3E3D6;
  --md-inverse-on-surface: #2E2F29;
  --md-inverse-primary: #536800;
  --accent: var(--md-primary);
  --thumb2: #8FB34A;
  color-scheme: dark;
}

[data-theme="sunset"] {
  --md-primary: #FF6B6B;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #FFDAD6;
  --md-on-primary-container: #3B0E0B;
  --md-secondary: #775752;
  --md-on-secondary: #FFFFFF;
  --md-secondary-container: #FFDAD6;
  --md-on-secondary-container: #2C1612;
  --md-tertiary: #715B2F;
  --md-on-tertiary: #FFFFFF;
  --md-tertiary-container: #FDDDB2;
  --md-on-tertiary-container: #261900;
  --md-surface: #FFF8F6;
  --md-surface-container: #FCEAE5;
  --md-surface-container-high: #F6DFDA;
  --md-surface-container-highest: #F0D4CF;
  --md-on-surface: #231917;
  --md-on-surface-variant: #534340;
  --md-outline: #85736F;
  --md-outline-variant: #D8C2BD;
  --accent: var(--md-primary);
  --thumb2: #FF9E9E;
  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  background: var(--md-surface);
  color: var(--md-on-surface);
  display: flex;
  transition: background .25s ease, color .25s ease;
}

/* ---------- Typography (MD3 scale) ---------- */
.display-large { font-size: 57px; line-height: 64px; font-weight: 400; letter-spacing: -0.25px; margin: 0 0 16px; }
.display-medium { font-size: 45px; line-height: 52px; font-weight: 400; margin: 0 0 12px; }
.headline-large { font-size: 32px; line-height: 40px; font-weight: 400; margin: 0 0 8px; }
.headline-medium { font-size: 28px; line-height: 36px; font-weight: 400; margin: 0 0 8px; color: var(--md-on-surface); }
.headline-small { font-size: 24px; line-height: 32px; font-weight: 400; margin: 0; }
.title-large { font-size: 22px; line-height: 28px; font-weight: 500; }
.title-medium { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: 0.15px; }
.title-small { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; color: var(--md-on-surface-variant); text-transform: uppercase; margin: 0 0 12px; }
.body-large { font-size: 16px; line-height: 24px; font-weight: 400; color: var(--md-on-surface-variant); margin: 0; }
.body-medium { font-size: 14px; line-height: 20px; font-weight: 400; }
.label-large { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; }
.label-medium { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.5px; }

/* ---------- Navigation Rail ---------- */
.nav-rail {
  width: 80px;
  background: var(--md-surface-container-low);
  border-right: 1px solid var(--md-outline-variant);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  width: 56px;
  border-radius: var(--shape-lg);
  color: var(--md-on-surface-variant);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--md-surface-container-high); }
.nav-item.active {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.nav-item.active .icon { color: var(--md-on-secondary-container); }
.nav-item .icon { width: 24px; height: 24px; }

/* ---------- Top App Bar ---------- */
.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.search {
  flex: 1;
  max-width: none;
  min-width: 200px;
  position: relative;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-full);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 48px;
}
.search-icon { color: var(--md-on-surface-variant); width: 20px; height: 20px; margin-right: 8px; }
#q {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 16px;
  color: var(--md-on-surface);
  font-family: inherit;
}
#q::placeholder { color: var(--md-on-surface-variant); }

.user-menu { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.username { font-size: 14px; color: var(--md-on-surface-variant); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- MD3 Buttons ---------- */
.md-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--shape-full);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  border: 0;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.md-btn.filled {
  background: var(--md-primary);
  color: var(--md-on-primary);
}
.md-btn.filled:hover { box-shadow: 0 1px 3px rgba(0,0,0,.2); filter: brightness(1.05); }
.md-btn.tonal {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
}
.md-btn.tonal:hover { filter: brightness(1.05); }
.md-btn.outlined {
  background: transparent;
  color: var(--md-primary);
  border: 1px solid var(--md-outline);
}
.md-btn.outlined:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.md-btn.text {
  background: transparent;
  color: var(--md-primary);
  padding: 10px 12px;
}
.md-btn.text:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }

.md-icon-btn {
  background: transparent;
  border: 0;
  color: var(--md-on-surface-variant);
  width: 40px;
  height: 40px;
  border-radius: var(--shape-full);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s;
}
.md-icon-btn:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.md-icon-btn.large { width: 56px; height: 56px; }
.md-icon-btn.large .icon { width: 28px; height: 28px; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  bottom: 100px;
  right: 32px;
  width: 56px;
  height: 56px;
  border-radius: var(--shape-lg);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.15), 0 4px 8px rgba(0,0,0,.1);
  transition: transform .15s, box-shadow .15s;
  z-index: 30;
}
.fab:hover { box-shadow: 0 2px 6px rgba(0,0,0,.2), 0 8px 16px rgba(0,0,0,.15); transform: translateY(-2px); }
.fab.large {
  position: static;
  width: 64px;
  height: 64px;
  border-radius: var(--shape-lg);
}
.fab .icon { width: 24px; height: 24px; }
.fab.large .icon { width: 32px; height: 32px; }

/* ---------- Main Content ---------- */
main {
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero { padding: 24px 0 32px; }

/* ---------- Section Head ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 16px; }

/* ---------- History Row ---------- */
.h-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 160px;
  gap: 16px;
  overflow-x: auto;
  padding: 8px 0 16px;
  scrollbar-width: thin;
}
.h-card { cursor: pointer; min-width: 0; }
.h-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--shape-lg);
  background: linear-gradient(135deg, var(--md-primary), var(--thumb2));
  display: grid;
  place-items: center;
  color: var(--md-on-primary);
  margin-bottom: 12px;
}
.h-thumb > .icon { width: 48px; height: 48px; opacity: .9; }
.h-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  border-radius: var(--shape-full);
  background: var(--md-primary);
  color: var(--md-on-primary);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .15s;
}
.h-play .icon { width: 20px; height: 20px; }
.h-card:hover .h-play { opacity: 1; }
.h-add {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 32px;
  height: 32px;
  border-radius: var(--shape-full);
  background: var(--md-primary);
  color: var(--md-on-primary);
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.h-card:hover .h-add { opacity: 1; }
.h-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--md-on-surface); }
.h-artist { font-size: 12px; color: var(--md-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-card.playing .h-title { color: var(--md-primary); }

/* ---------- Track List ---------- */
.tracklist { list-style: none; margin: 0; padding: 0; }
.track {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--shape-md);
  cursor: pointer;
  transition: background .15s;
}
.track:hover { background: var(--md-surface-container-high); }
.t-title { font-size: 14px; font-weight: 400; color: var(--md-on-surface); cursor: pointer; }
.t-title:hover { color: var(--md-primary); text-decoration: underline; }
.t-artist { color: var(--md-on-surface-variant); font-size: 14px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-dur { color: var(--md-on-surface-variant); font-size: 12px; font-variant-numeric: tabular-nums; font-family: 'Roboto Mono', monospace; }
.t-actions { display: flex; gap: 4px; opacity: 1; }
.track.playing { background: var(--md-secondary-container); }
.track.playing .t-title { color: var(--md-on-secondary-container); font-weight: 500; }

/* ---------- Playlist Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.card {
  background: var(--md-surface-container-low);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-xl);
  padding: 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.card:hover { background: var(--md-surface-container); border-color: var(--md-outline); }
.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--shape-lg);
  background: linear-gradient(135deg, var(--md-primary), var(--thumb2));
  color: var(--md-on-primary);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.card-icon .icon { width: 24px; height: 24px; }
.card-name { font-size: 14px; font-weight: 500; color: var(--md-on-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 4px; }

.hint { color: var(--md-on-surface-variant); padding: 16px 0; font-size: 14px; }
.more-wrap { text-align: center; margin: 24px 0; }

/* ---------- Playlist Head ---------- */
.playlist-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.playlist-head h2 { flex: 1; min-width: 200px; }

/* ---------- Track Page ---------- */
.tk-head { margin-bottom: 24px; }
.tk-layout { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.tk-thumb {
  width: min(320px, 70vw);
  aspect-ratio: 1;
  border-radius: var(--shape-xl);
  background: linear-gradient(135deg, var(--md-primary), var(--thumb2));
  display: grid;
  place-items: center;
  color: var(--md-on-primary);
  flex: 0 0 auto;
}
.tk-thumb .icon { width: 96px; height: 96px; opacity: .9; }
.tk-info { flex: 1; min-width: 280px; }
.tk-info h1 { margin: 0 0 8px; }
.tk-artist { color: var(--md-primary); text-decoration: none; font-size: 16px; font-weight: 500; }
.tk-artist:hover { text-decoration: underline; }
.tk-times { color: var(--md-on-surface-variant); margin: 16px 0 8px; font-variant-numeric: tabular-nums; font-family: 'Roboto Mono', monospace; font-size: 14px; }
#tk-seek { width: 100%; accent-color: var(--md-primary); }
.tk-buttons { display: flex; align-items: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Player Bar ---------- */
footer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--md-surface-container-highest);
  border-top: 1px solid var(--md-outline-variant);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
audio { display: none; }
.pb-track { flex: 0 1 240px; min-width: 120px; }
.pb-title { font-size: 14px; font-weight: 500; color: var(--md-on-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-artist { font-size: 12px; color: var(--md-on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-center { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; }
.pb-buttons { display: flex; align-items: center; gap: 8px; }
#btn-play {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: var(--shape-full);
  background: var(--md-primary);
  color: var(--md-on-primary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .1s;
}
#btn-play:hover { transform: scale(1.05); }
#btn-play .icon { width: 24px; height: 24px; }
#btn-repeat.active { color: var(--md-primary); background: var(--md-primary-container); }
.pb-progress { flex: 1; display: flex; align-items: center; gap: 8px; }
.pb-progress span { color: var(--md-on-surface-variant); font-size: 12px; font-variant-numeric: tabular-nums; font-family: 'Roboto Mono', monospace; min-width: 40px; text-align: center; }
input[type="range"] { accent-color: var(--md-primary); background: transparent; cursor: pointer; }
#seek { flex: 1; }
.pb-vol { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
#vol { width: 100px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-box {
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl);
  padding: 24px;
}
.modal-sm { width: min(440px, 92vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-head h2 { margin: 0; }
.modal section { margin-bottom: 24px; }
.modal h3 { margin: 0 0 12px; }

/* ---------- Theme Chips ---------- */
.themes { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--shape-full);
  border: 1px solid var(--md-outline);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.theme-chip.active { border-color: var(--md-primary); background: var(--md-primary-container); color: var(--md-on-primary-container); }
.sw { width: 16px; height: 16px; border-radius: var(--shape-full); }
.sw-dark { background: #1B1C17; border: 1px solid #555; }
.sw-light { background: #FDFCF5; border: 1px solid #ccc; }
.sw-sunset { background: linear-gradient(135deg, #FF6B6B, #FF9E9E); }

/* ---------- MD3 Switch ---------- */
.md-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--md-on-surface);
}
.md-switch input { display: none; }
.switch-track {
  width: 52px;
  height: 32px;
  border-radius: var(--shape-full);
  background: var(--md-surface-container-highest);
  border: 2px solid var(--md-outline);
  position: relative;
  transition: background .2s, border-color .2s;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: var(--shape-full);
  background: var(--md-outline);
  transition: transform .2s, background .2s;
}
.md-switch input:checked + .switch-track {
  background: var(--md-primary);
  border-color: var(--md-primary);
}
.md-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
  background: var(--md-on-primary);
}

/* ---------- MD3 Field ---------- */
.md-field {
  display: block;
  margin-bottom: 12px;
}
.md-field span {
  display: block;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  margin-bottom: 4px;
}
.md-field input {
  width: 100%;
  padding: 12px 16px;
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline);
  border-radius: var(--shape-sm);
  color: var(--md-on-surface);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.md-field input:focus { border-color: var(--md-primary); border-width: 2px; padding: 11px 15px; }

/* ---------- AddTo Modal ---------- */
.addto-list { display: grid; gap: 8px; margin-bottom: 16px; max-height: 280px; overflow-y: auto; }
.addto-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--shape-md);
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  color: var(--md-on-surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  transition: background .15s;
}
.addto-item:hover { background: var(--md-surface-container-high); }
.addto-item em { margin-left: auto; color: var(--md-on-surface-variant); font-style: normal; font-size: 12px; }
.addto-create-row { border-style: dashed !important; color: var(--md-on-surface-variant); }
.addto-create-row:hover { color: var(--md-on-surface); border-color: var(--md-primary) !important; }
.addto-new { display: flex; align-items: center; gap: 12px; }
.addto-new .md-field { flex: 1; margin: 0; }
.addto-new .md-btn { flex: 0 0 auto; }

/* ---------- Suggest ---------- */
.suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--md-surface-container-high);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--shape-lg);
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  max-height: 320px;
  overflow-y: auto;
}
.s-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; font-size: 14px; }
.s-item:hover, .s-item.active { background: var(--md-surface-container-highest); }
.s-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-del { background: none; border: 0; color: var(--md-on-surface-variant); cursor: pointer; padding: 4px; border-radius: var(--shape-full); display: grid; place-items: center; }
.s-del:hover { color: #FF6B6B; }
.s-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  border-top: 1px solid var(--md-outline-variant);
}
.s-foot button { background: none; border: 0; color: var(--md-primary); cursor: pointer; font-size: 12px; font-family: inherit; }

/* ---------- Spinner ---------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Acc ---------- */
.acc-fields { display: grid; gap: 12px; margin-bottom: 16px; }
.acc-err { color: #FF6B6B; font-size: 12px; min-height: 1em; margin-top: 8px; }

/* ---------- Icons ---------- */
.icon { width: 20px; height: 20px; fill: currentColor; display: block; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-rail { width: 64px; }
  .nav-item span { display: none; }
  main { padding: 16px; }
}
@media (max-width: 720px) {
  .nav-rail { display: none; }
  .top-app-bar { padding: 8px 16px; }
  .tk-layout { flex-direction: column; }
  .tk-thumb { width: 100%; max-width: 280px; margin: 0 auto; }
  footer { padding: 8px 16px; }
  .pb-track { display: none; }
  .pb-vol { display: none; }
  .track { grid-template-columns: 1fr auto auto; }
  .t-artist { display: none; }
}

/* ---------- v8: фикс layout ---------- */
body { display: flex; }
.app-shell { display: flex; width: 100%; min-height: 100vh; }
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nav-rail {
  flex: 0 0 80px;
  height: 100vh;
  position: sticky;
  top: 0;
}
.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
main {
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}
footer#playerbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--md-surface-container-highest);
  border-top: 1px solid var(--md-outline-variant);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
/* FAB привязан к app-content, а не к body */
.fab { right: 32px; bottom: 100px; }


/* ---------- Страница плейлистов ---------- */
.playlists-page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
.playlists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}
.playlists-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 80px 24px;
  gap: 16px;
}
.empty-icon {
  width: 96px;
  height: 96px;
  color: var(--md-on-surface-variant);
  opacity: 0.5;
}
.playlists-empty h3 { margin: 0; }
.playlists-empty p { margin: 0; color: var(--md-on-surface-variant); max-width: 400px; }

@media (max-width: 720px) {
  .playlists-page-head { flex-direction: column; align-items: flex-start; }
  .playlists-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

.see-all-btn {
  margin-top: 16px;
  padding: 8px 16px;
}

/* ---------- Модалка авторизации ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.tabs button { flex: 1; }
.tabs button.active { background: var(--md-primary); color: var(--md-on-primary); }
.md-btn.wide { width: 100%; justify-content: center; }

/* ---------- Фикс: hidden должен побеждать любые display ---------- */
[hidden] { display: none !important; }


/* ============================================================
   MD3 Animations & Micro-interactions
   ============================================================ */

:root {
  /* Упругий отскок для интерактивных элементов */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Плавное замедление для фоновых изменений */
  --ease-smooth: cubic-bezier(0.2, 0.0, 0, 1.0);
}

/* 1. Переходы между страницами (плавное всплытие с легким отскоком) */
.view {
  display: none;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
}
.view.active {
  display: block;
  animation: viewEnter 0.4s var(--ease-bounce) forwards;
}
@keyframes viewEnter {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 2. Эффект нажатия (scale down) для всех кликабельных карточек и кнопок */
.md-btn, .card, .h-card, .track, .md-icon-btn, .theme-chip {
  transition: transform 0.2s var(--ease-bounce), 
              background-color 0.2s ease, 
              box-shadow 0.2s ease;
}
.md-btn:active, .card:active, .h-card:active, .track:active, .md-icon-btn:active {
  transform: scale(0.94) !important; /* Эффект "вдавливания" */
}

/* 3. Hover-эффекты (легкий подъем) */
.card:hover, .h-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.track:hover {
  transform: translateX(4px);
}

/* 4. FAB (Плавающая кнопка) */
.fab {
  transition: transform 0.3s var(--ease-bounce), box-shadow 0.3s ease;
}
.fab:hover {
  transform: translateY(-6px) scale(1.05);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}
.fab:active {
  transform: scale(0.9) !important;
}

/* 5. Модалки (упругое появление из центра/снизу) */
.modal-box {
  animation: modalPop 0.4s var(--ease-bounce) forwards;
}
@keyframes modalPop {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* 6. Каскадное появление элементов списка (будет управляться через JS delay) */
.stagger-item {
  animation: listItemEnter 0.4s var(--ease-bounce) backwards;
}
@keyframes listItemEnter {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* 7. Анимация спиннера загрузки (уже была, делаем чуть плавнее) */
@keyframes spin { 
  to { transform: rotate(360deg); } 
}

/* Фикс позиции FAB — принудительно внизу */
#view-home .fab {
  bottom: 100px !important;
  top: auto !important;
  right: 32px;
}

/* На странице плейлистов тоже внизу */
#view-playlists-page .fab {
  bottom: 100px !important;
  top: auto !important;
}

/* Фикс табов в модалке авторизации */
.tabs button {
  flex: 1;
  text-align: center;
  justify-content: center;
  padding: 10px 16px;
  min-width: 0;
}

@media (max-width: 720px) {
  .search {
    min-width: 150px;
  }
  .tabs button {
    padding: 8px 12px;
    font-size: 13px;
  }
}
