/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface2: #111111;
  --surface3: #1a1a1a;
  --border: #222222;
  --text: #ffffff;
  --text-dim: #888888;
  --text-muted: #444444;
  --accent: #ffffff;
  --accent-glow: rgba(255,255,255,0.15);
  --mic-color: #ffffff;
  --mic-active: #ff3b30;
  --mic-pulse: rgba(255, 59, 48, 0.3);
  --radius: 14px;
  --radius-sm: 8px;
  --nav-height: 60px;
  --mid-zone: 72px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ===== HIDDEN UTILITY ===== */
.hidden {
  display: none !important;
}

/* ===== LANDING PAGE ===== */
.screen.landing {
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  align-items: stretch;
}

.landing-glow {
  position: absolute;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.landing-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 28px 48px;
  padding-bottom: max(48px, calc(env(safe-area-inset-bottom) + 24px));
  gap: 0;
  width: 100%;
}

.landing-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}

.landing-logo-icon {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 0 24px rgba(255,255,255,0.15));
}

.landing-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.landing-hero {
  text-align: center;
  margin-bottom: 36px;
}

.landing-title {
  font-size: clamp(32px, 9vw, 48px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -1.5px;
  color: var(--text);
  margin-bottom: 16px;
}

.landing-sub {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 320px;
  margin: 0 auto;
}

.landing-features {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 40px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.landing-feature {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.landing-feature:last-child {
  border-bottom: none;
}

.lf-icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.lf-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.lf-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.landing-cta {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-install-big {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 16px;
  padding: 18px 24px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: -0.3px;
}

.btn-install-big:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.btn-install-icon {
  font-size: 22px;
}

.landing-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.landing-already {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.landing-link {
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Top Up / Payment ──────────────────────────────────────────────────────── */
.topup-plans {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.topup-plan {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 6px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
  background: var(--surface);
  -webkit-tap-highlight-color: transparent;
}
.topup-plan:active { opacity: 0.7; }
.topup-plan.selected {
  border-color: #f97316;
  background: rgba(249,115,22,0.08);
}
.topup-plan-badge {
  font-size: 10px;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.topup-plan-tokens {
  font-size: 15px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 2px;
}
.topup-plan-price {
  font-size: 13px;
  font-weight: 700;
  color: #f97316;
  margin-top: 4px;
}
.topup-custom-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.topup-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  transition: border-color 0.2s;
}
.topup-custom-row:focus-within { border-color: rgba(255,255,255,0.3); }
.topup-dollar {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.topup-custom-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  outline: none;
  min-width: 0;
}
.topup-custom-result {
  font-size: 12px;
  color: #f97316;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  min-width: 90px;
}

/* ── Crypto currency selector ─────────────────────────────────────────────── */
.topup-crypto-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.topup-crypto-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.topup-crypto-btn.selected {
  border-color: #f97316;
  background: rgba(249,115,22,0.08);
  color: var(--text);
}
.topup-crypto-btn:active { opacity: 0.7; }

/* ── Desktop: centered feature cards ─────────────────────────────────────── */
.landing-body.desktop-layout .landing-features {
  margin-top: 24px;
}

.landing-body.desktop-layout .landing-feature {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 18px;
  gap: 10px;
}

.landing-body.desktop-layout .lf-icon {
  width: auto;
  font-size: 28px;
}

/* iOS steps */
.ios-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 15px;
  line-height: 1.5;
  color: #ccc;
}

.ios-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== PWA INSTALL BANNER ===== */
#install-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 999;
  background: #111;
  border-bottom: 1px solid #2a2a2a;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

#install-banner span {
  flex: 1;
  color: var(--text);
}

#btn-install {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#btn-install-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 10;
  overflow: hidden;
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  gap: 0;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 48px;
  gap: 8px;
}

.auth-logo-icon {
  width: 72px;
  height: 72px;
  background: var(--surface3);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.auth-tabs {
  display: flex;
  width: 100%;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.input-group input:focus {
  border-color: rgba(255,255,255,0.4);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 6px;
  width: 100%;
}

.btn-primary:active {
  opacity: 0.85;
  transform: scale(0.99);
}

.auth-error {
  color: #ff3b30;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ===== SETUP SCREEN ===== */
#setup-screen {
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  gap: 24px;
}

.setup-header {
  text-align: center;
}

.setup-header h2 {
  font-size: 26px;
  font-weight: 800;
}

.setup-header p {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 6px;
}

.setup-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-form .select-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s;
}

.setup-form .select-btn:active {
  opacity: 0.7;
}

.setup-form .select-btn .arrow {
  color: var(--text-dim);
  font-size: 12px;
}

/* ===== MAIN TRANSLATOR SCREEN ===== */
#main-screen {
  flex-direction: column;
  overflow: hidden;
}

.translator-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* HALF PANELS */
.half {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding: 12px 16px;
}

.half-top {
  border-bottom: 1px solid var(--border);
}

.half-bottom {
  border-top: none;
}

/* Face-to-face: rotate top half */
.face-to-face .half-top {
  transform: rotate(180deg);
}

/* ── Recording mode: hide controls, maximise text space ── */
.is-recording .panel-controls {
  display: none !important;
}

.is-recording .half {
  padding: 4px 8px;
}

/* Panel controls row */
.panel-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  height: 48px;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.lang-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.2s;
  flex: 1;
  max-width: 220px;
  overflow: hidden;
}

.lang-selector-btn:active {
  background: var(--surface3);
}

.lang-selector-btn .flag {
  font-size: 18px;
  flex-shrink: 0;
}

.lang-selector-btn .lang-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-selector-btn .chevron {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

.f2f-toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 7px 12px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.f2f-toggle-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ===== CHAT LOG (replaces old panel-text-area) ===== */
.panel-text-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 6px 14px 6px;
  /* Enable user scroll on chat log */
  user-select: text;
  -webkit-user-select: text;
}

/* Chat log container — grows from bottom */
.chat-log {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  min-height: 100%;
}

/* Placeholder when no messages yet */
.chat-placeholder {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
  user-select: none;
  -webkit-user-select: none;
}

/* What the speaker in THIS panel said — small orange */
.chat-own {
  align-self: flex-end;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #f97316;
  background: rgba(249, 115, 22, 0.08);
  border-radius: 12px 12px 4px 12px;
  padding: 6px 10px 6px 12px;
  max-width: 90%;
  word-break: break-word;
  line-height: 1.4;
}

/* Translation from the OTHER panel — large white */
.chat-translation {
  align-self: flex-start;
  text-align: left;
  font-size: clamp(22px, 7vw, 36px);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.25;
  word-break: break-word;
  width: 100%;
}

/* Streaming cursor blink while GPT is still streaming */
.chat-translation.streaming::after {
  content: '▍';
  display: inline-block;
  animation: blink-cursor 0.7s step-end infinite;
  font-size: 0.8em;
  vertical-align: middle;
  color: var(--text-dim);
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ===== DIVIDER + MIC BUTTON ===== */
.divider-zone {
  height: var(--mid-zone);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 20;
  flex-shrink: 0;
  background: var(--bg);
}

.divider-line {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: var(--border);
  transform: translateY(-50%);
}

.mic-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 21;
  position: relative;
  transition: background 0.25s, transform 0.15s;
  box-shadow: 0 0 0 0 transparent;
  flex-shrink: 0;
}

.mic-btn svg {
  width: 26px;
  height: 26px;
  fill: var(--bg);
  transition: fill 0.25s;
}

.mic-btn.recording {
  background: var(--mic-active);
  animation: mic-pulse 1.4s ease-in-out infinite;
}

.mic-btn.recording svg {
  fill: #ffffff;
}

@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 var(--mic-pulse); }
  50%  { box-shadow: 0 0 0 16px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

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

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.bottom-nav.hidden-nav {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  min-width: 80px;
  transition: opacity 0.15s;
}

.nav-item:active {
  opacity: 0.6;
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-item.active .nav-label {
  color: var(--text);
}

.nav-item.active .nav-icon {
  filter: brightness(1.5);
}

/* ===== ACCOUNT SCREEN ===== */
#account-screen {
  overflow-y: auto;
}

.account-header {
  padding: 20px 20px 0;
  font-size: 26px;
  font-weight: 800;
}

.account-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.account-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.account-card h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.token-count {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -2px;
}

.token-label {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 4px;
}

.account-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.account-info-row:last-child {
  border-bottom: none;
}

.account-info-label {
  font-size: 14px;
  color: var(--text-dim);
}

.account-info-value {
  font-size: 14px;
  font-weight: 600;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.btn-secondary:active {
  background: var(--surface2);
}

.btn-danger {
  color: #ff3b30;
  border-color: rgba(255,59,48,0.3);
}

/* PayPal branded button */
.btn-paypal {
  background: #0070ba;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.btn-paypal:active {
  background: #003087;
  transform: scale(0.99);
}

.account-nav-wrapper {
  flex-shrink: 0;
}

/* ===== MODAL / PICKER ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.modal-header {
  padding: 16px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: var(--surface2);
  border: none;
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-search-wrap {
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.modal-search {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.modal-search::placeholder {
  color: var(--text-muted);
}

.modal-tabs {
  display: flex;
  padding: 0 16px;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.modal-tab {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.modal-tab.active {
  background: var(--text);
  color: var(--bg);
}

.modal-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 24px;
  -webkit-overflow-scrolling: touch;
}

.modal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.modal-item:active {
  background: var(--surface2);
}

.modal-item.selected {
  background: var(--surface2);
}

.modal-item.selected::after {
  content: '✓';
  margin-left: auto;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
}

.modal-item-flag {
  font-size: 22px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.modal-item-name {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
}

/* ===== LISTENING INDICATOR ===== */
.listening-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 20px;
  opacity: 0;
  transition: opacity 0.3s;
}

.listening-bar.visible {
  opacity: 1;
}

.listening-bar span {
  width: 3px;
  background: var(--mic-active);
  border-radius: 2px;
  animation: sound-wave 0.8s ease-in-out infinite alternate;
}

.listening-bar span:nth-child(1) { height: 6px; animation-delay: 0s; }
.listening-bar span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.listening-bar span:nth-child(3) { height: 10px; animation-delay: 0.2s; }
.listening-bar span:nth-child(4) { height: 18px; animation-delay: 0.05s; }
.listening-bar span:nth-child(5) { height: 8px; animation-delay: 0.15s; }

@keyframes sound-wave {
  from { transform: scaleY(0.4); }
  to   { transform: scaleY(1); }
}

/* ===== MIC LEVEL INDICATOR ===== */
#mic-level-track {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  z-index: 22;
}

#mic-level {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f97316, #ef4444);
  border-radius: 2px;
  transition: width 0.08s ease-out;
  opacity: 0;
}

/* ===== UPDATE BANNER ===== */
#update-banner {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 24px;
  padding: 10px 10px 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 999;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.8);
  animation: banner-slide-up 0.3s ease;
}

#update-banner button {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 16px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

#update-banner button:active {
  opacity: 0.8;
}

@keyframes banner-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== LOADING ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Safe area for notch/home bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
}

/* Prevent zoom on input focus */
input, select, textarea {
  font-size: 16px !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 0;
  background: transparent;
}

/* ── Per-panel font scaling via CSS variables ────────────────────────────── */
#chat-log-a .chat-own         { font-size: var(--font-own-a, 13px) !important; color: var(--color-own-a, #f97316); }
#chat-log-a .chat-translation { font-size: var(--font-trans-a, 28px) !important; color: var(--color-trans-a, #ffffff); }
#chat-log-b .chat-own         { font-size: var(--font-own-b, 13px) !important; color: var(--color-own-b, #f97316); }
#chat-log-b .chat-translation { font-size: var(--font-trans-b, 28px) !important; color: var(--color-trans-b, #ffffff); }

/* ── Font & Color card ───────────────────────────────────────────────────── */
.fc-section { margin-bottom: 2px; }
.fc-label {
  font-size: 11px;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  margin-top: 2px;
}
.fc-row { margin-bottom: 10px; }
.fc-caption {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}
.fc-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}
.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  outline: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, transform 0.1s, outline-color 0.15s;
  flex-shrink: 0;
}
.swatch.active {
  border-color: #000;
  outline-color: #fff;
  transform: scale(1.15);
}
.swatch:active { transform: scale(0.9); }

/* ── Delete button on own-text bubbles ────────────────────────────────────── */
.chat-own {
  position: relative;
  padding-right: 28px; /* make room for the ✕ button */
}
.del-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #888;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 50%;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.del-btn:hover,
.del-btn:active {
  color: #ff5555;
}

/* ── Mic sensitivity slider ──────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 6px;
}
.slider-row input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: #ff6b00;
  cursor: pointer;
}
.slider-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}
.slider-hint {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-top: 4px;
}
