:root {
  --bg: #fafafa;
  --fg: #0a0a0b;
  --fg-90: rgba(0, 0, 0, 0.9);
  --fg-70: rgba(0, 0, 0, 0.7);
  --fg-55: rgba(0, 0, 0, 0.55);
  --fg-40: rgba(0, 0, 0, 0.4);
  --fg-20: rgba(0, 0, 0, 0.15);
  --fg-12: rgba(0, 0, 0, 0.1);
  --fg-08: rgba(0, 0, 0, 0.07);
  --fg-05: rgba(0, 0, 0, 0.04);
  --fg-03: rgba(0, 0, 0, 0.025);

  --success: #5eb92d;
  --error: #eb4d4d;
  --pending: #f5b13a;

  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI',
    'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 18% 8%, rgba(80, 80, 140, 0.07), transparent 60%),
    radial-gradient(45% 40% at 92% 92%, rgba(160, 90, 100, 0.05), transparent 60%), var(--bg);
  overflow-x: hidden;
}

.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 88px 24px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
  opacity: 0;
  filter: blur(4px);
  animation: rise 600ms var(--ease) forwards;
}
.wordmark {
  width: 64px;
  height: auto;
  fill: var(--fg);
  display: block;
}
.title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-55);
  padding-left: 14px;
  border-left: 1px solid var(--fg-12);
  line-height: 1;
}

/* ── Known-issue notice ───────────────────────────────────────────────── */
.notice {
  background: rgba(235, 77, 77, 0.08);
  border: 1px solid rgba(235, 77, 77, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--error);
}
.notice strong {
  font-weight: 600;
}
.notice a {
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
}
.notice a:hover {
  text-decoration: none;
}

/* ── Persona pills ────────────────────────────────────────────────────── */
.persona-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  opacity: 0;
  filter: blur(4px);
  animation: rise 600ms 80ms var(--ease) forwards;
}
.personas {
  display: contents;
}
.persona {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-70);
  background: var(--fg-03);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  cursor: pointer;
  transition:
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    color 180ms var(--ease),
    transform 180ms var(--ease);
}
.persona:hover {
  background: var(--fg-05);
  border-color: var(--fg-20);
  color: var(--fg);
}
.persona.selected {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

/* ── Hear-reference button (right-aligned action; bordered but flat) ──── */
.ref-play {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg-55);
  background: transparent;
  border: 1px solid var(--fg-12);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  cursor: pointer;
  transition: all 160ms var(--ease);
}
.ref-play:hover:not(:disabled) {
  color: var(--fg-90);
  background: var(--fg-05);
  border-color: var(--fg-20);
}
.ref-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ref-play svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}
.ref-play .icon-pause {
  display: none;
}
.ref-play.playing .icon-play {
  display: none;
}
.ref-play.playing .icon-pause {
  display: block;
}

/* ── Composer card ────────────────────────────────────────────────────── */
.composer {
  background: var(--fg-03);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-lg);
  padding: 18px 18px 12px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 180ms var(--ease);
  opacity: 0;
  filter: blur(4px);
  animation: rise 600ms 160ms var(--ease) forwards;
}
.composer:focus-within {
  border-color: var(--fg-20);
}

#text {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  padding: 4px 4px 8px;
  min-height: 76px;
}
#text::placeholder {
  color: var(--fg-40);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
button,
.icon-btn {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.primary {
  background: var(--fg);
  color: var(--bg);
  font-weight: 500;
  padding: 9px 22px;
  border-radius: var(--radius-pill);
  transition:
    transform 160ms var(--ease),
    opacity 160ms var(--ease),
    background 160ms var(--ease);
}
.primary:hover {
  transform: translateY(-1px);
}
.primary:active {
  transform: translateY(0);
}
.primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.primary .label {
  display: inline-block;
  min-width: 64px;
  text-align: center;
}

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-55);
  padding: 7px 12px 7px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  transition: all 160ms var(--ease);
}
.ghost:hover {
  color: var(--fg-90);
  background: var(--fg-05);
  border-color: var(--fg-08);
}

/* ── Connection dot ───────────────────────────────────────────────────── */
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-20);
  display: inline-block;
  transition: background 160ms var(--ease);
}
.dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px rgba(94, 185, 45, 0.5);
}
.dot.busy {
  background: var(--pending);
  animation: pulse 1.1s infinite ease-in-out;
}
.dot.err {
  background: var(--error);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes rise {
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* ── Settings drawer ──────────────────────────────────────────────────── */
.settings {
  background: var(--fg-03);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-lg);
  padding: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings label,
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-55);
}
.settings label em,
.settings-field-label em {
  font-style: normal;
  font-weight: 400;
  color: var(--fg-40);
  text-transform: none;
  letter-spacing: 0;
}
.settings input {
  background: var(--fg-05);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-md);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 160ms var(--ease);
}
.settings input:focus {
  border-color: var(--fg-40);
}

.env-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: -2px;
}
.env-pill {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--fg-55);
  background: var(--fg-05);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 150ms var(--ease);
  text-transform: none;
}
.env-pill:hover {
  color: var(--fg-90);
  background: var(--fg-08);
  border-color: var(--fg-20);
}
.env-pill.selected {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ── Result row ───────────────────────────────────────────────────────── */
.result {
  background: var(--fg-03);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: rise 400ms var(--ease);
}

.play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    transform 160ms var(--ease),
    background 160ms var(--ease);
}
.play:hover {
  transform: scale(1.04);
}
.play svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.play .icon-pause {
  display: none;
}
.play.playing .icon-play {
  display: none;
}
.play.playing .icon-pause {
  display: block;
}

.meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.time {
  font-size: 15px;
  font-weight: 500;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.time .dim {
  color: var(--fg-40);
  font-weight: 400;
}
.stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-70);
  background: var(--fg-05);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}
.chip.dim {
  color: var(--fg-40);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-55);
  transition: all 160ms var(--ease);
  flex-shrink: 0;
  text-decoration: none;
}
.icon-btn:hover {
  background: var(--fg-05);
  color: var(--fg);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Status line ──────────────────────────────────────────────────────── */
.status {
  text-align: center;
  font-size: 11px;
  color: var(--fg-40);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-top: 12px;
  min-height: 1.2em;
  transition: color 200ms var(--ease);
}
.status.err {
  color: var(--error);
}

/* ── Utility ──────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.token-panel {
  background: var(--fg-03);
  border: 1px solid var(--fg-08);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  font-size: 11px;
  color: var(--fg-55);
}
.token-panel summary {
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  outline: none;
  user-select: none;
}
.token-panel summary:hover {
  color: var(--fg-90);
}
.token-list {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--fg-05);
  border-radius: var(--radius-md);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg-70);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

@media (max-width: 520px) {
  .shell {
    padding: 56px 16px 64px;
  }
  .hero {
    margin-bottom: 28px;
  }
  .ref-play {
    margin-left: 0;
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 12px;
  }
  .env-pill {
    font-size: 14px;
    padding: 10px 16px;
  }
}

/* Model picker (in the composer action bar) */
#model {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
}
.hidden {
  display: none;
}
