:root {
  color-scheme: light;
  --bg: #f4efe6;
  --paper: #fffdf9;
  --ink: #171716;
  --muted: #716c63;
  --line: #d7cec0;
  --accent: #1d5a50;
  --accent-ink: #f8fffd;
  --danger: #a53c36;
  --shelf: #9d7754;
  --shadow: 0 16px 40px rgba(50, 40, 25, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.7), transparent 32rem),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .album-card:focus-visible {
  outline: 3px solid rgba(29,90,80,.3);
  outline-offset: 3px;
}

.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 28px 22px 36px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; font-size: .72rem; letter-spacing: .15em; font-weight: 800; color: var(--muted); }
h1 { margin: 0; font-size: clamp(2.3rem, 7vw, 4.8rem); line-height: .9; letter-spacing: -.055em; }
h2 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.035em; }

.primary-button, .ghost-button, .danger-button, .icon-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 17px;
  font-weight: 750;
}
.primary-button { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(29,90,80,.16); }
.primary-button:hover { filter: brightness(.96); }
.ghost-button { background: rgba(255,255,255,.56); border: 1px solid var(--line); color: var(--ink); }
.danger-button { background: #f8e5e2; color: var(--danger); }
.icon-button { width: 42px; height: 42px; padding: 0; font-size: 1.7rem; background: transparent; color: var(--muted); }
.hidden { display: none !important; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: rgba(255,255,255,.46); border: 1px solid rgba(215,206,192,.8); border-radius: 18px; padding: 15px 18px; }
.stat-card span { display: block; font-weight: 850; font-size: 1.8rem; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }

.toolbar { display: grid; grid-template-columns: minmax(190px, 1fr) auto auto auto; gap: 9px; align-items: center; margin-bottom: 28px; }
.toolbar input, .toolbar select, .catalog-search-row input, .field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  color: var(--ink);
  border-radius: 15px;
  padding: 12px 14px;
}
.toolbar select { min-width: 178px; }
.file-label { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

.empty-state { text-align: center; padding: 60px 20px 78px; max-width: 620px; margin: 10px auto; }
.empty-state p { color: var(--muted); line-height: 1.6; margin: 12px auto 22px; max-width: 510px; }
.empty-cover {
  width: 118px; aspect-ratio: 1; margin: 0 auto 24px; border-radius: 9px;
  display: grid; place-items: center; font-size: 3rem; font-weight: 900;
  background: linear-gradient(135deg, #1d5a50, #93b3a6 48%, #e7b472);
  color: white; box-shadow: var(--shadow); transform: rotate(-2deg);
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 34px 22px;
}
.album-card { position: relative; min-width: 0; border-radius: 12px; cursor: pointer; }
.album-card::after {
  content: "";
  position: absolute;
  left: -7px; right: -7px; top: calc(min(240px, 100vw) * .0); bottom: 72px;
  height: 8px;
  background: linear-gradient(#b18a65, var(--shelf));
  border-radius: 3px;
  transform: translateY(8px);
  z-index: -1;
  box-shadow: 0 5px 7px rgba(77,54,34,.18);
}
.cover-wrap { position: relative; aspect-ratio: 1; border-radius: 8px; background: #ddd; box-shadow: 0 12px 28px rgba(39,32,24,.18); transition: transform .18s ease, box-shadow .18s ease; overflow: hidden; }
.album-card:hover .cover-wrap { transform: translateY(-4px); box-shadow: 0 18px 34px rgba(39,32,24,.22); }
.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.rating-badge {
  position: absolute; right: 9px; bottom: 9px; min-width: 49px; height: 38px; padding: 0 9px;
  display: grid; place-items: center; border-radius: 999px;
  color: white; background: rgba(18,18,17,.82); backdrop-filter: blur(10px);
  font-weight: 850; font-variant-numeric: tabular-nums; box-shadow: 0 4px 12px rgba(0,0,0,.16);
}
.album-text { padding-top: 12px; }
.album-title { margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-artist, .album-year { margin: 4px 0 0; color: var(--muted); font-size: .87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.album-year { font-size: .78rem; opacity: .84; }

footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); margin-top: 54px; padding-top: 18px; color: var(--muted); font-size: .76rem; }

.dialog { border: 0; padding: 0; background: transparent; width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 28px); }
.dialog::backdrop { background: rgba(22,19,15,.46); backdrop-filter: blur(5px); }
.dialog-card { background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: 0 28px 80px rgba(0,0,0,.28); overflow: auto; max-height: calc(100dvh - 28px); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }

/* v0.2: Die eigentliche Albumwertung soll im Fokus stehen, nicht die Dialogüberschrift. */
.rating-dialog-header { align-items: center; }
.rating-dialog-header .eyebrow { margin-bottom: 2px; }
.rating-dialog-heading {
  margin: 0;
  font-size: .98rem;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 720;
  color: var(--muted);
}
.rating-dialog .rating-album-head { margin-top: 14px; }
.catalog-search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 22px; }
.hint { color: var(--muted); font-size: .8rem; margin: 7px 3px 13px; }
.catalog-status { min-height: 20px; color: var(--muted); font-size: .88rem; }
.catalog-results { display: grid; gap: 9px; margin-top: 8px; }
.catalog-item { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 15px; padding: 9px; background: #fff; }
.catalog-item img { width: 72px; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.catalog-item h3 { margin: 0 0 3px; font-size: 1rem; }
.catalog-item p { margin: 0; color: var(--muted); font-size: .82rem; }
.catalog-item button { white-space: nowrap; }

.rating-album-head { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; margin: 22px 0 20px; }
.rating-album-head img { width: 120px; aspect-ratio: 1; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); }
.rating-album-head h3 { font-size: 1.35rem; margin: 0 0 4px; }
.rating-album-head p { margin: 2px 0; color: var(--muted); }
.rating-control { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 10px 0 6px; }
.rating-control output { font-size: clamp(3.6rem, 15vw, 6rem); line-height: 1; font-weight: 900; letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.rating-control span { font-size: 1.2rem; color: var(--muted); font-weight: 700; }
#ratingSlider { width: 100%; accent-color: var(--accent); margin: 2px 0 23px; }
.field { display: grid; gap: 8px; margin: 15px 0; font-weight: 700; }
.field span { font-size: .86rem; }
.field em { color: var(--muted); font-weight: 500; font-style: normal; }
.field textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
.dialog-actions { display: flex; gap: 9px; align-items: center; margin-top: 22px; }
.spacer { flex: 1; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 680px) {
  .app-shell { padding: 18px 14px 28px; }
  .topbar { align-items: center; }
  .topbar .primary-button { padding: 10px 14px; }
  .stats { gap: 7px; }
  .stat-card { padding: 12px; }
  .stat-card span { font-size: 1.45rem; }
  .stat-card small { font-size: .7rem; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-mini { grid-column: 1 / -1; }
  .toolbar select { min-width: 0; }
  .shelf { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 30px 14px; }
  footer { flex-direction: column; }
  .dialog-card { padding: 18px; border-radius: 20px; }
  .catalog-search-row { grid-template-columns: 1fr; }
  .catalog-item { grid-template-columns: 62px 1fr; }
  .catalog-item img { width: 62px; }
  .catalog-item button { grid-column: 1 / -1; width: 100%; }
  .rating-album-head { grid-template-columns: 94px 1fr; }
  .rating-album-head img { width: 94px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .spacer { display: none; }
  .dialog-actions button { flex: 1 1 auto; }
  .danger-button { flex-basis: 100% !important; }
}

/* v0.3 cloud sync */
.sync-button { position: relative; }
.sync-button::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
  background: #aaa096;
  vertical-align: 1px;
}
.sync-button.sync-active::before { background: #2f8c70; }
.sync-button.sync-pending::before { background: #d39a39; }
.sync-explainer {
  color: var(--muted);
  line-height: 1.55;
  margin: 18px 0 6px;
  max-width: 650px;
}
.sync-dialog-status {
  min-height: 22px;
  margin: 12px 1px 2px;
  color: var(--muted);
  font-size: .88rem;
}
.sync-actions { margin-top: 18px; }

@media (min-width: 681px) {
  .toolbar { grid-template-columns: minmax(190px, 1fr) auto auto auto auto; }
}

@media (max-width: 680px) {
  .sync-button { width: 100%; }
  footer { gap: 7px; }
}
