:root {
  --bg: #16110e;
  --surface: #221b16;
  --surface-2: #2c241d;
  --text: #f4efe8;
  --muted: #b5a89a;
  --faint: #8a7d72;
  --accent: #e8b86d;
  --accent-dim: #c4923f;
  --danger: #e08a74;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Assistant", "Segoe UI", "Helvetica Neue", "Arial Hebrew", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 80% -10%, #3a2a18 0%, transparent 55%),
    var(--bg);
}

.app {
  max-width: 40rem;
  margin: 0 auto;
  padding: calc(1.4rem + env(safe-area-inset-top)) 1.2rem calc(2rem + env(safe-area-inset-bottom));
}

.top h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.banner {
  margin-top: 1.2rem;
  padding: 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid #3d3228;
  border-radius: var(--radius);
}

.banner p { margin: 0 0 0.8rem; }

.banner a { color: var(--accent); }

.token-form {
  display: grid;
  gap: 0.45rem;
}

.token-form label {
  font-weight: 600;
  font-size: 0.95rem;
}

.token-form input {
  width: 100%;
  border: 1px solid #4a3d32;
  background: #16110e;
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}

.token-form button,
.text-btn,
.listen-btn {
  font: inherit;
}

.token-form button {
  border: 0;
  background: var(--accent);
  color: #1a140e;
  font-weight: 700;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  cursor: pointer;
}

.listen-wrap {
  display: grid;
  justify-items: center;
  margin: 2rem 0 1.6rem;
}

.listen-btn {
  position: relative;
  width: 10.5rem;
  height: 10.5rem;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f3d19a, var(--accent) 45%, var(--accent-dim));
  color: #1a140e;
  font-size: 1.55rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow), 0 0 0 10px rgba(232, 184, 109, 0.08);
  -webkit-tap-highlight-color: transparent;
}

.listen-btn:disabled {
  cursor: default;
  opacity: 0.9;
}

.listen-btn.listening {
  color: #fff8ee;
  background: radial-gradient(circle at 35% 30%, #c9843c, #8a4f1a 70%);
}

.listen-btn .rings {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  pointer-events: none;
}

.listen-btn.listening .rings {
  box-shadow:
    0 0 0 0 rgba(232, 184, 109, 0.55),
    0 0 0 14px rgba(232, 184, 109, 0);
  animation: pulse 1.2s ease-out infinite;
}

.btn-label {
  position: relative;
  z-index: 1;
}

.status {
  margin: 1rem 0 0;
  color: var(--muted);
  text-align: center;
  min-height: 1.5em;
}

.status.error { color: var(--danger); }

.result {
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cover-wrap {
  background: #100c0a;
  aspect-ratio: 1 / 1;
  max-height: 22rem;
  display: grid;
  place-items: center;
}

.cover-wrap img,
.cover-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-placeholder {
  display: grid;
  place-items: center;
  color: var(--faint);
  font-size: 1.1rem;
  background: repeating-linear-gradient(135deg, #1b1511, #1b1511 12px, #201a15 12px, #201a15 24px);
}

.meta {
  padding: 1.15rem 1.2rem 1.4rem;
}

.title {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.25;
}

.artist {
  margin: 0.15rem 0 1rem;
  font-size: 1.15rem;
  color: var(--muted);
}

.facts {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.facts div {
  display: grid;
  gap: 0.1rem;
}

.facts dt {
  color: var(--faint);
  font-size: 0.82rem;
  font-weight: 600;
}

.facts dd {
  margin: 0;
  font-size: 1.05rem;
}

.facts .missing {
  color: var(--faint);
  font-style: italic;
}

.source {
  display: block;
  margin-top: 0.15rem;
  color: var(--faint);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 400;
}

.lyrics {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid #3a3129;
}

.lyrics h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.lyrics pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.7;
}

.history-wrap { margin-top: 2rem; }

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.history-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.text-btn {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.history {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.history button.item {
  width: 100%;
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.8rem;
  align-items: center;
  text-align: right;
  background: var(--surface);
  border: 0;
  border-radius: 14px;
  padding: 0.45rem 0.7rem 0.45rem 0.45rem;
  color: inherit;
  cursor: pointer;
}

.history img,
.history .thumb-fallback {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
}

.history .who {
  font-weight: 700;
}

.history .when,
.history .by {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.hidden { display: none !important; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 184, 109, 0.5); }
  100% { box-shadow: 0 0 0 22px rgba(232, 184, 109, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .listen-btn.listening .rings { animation: none; }
}
