:root {
  /* talkytap. Brand Palette */
  --tt-coral: #FF6B57;
  --tt-coral-soft: #FFF2F0;
  --tt-coral-glow: rgba(255, 107, 87, 0.16);
  --tt-teal: #14B8A6;
  --tt-teal-soft: #ECFDFA;
  --tt-teal-glow: rgba(20, 184, 166, 0.16);
  --tt-amber: #FFA93A;
  --tt-amber-soft: #FFF7E6;

  /* Light Surfaces & Ink */
  --bg: #FFFFFF;
  --bg-cream: #FAF8F5;
  --surface: #FFFFFF;
  --card: #F6F7F9;
  --border: #E8E4DD;
  --text: #1E293B;
  --muted: #64748B;

  /* Semantic aliases for legacy hooks */
  --thai-bg: #FFFFFF;
  --thai-text: #1E293B;
  --thai-pill: #14B8A6;
  --thai-pill-text: #FFFFFF;
  --thai-circle: #ECFDFA;

  --tour-bg: #FFFFFF;
  --tour-text: #1E293B;
  --tour-pill: #FF6B57;
  --tour-pill-text: #FFFFFF;
  --tour-circle: #FFF2F0;

  --active-color: var(--tt-coral);
  --active-soft: var(--tt-coral-soft);
  --active-glow: var(--tt-coral-glow);

  --accent: #14B8A6;
  --danger: #EF4444;
  --danger-bg: #DC2626;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', 'Prompt', -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   ONBOARDING OVERLAY (Seamless SPA layer over live dialog)
   ========================================================= */
.spa-body {
  background: var(--bg);
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  transition: background-color 0.25s ease;
}

.onboarding-overlay.is-revealing {
  background: transparent !important;
  pointer-events: none;
}

.onboarding-overlay.is-hidden {
  display: none;
}

@media (min-width: 520px) {
  .onboarding-overlay {
    background: #EFECE6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
  }
}

.onboarding-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: var(--surface);
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 100dvh;
  will-change: transform, opacity;
  transform-origin: center center;
}

@media (min-width: 520px) {
  .onboarding-shell {
    min-height: auto;
    border-radius: 30px;
    padding: 20px 18px 22px;
    box-shadow:
      0 20px 50px rgba(30, 41, 59, 0.10),
      0 2px 8px rgba(30, 41, 59, 0.04);
  }
}

.icon-circle-btn.is-absorbing {
  animation: absorbPulse 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.brand-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-wordmark {
  font-size: 23px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brand-wordmark .w-talky { font-weight: 700; color: var(--text); }
.brand-wordmark .w-tap   { font-weight: 500; color: var(--tt-teal); }
.brand-wordmark .w-dot   { font-weight: 700; color: var(--tt-amber); }

.brand-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--tt-teal);
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0;
}

.icon-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #F1F5F9;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.16s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, width 0.22s ease, margin-right 0.22s ease;
}

.icon-circle-btn:hover { background: #E2E8F0; }
.icon-circle-btn:active { transform: scale(0.93); }
.icon-circle-btn.active {
  background: var(--tt-teal-soft);
  color: var(--tt-teal);
}

/* Settings icon hidden on onboarding, flies in on Start */
.settings-slot-btn {
  width: 0;
  margin-right: 0;
  opacity: 0;
  transform: scale(0.35);
  pointer-events: none;
  overflow: hidden;
}

.settings-slot-btn.is-visible {
  width: 38px;
  margin-right: 7px;
  opacity: 1;
  transform: scale(1);
}

.settings-slot-btn.is-absorbing {
  animation: absorbPulse 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes absorbPulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 107, 87, 0.45); }
  45%  { transform: scale(1.22); background: var(--tt-coral-soft); color: var(--tt-coral); box-shadow: 0 0 0 9px rgba(255, 107, 87, 0); }
  100% { transform: scale(1); background: #F1F5F9; color: var(--text); box-shadow: 0 0 0 0 rgba(255, 107, 87, 0); }
}

.setup-form-wrap {
  display: flex;
  flex-direction: column;
  gap: 15px;
  will-change: transform, opacity;
  transform-origin: center center;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding-left: 2px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0;
}

.help-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid #CBD5E1;
  background: #FFFFFF;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.help-btn:hover,
.help-btn.is-open {
  border-color: var(--tt-coral);
  color: var(--tt-coral);
  background: var(--tt-coral-soft);
}

.help-popover {
  display: none;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #FFFBF4;
  border: 1px solid #FDE4B8;
  font-size: 12px;
  line-height: 1.42;
  color: #475569;
}

.help-popover.is-open {
  display: block;
  animation: fadeSlide 0.18s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Mode Cards */
.modes-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  padding: 10px 12px 10px 10px;
  border-radius: 18px;
  border: 2px solid transparent;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.mode-card:hover { background: #F0F2F5; }
.mode-card:active { transform: scale(0.99); }

.mode-card.is-active {
  background: var(--active-soft);
  border-color: var(--active-color);
  box-shadow: 0 6px 18px var(--active-glow);
}

.mode-icon-box {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: var(--bg-cream);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(30, 41, 59, 0.06);
  box-shadow: 0 2px 5px rgba(30, 41, 59, 0.04);
}

.mode-card.is-active .mode-icon-box {
  border-color: rgba(255, 107, 87, 0.22);
}

.mode-icon-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

.mode-icon-box img.is-visible { opacity: 1; }

.mode-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mode-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: nowrap;
}

.mode-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
}

.mode-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: #475569;
}

.pill-device,
.pill-duration {
  background: #FFFFFF;
  color: #475569;
  border: 1px solid #E2E8F0;
}

.pill-airpods {
  background: #FFFFFF;
  color: var(--tt-teal);
  border: 1px solid rgba(20, 184, 166, 0.35);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  gap: 3px;
}

.pill-airpods-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.mode-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.32;
}

.mode-radio {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mode-card.is-active .mode-radio {
  border-color: var(--active-color);
  background: var(--active-color);
}

.mode-radio::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFFFFF;
  transform: scale(0);
  transition: transform 0.18s ease;
}

.mode-card.is-active .mode-radio::after { transform: scale(1); }

/* Collapsible Topic Selector */
.topic-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 8px 9px;
  border-radius: 16px;
  border: 1.5px solid #E5E7EB;
  background: var(--card);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.topic-trigger:hover { background: #F0F2F5; }

.topic-trigger.is-open {
  background: #FFFFFF;
  border-color: var(--active-color);
  box-shadow: 0 4px 14px var(--active-glow);
}

.topic-selected {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topic-icon-mini {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-cream);
  border: 1px solid rgba(30, 41, 59, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topic-selected-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.topic-trigger.is-open .topic-chevron {
  transform: rotate(180deg);
  color: var(--active-color);
}

.topic-drawer {
  display: none;
  margin-top: 6px;
  padding: 6px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 1.5px solid #E5E7EB;
  box-shadow: 0 10px 26px rgba(30, 41, 59, 0.08);
}

.topic-drawer.is-open {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeSlide 0.18s ease;
}

.topic-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 7px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topic-chip:hover { background: var(--card); }

.topic-chip.is-active {
  background: var(--active-soft);
  border-color: var(--active-color);
}

.topic-chip-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg-cream);
  border: 1px solid rgba(30, 41, 59, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topic-chip-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--active-color);
  opacity: 0;
  flex-shrink: 0;
}

.topic-chip.is-active .topic-chip-dot { opacity: 1; }

/* Gender + Language Pair in ONE Row */
.dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

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

.label-with-hint {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 2px;
}

.label-hint {
  font-size: 10px;
  font-weight: 400;
  color: #94A3B8;
  line-height: 1.2;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid #EAECEF;
  gap: 3px;
}

.seg-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 4px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.seg-btn.is-active {
  background: var(--active-color);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 3px 10px var(--active-glow);
}

.seg-thai {
  font-family: 'Prompt', sans-serif;
  font-size: 11px;
  opacity: 0.9;
}

/* =========================================================
   SHARED LAYOUT, HEADERS & BUTTONS
   ========================================================= */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.room-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
}

/* Hand mode ("На ходу"): rotate 180deg so user holds phone mic & loud speaker up */
.room-layout.is-hand-flipped {
  transform: rotate(180deg);
  transform-origin: center center;
}

.room-layout.is-hand-flipped .topbar {
  padding-top: calc(10px + env(safe-area-inset-bottom));
}

.room-layout.is-hand-flipped .chat-stage.is-hand-stage {
  padding-bottom: env(safe-area-inset-top);
}

/* Flip-phone onboarding overlay for "На ходу" */
.hand-flip-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(250, 248, 245, 0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.hand-flip-overlay.hidden {
  display: none;
}

.hand-flip-overlay.is-dismissing {
  opacity: 0;
  pointer-events: none;
}

.hand-flip-overlay.is-dismissing .hand-flip-card {
  transform: scale(0.92);
}

.hand-flip-card {
  width: 100%;
  max-width: 312px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px 22px 20px;
  text-align: center;
  box-shadow: 0 18px 42px rgba(30, 41, 59, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform 0.25s ease;
}

.hand-flip-icon-wrap {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}

.hand-flip-arrows {
  position: absolute;
  inset: 0;
  animation: handArrowsSpin 4.8s linear infinite;
}

.hand-flip-phone {
  position: relative;
  z-index: 1;
  animation: handPhoneFlip 2.4s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes handPhoneFlip {
  0%, 18% { transform: rotate(0deg); }
  46%, 68% { transform: rotate(180deg); }
  96%, 100% { transform: rotate(360deg); }
}

@keyframes handArrowsSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hand-flip-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.hand-flip-desc {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 6px;
}

.hand-flip-dismiss {
  min-width: 132px;
  border-radius: 999px;
}

/* =========================================================
   Closed Beta: Balance pill, Code Gate, Feedback Modal
   ========================================================= */
.balance-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--tt-teal-soft);
  color: #0F766E;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.balance-pill.hidden {
  display: none;
}

.balance-pill.is-low {
  background: rgba(255, 107, 87, 0.14);
  color: #C2410C;
}

.beta-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.beta-gate-overlay.hidden {
  display: none;
}

.beta-gate-card {
  width: 100%;
  max-width: 340px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px 22px 22px;
  text-align: center;
  box-shadow: 0 20px 48px rgba(30, 41, 59, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.beta-gate-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.beta-gate-desc {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
  margin-bottom: 16px;
}

.beta-gate-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.beta-code-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #FAF8F5;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.beta-code-input:focus {
  border-color: var(--tt-coral);
  background: #FFFFFF;
}

.beta-gate-error {
  font-size: 12.5px;
  color: #DC2626;
  font-weight: 500;
}

.beta-gate-error.hidden {
  display: none;
}

.beta-exhausted-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.feedback-card {
  max-width: 360px;
}

.feedback-rating-row {
  display: flex;
  gap: 6px;
  width: 100%;
}

.feedback-chip {
  flex: 1;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #FAF8F5;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.feedback-chip.is-active {
  background: #FFF4F2;
  border-color: var(--tt-coral);
  color: #C2410C;
}

.feedback-status {
  width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.feedback-status.hidden {
  display: none;
}

.feedback-status.is-ok {
  color: #0F766E;
}

.feedback-status.is-err {
  color: #DC2626;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 8px;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.title-group {
  min-width: 0;
}

.title-group h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.dot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tt-teal);
  display: inline-block;
  flex-shrink: 0;
}

.dot.warm { background: var(--tt-coral); }
.dot.mint { background: var(--tt-teal); }
.dot.offline { background: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  font-size: 12px;
  font-weight: 600;
  padding: 0 11px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1.5px solid #E2E8F0;
  color: var(--text);
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94A3B8;
  flex-shrink: 0;
}

.badge.online {
  border-color: rgba(20, 184, 166, 0.42);
  color: var(--tt-teal);
  background: #FFFFFF;
}

.badge.online::before {
  background: var(--tt-teal);
}

.badge.warn {
  border-color: rgba(255, 169, 58, 0.55);
  color: var(--text);
  background: #FFFFFF;
}

.badge.warn::before {
  background: var(--tt-amber);
  box-shadow: 0 0 0 3px rgba(255, 169, 58, 0.22);
}

.badge.offline {
  border-color: rgba(255, 107, 87, 0.45);
  color: var(--tt-coral);
  background: #FFFFFF;
}

.badge.offline::before {
  background: var(--tt-coral);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 15px 22px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  color: #FFFFFF;
  background: var(--tt-coral);
  box-shadow: 0 8px 20px rgba(255, 107, 87, 0.26);
  width: 100%;
  transition: transform 0.1s, opacity 0.15s, background-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.btn:active { transform: scale(0.98); }

.btn.secondary {
  background: var(--card);
  border: 1px solid #E2E8F0;
  color: var(--text);
  font-weight: 500;
  box-shadow: none;
}

.btn.secondary:hover { background: #EEF2F6; }

.btn.secondary.active-toggle {
  border-color: var(--tt-teal);
  background: var(--tt-teal-soft);
  color: #0F766E;
  font-weight: 600;
}

.btn.accent, .btn.mint {
  background: var(--tt-teal);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.24);
}

.btn.recording {
  background: var(--danger-bg) !important;
  color: #FFFFFF !important;
  animation: pulse 1.2s infinite;
}

.btn.small {
  width: auto;
  padding: 7px 13px;
  font-size: 12.5px;
  box-shadow: none;
}

.btn.danger {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #DC2626;
  box-shadow: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

@keyframes tealPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(20, 184, 166, 0); }
}

/* =========================================================
   TABLE SPLIT-SCREEN MODE (Always sideways ±90° across table)
   White canvas, brand-colored buttons, dual-color seam & fade
   ========================================================= */
.table-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: #FFFFFF;
  overflow: hidden;
  position: relative;
}

.table-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #FFFFFF;
  border-bottom: 1.5px solid #CBD5E1;
  gap: 8px;
  flex-shrink: 0;
  z-index: 20;
}

.table-divider-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-title-wrap {
  min-width: 0;
}

.table-divider-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
}

.table-divider-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-shrink: 0;
}

/* Compact Auto-VAD pill centered in Table header (coral equalizer icon in idle, teal when active) */
.table-vad-pill {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid #E2E8F0;
  background: #F1F5F9;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.table-vad-icon {
  color: var(--tt-coral);
  transition: color 0.18s ease;
}

.table-vad-pill:active { transform: scale(0.95); }

.table-vad-pill.is-active {
  background: var(--tt-teal-soft);
  border-color: var(--tt-teal);
  color: var(--tt-teal);
  animation: tealPulse 1.5s infinite;
}

.table-vad-pill.is-active .table-vad-icon {
  color: var(--tt-teal);
}

/* Gently dim manual mic FABs while Table Auto-VAD is active */
.table-layout.is-table-vad .table-mic-fab {
  opacity: 0.45;
}

/* Container-queried 50/50 side-by-side split (exact proven geometry!) */
.table-sides-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: row;
  position: relative;
  overflow: hidden;
  container-type: size;
  background: #FFFFFF;
}

.table-half {
  width: 50%;
  flex: 0 0 50%;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: visible;
  background: #FFFFFF;
  color: var(--text);
}

/* Single crisp 1.5px neutral gray center divider (z-index 25: above white fade, below lang-tabs) */
.table-sides-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 0.75px);
  width: 1.5px;
  background: #CBD5E1;
  z-index: 25;
  pointer-events: none;
}

.table-half-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100cqh;
  height: 50cqw;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Clean white fade-out gradient where scrolling history disappears */
.table-half-inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  pointer-events: none;
  z-index: 8;
  background: linear-gradient(
    to bottom,
    #FFFFFF 0%,
    rgba(255, 255, 255, 0.85) 38%,
    rgba(255, 255, 255, 0) 100%
  );
}

.table-half.thai .table-half-inner {
  transform: translate(-50%, -50%) rotate(90deg);
}

.table-half.tourist .table-half-inner {
  transform: translate(-50%, -50%) rotate(-90deg);
}

/* White language tabs with matching 1.5px gray border seamlessly connecting to the single center divider */
.lang-tab {
  position: absolute;
  height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 0 10px;
  border-radius: 0 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  z-index: 30;
  pointer-events: none;
  background: #FFFFFF;
  border-top: 1.5px solid #CBD5E1;
  border-right: 1.5px solid #CBD5E1;
  border-bottom: none;
  border-left: none;
  transform-origin: top left;
}

.lang-tab.thai-tab {
  top: 0;
  left: calc(50% + 25.25px);
  transform: rotate(90deg);
  color: var(--tt-teal);
}

.lang-tab.tourist-tab {
  top: 100%;
  left: calc(50% - 25.25px);
  transform: rotate(-90deg);
  color: var(--tt-coral);
}

/* Full-bleed scrollable messenger-style history inside each half */
.table-text-area {
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px 12px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.table-text-area::-webkit-scrollbar { width: 4px; }
.table-text-area::-webkit-scrollbar-track { background: transparent; }
.table-text-area::-webkit-scrollbar-thumb { border-radius: 999px; }

.table-half.thai .table-text-area {
  scrollbar-color: rgba(20, 184, 166, 0.28) transparent;
}
.table-half.thai .table-text-area::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.28);
}

.table-half.tourist .table-text-area {
  scrollbar-color: rgba(255, 107, 87, 0.28) transparent;
}
.table-half.tourist .table-text-area::-webkit-scrollbar-thumb {
  background: rgba(255, 107, 87, 0.28);
}

.table-sub {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  min-height: 0;
}

.table-sub:empty { display: none; }

/* Latest (current) phrase: large, crisp, frameless */
.table-latest-phrase {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.26;
  letter-spacing: -0.015em;
  color: var(--text);
  word-break: break-word;
  padding: 2px 2px 6px;
}

.table-half.thai .table-latest-phrase {
  font-family: 'Prompt', 'Rubik', sans-serif;
}

/* History row: soft tinted card + small timestamp */
.table-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 94%;
}

.table-msg-row.mine { align-self: flex-end; }
.table-msg-row.theirs { align-self: flex-start; }

.table-msg-time {
  font-size: 10px;
  color: #94A3B8;
  flex-shrink: 0;
  padding-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

.table-msg {
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.34;
  word-break: break-word;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.table-msg-row.mine .table-msg { border-bottom-right-radius: 5px; }
.table-msg-row.theirs .table-msg { border-bottom-left-radius: 5px; }

.table-half.thai .table-msg-row.mine .table-msg {
  background: var(--tt-teal-soft);
  border: 1px solid rgba(20, 184, 166, 0.22);
}

.table-half.thai .table-msg-row.theirs .table-msg {
  background: #F4F6F9;
  border: 1px solid #E5E7EB;
}

.table-half.tourist .table-msg-row.mine .table-msg {
  background: var(--tt-coral-soft);
  border: 1px solid rgba(255, 107, 87, 0.22);
}

.table-half.tourist .table-msg-row.theirs .table-msg {
  background: #F4F6F9;
  border: 1px solid #E5E7EB;
}

/* Curved-arrow onboarding hints (exact proven positioning, above fade gradient) */
.table-hints {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity 0.25s ease;
}

.table-hints.hidden {
  opacity: 0;
  display: none;
}

.hint-callout {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Caveat', 'Mali', cursive;
  font-size: 17px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.12;
  color: var(--muted);
  max-width: 68%;
}

.table-half.thai .hint-callout,
.guest-theme .hint-callout {
  font-family: 'Mali', cursive;
  font-size: 13px;
  font-style: italic;
  line-height: 1.25;
}

.hint-callout.to-auto-thai {
  top: 26px;
  left: 8px;
  text-align: left;
  font-size: 12.5px;
}

.hint-callout.to-auto-tourist {
  top: 32px;
  right: 8px;
  text-align: right;
  font-size: 16px;
}

.hint-callout.to-replay {
  bottom: 22px;
  left: 62px;
  text-align: left;
}

.hint-callout.to-mic {
  bottom: 34px;
  right: 100px;
  text-align: right;
}

.hint-arrow {
  flex-shrink: 0;
  opacity: 0.75;
}

/* Floating replay button (bottom-left of each half, opposite mic button, 42x42) */
.table-replay-fab {
  position: absolute;
  bottom: 14px;
  left: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.table-replay-fab:active { transform: scale(0.92); }

.table-half.thai .table-replay-fab {
  background: rgba(236, 253, 250, 0.55);
  color: #0F766E;
  border: 1.5px solid rgba(20, 184, 166, 0.40);
}

.table-half.tourist .table-replay-fab {
  background: rgba(255, 242, 240, 0.55);
  color: #D94635;
  border: 1.5px solid rgba(255, 107, 87, 0.40);
}

/* Circular Hold-to-Talk mic button (translucent so text underneath stays readable) */
.table-mic-fab {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  color: #FFFFFF;
  transition: transform 0.1s, background-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.table-half.thai .table-mic-fab {
  background: rgba(20, 184, 166, 0.55);
  border: 1.5px solid rgba(20, 184, 166, 0.45);
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.22);
}

.table-half.tourist .table-mic-fab {
  background: rgba(255, 107, 87, 0.55);
  border: 1.5px solid rgba(255, 107, 87, 0.45);
  box-shadow: 0 6px 18px rgba(255, 107, 87, 0.22);
}

.table-mic-fab:active { transform: scale(0.94); }

.table-mic-fab.recording {
  background: var(--danger-bg) !important;
  color: #FFFFFF !important;
  animation: pulse 1.2s infinite;
}

/* =========================================================
   HAND (MARKET) & DUAL (QR) DIALOG VIEWS
   ========================================================= */
/* Sub-header row in Hand mode: Talk Mode dropdown + "?" help */
.hand-subbar {
  position: relative;
  padding: 8px 14px 10px;
  background: #FFFFFF;
  border-bottom: 1.5px solid #CBD5E1;
  flex-shrink: 0;
  z-index: 30;
}

.hand-mode-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hand-mode-trigger {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 7px;
  border-radius: 999px;
  border: 1.5px solid #E2E8F0;
  background: var(--card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.16s ease;
}

.hand-mode-inline-desc {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inline-mic-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  color: #FFFFFF;
  vertical-align: -2px;
  margin: 0 2px;
}

.inline-mic-badge.is-coral {
  background: var(--tt-coral);
}

.inline-mic-badge.is-teal {
  background: var(--tt-teal);
}

.hand-mode-trigger:hover { background: #EEF2F6; }

.hand-mode-trigger.is-open {
  background: #FFFFFF;
  border-color: var(--tt-coral);
  box-shadow: 0 4px 14px var(--tt-coral-glow);
}

.hand-mode-trigger-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hand-mode-chevron {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.hand-mode-trigger.is-open .hand-mode-chevron {
  transform: rotate(180deg);
  color: var(--tt-coral);
}

.hand-mode-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  padding: 6px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 1.5px solid #E5E7EB;
  box-shadow: 0 12px 28px rgba(30, 41, 59, 0.12);
  z-index: 40;
}

.hand-mode-menu.is-open {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeSlide 0.16s ease;
}

.hand-help-popover {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Chat stage container for floating Replay, Hints & Center FABs */
.chat-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  overflow: hidden;
}

.chat-stage.is-hand-stage .chat-feed {
  background: #FFFFFF;
  padding: 16px 14px 230px;
}

.chat-stage.is-hand-stage .partial-bar {
  background: #FFFFFF;
}

/* Top-left translucent Replay button in Hand mode */
.hand-replay-fab {
  position: absolute;
  top: 14px;
  left: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  background: rgba(255, 242, 240, 0.58);
  color: #D94635;
  border: 1.5px solid rgba(255, 107, 87, 0.38);
  transition: transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.hand-replay-fab:active { transform: scale(0.92); }

/* Curved-arrow onboarding hints in Hand mode */
.hand-hints {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.hand-hints.hidden {
  display: none !important;
}

.hint-callout.hand-to-replay {
  top: 20px;
  left: 62px;
  text-align: left;
}

.hint-callout.hand-to-mic {
  top: calc(66% - 134px);
  left: 50%;
  transform: translateX(-85%);
  align-items: flex-end;
  text-align: right;
}

/* Floating lower-third FAB dock: center of button sits at center of lower third (~66% down) */
.hand-fab-dock {
  position: absolute;
  left: 0;
  right: 0;
  top: 66%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 16;
}

.hand-auto-reply-wrap,
.hand-vad-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.hand-listen-caption {
  position: absolute;
  bottom: calc(100% + 12px);
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tt-teal);
  background: rgba(236, 253, 250, 0.96);
  border: 1px solid rgba(20, 184, 166, 0.45);
  padding: 6px 14px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hand-listen-caption.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hand-mic-fab {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #FFFFFF;
  pointer-events: auto;
  transition: transform 0.12s ease, background-color 0.22s ease, box-shadow 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.hand-mic-fab.is-medium {
  width: 140px;
  height: 140px;
}

.hand-mic-fab.is-coral {
  background: rgba(255, 107, 87, 0.58);
  border: 1.5px solid rgba(255, 107, 87, 0.48);
  box-shadow: 0 8px 24px rgba(255, 107, 87, 0.24);
}

.hand-mic-fab.is-teal {
  background: rgba(20, 184, 166, 0.62);
  border: 1.5px solid rgba(20, 184, 166, 0.50);
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.26);
}

.hand-mic-fab:active { transform: scale(0.94); }

.hand-mic-fab.recording {
  background: var(--danger-bg) !important;
  border-color: var(--danger-bg) !important;
  animation: pulse 1.2s infinite;
}

.hand-mic-fab.is-listening {
  animation: tealPulse 1.35s infinite;
}

.hand-mic-fab .fab-ear-view {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.hand-mic-fab.is-listening .fab-mic-view { display: none; }
.hand-mic-fab.is-listening .fab-ear-view { display: flex; }

.fab-vad-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.fab-stop-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin-top: 2px;
}

/* Manual 2-button mode */
.hand-manual-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  pointer-events: auto;
}

.hand-dual-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hand-fab-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Headphone warning banner (Hand & Table modes) */
.headphone-banner {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 530px;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--tt-amber-soft);
  border: 1.5px solid var(--tt-amber);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 10px 28px rgba(30, 41, 59, 0.14);
}

.headphone-banner.hidden { display: none; }

.headphone-banner-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 500;
}

.headphone-banner-icon {
  flex-shrink: 0;
}

.headphone-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.headphone-qr-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 11px;
  background: var(--tt-teal);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.headphone-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(30, 41, 59, 0.08);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* QR Invite Card (full-focus clean invite in Dual mode) */
.qr-panel {
  padding: 14px 16px 18px;
  background: var(--bg-cream);
  border-bottom: 1.5px solid #CBD5E1;
  text-align: center;
  color: var(--text);
  flex-shrink: 0;
  z-index: 22;
}

.qr-panel.hidden { display: none; }

.qr-panel-card {
  max-width: 340px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-panel-title {
  font-family: 'Prompt', 'Rubik', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.qr-panel-sub {
  font-family: 'Prompt', 'Rubik', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--tt-teal);
  margin-top: 4px;
}

.qr-panel-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  max-width: 290px;
}

.qr-box {
  position: relative;
  background: #FFFFFF;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  display: inline-block;
  margin: 14px 0 12px;
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.07);
}

/* 4 Contact Amber scan brackets around QR code */
.qr-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--tt-amber);
  border-style: solid;
  pointer-events: none;
}
.qr-corner.tl { top: 6px; left: 6px; border-width: 3.5px 0 0 3.5px; border-top-left-radius: 10px; }
.qr-corner.tr { top: 6px; right: 6px; border-width: 3.5px 3.5px 0 0; border-top-right-radius: 10px; }
.qr-corner.bl { bottom: 6px; left: 6px; border-width: 0 0 3.5px 3.5px; border-bottom-left-radius: 10px; }
.qr-corner.br { bottom: 6px; right: 6px; border-width: 0 3.5px 3.5px 0; border-bottom-right-radius: 10px; }

.qr-panel-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.qr-share-btn {
  background: var(--tt-teal);
  color: #FFFFFF;
}

/* Chat Feed & Bubbles */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-cream);
}

.bubble {
  max-width: 90%;
  padding: 13px 15px;
  border-radius: 20px;
  line-height: 1.38;
  color: var(--text);
}

.bubble.mine {
  align-self: flex-end;
  background: var(--tt-coral-soft);
  border: 1px solid rgba(255, 107, 87, 0.24);
  border-bottom-right-radius: 6px;
}

.bubble.theirs {
  align-self: flex-start;
  background: #FFFFFF;
  border: 1px solid rgba(20, 184, 166, 0.28);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.04);
}

.bubble .main-text {
  font-family: 'Prompt', 'Rubik', sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.bubble .sub-text {
  font-size: 13px;
  color: var(--muted);
  margin-top: 5px;
}

.bubble .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bubble .meta-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.bubble-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFFFFF;
  border: 1px solid rgba(20, 184, 166, 0.45);
  color: var(--tt-teal);
  border-radius: 999px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.bubble-replay-btn:hover {
  background: var(--tt-teal-soft);
}

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

.partial-bar {
  padding: 6px 14px;
  font-size: 13.5px;
  color: #0F766E;
  min-height: 24px;
  font-style: italic;
  background: var(--bg-cream);
}

.level-meter {
  height: 4px;
  background: #E2E8F0;
  margin: 0 14px;
  border-radius: 999px;
  overflow: hidden;
}

.level-meter-fill {
  height: 100%;
  width: 0%;
  background: #CBD5E1;
  transition: width 0.06s linear, background-color 0.1s;
}

.level-meter-fill.speaking {
  background: var(--tt-amber);
}

.controls {
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.toolbar-row {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.text-fallback {
  display: flex;
  gap: 8px;
}

.text-fallback input {
  flex: 1;
  background: var(--card);
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  padding: 10px 15px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
}

.text-fallback input:focus {
  border-color: var(--tt-coral);
  background: #FFFFFF;
}

/* Guest (Thai) screen — Light TalkyTap theme with Teal accent */
.guest-theme {
  background: #FFFFFF;
}

.guest-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  text-align: center;
  gap: 14px;
  background: var(--bg-cream);
  color: var(--text);
}

.guest-welcome h2 {
  margin: 4px 0 0;
  font-family: 'Prompt', 'Rubik', sans-serif;
  font-size: 24px;
  font-weight: 600;
}

.guest-welcome p {
  margin: 0;
  color: var(--muted);
  font-family: 'Prompt', 'Rubik', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.error-toast {
  margin: 8px 14px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  font-size: 13px;
  display: none;
  z-index: 60;
}

.error-toast.show { display: block; }

/* =========================================================
   HISTORY PAGE (Consistent Light TalkyTap Theme)
   ========================================================= */
.search-bar-wrap {
  padding: 12px 14px 8px;
  background: #FFFFFF;
}

.search-input {
  width: 100%;
  background: var(--card);
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  padding: 11px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
}

.search-input:focus {
  border-color: var(--tt-teal);
  background: #FFFFFF;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg-cream);
}

.date-group-header {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 8px;
}

.history-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.history-card:active {
  border-color: #CBD5E1;
}

.history-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 10px 11px 14px;
}

/* TalkyTap-styled QR pill */
.history-qr-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background: #FFF9F0;
  border: 1px solid rgba(255, 169, 58, 0.42);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  flex-shrink: 0;
  margin-left: auto;
}

.history-qr-pill.is-inline {
  margin-left: 0;
  padding: 2px 6px 2px 5px;
  font-size: 10.5px;
  vertical-align: middle;
}

.history-qr-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 2px 16px 8px;
  background: var(--bg-cream);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

/* Comment & photo thumbnails underneath the dialog row */
.history-card-extras {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 14px 11px;
  background: #FAF8F5;
  border-top: 1px solid #F1F5F9;
  cursor: pointer;
}

.history-card-comment {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  line-height: 1.4;
}

.history-comment-icon {
  color: var(--tt-teal);
  flex-shrink: 0;
  margin-top: 2px;
}

.history-comment-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.history-card-photos {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.history-card-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(30, 41, 59, 0.07);
  cursor: zoom-in;
  transition: transform 0.14s ease;
}

.history-card-thumb:active {
  transform: scale(0.95);
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 11px 10px 11px 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 6px rgba(30, 41, 59, 0.03);
}

.history-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.history-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.history-time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.history-preview {
  font-size: 14.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-del-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.history-del-btn:active {
  background: #FEF2F2;
  color: #DC2626;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.hidden { display: none; }

.modal-sheet {
  width: 100%;
  max-width: 560px;
  height: 86dvh;
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.14);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

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

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #FFFFFF;
}

.modal-footer-secondary {
  display: flex;
  gap: 10px;
}

/* History row comment/photo meta tags */
.history-meta-tags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.history-meta-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--tt-teal);
  background: var(--tt-teal-soft);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.history-meta-tag.is-qr {
  color: #B45309;
  background: rgba(255, 169, 58, 0.16);
  border: 1px solid rgba(255, 169, 58, 0.4);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Dialog Notes & Photos box inside History Modal */
.dialog-notes-box {
  padding: 12px 16px;
  background: var(--bg-cream);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.notes-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notes-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.notes-save-status {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--tt-teal);
}

.dialog-comment-input {
  width: 100%;
  resize: none;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 9px 12px;
  background: #FFFFFF;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.16s ease;
}

.dialog-comment-input:focus {
  border-color: var(--tt-teal);
}

.dialog-photos-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-top: 2px;
}

.photo-thumb-wrap {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  background: #FFFFFF;
}

.photo-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.photo-thumb-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-add-tile {
  width: 62px;
  height: 62px;
  border-radius: 12px;
  border: 1.5px dashed rgba(20, 184, 166, 0.55);
  background: #FFFFFF;
  color: var(--tt-teal);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.photo-add-tile:hover {
  background: var(--tt-teal-soft);
}

/* Fullscreen Photo Lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.photo-lightbox.hidden { display: none; }

.photo-lightbox img {
  max-width: 100%;
  max-height: 90dvh;
  border-radius: 14px;
  object-fit: contain;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.lightbox-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
