@import url("https://fonts.googleapis.com/css2?family=Jersey+10&display=swap");

: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-card:
    0 3px 5px rgba(16, 24, 22, 0.1), 0 7px 15px rgba(16, 24, 22, 0.2);
  --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);
}

/* Dark theme: data-bs-theme is set in index.html from Profile > Settings
   (auto follows the system). */
:root[data-bs-theme="dark"] {
  --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);
}
[data-bs-theme="dark"] 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.5rem;
  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;
}

/* Line icons (inline SVG in index.html) that pick up the item's color;
   the active item's shape gets a soft tint so selection doesn't rely on
   color alone. */
.nav-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-icon .nav-icon-dot {
  fill: currentColor;
  stroke: none;
}
.nav-icon .nav-icon-accent {
  fill: currentColor;
  stroke-width: 1.4;
}
.bottom-nav-item .nav-icon-fill {
  transition: fill-opacity 0.15s ease;
  fill: currentColor;
  fill-opacity: 0;
}
.bottom-nav-item.active .nav-icon-fill {
  fill-opacity: 0.16;
}
.bottom-nav-item.active .nav-icon {
  stroke-width: 2.1;
}
.bottom-nav-item:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -3px;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  .bottom-nav-item .nav-icon-fill {
    transition: none;
  }
}

.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;
  /* Three across on a phone now that the directory is growing; minmax(0,..)
     lets long names truncate instead of widening a column. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Rows further apart than columns, so each card's buttons clearly belong
     to the card above them, not the one below. */
  gap: 28px 12px;
  padding-bottom: 46px;
}
@media (min-width: 768px) {
  .explore-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 16px; }
}

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

.explore-card-portrait {
  aspect-ratio: 1 / 1.3;
  background-color: var(--bubble-in);
  /* Set from app.js (showPortrait). Faces sit in the upper part of a
     portrait, so crop from the bottom and sides, never the head. */
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

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

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

.explore-card-body {
  padding: 8px 8px 10px;
}
.explore-card-name {
  font-weight: 700;
  font-size: .9rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.explore-card-meta {
  font-size: .72rem;
  line-height: 1.4;
  margin-top: 2px;
}
/* Job, then region: each starts on its own line and wraps in full, never cut. */
.explore-card-meta-line {
  display: block;
  overflow-wrap: anywhere;
}

/* Cards in a row are equally tall (grid stretch) and the buttons sit at the
   bottom of each, so they line up however many lines the text above takes. */
.explore-card {
  display: flex;
  flex-direction: column;
}
.explore-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.explore-card-actions {
  margin-top: auto;
}
/* Interest tags: small, at most two lines. */
.explore-card-tags {
  font-size: .68rem;
  line-height: 1.5;
  margin: 6px 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.explore-card-actions {
  display: flex;
  gap: 4px;
}
.explore-card-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 2px;
  font-size: .75rem;
  white-space: nowrap;
}

/* 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);
}

/* Crisis policy message: calm, readable, clearly from the app (not the
   character), left-aligned so the helpline list reads easily. */
.system-notice--safety {
  max-width: 94%;
  padding: 14px 16px;
  text-align: left;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  font-size: 0.95em;
}
.system-notice--safety .system-notice-text {
  white-space: pre-line;
  line-height: 1.5;
}
.system-notice--safety a {
  color: var(--accent);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* 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);
}

[data-bs-theme="dark"] .tutor-note-label,
[data-bs-theme="dark"] .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;
}

/* Explore Browse interest tags */
.tag-chips {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px 2px;
}
.tag-chips::-webkit-scrollbar {
  display: none;
}
.tag-chips.is-expanded {
  flex-wrap: wrap;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 33vh;
  scrollbar-width: auto;
}
.tag-chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bubble-in);
  color: inherit;
  font-size: 0.95rem;
  white-space: nowrap;
}
.tag-chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}
.tag-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@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);
}

/* 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;
}

[data-bs-theme="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;
  }
}

/* Text size (Profile > Settings). Bootstrap sizes everything in rem, so
   scaling the root scales the whole app evenly. */
html[data-text-size="large"] {
  font-size: 112.5%;
}
html[data-text-size="extra_large"] {
  font-size: 125%;
}

/* ---------- Profile hub ---------- */
.profile-page {
  padding: 1rem 1rem 1.5rem;
}
.profile-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0 1.25rem;
}
.profile-avatar {
  width: 64px;
  height: 64px;
  color: var(--accent);
  background: var(--accent-soft);
}
.profile-avatar .nav-icon {
  width: 34px;
  height: 34px;
}
.profile-hero-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.min-w-0 {
  min-width: 0;
}

.profile-save-callout {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1.25rem;
}
.profile-save-callout strong {
  display: block;
  color: var(--accent);
}
.profile-save-callout span {
  font-size: 0.9rem;
  color: var(--text-muted);
}
[data-bs-theme="dark"] .profile-save-callout strong {
  color: color-mix(in srgb, var(--accent) 55%, white);
}

.menu-group {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.menu-group li + li {
  border-top: 1px solid var(--border);
}
.menu-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 60px;
  padding: 0.7rem 0.9rem;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
.menu-row:hover {
  background: var(--surface-muted);
  color: var(--text);
}
.menu-row:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -3px;
}
.menu-icon,
.menu-chevron {
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-icon {
  width: 36px;
  height: 36px;
  padding: 7px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
[data-bs-theme="dark"] .menu-icon {
  color: color-mix(in srgb, var(--accent) 55%, white);
}
.menu-icon .menu-icon-dot {
  fill: currentColor;
  stroke: none;
}
.menu-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}
.menu-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.menu-label {
  font-weight: 600;
}
.menu-text small {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.profile-page-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  margin-bottom: 1rem;
}
.profile-page-head h2 {
  width: 100%;
  margin: 0;
  outline: none;
  order: 2;
}
.profile-back {
  padding: 0;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}
.profile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
}

/* Segmented control (theme, text size): real radios, big targets. */
.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: 14px;
  background: var(--bubble-in);
}
.segmented label {
  flex: 1;
  position: relative;
  margin: 0;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.segmented input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.text-size-sample-lg {
  font-size: 1.08em;
}
.text-size-sample-xl {
  font-size: 1.18em;
}
.list-group-item.form-switch {
  padding-left: var(--bs-list-group-item-padding-x);
  min-height: 56px;
}
.list-group-item.form-switch .form-check-input {
  margin: 0;
  float: none;
}
.form-switch .form-switch-lg {
  width: 2.75rem;
  height: 1.5rem;
  cursor: pointer;
}

/* Interest tag picker (Profile > Interests). */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag-picker .tag-chip {
  white-space: normal;
  text-align: left;
}
.tag-picker .tag-chip[draggable="true"] {
  cursor: grab;
}
.tag-chip .tag-remove {
  margin-left: 0.4rem;
  opacity: 0.75;
  font-weight: 700;
}
.tag-picker-sm .tag-chip {
  min-height: 34px;
  padding: 3px 11px;
  font-size: 0.85rem;
}
.skip-zone {
  padding: 0.6rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}
.skip-zone.is-drop-target {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.skip-zone .tag-chip[aria-pressed="true"] {
  background: var(--text);
  color: var(--surface);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.tag-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.tag-add .form-control {
  min-height: 40px;
}
@media (prefers-reduced-motion: reduce) {
  .skip-zone {
    transition: none;
  }
}
.form-check-input:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--accent) 25%, transparent);
}
.form-switch .form-check-input:focus:not(:checked) {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23999'/%3e%3c/svg%3e");
}

/* ---------- Welcome (first visit) ---------- */
.welcome-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(
      120% 55% at 50% 0%,
      color-mix(in srgb, var(--accent) 16%, transparent),
      transparent 70%
    ),
    var(--surface);
}
.welcome-inner {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
}
.welcome-top {
  display: flex;
  justify-content: flex-end;
  min-height: 44px;
  align-items: center;
}
.welcome-hero {
  text-align: center;
  padding: 0.25rem 0 1.1rem;
}
.welcome-logo {
  width: 256px;
  height: auto;
  margin-bottom: 0.6rem;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
}
.welcome-name {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  color: var(--text);
}
.welcome-lead {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text);
}
.welcome-text {
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}
.welcome-points {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.welcome-points li {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  line-height: 1.4;
  font-size: 0.95rem;
}
.welcome-points svg {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 7px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-bs-theme="dark"] .welcome-points svg {
  color: color-mix(in srgb, var(--accent) 55%, white);
}
.welcome-points span {
  color: var(--text-muted);
}
.welcome-points strong {
  color: var(--text);
}
.welcome-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: auto;
}
.welcome-age {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
}
.welcome-age .form-check-input {
  width: 1.3rem;
  height: 1.3rem;
  margin: 0;
  flex-shrink: 0;
}
.welcome-actions .btn:disabled {
  opacity: 0.45;
}
.welcome-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.1rem 0 0;
}
.welcome-login {
  text-align: center;
  margin: 0.9rem 0 0.4rem;
  color: var(--text-muted);
}
.welcome-login .btn-link {
  font-weight: 600;
  text-decoration: none;
}
.welcome-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1rem;
  font-size: 0.85rem;
}
.welcome-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0;
}
.welcome-links a:hover {
  color: var(--text);
  text-decoration: underline;
}
@media (min-width: 600px) {
  .welcome-screen {
    align-items: center;
    padding: 2rem 1rem;
  }
  .welcome-actions {
    margin-top: 0;
  }
}
.btn-primary {
  --bs-btn-disabled-bg: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
  --bs-btn-active-bg: color-mix(in srgb, var(--accent) 80%, black);
  --bs-btn-active-border-color: color-mix(in srgb, var(--accent) 80%, black);
}
.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);
  --bs-btn-disabled-color: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
}
[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: color-mix(in srgb, var(--accent) 55%, white);
  --bs-btn-border-color: color-mix(in srgb, var(--accent) 55%, white);
  --bs-btn-disabled-color: color-mix(in srgb, var(--accent) 55%, white);
  --bs-btn-disabled-border-color: color-mix(in srgb, var(--accent) 55%, white);
}

/* PersonAiO logo in the app header and on the login card. */
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.app-brand-logo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}
.auth-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 0.75rem;
}

.memory-heading {
  font-weight: 700;
  margin: 0 0 6px;
}
.memory-summary {
  line-height: 1.55;
  white-space: pre-line;
}

.pixelated {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  font-family: "Jersey 10", monospace;
  letter-spacing: 0.2em;
  font-size:3em;
}

.large {
  font-size: 4em;
}

/* App-like touch: no double-tap zoom anywhere (pinch is blocked in
   index.html). Panning and scrolling still work normally. */
html, body {
  touch-action: pan-x pan-y;
}
a, button, input, select, textarea, label, [role="button"] {
  touch-action: manipulation;
}

/* Request a character (Favorites, Pro) */
.request-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.request-card-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.request-card-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pro-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: .7rem;
  font-weight: 700;
  vertical-align: middle;
}
.request-card.is-locked .request-card-icon { opacity: .55; }
.request-list { margin-top: 12px; }
.request-list li { padding: 10px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.request-list .request-status { font-weight: 600; }
.request-list .request-note { color: var(--text-muted); margin-top: 2px; }

/* Games: banner while one runs, and the picker list. */
.game-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
  font-size: .9rem;
  font-weight: 600;
}
.game-banner.d-none { display: none; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
  text-align: left;
}
.game-option:hover, .game-option:focus-visible { border-color: var(--accent); }
.game-option-icon { font-size: 1.6rem; flex: 0 0 auto; }
.game-option-name { font-weight: 700; }
.game-option-desc { font-size: .85rem; color: var(--text-muted); }
