: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; }

/* Tune the stream to a feeling. */
.freq-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  margin: 0 -22px 4px;
  padding-left: 22px;
  padding-right: 22px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.freq-bar::-webkit-scrollbar { display: none; }
.freq-chip {
  appearance: none;
  flex: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}
.freq-chip:hover { color: var(--ink); }
.freq-chip.is-on {
  color: #0a0a10;
  background: var(--f, var(--ink));
  border-color: var(--f, var(--ink));
}

.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);
  transition: color 1.2s ease, opacity 0.3s ease;
}
.now-freq.fading, .transcript.fading { opacity: 0; }

/* 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;
  transition: opacity 0.3s ease;
}
.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: 26px;
  line-height: 1.45;
  font-weight: 500;
  margin: 18px auto 6px;
  max-width: 17ch;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.speak .hint { color: var(--ink-faint); font-size: 14px; margin-bottom: 22px; }

.mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 18px auto 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.mode-btn.on { color: #0a0a10; background: var(--ink); }

.type-field {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  line-height: 1.5;
  padding: 16px;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
}
.type-field:focus { border-color: color-mix(in srgb, var(--freq) 60%, transparent); }
.type-field::placeholder { color: var(--ink-faint); }

.feelings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 8px 0 22px;
}
.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); }

/* Moderation ------------------------------------------------------------- */
.admin-flash {
  text-align: center;
  color: #7fe0a8;
  background: rgba(127, 224, 168, 0.08);
  border: 1px solid rgba(127, 224, 168, 0.25);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 18px;
  font-size: 14px;
}
.admin-list { display: flex; flex-direction: column; gap: 14px; }
.admin-row {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 16px;
  padding: 16px 18px;
}
.admin-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.admin-freq { text-transform: capitalize; font-weight: 500; font-size: 14px; }
.admin-tag {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.admin-when { margin-left: auto; color: var(--ink-faint); font-size: 12px; }
.admin-text {
  font-family: "Fraunces", Georgia, serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 14px;
}
.admin-actions { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.admin-actions audio { width: 100%; height: 38px; }
.admin-delete {
  appearance: none;
  border: 1px solid rgba(236, 106, 87, 0.4);
  background: rgba(236, 106, 87, 0.1);
  color: #ec6a57;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  flex: none;
}
.admin-delete:hover { background: rgba(236, 106, 87, 0.2); }
.admin-actions .button_to { margin: 0; width: 100%; }
.admin-actions .admin-delete { width: 100%; }

/* Dashboard -------------------------------------------------------------- */
.admin-nav { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.admin-nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.admin-nav-link.is-on { color: #0a0a10; background: var(--ink); border-color: var(--ink); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 16px;
  padding: 18px 8px;
  text-align: center;
  min-width: 0;
}
.stat-num { font-family: "Fraunces", serif; font-size: 30px; font-weight: 500; color: var(--ink); }
.stat-cap { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin-top: 4px; }

.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 14px; }
.panel-prompt { font-family: "Fraunces", serif; font-size: 20px; color: var(--ink); line-height: 1.4; overflow-wrap: break-word; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-name { width: 38%; font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 8px; }
.bar-count { width: 28px; text-align: right; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.spark { display: flex; align-items: flex-end; gap: 5px; height: 80px; }
.spark-bar { flex: 1; min-width: 0; background: var(--ink-soft); border-radius: 3px; min-height: 4px; opacity: 0.85; }

.recent-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.recent-row:first-of-type { border-top: 0; }
.recent-text { flex: 1; font-size: 14px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-when { font-size: 11px; color: var(--ink-faint); flex: none; }
