/* ── Expo Design System – Dark Surface adaptation ── */
:root {
  /* Surface */
  --surface-dark:          #171717;
  --surface-dark-elevated: #1a1a1a;
  --surface-strong:        #242424;

  /* Text */
  --on-dark:               #ffffff;
  --on-dark-soft:          #b0b4ba;
  --muted:                 #999999;

  /* Hairlines */
  --hairline:              rgba(255,255,255,0.07);
  --hairline-strong:       rgba(255,255,255,0.12);

  /* Brand accents (functional — not Expo CTAs) */
  --ru-accent:             #2AABEE;
  --fi-accent:             #3d9e54;
  --danger:                #eb8e90;

  /* Radius tokens */
  --rounded-sm:  6px;
  --rounded-md:  8px;
  --rounded-lg:  12px;
  --rounded-xl:  16px;

  /* Spacing */
  --space-xs:    8px;
  --space-sm:    12px;
  --space-base:  16px;
  --space-md:    20px;
  --space-lg:    24px;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--surface-dark);
  color: var(--on-dark);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-base);
  background: var(--surface-dark-elevated);
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
  height: 52px;
  position: relative;
  z-index: 10;
}

#header-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--on-dark);
}

#header-lang {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.1px;
}

/* ── Settings button ── */
#settings-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--rounded-md);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 11;
  pointer-events: auto;
  touch-action: manipulation;
  transition: background 0.1s;
}
#settings-btn:active { background: var(--surface-strong); }

/* ── Feed ── */
#feed {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-base) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}
#feed::-webkit-scrollbar { display: none; }

/* ── Turns & Bubbles ── */
.turn {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
}
.turn.me   { align-items: flex-end; }
.turn.them { align-items: flex-start; }

.bubble {
  max-width: 80%;
  padding: 10px var(--space-base);
  border-radius: var(--rounded-lg);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.turn.me .bubble {
  background: var(--ru-accent);
  color: #fff;
  border-bottom-right-radius: var(--rounded-sm);
}
.turn.them .bubble {
  background: var(--fi-accent);
  color: #fff;
  border-bottom-left-radius: var(--rounded-sm);
}

.bubble.processing {
  opacity: 0.55;
  font-style: italic;
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

/* Translation + original inside bubble */
.bubble-translation {
  font-size: 16px;
  line-height: 1.5;
}
.bubble-original {
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid rgba(255,255,255,0.22);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
  opacity: 0.72;
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  margin: var(--space-xs) 0;
}
.divider-line {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

/* ── Empty state ── */
#empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  text-align: center;
  padding: var(--space-lg);
}
#empty .empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

/* ── Controls (PTT buttons) ── */
#controls {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm) 20px;
  background: var(--surface-dark-elevated);
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
}

.ptt-btn {
  flex: 1;
  height: 112px;
  border: none;
  border-radius: var(--rounded-xl);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: transform 0.1s, filter 0.15s;
  position: relative;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.ptt-btn .btn-icon  { font-size: 26px; }
.ptt-btn .btn-lang  { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; color: #fff; }
.ptt-btn .btn-label { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.7); }

#btn-ru { background: var(--ru-accent); }
#btn-fi { background: var(--fi-accent); }

.ptt-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.ptt-btn.recording {
  background: var(--danger) !important;
  animation: pulse 0.75s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(235,142,144,0.25);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.025); }
}
.ptt-btn:not(:disabled):active { transform: scale(0.96); filter: brightness(0.9); }

/* ── Settings overlay ── */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
}

#settings-sheet {
  background: var(--surface-dark-elevated);
  width: 100%;
  border-radius: var(--rounded-xl) var(--rounded-xl) 0 0;
  padding: var(--space-md) var(--space-base) 36px;
  border-top: 1px solid var(--hairline-strong);
}

#settings-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.88px;
  margin-bottom: var(--space-sm);
}

/* ── Settings rows (main screen) ── */
.settings-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.88px;
  margin-bottom: var(--space-sm);
}

.settings-row {
  display: flex;
  align-items: center;
  padding: 13px var(--space-base);
  border-radius: var(--rounded-md);
  margin-bottom: 4px;
  background: var(--surface-strong);
  cursor: pointer;
  touch-action: manipulation;
  gap: 8px;
}
.settings-row:active { filter: brightness(0.85); }
.settings-row-label  { font-size: 15px; font-weight: 500; color: var(--on-dark); flex: 1; }
.settings-row-value  { font-size: 14px; color: var(--muted); }
.settings-row-chevron{ font-size: 18px; color: var(--muted); margin-left: 4px; }

/* Toggle (iOS-style) */
.settings-row-toggle { cursor: default; }
.toggle {
  width: 44px; height: 26px;
  background: var(--hairline-strong);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle.on { background: var(--ru-accent); }
.toggle-thumb {
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px; left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle.on .toggle-thumb { transform: translateX(18px); }

/* Back button */
.settings-back-btn {
  background: none;
  border: none;
  color: var(--ru-accent);
  font-size: 15px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  padding: 0;
  margin-bottom: var(--space-sm);
  cursor: pointer;
  touch-action: manipulation;
}

/* Lang & voice options */
.lang-option, .voice-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px var(--space-base);
  border-radius: var(--rounded-md);
  margin-bottom: 4px;
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--on-dark);
  border: 1px solid transparent;
  touch-action: manipulation;
}
.lang-option.active, .voice-option.active { border-color: var(--ru-accent); }
.lang-option .check, .voice-option .check { color: var(--ru-accent); font-size: 16px; opacity: 0; }
.lang-option.active .check, .voice-option.active .check { opacity: 1; }
.lang-option:active, .voice-option:active { filter: brightness(0.85); }

/* Play button on bubble */
.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.play-btn:active { background: rgba(255,255,255,0.3); }
.play-btn.playing { background: rgba(255,255,255,0.28); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-dark-elevated);
  border: 1px solid var(--hairline-strong);
  color: var(--on-dark-soft);
  padding: 8px 16px;
  border-radius: var(--rounded-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
