/* Hark — warm, dark, calm. One thing on screen: the listen button. */
:root {
  --bg: #17130f;
  --bg-2: #1f1913;
  --ink: #f3ece3;
  --ink-dim: #b6a996;
  --ink-faint: #7d7264;
  --amber: #f0a24b;
  --amber-deep: #d8792a;
  --card: #221b14;
  --card-line: #362b20;
  --good: #7bc47f;
  --bad: #e2685f;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 20px) calc(var(--safe-l) + 18px);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* warm ambient glow behind everything */
.glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 30%, rgba(240,162,75,0.16), transparent 70%),
    radial-gradient(90% 60% at 50% 120%, rgba(216,121,42,0.10), transparent 70%);
}

.top { display: flex; align-items: center; justify-content: space-between; }
.wordmark {
  margin: 0; font-size: 22px; letter-spacing: 0.28em; text-transform: uppercase;
  font-weight: 700; color: var(--ink);
  padding-left: 0.28em; /* optical center for the tracking */
}
.ghost {
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--card-line); font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.ghost:active { transform: scale(0.94); }

/* the stage centers the single action */
.stage {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; min-height: 46dvh; padding: 18px 0;
}

.listen {
  position: relative; width: 214px; height: 214px; border-radius: 50%;
  border: none; cursor: pointer; color: #2a1c0c;
  background:
    radial-gradient(120% 120% at 30% 25%, #ffc074, var(--amber) 42%, var(--amber-deep) 100%);
  box-shadow: 0 18px 50px -14px rgba(240,162,75,0.55), inset 0 2px 8px rgba(255,255,255,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  touch-action: manipulation;
}
.listen:active { transform: scale(0.97); }
.listen .mic { color: #3a2408; display: flex; }
.listen-label { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }

/* pulse rings — idle: still; listening: animated */
.rings { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.rings i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(240,162,75,0.5); opacity: 0; transform: scale(1);
}
.listen.on .rings i { animation: pulse 2.2s ease-out infinite; }
.listen.on .rings i:nth-child(2) { animation-delay: 0.7s; }
.listen.on .rings i:nth-child(3) { animation-delay: 1.4s; }
@keyframes pulse { 0% { opacity: 0.55; transform: scale(1); } 100% { opacity: 0; transform: scale(1.7); } }

.listen.busy { filter: saturate(0.85) brightness(0.96); cursor: default; }

.status { color: var(--ink-dim); margin: 0; text-align: center; min-height: 1.4em; padding: 0 8px; }
.status.err { color: var(--bad); }

/* result card */
.result { margin-top: 6px; }
.result.hidden, .history-head.hidden { display: none; }
.card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: var(--radius);
  padding: 16px; display: flex; gap: 15px; align-items: center;
  animation: rise 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card .art {
  width: 78px; height: 78px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--bg-2); border: 1px solid var(--card-line);
}
.card .meta { min-width: 0; flex: 1; }
.card .title { font-weight: 700; font-size: 18px; margin: 0 0 2px; }
.card .artist { color: var(--ink-dim); margin: 0 0 8px; }
.chip {
  display: inline-block; font-size: 12px; color: var(--amber);
  border: 1px solid rgba(240,162,75,0.4); border-radius: 999px; padding: 1px 9px;
}
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.links a {
  text-decoration: none; font-size: 13px; font-weight: 600;
  color: var(--ink); background: var(--bg-2); border: 1px solid var(--card-line);
  padding: 7px 12px; border-radius: 10px;
}
.links a:active { transform: scale(0.96); }

.result .retry {
  margin-top: 12px; width: 100%; padding: 12px; border-radius: 12px;
  background: transparent; color: var(--amber); border: 1px solid rgba(240,162,75,0.4);
  font-weight: 600; cursor: pointer;
}

/* history */
.history { margin-top: 26px; }
.history-head { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-faint); margin: 0 0 10px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 12px; }
.history-list li:active { background: var(--bg-2); }
.history-list img { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--bg-2); flex: none; }
.history-list .h-meta { min-width: 0; flex: 1; }
.history-list .h-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list .h-sub { color: var(--ink-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list a { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

/* about dialog */
.about {
  border: 1px solid var(--card-line); background: var(--card); color: var(--ink);
  border-radius: var(--radius); max-width: 380px; width: calc(100vw - 40px); padding: 22px;
}
.about::backdrop { background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); }
.about h2 { margin: 0 0 12px; font-size: 19px; }
.about ol { margin: 0 0 12px; padding-left: 18px; }
.about li { margin-bottom: 9px; color: var(--ink-dim); }
.about li b { color: var(--ink); }
.about .fine { color: var(--ink-faint); font-size: 13px; margin: 0 0 16px; }
.about .primary, .about form { margin: 0; }
.about .primary {
  width: 100%; padding: 12px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--amber); color: #2a1c0c; font-weight: 700; font-size: 15px;
}

.about .lead { color: var(--ink-dim); margin: 0 0 12px; }
.about .lead b { color: var(--ink); }
.consent-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.link-btn { background: none; border: none; color: var(--ink-faint); font-size: 14px; padding: 8px; cursor: pointer; }

.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
