:root {
  --accent: #2f6f5e; /* one distinctive accent color, not copied from another product */
  --accent-contrast: #ffffff;
  --accent-soft: #e4efec;
  --surface: #ffffff;
  --surface-muted: #f6f7f6;
  --bubble-in: #f0f2f0;
  --bubble-out: var(--accent);
  --text: #16201d;
  --text-muted: #6d7975;
  --border: rgba(20, 30, 27, 0.08);
  --radius: 18px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 22, 0.04), 0 2px 10px rgba(16, 24, 22, 0.05);
  --shadow-md: 0 4px 16px rgba(16, 24, 22, 0.08), 0 1px 3px rgba(16, 24, 22, 0.05);

  /* Reskin Bootstrap's own component palette from these same tokens instead
     of overriding individual .btn/.card/.form-control rules -- Bootstrap
     5.3 derives its components from these CSS variables, so this is the
     highest-leverage lever for a consistent look with no build step. */
  --bs-body-bg: var(--surface-muted);
  --bs-body-color: var(--text);
  --bs-emphasis-color: var(--text);
  --bs-secondary-color: var(--text-muted);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: var(--border);
  --bs-link-color: var(--accent);
  --bs-link-hover-color: color-mix(in srgb, var(--accent) 85%, black);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius);
  --bs-border-radius-sm: 8px;
  --bs-box-shadow-sm: var(--shadow-sm);
  --bs-box-shadow: var(--shadow-md);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #14181a;
    --surface-muted: #1c2225;
    --bubble-in: #232a2d;
    --text: #f2f4f3;
    --text-muted: #98a3a0;
    --border: rgba(255, 255, 255, 0.08);
    --accent-soft: #1e2d29;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 10px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);

    --bs-body-bg: var(--surface-muted);
    --bs-body-color: var(--text);
    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-muted);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
  }
  body { background: var(--surface); color: var(--text); }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--surface-muted);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Bold, clear type scale (2026+ redesign backlog: "bold titles and clear
   fonts") -- scoped to the app UI, not third-party widgets. */
.app-shell h1, .app-shell h2, .app-shell h3,
.auth-card h1, .auth-card h2,
.modal h1, .modal h2 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: color-mix(in srgb, var(--accent) 85%, black);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--accent) 85%, black);
}

.nav-pills .nav-link {
  font-weight: 600;
  color: var(--text-muted);
}

.nav-pills .nav-link.active {
  background-color: var(--accent);
  color: var(--accent-contrast);
}

/* Auth */
.auth-screen { min-height: 100vh; padding: 1rem; background: var(--surface-muted); }
.auth-card { width: 100%; max-width: 420px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 0; }
.auth-card .card-body { padding: 2rem 1.75rem; }
.auth-card h1 {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

/* App shell: full-height, bottom nav on mobile, focused layout on desktop */
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

@media (min-width: 900px) {
  .app-shell { max-width: 720px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

.app-header {
  height: 56px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header #headerTitle {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.app-view {
  height: 100%;
  overflow-y: auto;
}

.bottom-nav {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  border: 0;
  background: none;
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  min-height: 48px;
}

.bottom-nav-item.active { color: var(--accent); font-weight: 700; }
.bottom-nav-item span { font-size: 1.2rem; }

.presence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 2px;
}
.presence-dot.is-online { background: #34c759; }

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bubble-in);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex: 0 0 auto;
}

/* Explore */
.explore-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding-bottom: 16px;
}

.explore-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.explore-card-portrait {
  aspect-ratio: 4 / 5;
  background: var(--bubble-in);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.explore-card-portrait img,
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-circle img { border-radius: 50%; }

.explore-card-body { padding: 12px; }
.explore-card-body [data-role="name"] { font-weight: 700; }

/* Conversation */
.conversation-view { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.conversation-header { height: 56px; flex: 0 0 auto; border-bottom: 1px solid var(--border); background: var(--surface); }

.message-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-muted);
}

.bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: var(--radius);
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bubble.in {
  align-self: flex-start;
  background: var(--bubble-in);
  border-bottom-left-radius: 4px;
}

.bubble.out {
  align-self: flex-end;
  background: var(--bubble-out);
  color: var(--accent-contrast);
  border-bottom-right-radius: 4px;
}

/* Wraps a character bubble + its report control; the row (not the bubble
   itself) now owns the flex-start alignment within .message-list. */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  align-self: flex-start;
  max-width: 100%;
}

/* Replay + report, stacked beside the bubble. 40px targets: small enough
   to stay out of the way, large enough to tap reliably. */
.message-actions {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}

.msg-action-btn {
  background: none;
  border: none;
  border-radius: 50%;
  color: inherit;
  opacity: 0.4;
  font-size: 0.95rem;
  line-height: 1;
  width: 40px;
  height: 40px;
  padding: 0;
  cursor: pointer;
}

.msg-action-btn:hover,
.msg-action-btn:focus-visible { opacity: 0.85; }
.replay-btn.speaking { opacity: 1; color: var(--accent); background: var(--accent-soft); }
.flag-btn.flagged { opacity: 0.9; color: #d64545; cursor: default; }

/* Notices from the app itself (errors, daily limit) -- centered and
   outlined so they can't be mistaken for the character talking. */
.system-notice {
  align-self: center;
  max-width: 88%;
  margin: 6px 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.88em;
  text-align: center;
}

.system-notice-label {
  font-size: 0.75em;
  font-weight: 600;
}

/* The user's own message when the send failed (limit reached, network
   error) -- it never reached the server, so it must not look delivered. */
.bubble.out.not-sent { opacity: 0.6; }
.not-sent-label {
  align-self: flex-end;
  margin-top: -6px;
  font-size: 0.75em;
  color: var(--text-muted);
}

.system-notice-text { color: var(--text); }

/* A practice character's explanation of its own message, in the
   learner's language -- set under the practice-language text like a
   subtitle, visibly secondary so the Spanish stays the thing to read. */
.bubble-support {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9em;
}

/* Private practice note under a user's own bubble (language-practice
   characters). Styled as app UI, not a message: outlined card, muted
   text, never the character's bubble colors. */
.tutor-note {
  align-self: flex-end;
  max-width: 78%;
  margin-top: -2px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9em;
  color: var(--text);
}

.tutor-note summary {
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  list-style-position: inside;
}

.tutor-note summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tutor-note-label { font-weight: 600; color: var(--accent); }
.tutor-note-summary { color: var(--text-muted); white-space: pre; }
.tutor-note-body { padding: 0 12px 10px; }
.tutor-note-item + .tutor-note-item { margin-top: 8px; }
.tutor-note-original { color: var(--text-muted); }
.tutor-note-corrected { text-decoration: none; font-weight: 600; }
.tutor-note-why { color: var(--text-muted); margin-top: 1px; }
.tutor-note-tip { margin-top: 8px; }
.tutor-note-private { margin-top: 8px; font-size: 0.8em; color: var(--text-muted); }

.practice-badge {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  .tutor-note-label,
  .practice-badge { color: color-mix(in srgb, var(--accent) 55%, white); }
}

.bubble-time {
  font-size: 0.68rem;
  opacity: 0.6;
  margin-top: 2px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 0.9; }
}

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.composer textarea {
  resize: none;
  max-height: 120px;
}

.composer-send,
.composer-mic,
.composer-mic-cancel {
  border-radius: 50%;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.composer-mic.listening {
  background: #d64545;
  border-color: #d64545;
  color: #fff;
  animation: mic-pulse 1.4s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(214, 69, 69, 0); }
}

.mic-status {
  padding-bottom: 4px;
}

.back-btn {
  text-decoration: none;
  padding-left: 4px;
}

.min-w-0 { min-width: 0; }

/* Chat header identity: avatar + name open the character profile */
.conversation-identity {
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: inherit;
  min-height: 44px;
}
.conversation-identity:hover,
.conversation-identity:focus-visible { background: var(--bubble-in); }
.avatar-circle.avatar-sm { width: 36px; height: 36px; font-size: 1rem; }

/* Character profile & gallery */
.character-detail { max-width: 560px; margin: 0 auto; }
.character-detail h2 { font-size: 1.4rem; }
.character-hero {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  max-height: 60vh;
  background: var(--bubble-in);
  font-size: 3rem;
  box-shadow: var(--shadow-sm);
}
.character-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gallery-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 16px) / 3);
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
}
.gallery-thumb {
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--bubble-in);
  scroll-snap-align: start;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb:focus-visible { border-color: var(--accent); outline: none; }

.profile-section { margin-top: 1.5rem; }
.profile-section h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.profile-section p { margin-bottom: 0.4rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.chip-list li {
  background: var(--bubble-in);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-lightbox.d-none { display: none !important; }
.gallery-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.gallery-lightbox button {
  position: absolute;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}
.gallery-lightbox-close { top: max(12px, env(safe-area-inset-top)); right: 12px; font-size: 1.2rem !important; }
.gallery-lightbox-nav.prev { left: 8px; top: 50%; transform: translateY(-50%); }
.gallery-lightbox-nav.next { right: 8px; top: 50%; transform: translateY(-50%); }
.gallery-lightbox-count {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  color: #fff;
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Google Website Translator (js/translate.js): keep only its translation
   effect, hide all of its own UI -- the .language-select dropdowns are the
   only visible language control. Google's banner iframe class name is
   machine-generated and changes across deployments (observed as something
   like "VIpgJd-ZVi9od-ORHb-OEVmcd skiptranslate", not the older documented
   ".goog-te-banner-frame"), so target every iframe it tags with its one
   stable marker class instead of a specific generated class name. */
iframe.skiptranslate,
.goog-te-gadget-icon,
#goog-gt-tt,
.goog-te-balloon-frame {
  display: none !important;
}
body {
  top: 0 !important; /* Google's banner normally pushes body down */
}
.goog-text-highlight {
  background: none !important;
  box-shadow: none !important;
}

/* "What they remember" list -- one note per row, Forget always visible. */
.memory-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.memory-item:last-child { border-bottom: 0; }
.memory-text { flex: 1 1 auto; line-height: 1.4; }
.memory-item .btn { flex: 0 0 auto; min-height: 40px; }


.alert-warning {
  background: var(--warning);
  color: var(--warning-contrast);
  font-weight: 600;
  border-radius: var(--radius);
}

.btn-outline-primary {
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
}

/* Stands in for the composer while chatting is paused for an age check. */
.age-notice {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* "Age verified" perk badge on the user's own profile. */
.age-verified-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (prefers-color-scheme: dark) {
  .age-verified-badge { color: color-mix(in srgb, var(--accent) 55%, white); }
}

/* First-run setup wizard (#onboardingScreen). Full-height on phones, a
   centered card on wider screens. */
.onboarding-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background: var(--surface-muted);
}
.onboarding-card {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
  background: var(--surface);
}
@media (min-width: 600px) {
  .onboarding-screen { align-items: center; padding: 1.5rem; }
  .onboarding-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 1.25rem 1.75rem 1.5rem; }
}
.onboarding-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.onboarding-top .btn-link { font-weight: 600; text-decoration: none; min-height: 44px; }
.onboarding-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.onboarding-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s ease;
}
.onboarding-step { flex: 1; min-width: 0; }
.onboarding-step legend {
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
  outline: none;
}
.onboarding-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  position: sticky;
  bottom: 0;
  padding-top: 0.75rem;
  background: var(--surface);
}

/* Big tappable option cards (goals, interaction mode). The real input is
   visually hidden but stays focusable and announced. */
.choice-grid { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
@media (min-width: 420px) { .choice-grid { grid-template-columns: 1fr 1fr; } }
.choice-grid.choice-grid-single { grid-template-columns: 1fr; }
.choice-card, .chip-choice { position: relative; cursor: pointer; margin: 0; }
.choice-card input, .chip-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.choice-card span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  height: 100%;
  min-height: 64px;
  padding: 0.8rem 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.choice-card small { color: var(--text-muted); font-size: 0.85em; }
.choice-card input:checked + span,
.chip-choice input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice-card input:focus-visible + span,
.chip-choice input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.chip-choices { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-choice span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 1rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  background: var(--surface);
}
.promise-check {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-weight: 600;
  cursor: pointer;
}
.promise-check .form-check-input { width: 1.5rem; height: 1.5rem; flex-shrink: 0; margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .onboarding-progress-bar { transition: none; }
}
