:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #f7f7f7;
  --muted: #9b9ba1;
  --muted-2: #6f7077;
  --line: rgba(255, 255, 255, 0.12);
  --panel: #161616;
  --panel-2: #242424;
  --user: #292929;
  --accent: #2f7dff;
  --accent-2: #dff7ff;
  --danger: #ff4b4b;
  --ok: #79e6a6;
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

.voice-app {
  width: 100%;
  max-width: 760px;
  height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(20px + var(--safe-bottom));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  background: radial-gradient(circle at 50% 72%, rgba(47, 125, 255, 0.14), transparent 28%), var(--bg);
}

.topbar,
.status-row,
.dialog-head,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar,
.dialog-head {
  justify-content: space-between;
  gap: 14px;
}

.app-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

h1 {
  margin-top: 2px;
  font-size: clamp(28px, 8vw, 42px);
  line-height: 1;
  letter-spacing: 0;
}

.top-actions {
  gap: 9px;
}

.icon-button {
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.status-row {
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.status-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 14px 0 8px;
  scrollbar-width: none;
}

.messages::-webkit-scrollbar {
  display: none;
}

.message {
  display: grid;
  gap: 10px;
}

.message.user {
  justify-items: end;
}

.message.assistant {
  justify-items: start;
}

.bubble {
  max-width: min(86vw, 640px);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.44;
  letter-spacing: 0;
}

.user .bubble {
  padding: 11px 16px;
  border-radius: 24px;
  background: var(--user);
  color: #f2f2f2;
  font-size: clamp(18px, 4.6vw, 24px);
}

.assistant .bubble {
  color: #f4f4f5;
  font-size: clamp(22px, 6vw, 34px);
}

.meta {
  color: var(--muted-2);
  font-size: 12px;
}

.coach-card {
  max-width: min(86vw, 560px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #d9dadf;
  display: grid;
  gap: 6px;
  line-height: 1.42;
}

.coach-card strong {
  color: var(--accent-2);
}

.play-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #f2f2f2;
  cursor: pointer;
}

.voice-dock {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding-bottom: 6px;
}

.voice-orb {
  position: relative;
  width: clamp(142px, 40vw, 190px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 46% 24%, rgba(255, 255, 255, 0.95), rgba(225, 250, 255, 0.9) 17%, transparent 34%),
    radial-gradient(circle at 58% 62%, #1f6fff, #63c5ff 48%, #ecfbff 82%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 18px 60px rgba(47, 125, 255, 0.42);
  cursor: pointer;
  touch-action: none;
}

.orb-glow,
.orb-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.orb-core::before,
.orb-core::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  transform: translate(-16px, -50%);
  opacity: 0;
}

.orb-core::after {
  transform: translate(4px, -50%);
}

.voice-orb.recording {
  animation: orbPulse 900ms ease-in-out infinite alternate;
}

.voice-orb.recording .orb-glow {
  box-shadow: 0 0 0 18px rgba(47, 125, 255, 0.16);
}

.voice-orb.processing {
  animation: orbSpin 1.4s linear infinite;
}

.voice-orb.speaking .orb-core::before,
.voice-orb.speaking .orb-core::after {
  opacity: 1;
  animation: speakingBars 520ms ease-in-out infinite alternate;
}

.voice-orb.speaking .orb-core::after {
  animation-delay: 140ms;
}

.orb-label {
  min-height: 22px;
  color: var(--muted);
  font-size: 15px;
}

.settings-dialog {
  width: min(480px, calc(100% - 26px));
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.settings-dialog form {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101010;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
  display: grid;
  gap: 14px;
}

h2 {
  font-size: 22px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #1d1d1f;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 3px solid rgba(47, 125, 255, 0.28);
  border-color: rgba(47, 125, 255, 0.7);
}

.policy-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.primary-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #f2f2f2;
  color: #070707;
  cursor: pointer;
  font-weight: 850;
}

@keyframes orbPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.045);
  }
}

@keyframes orbSpin {
  from {
    filter: hue-rotate(0deg);
  }
  to {
    filter: hue-rotate(24deg);
  }
}

@keyframes speakingBars {
  from {
    height: 28px;
  }
  to {
    height: 56px;
  }
}

@media (max-height: 720px) {
  .messages {
    gap: 18px;
  }

  .voice-orb {
    width: clamp(118px, 34vw, 150px);
  }
}
