:root {
  --bg: #f8f9fb;
  --surface: #fff;
  --ink: #20262e;
  --muted: #66717e;
  --line: #e4e8ed;
  --blue: #1765ed;
  --blue-light: #dfeaff;
  --red: #d64045;
  --radius: 24px;
  color-scheme: light;
  font-family:
    Inter,
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}
button,
select,
input,
a {
  -webkit-tap-highlight-color: transparent;
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button {
  border: 0;
}
button:disabled {
  cursor: default;
  opacity: 0.35;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 5px;
}
button {
  transition:
    background 0.18s,
    opacity 0.18s,
    box-shadow 0.18s;
}
button:active:not(:disabled) {
  opacity: 0.72;
}
button:hover:not(:disabled) {
  background-color: var(--blue-light);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.studio {
  width: 100%;
  max-width: 520px;
  height: 100svh;
  min-height: 0;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 24px
    calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}
.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.6px;
  min-height: 44px;
}
.icon-button {
  background: transparent;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--ink);
}
.icon-button svg {
  width: 23px;
  height: 23px;
}
.topic-wrap {
  flex-shrink: 0;
  height: 46px;
  display: flex;
  align-items: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  margin-top: 12px;
  max-width: 100%;
}
.topic-dot {
  width: 6px;
  height: 6px;
  background: var(--blue);
  border-radius: 50%;
  margin-left: 19px;
  position: absolute;
  pointer-events: none;
}
.topic-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 11px 44px 11px 35px;
  min-height: 44px;
  max-width: 100%;
  font-size: 14px;
  font-weight: 500;
  border-radius: 24px;
}
.chevron {
  width: 19px;
  height: 19px;
  position: absolute;
  right: 15px;
  pointer-events: none;
}
.companion {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 0;
  min-height: 0;
}
.orb {
  width: min(clamp(148px, calc(100svh - 490px), 310px), calc(100vw - 52px));
  flex-shrink: 0;
  aspect-ratio: 1;
  position: relative;
  isolation: isolate;
  contain: layout paint;
  --wave-color: var(--blue);
}
.orbit {
  position: absolute;
  inset: 7.5%;
  border: 1px solid var(--line);
  border-radius: 50%;
  pointer-events: none;
}
.orbit-inner {
  inset: 10%;
  border-color: #edf0f5;
}
.portrait {
  position: absolute;
  inset: 12%;
  background: #edf1f5;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.portrait img {
  width: 110%;
  height: 110%;
  max-width: none;
  object-fit: contain;
  object-position: center bottom;
  transform: translateY(4%);
}
.radial-wave {
  position: absolute;
  inset: 0;
  opacity: 0.6;
  transition: opacity 0.25s;
}
.wave-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: calc(var(--length) * var(--bar-scale, 1));
  border-radius: 3px;
  background: var(--wave-color);
  transform: translate(-50%, -50%) rotate(var(--angle))
    translateY(calc(var(--radius) * -1)) scaleY(var(--energy, 1));
  transform-origin: center;
  transition:
    background 0.2s,
    opacity 0.2s;
  opacity: 0.5;
}
.presence {
  position: absolute;
  right: 16%;
  bottom: 11%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--bg);
}
.identity {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}
.identity > span:first-child {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 1px;
  color: var(--ink);
}
.identity-line {
  height: 10px;
  width: 1px;
  background: #b7c1ce;
}
.status {
  text-align: center;
  line-height: 1.55;
  font-size: 14px;
  height: 44px;
  flex-shrink: 0;
  overflow: auto;
  max-width: 300px;
  margin: 6px 0 0;
  text-wrap: balance;
}
.record-meter {
  height: 18px;
  display: none;
  align-items: center;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
}
.record-meter span {
  height: 5px;
  width: 3px;
  background: var(--red);
  border-radius: 3px;
  animation: meter 0.65s ease-in-out infinite alternate;
}
.record-meter span:nth-child(2n) {
  animation-delay: -0.3s;
}
.record-meter span:nth-child(3) {
  animation-delay: -0.5s;
}
.controls {
  flex-shrink: 0;
  text-align: center;
  padding-top: 8px;
  width: 100%;
  margin-top: 8px;
}
.practice-slot {
  width: 100%;
  height: 104px;
  flex-shrink: 0;
  min-width: 0;
}
.practice-card {
  height: 100%;
  padding: 10px 15px;
  border: 1px solid #cbdcff;
  border-radius: 20px;
  background: #edf4ff;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.practice-card[hidden] {
  display: none;
}
.practice-label {
  margin: 0;
  flex-shrink: 0;
  color: #32578d;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.practice-text {
  margin: 0;
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  color: #15345e;
}
.emotion-tag {
  display: none;
  position: absolute;
  top: 25%;
  right: 8px;
  padding: 7px 10px;
  border: 2px solid white;
  border-radius: 14px 14px 14px 3px;
  background: #1765ed;
  color: white;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 4px 15px #1765ed33;
}
[data-state="speaking"] .emotion-tag:not(:empty) {
  display: block;
}
[data-state="speaking"][data-emotion="amused"] .portrait img {
  animation: laugh 0.36s ease-in-out 6 alternate;
}
[data-state="speaking"][data-emotion="firm"] .portrait img {
  transform: translateY(4%) scale(1.06);
}
[data-emotion="firm"] .emotion-tag {
  background: #b94e23;
}
[data-state="speaking"][data-emotion="surprised"] .portrait img {
  animation: react 0.5s ease-out 2;
}
[data-state="speaking"][data-emotion="proud"] .portrait img {
  animation: laugh 0.65s ease-in-out 3 alternate;
}
@keyframes laugh {
  from {
    transform: translateY(4%) rotate(-3deg);
  }
  to {
    transform: translateY(1%) rotate(3deg);
  }
}
@keyframes react {
  50% {
    transform: translateY(1%) scale(1.08);
  }
}
.control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
}
.mic-button {
  display: grid;
  place-items: center;
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  box-shadow: 0 6px 18px #20262e12;
}
.mic-button:hover:not(:disabled) {
  background: #344254;
}
.mic-button:disabled {
  opacity: 0.7;
}
.mic-button svg {
  width: 34px;
  height: 34px;
}
.send-icon,
.spinner {
  display: none;
}
.secondary-control {
  color: var(--muted);
}
.button-label {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 0;
}
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 4px 0 0;
}
.spinner {
  width: 25px;
  height: 25px;
  border: 2px solid #ffffff40;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
[data-state="recording"] .mic-button {
  background: var(--red);
  box-shadow: 0 0 0 9px #d6404510;
}
[data-state="recording"] .mic-icon {
  display: none;
}
[data-state="recording"] .send-icon {
  display: block;
}
[data-state="recording"] .orb {
  --wave-color: var(--red);
}
[data-state="recording"] .record-meter {
  opacity: 1;
  visibility: visible;
}
[data-state="recording"] .presence {
  background: var(--red);
}
[data-state="speaking"] .radial-wave {
  opacity: 1;
}
[data-state="speaking"] .wave-bar {
  animation: wave 0.42s cubic-bezier(0.22, 0.8, 0.36, 1) infinite alternate;
  animation-delay: var(--delay);
  opacity: 1;
}
[data-state="speaking"][data-live-wave="true"] .wave-bar {
  animation: none;
}
[data-state="speaking"] .orbit-inner {
  border-color: #85b2ff;
  box-shadow: 0 0 18px #1765ed22;
}
.orbit-outer {
  overflow: hidden;
}
[data-state="processing"] .orbit-outer::after,
[data-state="starting"] .orbit-outer::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}
[data-state="processing"] .mic-icon,
[data-state="starting"] .mic-icon {
  display: none;
}
[data-state="processing"] .spinner,
[data-state="starting"] .spinner {
  display: block;
}
[data-state="error"] .status {
  color: #a73236;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px;
  width: calc(100% - 32px);
  max-width: 380px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 22px 80px #20262e20;
}
dialog::backdrop {
  background: #20262e55;
  backdrop-filter: blur(5px);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.dialog-header h1 {
  font-size: 20px;
  letter-spacing: -0.6px;
  margin: 0;
}
dialog label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 19px 0 9px;
}
dialog select {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #cbd3dd;
  padding: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
dialog input {
  width: 100%;
  accent-color: var(--blue);
  min-height: 30px;
}
dialog output {
  float: right;
  font-weight: 400;
  color: var(--muted);
}
.settings-note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  margin: 20px 0;
}
.save-button {
  min-height: 48px;
  width: 100%;
  border-radius: 14px;
  background: var(--ink);
  color: white;
  font-weight: 600;
  font-size: 14px;
}
.save-button:hover:not(:disabled) {
  background: #344254;
}
@keyframes wave {
  from {
    transform: translate(-50%, -50%) rotate(var(--angle))
      translateY(calc(var(--radius) * -1)) scaleY(0.8);
  }
  to {
    transform: translate(-50%, -50%) rotate(var(--angle))
      translateY(calc(var(--radius) * -1)) scaleY(var(--peak));
  }
}
@keyframes meter {
  from {
    height: 4px;
  }
  to {
    height: 15px;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (min-width: 768px) {
  .studio {
    max-width: 600px;
  }
  .brand {
    font-size: 20px;
  }
  .topic-wrap {
    margin-top: 12px;
  }
  .companion {
    padding: 8px 0;
  }
  .mic-button {
    width: 84px;
    height: 84px;
  }
  .controls {
    padding-top: 4px;
  }
  .identity {
    margin-top: 8px;
  }
}
@media (max-height: 690px) {
  .studio {
    padding-top: 12px;
    padding-bottom: 14px;
  }
  .topic-wrap {
    margin-top: 8px;
  }
  .companion {
    min-height: 0;
    padding: 4px 0;
  }
  .orb {
    width: min(clamp(132px, calc(100svh - 440px), 210px), calc(100vw - 52px));
  }
  .identity {
    margin-top: 6px;
  }
  .status {
    margin-top: 4px;
    font-size: 14px;
    height: 40px;
  }
  .mic-button {
    width: 72px;
    height: 72px;
  }
  .button-label {
    margin-top: 12px;
  }
  .hint {
    margin-top: 4px;
  }
  .practice-slot {
    height: 88px;
  }
  .practice-text {
    font-size: 18px;
  }
}
@media (max-height: 590px) and (orientation: portrait) {
  .studio {
    padding: 8px 18px;
  }
  .header,
  .icon-button {
    height: 44px;
  }
  .icon-button {
    width: 44px;
  }
  .topic-wrap {
    height: 44px;
    margin-top: 4px;
  }
  .companion {
    padding: 2px 0;
  }
  .orb {
    width: min(150px, max(100px, calc(100svh - 365px)));
  }
  .identity {
    display: none;
  }
  .status {
    height: 32px;
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.2;
  }
  .practice-slot {
    height: 76px;
  }
  .practice-text {
    font-size: 17px;
  }
  .controls {
    padding-top: 4px;
    margin-top: 4px;
  }
  .mic-button {
    width: 64px;
    height: 64px;
  }
  .button-label {
    margin-top: 8px;
    font-size: 13px;
  }
  .hint {
    font-size: 11px;
    margin-top: 3px;
  }
}
@media (orientation: landscape) and (max-height: 550px) {
  .studio {
    max-width: 760px;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 44px 44px minmax(56px, 1fr) 108px;
    column-gap: 30px;
    padding: 6px 20px;
  }
  .header {
    grid-column: 1/-1;
  }
  .topic-wrap {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
    margin: 0;
  }
  .companion {
    grid-column: 1;
    grid-row: 2 / -1;
    min-height: 0;
    padding: 10px 0;
  }
  .orb {
    width: min(170px, 40svh);
  }
  .identity {
    margin-top: 10px;
  }
  .status {
    margin-top: 7px;
    max-width: 250px;
  }
  .controls {
    grid-column: 2;
    grid-row: 4;
    margin: 0;
    padding-top: 0;
  }
  .mic-button {
    width: 64px;
    height: 64px;
  }
  .button-label {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.2;
  }
  .hint {
    margin-top: 3px;
    font-size: 10.5px;
    line-height: 1.2;
  }
  .control-row {
    gap: 15px;
  }
  .record-meter {
    display: none;
  }
  .practice-slot {
    grid-column: 2;
    grid-row: 3;
    height: 100%;
    max-height: 100px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .wave-bar {
    height: 7px;
  }
  .spinner {
    border-color: #ffffff70;
    border-top-color: #fff;
  }
}
