:root {
  --bg: #08080c;
  --bg-soft: #101018;
  --ink: #f4f3f7;
  --ink-soft: #a7a6b8;
  --ink-faint: #6c6b80;
  --line: rgba(255, 255, 255, 0.08);
  --freq: #8b8bff;
  --tab-h: 88px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* A slow living wash of colour behind everything, tinted by the current Moment. */
body::before {
  content: "";
  position: fixed;
  inset: -40vh -20vw;
  z-index: 0;
  background:
    radial-gradient(40vw 40vw at 25% 20%, color-mix(in srgb, var(--freq) 22%, transparent), transparent 70%),
    radial-gradient(45vw 45vw at 80% 80%, color-mix(in srgb, var(--freq) 16%, transparent), transparent 70%);
  filter: blur(20px);
  transition: background 1.6s ease;
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-3%, -2%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.12); }
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 22px calc(var(--tab-h) + 28px);
  min-height: 100dvh;
}

/* Masthead ---------------------------------------------------------------- */
.masthead { text-align: center; padding: 8px 0 26px; }
.wordmark {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  letter-spacing: 0.42em;
  font-size: 15px;
  text-indent: 0.42em;
  color: var(--ink);
}
.masthead .tagline {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* The player ------------------------------------------------------------- */
.player { text-align: center; padding-top: 10px; }

.now-label {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.now-freq {
  margin-top: 8px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  color: var(--freq);
  text-transform: capitalize;
  transition: color 1.2s ease;
}

/* The orb: a breathing circle that reacts to the voice. */
.orb-wrap {
  position: relative;
  height: 280px;
  display: grid;
  place-items: center;
  margin: 14px 0 6px;
}
.orb {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--freq) 75%, white 8%), var(--freq) 55%, color-mix(in srgb, var(--freq) 40%, black) 100%);
  box-shadow: 0 0 70px color-mix(in srgb, var(--freq) 55%, transparent),
              inset 0 0 50px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease-out, background 1.2s ease, box-shadow 1.2s ease;
  will-change: transform;
}
.orb-ring {
  position: absolute;
  width: 180px; height: 180px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--freq) 50%, transparent);
  opacity: 0;
}
.is-playing .orb { animation: breathe 4.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.is-playing .orb-ring { animation: ripple 3.4s ease-out infinite; }
.is-playing .orb-ring:nth-child(2) { animation-delay: 1.1s; }
.is-playing .orb-ring:nth-child(3) { animation-delay: 2.2s; }

@keyframes ripple {
  0%   { opacity: 0.5; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.1); }
}

/* The transcript, surfacing word by word. */
.transcript {
  min-height: 132px;
  font-family: "Fraunces", Georgia, serif;
  font-size: 23px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.005em;
  padding: 6px 4px 2px;
}
.transcript .w {
  opacity: 0.12;
  transition: opacity 0.5s ease;
}
.transcript .w.lit { opacity: 1; }
.transcript.empty {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 19px;
}

.scrubline {
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  margin: 20px 8px 8px;
  overflow: hidden;
}
.scrubline > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--freq);
  transition: width 0.2s linear, background 1.2s ease;
}
.counter {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-top: 26px;
}
.ctl {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 22px;
  cursor: pointer;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: color 0.2s ease, background 0.2s ease;
}
.ctl:hover { color: var(--ink); }
.ctl.play {
  width: 78px; height: 78px;
  background: var(--ink);
  color: #0a0a10;
  font-size: 28px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5);
}
.ctl.play:hover { background: #fff; }

/* Speak screen ----------------------------------------------------------- */
.speak { text-align: center; padding-top: 6px; }
.prompt {
  font-family: "Fraunces", Georgia, serif;
  font-size: 28px;
  line-height: 1.45;
  font-weight: 500;
  margin: 18px auto 6px;
  max-width: 24ch;
}
.speak .hint { color: var(--ink-faint); font-size: 14px; margin-bottom: 22px; }

.feelings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0 30px;
}
.feeling {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--ink-soft);
  border-radius: 14px;
  padding: 13px 4px;
  font-size: 13px;
  font-weight: 500;
  text-transform: capitalize;
  cursor: pointer;
  transition: all 0.18s ease;
}
.feeling:hover { color: var(--ink); border-color: rgba(255,255,255,0.2); }
.feeling.on {
  color: #0a0a10;
  background: var(--f);
  border-color: var(--f);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--f) 45%, transparent);
}

.record {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 116px; height: 116px;
  border-radius: 50%;
  margin: 4px auto 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 38% 32%, #ff7a6b, #e5604d 60%, #b8362a);
  box-shadow: 0 0 60px rgba(229, 96, 77, 0.5);
  transition: transform 0.15s ease;
}
.record:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.record .dot {
  width: 34px; height: 34px;
  background: #fff;
  border-radius: 9px;
  transition: all 0.2s ease;
}
.record.recording .dot { border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.7); opacity: 0.7; } }

.rec-state { margin-top: 18px; color: var(--ink-soft); font-size: 15px; min-height: 22px; letter-spacing: 0.02em; }
.rec-timer { font-variant-numeric: tabular-nums; color: var(--freq); }

.speak-actions { margin-top: 26px; display: flex; gap: 12px; justify-content: center; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn:hover { color: var(--ink); }
.btn.primary { background: var(--ink); color: #0a0a10; border-color: var(--ink); }
.btn.primary:hover { background: #fff; }
.btn[hidden] { display: none; }

/* Echo screen ------------------------------------------------------------ */
.echo { text-align: center; padding-top: 30px; }
.echo .mark { font-size: 40px; color: var(--freq); }
.echo h1 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: 26px;
  margin: 18px 0 8px;
}
.echo .big {
  font-family: "Fraunces", serif;
  font-size: 64px;
  font-weight: 500;
  color: var(--freq);
  margin: 8px 0;
}
.echo .sub { color: var(--ink-soft); font-size: 16px; line-height: 1.6; max-width: 30ch; margin: 0 auto; }
.echo-card {
  margin: 30px 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.02);
}
.echo-card .label { font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 14px; }
.echo-line { font-family: "Fraunces", serif; font-size: 18px; line-height: 1.5; color: var(--ink); }

/* Tab bar ---------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  justify-content: center;
  gap: 14px;
  align-items: center;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  backdrop-filter: blur(8px);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
  width: 96px;
  padding: 10px 0;
  border-radius: 16px;
  transition: color 0.2s ease;
}
.tab-glyph { font-size: 19px; }
.tab.is-active { color: var(--ink); }

.empty-state {
  text-align: center;
  color: var(--ink-faint);
  padding: 80px 20px;
  font-family: "Fraunces", serif;
  font-size: 20px;
}

a { color: var(--freq); }
