:root {
  --bg: #f3e9d2;
  --paper: #fff8ea;
  --paper-2: #f7ecd4;
  --ink: #2b1d12;
  --muted: #8a6d4f;
  --accent: #e4572e;
  --accent-dark: #c23e1a;
  --mustard: #f2a03d;
  --spotify: #1db954;
  --radius: 14px;
  --border: 2px solid var(--ink);
  --shadow: 4px 4px 0 rgba(43, 29, 18, 0.9);
  --shadow-soft: 3px 3px 0 rgba(43, 29, 18, 0.35);
  --display: "Shrikhand", "Georgia", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: var(--border);
  z-index: 10;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--accent-dark);
}

.header-right { display: flex; align-items: center; gap: 10px; }
.nav-btn {
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  touch-action: manipulation;
}
.nav-btn:active { transform: translate(2px, 2px); box-shadow: none; }

main { max-width: 640px; margin: 0 auto; padding: 20px; }

/* ---------- Slogan ---------- */

.slogan {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.3;
  text-align: center;
  color: var(--ink);
  min-height: 3.6rem;
  margin: 18px 0 22px;
  transition: opacity 0.5s ease;
}
.slogan.fading { opacity: 0; }
.slogan .accent { color: var(--accent-dark); }

/* ---------- Auth ---------- */

.auth-box {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  margin-top: 40px;
}
.auth-box h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: var(--accent-dark); }
.auth-box p { font-size: 0.92rem; line-height: 1.5; }
.auth-box input { text-align: center; }
.auth-box .btn { width: 100%; }
#code-step { display: flex; flex-direction: column; gap: 14px; }
#code-step[hidden] { display: none; }
#code-input { letter-spacing: 6px; font-size: 1.3rem; }

/* ---------- Scan ---------- */

.capture-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 12px;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.capture:active, .capture:hover { background: var(--paper-2); color: var(--accent-dark); border-color: var(--accent-dark); }
.capture strong { color: var(--ink); font-size: 1rem; }
.capture span { font-size: 0.82rem; }

.capture-hint {
  text-align: center;
  font-size: 0.88rem;
  margin-top: 14px;
}

.photo-strip {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  overflow-x: auto;
  padding: 6px 2px;
}
.thumb { position: relative; flex-shrink: 0; }
.thumb img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: var(--border);
  background: var(--paper);
}
.thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

#photo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}
#photo-actions .btn { width: 100%; }

.manual { margin-top: 24px; text-align: center; }
.link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.95rem;
}
.link:hover { color: var(--accent-dark); }
#manual-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

input[type="text"],
input[type="email"] {
  background: var(--paper);
  border: var(--border);
  border-radius: 10px;
  color: var(--ink);
  padding: 14px 16px;
  font-size: 16px; /* verhindert iOS-Auto-Zoom */
  outline: none;
  width: 100%;
}
input[type="text"]:focus,
input[type="email"]:focus { border-color: var(--accent-dark); box-shadow: var(--shadow-soft); }
input::placeholder { color: var(--muted); opacity: 0.7; }

.btn {
  background: var(--accent);
  color: #fff;
  border: var(--border);
  border-radius: 999px;
  padding: 14px 24px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  box-shadow: 3px 3px 0 var(--ink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.05s, box-shadow 0.05s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn.spotify { background: var(--spotify); color: #04150a; }
.btn.ghost { background: var(--paper); color: var(--ink); width: 100%; margin-top: 28px; }
.btn.small { padding: 8px 16px; font-size: 0.85rem; min-height: 38px; }

/* ---------- Loading ---------- */

#loading-view { text-align: center; padding: 60px 0; }
.vinyl-spin {
  width: 90px; height: 90px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, #241609 0 2px, #3a2a18 2px 4px);
  border: 3px solid var(--ink);
  position: relative;
  animation: spin 1.6s linear infinite;
}
.vinyl-spin::after {
  content: "";
  position: absolute; inset: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--ink);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ergebnis ---------- */

.identified {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.identified strong { color: var(--ink); }
.confidence { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; margin-left: 8px; border: 1.5px solid var(--ink); }
.confidence.high { background: #cdeac0; color: #1d5c22; }
.confidence.medium { background: #fbe2a0; color: #8a5c00; }
.confidence.low { background: #f6c1b2; color: #a3320f; }
.transcription { font-size: 0.82rem; font-style: italic; }
.mismatch-warn { color: var(--accent-dark); font-weight: 700; font-size: 0.85rem; }

/* ---------- Hinweis ---------- */

#hint-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
#hint-area .btn { align-self: flex-start; margin-top: 0; width: auto; }

.album-card {
  display: flex;
  gap: 16px;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
#album-cover {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  border: var(--border);
  flex-shrink: 0;
}
.album-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.album-meta h2 { font-family: var(--display); font-weight: 400; font-size: 1.2rem; line-height: 1.25; }
.album-meta .btn { margin-top: auto; }

.section-title {
  margin: 26px 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.75rem;
  font-weight: 800;
}

.tracks { list-style: none; }
.tracks li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 10px;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tracks li:hover, .tracks li:active { background: var(--paper-2); }
.tracks .num { color: var(--muted); width: 22px; text-align: right; font-size: 0.9rem; flex-shrink: 0; }
.tracks .tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks .dur { color: var(--muted); font-size: 0.85rem; flex-shrink: 0; }
.tracks .play { color: var(--accent-dark); font-size: 1.1rem; flex-shrink: 0; }
.tracks li.playing { background: var(--paper-2); }
.tracks li.playing .tname { color: var(--accent-dark); font-weight: 700; }

#history { display: flex; flex-direction: column; gap: 14px; }
.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
  font-size: 0.92rem;
}
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }
.story {
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px;
}
#history a { color: var(--accent-dark); }

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

/* ---------- Alternativen ---------- */

.alt-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}
.alt-item {
  background: var(--paper);
  border: var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  font-size: 0.8rem;
  box-shadow: 2px 2px 0 rgba(43, 29, 18, 0.35);
}
.alt-item:hover, .alt-item:active { border-color: var(--accent-dark); }
.alt-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--paper-2); }
.alt-item .alt-name { font-weight: 700; line-height: 1.25; }
.alt-item .muted { font-size: 0.75rem; }

/* ---------- Sammlung ---------- */

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.record-card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 12px;
  cursor: pointer;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  font-size: 0.85rem;
}
.record-card:hover, .record-card:active { border-color: var(--accent-dark); }
.record-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: var(--border);
  background: var(--paper-2);
}

#record-view { display: flex; flex-direction: column; }
#record-back { align-self: flex-start; margin-bottom: 14px; }
#record-photos img { width: 130px; height: 130px; border: var(--border); border-radius: 8px; }
.record-head { margin: 16px 0 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.record-head h2 { font-family: var(--display); font-weight: 400; font-size: 1.4rem; }

.badge {
  background: var(--mustard);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.track-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}
.track-del:hover, .track-del:active { color: var(--accent-dark); }

#add-track-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px;
  margin-top: 10px;
}
#add-track-form .btn { margin-top: 0; }

/* ---------- QR-Pairing ---------- */

.pair-link { display: block; margin: 16px auto 0; }
.qr-box {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  margin-top: 24px;
}
.qr-box h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: var(--accent-dark); }
.qr-box p { font-size: 0.92rem; line-height: 1.5; }
#qr-code {
  background: var(--paper);
  border: var(--border);
  border-radius: 10px;
  padding: 14px;
}
#qr-code img, #qr-code canvas { display: block; }
.qr-url { font-size: 0.78rem; word-break: break-all; }
.qr-status { font-weight: 700; color: var(--accent-dark); }
.qr-status::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: dots 1.5s steps(4) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.qr-box .btn { width: 100%; margin-top: 0; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  padding: 12px 20px;
  border-radius: 10px;
  max-width: 90vw;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}

/* ---------- Player-Bar ---------- */

#player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  border-top: 3px solid var(--accent);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
  color: var(--paper);
}
#player-cover { width: 48px; height: 48px; border-radius: 6px; border: 2px solid var(--paper); }
.player-info { flex: 1; min-width: 0; }
#player-track { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player-bar .muted { color: #c9b391; }
#player-toggle {
  background: var(--accent);
  border: 2px solid var(--paper);
  border-radius: 50%;
  width: 42px; height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .album-card { flex-direction: row; }
  #album-cover { width: 110px; height: 110px; }
  .slogan { font-size: 1.15rem; }
}
