/* ============================================================
   Translator — Powerful Matter skin
   Imports the PM design tokens, mirrors aichat's theme aliases,
   and adds translator-specific UI. Dark-only by design.
   ============================================================ */

@import url("/css-v2/tokens.css");

/* ===== Webfonts (mirrored from base.css) ===== */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces/Fraunces-Latin-Roman-Full.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces/Fraunces-Latin-Italic-Full.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}

/* ===== Local theme aliases mapped onto PM tokens ===== */
:root {
  --bg-primary:        var(--pm-black);
  --bg-secondary:      #111114;
  --bg-tertiary:       #1a1a1f;
  --bg-input:          rgba(255, 255, 255, 0.02);
  --bg-msg-out:        rgba(196, 0, 173, 0.10);
  --bg-msg-in:         transparent;
  --bg-hover:          rgba(196, 0, 173, 0.10);
  --bg-active:         rgba(196, 0, 173, 0.16);
  --bg-modal:          #0F0F12;

  --text-primary:      var(--pm-white);
  --text-secondary:    var(--pm-gray-300);
  --text-muted:        var(--pm-gray-400);

  --accent:            var(--pm-purple-400);
  --accent-deep:       var(--pm-purple-500);
  --accent-hover:      var(--pm-purple-300);
  --focus-ring:        var(--pm-accent);

  --border:            rgba(255, 255, 255, 0.08);
  --border-strong:     rgba(255, 255, 255, 0.14);
  --error:             #FF7B9C;
  --success:           #6BD16B;
  --warning:           #E5FF3A;
  --shadow-modal:      0 24px 64px rgba(0, 0, 0, 0.65);

  --topbar-height:     56px;
  --radius:            10px;
  --radius-lg:         14px;
  --radius-pill:       999px;
  --transition:        180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }

body {
  font-family: var(--ff-body);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100svh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent); color: var(--pm-white); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden { display: none !important; }

/* ===== Buttons (lean local set; mirrors PM design system) ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn--primary {
  background: var(--accent);
  color: var(--pm-white);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }
.btn__arrow { transition: transform var(--transition); }
.btn:hover .btn__arrow { transform: translateX(3px); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: none; border: none; color: var(--text-secondary);
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-sm {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 7px 12px; font-size: 12.5px;
  border-radius: var(--radius); transition: background var(--transition);
}
.btn-sm:hover { background: var(--bg-hover); }

.eyebrow {
  font-size: 12px; text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--accent); font-weight: 500;
}

.arrow {
  display: inline-block;
  transition: transform var(--transition);
}

/* ===== Brand back-link ===== */
.brand-back {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  color: var(--text-primary); text-decoration: none;
  font-family: var(--ff-display); font-weight: 500; font-size: 14px;
  letter-spacing: -0.01em;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}
.brand-back:hover { color: var(--pm-white); background: var(--bg-hover); }
.brand-back__mark { display: inline-flex; align-items: center; justify-content: center; }
.brand-back__mark img { display: block; }
.brand-back__text { white-space: nowrap; }
.brand-back__arrow {
  width: 14px; height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}
.brand-back:hover .brand-back__arrow {
  color: var(--accent);
  transform: translateX(-3px);
}

/* ===== Topbar ===== */
.translator-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: rgba(15, 15, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky; top: 0;
  z-index: 60;
}
.translator-topbar__title {
  font-family: var(--ff-display); font-weight: 500; font-size: 14px;
  color: var(--text-secondary);
  margin-left: auto;
  margin-right: 12px;
}
.translator-topbar__nav {
  display: flex; gap: 4px;
}
.translator-topbar__chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.translator-topbar__chip:hover { background: var(--bg-hover); color: var(--text-primary); }
.translator-topbar__chip.is-active {
  background: rgba(196, 0, 173, 0.18);
  color: var(--accent-hover);
}
.translator-topbar__settings {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: none; border: none; color: var(--text-secondary);
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.translator-topbar__settings:hover {
  background: var(--bg-hover); color: var(--text-primary);
}
.translator-topbar__settings svg { width: 18px; height: 18px; }

/* ===== Welcome screen (mirrors aichat) ===== */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  text-align: center; gap: 16px;
  padding: 48px 24px 32px;
  max-width: 640px;
  margin: 0 auto;
}
.welcome-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.welcome-logo {
  width: clamp(140px, 18vw, 200px); height: auto;
  filter: drop-shadow(0 0 60px rgba(196, 0, 173, 0.35)) drop-shadow(0 0 120px rgba(196, 0, 173, 0.18));
  animation: welcome-logo-float 8s ease-in-out infinite;
}
@keyframes welcome-logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.welcome-wordmark {
  font-family: var(--ff-display); font-weight: 500;
  font-size: clamp(2rem, 1.4rem + 1.6vw, 2.6rem);
  line-height: 0.92; letter-spacing: -0.03em;
  color: var(--pm-white);
}
.welcome-tagline {
  font-family: var(--ff-body); font-size: 13px;
  letter-spacing: 0.02em; color: var(--text-muted);
  font-style: italic;
}
.welcome-screen .eyebrow { margin-top: 16px; }
.welcome-screen h2 {
  font-family: var(--ff-display); font-weight: 500;
  font-size: clamp(2.25rem, 1.5rem + 2vw, 3rem);
  line-height: 0.95; letter-spacing: -0.03em;
  color: var(--pm-white);
}
.welcome-screen p { font-size: 16px; color: var(--text-secondary); max-width: 44ch; line-height: 1.6; }
.welcome-attrs {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px 10px; list-style: none; padding: 0; margin: 8px 0 4px;
  max-width: 560px;
}
.welcome-attrs li {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: 12.5px; color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--transition), color var(--transition);
}
.welcome-attrs li:hover { border-color: var(--accent); color: var(--text-primary); }
.welcome-attrs li svg { color: var(--accent); flex-shrink: 0; }
.welcome-link {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--accent-hover); border-bottom: 1px solid currentColor;
  cursor: pointer;
}
.welcome-link:hover { color: var(--pm-white); }
.welcome-foot { margin-top: 24px; font-size: 12px; color: var(--text-muted); opacity: 0.85; }
.welcome-foot a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.welcome-foot a:hover { color: var(--accent); }

/* ===== Main mount slot ===== */
.translator-main {
  flex: 1;
  padding: 24px clamp(16px, 4vw, 48px);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== Mode picker cards ===== */
.mode-picker {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.mode-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, rgba(196, 0, 173, 0.04), rgba(196, 0, 173, 0));
  color: inherit; text-decoration: none;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.mode-card:hover {
  transform: translateY(-3px);
  border-color: rgba(196, 0, 173, 0.5);
  box-shadow: 0 12px 32px rgba(196, 0, 173, 0.18);
}
.mode-card__head { display: flex; align-items: center; gap: 12px; }
.mode-card__icon { width: 28px; height: 28px; color: var(--accent); flex-shrink: 0; }
.mode-card__title {
  font-family: var(--ff-display); font-weight: 500;
  font-size: 24px; letter-spacing: -0.02em; color: var(--pm-white);
}
.mode-card__blurb { color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.mode-card__cta {
  margin-top: auto; display: inline-flex; gap: 6px;
  font-size: 13px; color: var(--accent-hover);
}

/* ===== Generic mode header ===== */
.mode { display: flex; flex-direction: column; gap: 24px; }
.mode__header { text-align: left; }
.mode__title {
  font-family: var(--ff-display); font-weight: 500;
  font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.4rem);
  letter-spacing: -0.025em; color: var(--pm-white);
}
.mode__sub { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ===== Form primitives ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group > label {
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--text-muted);
}
.form-group--inline { flex-direction: row; align-items: center; gap: 10px; }
.form-hint { font-size: 12px; color: var(--text-muted); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
.form-input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
input:focus, select:focus, textarea:focus, .form-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}
textarea { resize: vertical; }
.input-with-action {
  display: flex; gap: 6px;
}
.input-with-action input { flex: 1; }
.toggle-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-primary); cursor: pointer;
}
.form-row {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px;
}
.form-row .form-label {
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--text-muted);
}
.form-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }

/* Multi-select language chip grid */
.lang-chip-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px; max-height: 240px; overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-input);
}
.lang-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font-size: 13px; color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.lang-chip:hover { background: var(--bg-hover); color: var(--text-primary); }
.lang-chip input { accent-color: var(--accent); width: 14px; height: 14px; }
.lang-chip:has(input:checked) {
  background: rgba(196, 0, 173, 0.16);
  color: var(--text-primary);
  border-color: rgba(196, 0, 173, 0.4);
}

/* ===== Modal (mirrors aichat) ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  width: min(560px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: var(--ff-display); font-weight: 500;
  font-size: 18px; letter-spacing: -0.02em;
  color: var(--pm-white);
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* Settings onboarding banner */
.settings-onboarding { display: none; }
#settings-modal[data-empty-key="true"] .settings-onboarding {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(196, 0, 173, 0.08), rgba(196, 0, 173, 0.02));
  margin-bottom: 4px;
}
.settings-onboarding__brand { display: flex; align-items: flex-start; gap: 14px; }
.settings-onboarding__brand img { flex-shrink: 0; filter: drop-shadow(0 0 24px rgba(196, 0, 173, 0.45)); }
.settings-onboarding__brand h3 {
  font-family: var(--ff-display); font-weight: 500; font-size: 19px;
  letter-spacing: -0.02em; color: var(--pm-white); margin-bottom: 4px;
}
.settings-onboarding__brand p { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.settings-onboarding__attrs { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; padding: 0; }
.settings-onboarding__attrs li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: 11.5px; color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}
.settings-onboarding__attrs li svg { color: var(--accent); flex-shrink: 0; }
.settings-onboarding__cta {
  font-size: 12.5px; color: var(--text-muted);
  padding-top: 4px; border-top: 1px solid var(--border);
}
.settings-onboarding__cta a {
  color: var(--accent-hover); text-decoration: none;
  border-bottom: 1px solid currentColor;
}
.settings-onboarding__cta a:hover { color: var(--pm-white); }

/* ===== Language picker pill + popover ===== */
.lang-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  transition: border-color var(--transition), background var(--transition);
}
.lang-pill:hover { border-color: var(--border-strong); background: var(--bg-active); }
.lang-pill__code {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent);
  padding: 2px 6px; border-radius: 4px;
  background: rgba(196, 0, 173, 0.15);
}
.lang-pill__name { white-space: nowrap; }
.lang-pill__caret { color: var(--text-muted); margin-left: 2px; font-size: 10px; }
.lang-pill--multi { background: var(--bg-input); }

.lang-popover {
  position: fixed;
  z-index: 200;
  width: min(360px, calc(100vw - 16px));
  max-height: 60dvh;
  display: flex; flex-direction: column;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.lang-popover__search {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.lang-popover__search input {
  width: 100%; padding: 8px 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary); font-size: 13px; outline: none;
}
.lang-popover__list { overflow-y: auto; max-height: calc(60dvh - 60px); }
.lang-popover__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: none; border: none; color: var(--text-primary);
  text-align: left; font: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background var(--transition);
}
.lang-popover__item:hover { background: var(--bg-hover); }
.lang-popover__item.is-selected { background: rgba(196, 0, 173, 0.12); }
.lang-popover__code {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent);
  min-width: 28px;
}
.lang-popover__name { flex: 1; font-size: 14px; }
.lang-popover__native { color: var(--text-muted); font-size: 13px; }
.lang-popover__empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ===== Mic button ===== */
.mic-button {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 88px; height: 88px;
  background: linear-gradient(135deg, var(--pm-purple-700), var(--pm-purple-400));
  border: none; border-radius: 50%;
  color: var(--pm-white);
  box-shadow: 0 8px 24px rgba(196, 0, 173, 0.35);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform 120ms ease, box-shadow var(--transition);
}
.mic-button:active { transform: scale(0.96); }
.mic-button__core {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  z-index: 2;
}
.mic-button__icon { width: 32px; height: 32px; }
.mic-button__pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(196, 0, 173, 0.3);
  opacity: 0;
}
.mic-button.is-recording .mic-button__pulse {
  animation: mic-pulse 1.4s ease-out infinite;
}
@keyframes mic-pulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
.mic-button__waveform {
  position: absolute;
  bottom: -28px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: end; gap: 2px;
  width: 80%; height: 22px;
  opacity: 0;
  transition: opacity var(--transition);
}
.mic-button.is-recording .mic-button__waveform { opacity: 0.85; }
.mic-button__waveform i {
  flex: 1;
  background: var(--accent);
  border-radius: 2px;
  height: 15%;
  transition: height 60ms linear;
}
.mic-button__hint {
  margin-top: 36px;
  font-size: 13px; color: var(--text-muted);
  text-align: center;
}
.mic-button--lg {
  width: clamp(120px, 26vw, 160px);
  height: clamp(120px, 26vw, 160px);
}
.mic-button--lg .mic-button__icon { width: 44px; height: 44px; }

@media (prefers-reduced-motion: reduce) {
  .mic-button.is-recording .mic-button__pulse { animation: none; opacity: 0.3; }
  .welcome-logo { animation: none; }
}

/* ===== Solo mode ===== */
.mode-solo {
  display: flex; flex-direction: column;
  gap: 16px;
  min-height: calc(100dvh - var(--topbar-height) - 48px);
}
.mode-solo__lang-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.mode-solo__lang-block {
  display: flex; flex-direction: column; gap: 6px;
}
.mode-solo__label {
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--text-muted);
}
.mode-solo__arrow { color: var(--text-muted); font-size: 18px; align-self: end; padding-bottom: 8px; }
.mode-solo__bubbles {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  flex: 1;
  min-height: 0;
}
.mode-solo__dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 14px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 15, 18, 0) 0%, var(--bg-primary) 32%, var(--bg-primary) 100%);
  display: flex; flex-direction: column; gap: 12px;
  z-index: 5;
}
.mode-solo__stage {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(16px, 4vw, 32px);
}
.mode-solo__stage-spacer {
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  visibility: hidden;
}
.mode-solo .mic-button__hint { margin-top: 0; }

/* Auto-play toggle that lives next to the mic */
.autoplay-toggle {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: clamp(56px, 14vw, 72px);
  height: clamp(56px, 14vw, 72px);
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.autoplay-toggle:hover { color: var(--text-primary); border-color: var(--border-strong); }
.autoplay-toggle:active { transform: scale(0.96); }
.autoplay-toggle svg { width: 24px; height: 24px; }
.autoplay-toggle__on { display: none; }
.autoplay-toggle[aria-pressed="true"] .autoplay-toggle__on { display: block; }
.autoplay-toggle[aria-pressed="true"] .autoplay-toggle__off { display: none; }
.autoplay-toggle[aria-pressed="true"] {
  background: rgba(196, 0, 173, 0.18);
  border-color: rgba(196, 0, 173, 0.55);
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(196, 0, 173, 0.28);
}

/* Type-to-translate composer */
.mode-solo__compose {
  display: flex; gap: 8px; align-items: flex-end;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  transition: border-color var(--transition);
}
.mode-solo__compose:focus-within {
  border-color: rgba(196, 0, 173, 0.55);
}
.mode-solo__compose-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 8px;
  resize: none;
  max-height: 140px;
  outline: none;
  min-height: 22px;
}
.mode-solo__compose-input::placeholder { color: var(--text-muted); }
.mode-solo__compose-send {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--pm-white);
  border: none;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  transition: background var(--transition), transform 120ms ease, opacity var(--transition);
}
.mode-solo__compose-send:hover { background: var(--accent-deep); }
.mode-solo__compose-send:active { transform: scale(0.96); }
.mode-solo__compose-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Last bubble shouldn't tuck behind the dock when scrolled to bottom */
.tx-bubble { scroll-margin-bottom: 220px; }

/* ===== Transcript bubbles ===== */
.tx-bubble {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-secondary);
}
.tx-bubble--right {
  align-self: flex-end; max-width: 85%;
  background: var(--bg-msg-out);
  border-color: rgba(196, 0, 173, 0.25);
  border-radius: 14px 14px 4px 14px;
}
.tx-bubble--left {
  align-self: flex-start; max-width: 85%;
  border-radius: 14px 14px 14px 4px;
}
.tx-bubble__meta {
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.tx-bubble__source {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
}
.tx-bubble__translations {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 8px; margin-top: 4px;
}
.tx-bubble__translation {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 8px; align-items: start;
}
.tx-bubble__text { font-size: 15px; line-height: 1.5; color: var(--pm-white); }
.tx-bubble__text::selection { background: rgba(196, 0, 173, 0.35); color: var(--pm-white); }

/* Typewriter caret — used on bubble text, explain panels, reading rows, duo cards. */
.is-typing::after {
  content: '';
  display: inline-block;
  width: 0.55ch;
  height: 1em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: currentColor;
  animation: tx-caret-blink 1s steps(1) infinite;
}
@keyframes tx-caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .is-typing::after { display: none; }
}
.tx-bubble__lang {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent);
  padding: 2px 6px; border-radius: 4px;
  background: rgba(196, 0, 173, 0.12);
  align-self: start;
}
.tx-speak {
  background: none; border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.tx-speak:hover { color: var(--accent); border-color: var(--accent); }
.tx-speak.is-busy { animation: pulse-soft 1s ease-in-out infinite; }
@keyframes pulse-soft { 50% { opacity: 0.5; } }

.tx-explain {
  background: none; border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.tx-explain:hover { color: var(--accent); border-color: var(--accent); }
.tx-explain.is-active { color: var(--accent); border-color: var(--accent); background: rgba(196, 0, 173, 0.12); }
.tx-explain.is-busy { animation: pulse-soft 1s ease-in-out infinite; }
.tx-explain-panel {
  font-size: 13px; line-height: 1.55;
  color: var(--text-secondary);
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  white-space: pre-wrap;
  margin-top: -2px;
}
.tx-explain-panel[hidden] { display: none; }

/* ===== Duo mode ===== */
.mode-duo {
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  background: var(--bg-primary);
}
.duo-half {
  position: relative;
  display: flex; align-items: stretch;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.duo-half:last-child { border-bottom: none; }
.duo-half--top .duo-half__inner { transform: rotate(180deg); }
.duo-half__inner {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  min-height: 0;
}
.duo-half__history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 4px 8px;
  scrollbar-width: thin;
}
.duo-half__history:empty { border: 1px dashed var(--border); border-radius: var(--radius); }
.duo-half__controls {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.duo-half__lang-row {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.duo-half__lang-row .lang-pill {
  font-size: 14px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-color: var(--border-strong);
}
.duo-half__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--text-muted);
}
.duo-mic {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-purple-700), var(--pm-purple-400));
  color: var(--pm-white);
  border: none;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(196, 0, 173, 0.40);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: transform var(--transition), box-shadow var(--transition);
}
.duo-mic:hover { box-shadow: 0 8px 22px rgba(196, 0, 173, 0.50); }
.duo-mic:active { transform: scale(0.96); }
.duo-mic svg { width: 30px; height: 30px; }
.duo-mic.is-recording {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  animation: mic-pulse 1.4s ease-in-out infinite;
}
.duo-half__hint { color: var(--text-muted); font-size: 12px; text-align: center; }
.duo-card {
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-secondary);
}
.duo-card--out { background: var(--bg-msg-out); border-color: rgba(196, 0, 173, 0.25); }
.duo-card__text { font-size: 16px; line-height: 1.4; }
.duo-card__meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.duo-card__source { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.duo-controls {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px;
  z-index: 10;
}
.duo-swap {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent); color: var(--pm-white);
  border: 2px solid var(--bg-primary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(196, 0, 173, 0.35);
}
.duo-swap svg { width: 18px; height: 18px; }
.duo-swap:hover { background: var(--accent-hover); }
.autoplay-toggle--duo {
  width: 40px; height: 40px;
  border: 2px solid var(--bg-primary);
}
.autoplay-toggle--duo svg { width: 18px; height: 18px; }

/* ===== Reading mode ===== */
.mode-reading__lang-row {
  display: flex; align-items: end; gap: 16px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}
.mode-reading__lang-block {
  display: flex; flex-direction: column; gap: 6px;
}
.mode-reading__go { margin-left: auto; }
.mode-reading__grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.mode-reading__col { display: flex; flex-direction: column; gap: 8px; }
.mode-reading__col-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls-eyebrow);
  color: var(--text-muted);
}
.mode-reading__textarea {
  min-height: 280px;
  font-family: var(--ff-body); font-size: 15px; line-height: 1.6;
}
.mode-reading__output {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 280px;
  padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-input);
  overflow-y: auto;
  max-height: 60vh;
}
.reading-row {
  position: relative;
  display: grid; grid-template-columns: 1fr; gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.reading-row:last-child { border-bottom: none; }
.reading-row__src { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.reading-row__dst { color: var(--pm-white); font-size: 15px; line-height: 1.55; }
.reading-row__loading { color: var(--text-muted); font-style: italic; }
.reading-row__error { color: var(--error); font-size: 13px; }
.reading-row__speak {
  position: absolute; right: 12px; top: 12px;
  width: 28px; height: 28px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.reading-row__speak:hover { color: var(--accent); border-color: var(--accent); }

/* ===== Room mode ===== */
.mode-room { display: flex; flex-direction: column; gap: 16px; }
.mode-room__entry {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  padding: 0;
  overflow: hidden;
}
.mode-room__tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.mode-room__tab {
  flex: 1; padding: 14px 18px;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.mode-room__tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.mode-room__tab.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.mode-room__panel { padding: 22px; }
.mode-room__intro { color: var(--text-secondary); font-size: 14px; margin-bottom: 18px; max-width: 60ch; }

.passphrase-row {
  display: flex; align-items: center; gap: 8px;
}
.passphrase {
  flex: 1;
  display: inline-block;
  padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; color: var(--accent-hover);
  letter-spacing: 0.02em;
  word-break: break-all;
}

.mode-room__live { display: flex; flex-direction: column; gap: 14px; min-height: 60vh; }
.mode-room__topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-secondary);
}
.mode-room__roleline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mode-room__lang { color: var(--text-secondary); font-size: 13px; }
.mode-room__actions { display: flex; gap: 6px; }

.mode-room__members {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.member-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12.5px; color: var(--text-secondary);
}
.member-pill--self { border-color: rgba(196, 0, 173, 0.4); color: var(--text-primary); }
.member-pill__lang {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent);
}

.mode-room__bubbles {
  flex: 1;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 240px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-input);
}
.mode-room__mic-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding-top: 8px;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge--accent {
  background: rgba(196, 0, 173, 0.18); color: var(--accent-hover);
  border-color: rgba(196, 0, 173, 0.35);
}
.badge--success {
  background: rgba(107, 209, 107, 0.12); color: var(--success);
  border-color: rgba(107, 209, 107, 0.28);
}

/* ===== Toasts ===== */
.toast-region {
  position: fixed; top: calc(var(--topbar-height) + 12px); right: 12px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  max-width: 340px;
}
.toast {
  display: flex; align-items: start; gap: 8px;
  padding: 12px 14px;
  background: var(--bg-modal); border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px; color: var(--text-primary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  animation: toast-in 200ms var(--ease-out-quart, ease-out);
}
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--error); }
.toast--info { border-left: 3px solid var(--accent); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity 250ms, transform 250ms; }
.toast__msg { flex: 1; line-height: 1.4; }
.toast__close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; line-height: 1; cursor: pointer;
  padding: 0 4px;
}
.toast__close:hover { color: var(--text-primary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Mobile responsive ===== */
@media (max-width: 880px) {
  .translator-topbar { padding: 0 8px; gap: 6px; flex-wrap: wrap; height: auto; min-height: var(--topbar-height); }
  .translator-topbar__title { display: none; }
  .translator-topbar__nav { order: 4; flex-basis: 100%; padding: 4px 0 8px; overflow-x: auto; }
  .translator-topbar__chip { font-size: 12.5px; padding: 5px 10px; flex-shrink: 0; }
  .brand-back { padding: 8px 10px; font-size: 13px; }

  .translator-main { padding: 16px; }
  .welcome-screen { padding: 24px 20px; }
  .welcome-screen h2 { font-size: 28px; }
  .welcome-screen p { font-size: 15px; }
  .welcome-logo { width: 120px; }
  .welcome-attrs li { font-size: 12px; padding: 6px 12px; }

  .mode-picker { grid-template-columns: 1fr; }

  /* Big mic on mobile — fills more vertical space */
  .mode-solo { min-height: calc(100dvh - var(--topbar-height) - 32px); }
  .mode-solo__stage { gap: 14px; }
  .mic-button {
    width: clamp(120px, 36vw, 180px);
    height: clamp(120px, 36vw, 180px);
  }
  .mic-button__icon { width: 40px; height: 40px; }
  .mic-button--lg {
    width: clamp(120px, 36vw, 180px);
    height: clamp(120px, 36vw, 180px);
  }
  .mic-button--lg .mic-button__icon { width: 48px; height: 48px; }
  .mic-button__hint { margin-top: 0; font-size: 14px; }
  .autoplay-toggle {
    width: clamp(52px, 14vw, 64px);
    height: clamp(52px, 14vw, 64px);
  }
  .mode-solo__stage-spacer {
    width: clamp(52px, 14vw, 64px);
    height: clamp(52px, 14vw, 64px);
  }

  /* Duo: scrollable history fills each half, mic is a discrete circle near the user */
  .mode-duo { inset: 0; padding-top: var(--topbar-height); }
  .duo-half__inner { padding: 10px; gap: 6px; }
  .duo-mic { width: 84px; height: 84px; }
  .duo-mic svg { width: 36px; height: 36px; }
  .duo-half__hint { font-size: 13px; }
  .duo-card__text { font-size: 17px; }

  .duo-swap { width: 44px; height: 44px; }
  .duo-swap svg { width: 20px; height: 20px; }
  .autoplay-toggle--duo { width: 44px; height: 44px; }
  .autoplay-toggle--duo svg { width: 20px; height: 20px; }

  .mode-reading__grid { grid-template-columns: 1fr; }
  .mode-reading__textarea { min-height: 180px; }
  .mode-reading__lang-row { flex-direction: column; align-items: stretch; }
  .mode-reading__go { margin-left: 0; }

  .mode-room__bubbles { max-height: 45vh; }
  .toast-region { left: 12px; right: 12px; max-width: none; }
}

/* ===== Tap & input affordance for iOS Safari ===== */
button, a, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}
