:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #ece6da;
  --ink: #171513;
  --muted: #6b6258;
  --line: #ddd5c8;
  --accent: #196b55;
  --accent-ink: #ffffff;
  --warm: #9d4f2f;
  --shadow: 0 10px 28px rgba(42, 34, 24, 0.13);
  --radius: 8px;
  --tap: 48px;
  font-family: Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(25, 107, 85, 0.08), rgba(247, 243, 234, 0) 260px),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100svh;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(247, 243, 234, 0.91);
  border-bottom: 1px solid rgba(221, 213, 200, 0.72);
  backdrop-filter: blur(18px);
}

.top-bar h1,
.section-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.top-bar h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: var(--tap);
  height: var(--tap);
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

@media (display-mode: fullscreen), (display-mode: standalone), (display-mode: minimal-ui), (display-mode: window-controls-overlay) {
  .install-button {
    display: none !important;
  }
}

.content {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 14px 14px 24px;
}

.toolbar {
  display: grid;
  gap: 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.search-field input::placeholder {
  color: #857b70;
}

.toolbar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
}

.primary-action,
.link-button,
.close-button {
  display: inline-flex;
  min-height: var(--tap);
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  font-weight: 750;
}

.primary-action {
  padding: 0 18px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 18px rgba(25, 107, 85, 0.22);
}

.sort-control {
  display: inline-flex;
  min-width: 126px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.sort-control select {
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 18px;
}

.stats-strip div {
  display: grid;
  min-width: 0;
  gap: 2px;
  padding: 12px;
  border: 1px solid rgba(221, 213, 200, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.78);
}

.stats-strip strong {
  overflow: hidden;
  color: var(--warm);
  font-size: 1.22rem;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.stats-strip span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 2px 2px 12px;
}

.section-header h2 {
  font-size: 1.08rem;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

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

.album-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 13px;
  width: 100%;
  min-height: 98px;
  padding: 10px;
  border: 1px solid rgba(221, 213, 200, 0.9);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.album-card:active {
  transform: scale(0.992);
}

.album-card__cover {
  width: 76px;
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--surface-2);
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(30, 24, 16, 0.12);
}

.album-card__body {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 4px;
}

.album-card__title,
.album-card__artist,
.album-card__meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-card__title {
  font-size: 1rem;
  line-height: 1.2;
}

.album-card__artist {
  color: var(--muted);
  font-size: 0.94rem;
}

.album-card__meta {
  color: var(--warm);
  font-size: 0.82rem;
  font-weight: 750;
}

.empty-state {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 16px 0 0;
}

.pagination[hidden] {
  display: none;
}

.page-button,
.page-select {
  display: inline-flex;
  min-height: var(--tap);
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.page-button {
  padding: 0 14px;
}

.page-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.page-select {
  min-width: 128px;
  padding: 0 10px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-select select {
  min-height: 46px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(221, 213, 200, 0.86);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-nav a,
.bottom-nav button {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 2px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.bottom-nav .active {
  background: #dfeee7;
  color: var(--accent);
}

.update-toast {
  position: fixed;
  right: 14px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 8px 8px 8px 16px;
  border: 1px solid rgba(23, 21, 19, 0.08);
  border-radius: var(--radius);
  background: rgba(23, 21, 19, 0.94);
  color: #fffdf8;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.update-toast[hidden] {
  display: none;
}

.update-toast span {
  min-width: 0;
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-toast button {
  min-height: 40px;
  border-radius: 999px;
  font-weight: 750;
}

.update-toast__refresh {
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
}

.update-toast__dismiss {
  padding: 0 12px;
  background: transparent;
  color: #fffdf8;
}

.album-dialog {
  width: min(100%, 760px);
  max-width: none;
  max-height: 100svh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.album-dialog::backdrop {
  background: rgba(23, 21, 19, 0.46);
}

.album-detail {
  max-height: 92svh;
  overflow: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.detail-hero {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-cover {
  width: 128px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  object-fit: cover;
  box-shadow: 0 14px 32px rgba(30, 24, 16, 0.26);
}

.detail-copy {
  min-width: 0;
}

.detail-copy h2 {
  margin: 0 0 5px;
  font-size: 1.38rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.detail-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.info-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.info-rows > span,
.info-rows > a,
.genre-chips b {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
}

.info-rows > span,
.info-rows > a {
  padding: 0 10px;
  background: #ece6da;
}

.info-rows > a {
  color: var(--accent);
}

.genre-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  background: transparent;
}

.genre-chips b {
  padding: 0 9px;
  background: #dfeee7;
  color: var(--accent);
  font-size: inherit;
}

.detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px 8px;
}

.link-button {
  min-width: 0;
  padding: 0 12px;
  background: #ece6da;
  color: var(--ink);
}

.link-button.spotify {
  background: #dceee5;
  color: #075236;
}

.link-button.youtube {
  background: #f2e0d9;
  color: #813418;
}

.link-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-list {
  display: grid;
  gap: 1px;
  margin: 8px 0 0;
  padding: 0 18px;
  list-style: none;
}

.track-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(221, 213, 200, 0.72);
}

.track-list b {
  color: var(--warm);
  font-size: 0.84rem;
}

.track-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.close-button {
  position: sticky;
  bottom: 0;
  width: calc(100% - 36px);
  margin: 16px 18px 0;
  background: var(--ink);
  color: #fffdf8;
}

[data-icon] {
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  background: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
}

[data-icon="download"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 3h2v9.2l3.6-3.6L18 10l-6 6-6-6 1.4-1.4 3.6 3.6V3Zm-6 15h14v2H5v-2Z'/%3E%3C/svg%3E");
}

[data-icon="library"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 4h11a3 3 0 0 1 3 3v13H7a3 3 0 0 1-3-3V5a1 1 0 0 1 1-1Zm2 2v11a1 1 0 0 0 1 1h9V7a1 1 0 0 0-1-1H7Zm2 2h6v2H9V8Zm0 4h6v2H9v-2Z'/%3E%3C/svg%3E");
}

[data-icon="search"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 4a6.5 6.5 0 0 1 5.17 10.44l4.45 4.44-1.42 1.42-4.44-4.45A6.5 6.5 0 1 1 10.5 4Zm0 2a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9Z'/%3E%3C/svg%3E");
}

[data-icon="shuffle"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17 3h5v5h-2V6.4l-4.38 4.38-1.42-1.42L18.6 5H17V3ZM4 7h3.2c1.43 0 2.8.57 3.81 1.59l8.99 9.01V16h2v5h-5v-2h1.6l-9-9.01A3.4 3.4 0 0 0 7.2 9H4V7Zm10.2 7.64 1.42-1.42L18.6 16H17v2h5v-5h-2v1.6l-2.97-2.97-2.83 3.01ZM4 17h3.2a3.4 3.4 0 0 0 2.4-.99l1.6-1.6-1.42-1.42-1.6 1.6a1.4 1.4 0 0 1-.98.41H4v2Z'/%3E%3C/svg%3E");
}

[data-icon="play"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 5v14l11-7L8 5Z'/%3E%3C/svg%3E");
}

[data-icon="chevron-left"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m14.7 6.7-1.4-1.4L6.6 12l6.7 6.7 1.4-1.4L9.4 12l5.3-5.3Z'/%3E%3C/svg%3E");
}

[data-icon="chevron-right"] {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m9.3 17.3 1.4 1.4 6.7-6.7-6.7-6.7-1.4 1.4 5.3 5.3-5.3 5.3Z'/%3E%3C/svg%3E");
}

@media (min-width: 720px) {
  .content {
    padding-inline: 22px;
  }

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

  .album-dialog {
    margin: auto;
    border-radius: 18px;
  }

  .bottom-nav {
    right: 50%;
    left: 50%;
    width: min(420px, calc(100% - 32px));
    transform: translateX(-50%);
    border: 1px solid rgba(221, 213, 200, 0.86);
    border-radius: 28px 28px 0 0;
  }

  .update-toast {
    right: 50%;
    left: auto;
    width: min(420px, calc(100% - 32px));
    transform: translateX(50%);
  }
}

@media (min-width: 980px) {
  .album-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
