:root {
  color-scheme: dark;
  --page: #0a0e10;
  --panel: #121719;
  --field: #0d1214;
  --field-hover: #11181a;
  --line: #2b3537;
  --line-strong: #435154;
  --text: #f4f7f6;
  --muted: #a2adae;
  --accent: #79dfcc;
  --accent-hover: #91ead9;
  --success: #71d691;
  --warning: #ffc86c;
  --danger: #ff8176;
  --danger-hover: #ff988f;
  --focus: rgb(121 223 204 / 58%);
  --radius-lg: 24px;
  --radius-md: 14px;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.page-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 680px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}

.brand-mark span {
  display: grid;
  color: var(--page);
  font-size: 12px;
  font-weight: 850;
  background: var(--accent);
  place-items: center;
}

.brand-mark span:last-child {
  background: var(--warning);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 15px;
  letter-spacing: -0.015em;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
}

.text-button,
.password-toggle {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

.text-button {
  padding: 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  background: transparent;
}

.text-button:hover:not(:disabled) {
  color: var(--text);
}

main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.translator-view,
.auth-view {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  place-items: center;
}

.translator-panel,
.auth-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.translator-panel {
  padding: clamp(24px, 6vw, 40px);
}

.language-stack {
  display: grid;
  gap: 10px;
}

.choice-field {
  display: grid;
  gap: 9px;
}

.choice-field > span,
.field-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0.01em;
}

.choice-field select {
  width: 100%;
  min-height: 68px;
  padding: 0 16px;
  color: var(--text);
  font-size: 20px;
  font-weight: 720;
  line-height: 1.2;
  background-color: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.choice-field select:hover:not(:disabled) {
  background-color: var(--field-hover);
  border-color: #5b6a6d;
}

.choice-field select:disabled {
  color: #c8cecd;
  cursor: not-allowed;
  opacity: 0.68;
}

.swap-button {
  display: grid;
  width: 52px;
  height: 52px;
  margin: -2px auto;
  color: var(--accent);
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
  place-items: center;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    transform 180ms ease;
}

.swap-button:hover:not(:disabled) {
  color: var(--accent-hover);
  border-color: var(--accent);
}

.swap-button:active:not(:disabled) {
  transform: rotate(180deg);
}

.swap-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.swap-button svg {
  width: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.voice-field {
  margin-top: 28px;
}

.voice-field select {
  min-height: 60px;
  font-size: 17px;
}

.session-control {
  display: grid;
  gap: 14px;
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.connection-status {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 720;
  text-align: center;
}

.status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  background: #687477;
  border-radius: 50%;
}

.connection-status[data-state="connecting"] .status-dot,
.connection-status[data-state="finishing"] .status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 5px rgb(255 200 108 / 12%);
}

.connection-status[data-state="connected"] .status-dot,
.connection-status[data-state="listening"] .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 5px rgb(113 214 145 / 12%);
}

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

.session-button,
.primary-button {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 74px;
  padding: 0 22px;
  color: #071311;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.015em;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.session-button:hover:not(:disabled),
.primary-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.session-button:active:not(:disabled),
.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.session-button[data-state="active"] {
  color: #1a0807;
  background: var(--danger);
}

.session-button[data-state="active"]:hover:not(:disabled) {
  background: var(--danger-hover);
}

.session-button[data-state="connecting"],
.session-button[data-state="closing"] {
  color: #181006;
  background: var(--warning);
}

.session-button:disabled,
.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-led {
  width: 10px;
  height: 10px;
  background: currentColor;
  border-radius: 50%;
}

.session-button[data-state="active"] .button-led {
  border-radius: 2px;
}

.session-hint {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.auth-card {
  max-width: 440px;
  padding: clamp(24px, 6vw, 40px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.06;
  letter-spacing: -0.04em;
}

.auth-intro {
  margin: 18px 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.setup-notice {
  display: grid;
  gap: 4px;
  margin-bottom: 20px;
  padding: 14px 16px;
  color: #ffd4d0;
  font-size: 13px;
  line-height: 1.45;
  background: rgb(255 129 118 / 8%);
  border: 1px solid rgb(255 129 118 / 32%);
  border-radius: 11px;
}

.field-label {
  display: block;
  margin-bottom: 9px;
}

.password-row {
  position: relative;
}

.password-row input {
  width: 100%;
  min-height: 58px;
  padding: 0 104px 0 16px;
  color: var(--text);
  font-size: 17px;
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}

.password-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  background: #1b2325;
  border-radius: 9px;
}

.form-error {
  margin: 10px 0 0;
  color: #ffaaa2;
  font-size: 14px;
}

.primary-button {
  min-height: 58px;
  margin-top: 20px;
  font-size: 16px;
}

.audio-unlock {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 20;
  min-height: 62px;
  padding: 0 18px;
  color: #181006;
  font-size: 16px;
  font-weight: 850;
  background: var(--warning);
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 14px 34px rgb(0 0 0 / 35%);
}

.toast {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 30;
  width: fit-content;
  max-width: min(560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 17px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  background: #222c2f;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgb(0 0 0 / 35%);
}

@media (max-width: 480px) {
  .page-shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .brand-copy small {
    display: none;
  }

  .translator-panel {
    padding: 22px 18px;
  }

  .choice-field select {
    min-height: 64px;
    font-size: 18px;
  }

  .voice-field {
    margin-top: 22px;
  }

  .voice-field select {
    min-height: 58px;
    font-size: 16px;
  }

  .session-control {
    margin-top: 26px;
    padding-top: 22px;
  }

  .session-button {
    min-height: 72px;
    font-size: 19px;
  }
}

@media (max-width: 360px) {
  .brand-copy {
    display: none;
  }

  .translator-panel {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-height: 760px) {
  .topbar {
    margin-bottom: 8px;
  }

  .translator-panel {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .choice-field select {
    min-height: 58px;
  }

  .swap-button {
    width: 46px;
    height: 46px;
  }

  .voice-field,
  .session-control {
    margin-top: 18px;
  }

  .session-control {
    gap: 10px;
    padding-top: 18px;
  }

  .session-button {
    min-height: 64px;
  }
}

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

@media (forced-colors: active) {
  .status-dot,
  .button-led {
    border: 1px solid currentColor;
  }
}
