:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --accent: #7c6cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080b12;
  --bg-elev: #101623;
  --surface: rgba(19, 25, 39, 0.74);
  --surface-solid: #121826;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #eef2ff;
  --muted: #98a3ba;
  --muted-2: #6b768d;
  --field: rgba(255, 255, 255, 0.045);
  --field-hover: rgba(255, 255, 255, 0.075);
  --track: rgba(255, 255, 255, 0.12);
  --focus: rgba(124, 108, 255, 0.18);
  --shadow: 0 26px 60px -32px rgba(0, 0, 0, 0.95);
  --log-bg: rgba(0, 0, 0, 0.22);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398a3ba' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5fc;
  --bg-elev: #ffffff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0d1526;
  --muted: #5b6579;
  --muted-2: #8a93a6;
  --field: rgba(15, 23, 42, 0.04);
  --field-hover: rgba(15, 23, 42, 0.07);
  --track: rgba(15, 23, 42, 0.12);
  --focus: rgba(99, 86, 255, 0.14);
  --shadow: 0 26px 50px -34px rgba(15, 23, 42, 0.4);
  --log-bg: rgba(15, 23, 42, 0.04);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6579' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: rgba(124, 108, 255, 0.35);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.aurora {
  position: fixed;
  inset: -25vmax;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  filter: blur(80px);
  background:
    radial-gradient(30vmax 30vmax at 12% 8%, rgba(124, 108, 255, 0.55), transparent 62%),
    radial-gradient(26vmax 26vmax at 88% 12%, rgba(34, 211, 238, 0.32), transparent 62%),
    radial-gradient(32vmax 32vmax at 72% 92%, rgba(244, 114, 182, 0.26), transparent 66%);
  animation: aurora-drift 24s ease-in-out infinite alternate;
}

[data-theme="light"] .aurora {
  opacity: 0.32;
}

@keyframes aurora-drift {
  0% { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(2%, 2%, 0) scale(1.06); }
}

.app-shell {
  width: min(100%, 780px);
  margin-inline: auto;
  padding:
    calc(18px + env(safe-area-inset-top))
    clamp(16px, 4.5vw, 26px)
    calc(40px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 4px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(140deg, #7c6cff, #5b8cff 55%, #22d3ee);
  box-shadow: 0 14px 30px -14px rgba(124, 108, 255, 0.85);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: background var(--ease), transform var(--ease), border-color var(--ease);
}

.icon-btn:hover {
  background: var(--field-hover);
  border-color: var(--border-strong);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-moon,
[data-theme="light"] .icon-sun {
  display: block;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--field);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: color var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--bg-elev);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.9);
}

.tab.is-active svg {
  color: var(--accent);
}

.panel[hidden] {
  display: none;
}

.panel.is-active {
  animation: panel-in 260ms var(--ease);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  margin-bottom: 14px;
  padding: clamp(16px, 3.6vw, 22px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card {
    background: var(--surface-solid);
  }
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0.005em;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 17px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--ease), transform var(--ease), opacity var(--ease), border-color var(--ease), filter var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--field-hover);
}

.btn:active:not(:disabled) {
  transform: scale(0.975);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7c6cff, #5b8cff 52%, #22d3ee);
  color: #fff;
  box-shadow: 0 16px 32px -16px rgba(99, 102, 241, 0.75);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #8a7bff, #6a97ff 52%, #3ddaf3);
  filter: brightness(1.04);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--field);
}

.btn-sm {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.79rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.72rem;
  border-radius: 8px;
}

.danger {
  color: var(--danger);
}

.danger:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.12);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.chip:hover {
  color: var(--text);
  background: var(--field-hover);
  border-color: var(--border-strong);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}

.status-pill[data-state="listening"] {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
}

[data-theme="light"] .status-pill[data-state="listening"] {
  color: #047857;
}

.status-pill[data-state="listening"] .dot {
  background: var(--success);
  animation: dot-pulse 1.4s ease-out infinite;
}

.status-pill[data-state="starting"],
.status-pill[data-state="speaking"] {
  border-color: rgba(124, 108, 255, 0.4);
  background: rgba(124, 108, 255, 0.1);
  color: var(--accent);
}

.status-pill[data-state="starting"] .dot,
.status-pill[data-state="speaking"] .dot {
  background: var(--accent);
  animation: dot-pulse 1.4s ease-out infinite;
}

.status-pill[data-state="paused"] {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

.status-pill[data-state="paused"] .dot {
  background: var(--warning);
}

.status-pill[data-state="finished"] {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
}

.status-pill[data-state="finished"] .dot {
  background: var(--success);
}

.status-pill[data-state="error"] {
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.1);
  color: var(--danger);
}

.status-pill[data-state="error"] .dot {
  background: var(--danger);
}

@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.listen-card {
  display: flex;
  flex-direction: column;
}

.mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 6px 0 2px;
}

.mic-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 28%, rgba(124, 108, 255, 0.26), transparent 68%),
    var(--field);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--ease), box-shadow var(--ease), background var(--ease), color var(--ease), border-color var(--ease);
}

.mic-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 44px -26px rgba(124, 108, 255, 0.8);
}

.mic-btn:active {
  transform: scale(0.97);
}

.mic-btn svg {
  width: 44px;
  height: 44px;
}

.mic-btn .stop-icon {
  display: none;
  width: 38px;
  height: 38px;
}

.mic-btn[aria-pressed="true"] {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(145deg, #7c6cff, #5b8cff 58%, #22d3ee);
  box-shadow: 0 18px 46px -18px rgba(99, 102, 241, 0.85);
}

.mic-btn[aria-pressed="true"] .mic-icon {
  display: none;
}

.mic-btn[aria-pressed="true"] .stop-icon {
  display: block;
}

.mic-btn::before,
.mic-btn::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(124, 108, 255, 0.7);
  opacity: 0;
  pointer-events: none;
}

.mic-btn[aria-pressed="true"]::before {
  animation: mic-ripple 2.4s ease-out infinite;
}

.mic-btn[aria-pressed="true"]::after {
  animation: mic-ripple 2.4s ease-out 1.2s infinite;
}

@keyframes mic-ripple {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.75); opacity: 0; }
}

.mic-hint {
  margin: 0;
  min-height: 1.3em;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.sound-bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  opacity: 0;
  transition: opacity 220ms var(--ease);
}

.sound-bars.is-live {
  opacity: 1;
}

.sound-bars span {
  width: 4px;
  height: 25%;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  animation: sound-bar 0.9s ease-in-out infinite;
}

.sound-bars span:nth-child(2) { animation-delay: 0.12s; }
.sound-bars span:nth-child(3) { animation-delay: 0.24s; }
.sound-bars span:nth-child(4) { animation-delay: 0.36s; }
.sound-bars span:nth-child(5) { animation-delay: 0.48s; }

@keyframes sound-bar {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}

.support-note {
  margin: 14px 0 0;
  padding: 10px 13px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius-md);
  background: rgba(251, 191, 36, 0.09);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.transcript,
.compose {
  display: block;
  width: 100%;
  min-height: 172px;
  max-height: 52dvh;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--field);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.transcript::placeholder,
.compose::placeholder {
  color: var(--muted-2);
  opacity: 0.85;
}

.transcript:focus,
.compose:focus {
  border-color: rgba(124, 108, 255, 0.65);
  background: var(--field-hover);
  box-shadow: 0 0 0 4px var(--focus);
}

.compose {
  min-height: 160px;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.meta-inline {
  color: var(--muted-2);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.73rem;
}

.confidence strong {
  color: var(--text);
  font-weight: 650;
}

.alternatives {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.alt-label {
  color: var(--muted-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
}

.alt-chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 0.74rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  margin-top: 14px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.75rem;
}

.progress {
  height: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 160ms linear;
}

.now-speaking {
  margin: 14px 0 0;
  min-height: 2.8em;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  word-break: break-word;
}

.now-speaking .word {
  border-radius: 6px;
  transition: background var(--ease), box-shadow var(--ease);
}

.now-speaking .word.is-active {
  background: linear-gradient(135deg, rgba(124, 108, 255, 0.32), rgba(34, 211, 238, 0.26));
  box-shadow: 0 0 0 1px rgba(124, 108, 255, 0.4);
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field select,
.field input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--field);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
  text-overflow: ellipsis;
}

.field input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.field select:focus,
.field input[type="number"]:focus {
  border-color: rgba(124, 108, 255, 0.65);
  box-shadow: 0 0 0 4px var(--focus);
}

.field output {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font-size: 0.73rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.hint {
  color: var(--muted-2);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  height: 30px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  --fill: 50%;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) var(--fill), var(--track) var(--fill));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  transition: transform 120ms var(--ease);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--track);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.switch-row:hover {
  background: var(--field-hover);
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.switch-text small {
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 500;
  line-height: 1.35;
}

input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--track);
  cursor: pointer;
  transition: background var(--ease);
}

input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
  transition: transform 200ms var(--ease);
}

input.switch:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

input.switch:checked::after {
  transform: translateX(20px);
}

input.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.advanced-card {
  padding: 0;
  overflow: hidden;
}

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 17px clamp(16px, 3.6vw, 22px);
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--ease);
}

.advanced-toggle:hover {
  background: var(--field);
}

.advanced-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 0.87rem;
  font-weight: 650;
}

.advanced-title svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.advanced-sub {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 0.74rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52%;
}

.chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 260ms var(--ease);
}

.advanced-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.collapse {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 300ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.collapse.is-open {
  grid-template-rows: 1fr;
}

.collapse-inner {
  min-height: 0;
  overflow: hidden;
}

.advanced-body {
  padding: 18px clamp(16px, 3.6vw, 22px) 20px;
  border-top: 1px solid var(--border);
}

.log-block {
  margin-top: 16px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  max-height: 158px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--log-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.75;
  overscroll-behavior: contain;
}

.event-log:empty::before {
  content: "Events will appear here…";
  color: var(--muted-2);
}

.event-log li[data-kind="error"] {
  color: var(--danger);
}

.event-log li[data-kind="ok"] {
  color: var(--success);
}

.event-log li[data-kind="warn"] {
  color: var(--warning);
}

.voice-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.details-label {
  color: var(--muted-2);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.voice-details p {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 0.79rem;
  line-height: 1.45;
}

.app-footer {
  padding-top: 6px;
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: min(92vw, 440px);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-kind="error"] {
  border-color: rgba(251, 113, 133, 0.55);
}

.toast[data-kind="success"] {
  border-color: rgba(52, 211, 153, 0.55);
}

.noscript-note {
  max-width: 520px;
  margin: 40px auto;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .brand-text p {
    font-size: 0.72rem;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand-mark svg {
    width: 20px;
    height: 20px;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
  }

  .mic-btn {
    width: 112px;
    height: 112px;
  }

  .mic-btn svg {
    width: 38px;
    height: 38px;
  }

  .card {
    border-radius: 22px;
  }

  .advanced-sub {
    display: none;
  }

  .fields {
    grid-template-columns: 1fr;
  }

  .btn-row {
    gap: 6px;
  }

  .btn {
    padding: 10px 13px;
    font-size: 0.83rem;
  }

  .btn-sm {
    padding: 7px 10px;
    font-size: 0.76rem;
  }

  .tab {
    font-size: 0.82rem;
    gap: 6px;
  }

  .tab svg {
    width: 17px;
    height: 17px;
  }
}

@media (max-width: 380px) {
  .brand-text p {
    display: none;
  }

  .brand-text h1 {
    font-size: 1.02rem;
  }

  .tab span {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
