/* PenPal AI — web port styles.
   Design tokens ported from the SwiftUI app (ContentView / CharacterContactsView / ChatView):
     deepSpace #0B0B10 · lovePink #FF69C7 · violet #8A5CFF · oceanBlue #2EA2FF
   Typography mirrors SF Rounded; bubbles mirror the iOS blue/gray Message style. */

:root {
  --deep-space: #0b0b10;
  --love-pink: #ff69c7;
  --violet: #8a5cff;
  --ocean: #2ea2ff;
  --ios-blue: #0a84ff;
  --ai-gray: #2c2c2e;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --app-height: 100dvh;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  min-height: var(--app-height);
  background: #050507;
  font-family: var(--font-rounded);
  color: #fff;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--app-height);
  overflow: hidden;
}

/* The app, presented in an iOS-width column so it reads 1-1 with the native app. */
.device {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: var(--app-height);
  max-height: none;
  overflow: hidden;
  background: var(--deep-space);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
@media (min-width: 480px) {
  .device { border-radius: 34px; border: 1px solid rgba(255, 255, 255, 0.06); }
}
@media (min-width: 700px) {
  body {
    align-items: stretch;
    justify-content: stretch;
  }

  .device {
    width: 100vw;
    max-width: none;
    height: var(--app-height);
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .features { display: none; }
}

/* ---- Screen switching ---- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.screen.is-active { display: flex; animation: screenIn 0.26s cubic-bezier(0.32, 0.72, 0, 1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .screen.is-active { animation: none; } }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; z-index: 1; }

/* ===================== LANDING ===================== */
.landing-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(430px 430px at 12% 8%, rgba(138, 92, 255, 0.34), transparent 70%),
    radial-gradient(430px 430px at 88% 92%, rgba(46, 162, 255, 0.22), transparent 70%),
    radial-gradient(360px 360px at 8% 92%, rgba(255, 105, 199, 0.16), transparent 70%),
    linear-gradient(140deg, var(--deep-space), #000 55%, #060818);
}
.landing-content {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: max(28px, env(safe-area-inset-top)) 26px max(28px, env(safe-area-inset-bottom)); gap: 22px;
  overflow-y: auto;
}
.landing-logo-wrap { position: relative; display: grid; place-items: center; margin-top: 8px; }
.glow { position: absolute; border-radius: 50%; filter: blur(18px); }
.glow--violet { width: 240px; height: 240px; background: rgba(138, 92, 255, 0.13); }
.glow--ocean { width: 200px; height: 200px; background: rgba(46, 162, 255, 0.12); transform: translate(28px, 18px); }
.landing-logo {
  position: relative; width: 210px; height: auto;
  filter: drop-shadow(-12px 12px 22px rgba(255, 105, 199, 0.24)) drop-shadow(12px 14px 22px rgba(46, 162, 255, 0.24));
}
.landing-headings { display: flex; flex-direction: column; gap: 9px; }
.landing-title { font-size: 56px; font-weight: 800; letter-spacing: -1px; }
.landing-tagline { font-size: 16px; font-weight: 400; color: rgba(255, 255, 255, 0.66); line-height: 1.45; max-width: 340px; }

.features { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 360px; }
.feature {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 18px;
}
.feature-icon {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; font-size: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 50%;
}
.feature-text { font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.84); }
@media (min-width: 700px) {
  .features { display: none; }
}

.landing-actions { display: flex; flex-direction: column; gap: 13px; width: 100%; max-width: 360px; margin-top: auto; }
.name-field {
  height: 50px; padding: 0 18px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  color: #fff; font-family: var(--font-rounded); font-size: 16px; font-weight: 500;
  text-align: center;
}
.name-field::placeholder { color: rgba(255, 255, 255, 0.4); }
.name-field:focus { outline: none; border-color: rgba(138, 92, 255, 0.5); }

.btn {
  border: none; cursor: pointer; font-family: var(--font-rounded);
  height: 54px; border-radius: 999px; font-size: 18px; font-weight: 600;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: #fff; color: #000; }
.btn--ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.72);
  height: 48px; font-size: 15px;
}
.landing-fineprint { font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, 0.42); }
.auth-panel {
  width: 100%; max-width: 360px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  text-align: left;
}
.auth-panel-title { font-size: 13px; font-weight: 800; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.4px; }
.auth-summary { font-size: 13px; color: rgba(255,255,255,0.58); margin-top: 4px; margin-bottom: 10px; overflow-wrap: anywhere; }
.auth-input {
  width: 100%; height: 42px; margin-top: 8px; padding: 0 13px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  color: #fff; font-family: var(--font-rounded); font-size: 14px;
}
.auth-input::placeholder { color: rgba(255,255,255,0.38); }
.auth-input:focus { outline: none; border-color: rgba(138,92,255,0.5); }
.auth-google {
  width: 100%; height: 44px; margin-top: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: none; border-radius: 999px; cursor: pointer;
  background: #fff; color: #151515;
  font-family: var(--font-rounded); font-size: 15px; font-weight: 800;
}
.auth-google-mark {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(0,0,0,0.08);
  color: #4285f4; background: #fff;
  font-family: Arial, sans-serif; font-size: 16px; font-weight: 800;
}
.auth-google:active { transform: scale(0.98); }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 2px 2px;
  color: rgba(255,255,255,0.38);
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(255,255,255,0.08);
}
.auth-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.auth-primary, .auth-secondary {
  height: 38px; border-radius: 999px; cursor: pointer; font-family: var(--font-rounded); font-size: 13px; font-weight: 800;
}
.auth-primary { border: none; background: #fff; color: #000; }
.auth-secondary { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.auth-primary:active, .auth-secondary:active { transform: scale(0.97); }
.auth-status { min-height: 16px; margin-top: 8px; font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.35; }
.auth-status.ok { color: rgba(52,199,89,0.95); }
.auth-status.err { color: #ff6b6b; }
.auth-panel.is-signed-in .auth-input,
.auth-panel.is-signed-in .auth-actions,
.auth-panel.is-signed-in .auth-google,
.auth-panel.is-signed-in .auth-divider { display: none; }

@media (max-width: 899px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 480px) {
  .landing-content {
    padding: max(18px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
    gap: 13px;
  }
  .landing-logo-wrap { margin-top: 0; }
  .glow--violet { width: 150px; height: 150px; }
  .glow--ocean { width: 128px; height: 128px; }
  .landing-logo { width: 118px; }
  .landing-title { font-size: 42px; }
  .landing-tagline { font-size: 14px; line-height: 1.35; max-width: 320px; }
  .features { display: none; }
  .landing-actions { gap: 8px; margin-top: 0; }
  .name-field { height: 46px; }
  .auth-panel { padding: 12px; border-radius: 16px; }
  .auth-google { height: 42px; margin-top: 10px; }
  .auth-input { height: 40px; margin-top: 7px; }
  .auth-actions { gap: 7px; margin-top: 9px; }
  .auth-primary, .auth-secondary { height: 36px; }
  .auth-status { margin-top: 6px; }
}

@media (min-width: 700px) and (max-width: 899px) {
  .landing-content {
    display: grid;
    grid-template-columns: minmax(190px, 240px) minmax(330px, 370px);
    grid-template-areas:
      "logo headings"
      "logo actions"
      "logo auth";
    align-content: center;
    justify-content: center;
    align-items: center;
    column-gap: clamp(28px, 5vw, 48px);
    row-gap: 14px;
    padding: 28px 30px;
    text-align: left;
  }
  .landing-logo-wrap { grid-area: logo; margin-top: 0; }
  .landing-headings { grid-area: headings; width: 100%; }
  .landing-actions { grid-area: actions; max-width: 370px; margin-top: 0; }
  .auth-panel { grid-area: auth; max-width: 370px; }
  .landing-logo { width: clamp(176px, 25vw, 220px); }
  .landing-title { font-size: clamp(46px, 7vw, 58px); }
  .landing-tagline { max-width: 370px; font-size: 15px; }
}

/* ===================== ONBOARDING ===================== */
.ob { position: relative; z-index: 1; flex: 1; min-height: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 20px 22px calc(14px + env(safe-area-inset-bottom)); }
.ob-top { padding-top: 14px; }
.ob-brand { font-size: 20px; font-weight: 800; text-align: center; letter-spacing: -0.5px; }
.ob-step-label { text-align: center; font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.5); margin-top: 6px; }
.ob-progress { height: 4px; border-radius: 3px; background: rgba(255,255,255,0.1); margin-top: 10px; overflow: hidden; }
.ob-progress-fill { height: 100%; width: 12.5%; border-radius: 3px; background: linear-gradient(90deg, var(--love-pink), var(--violet), var(--ocean)); transition: width 0.4s cubic-bezier(0.32,0.72,0,1); }
.ob-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 2px 14px; display: flex; flex-direction: column; }
.ob-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.ob-sub { font-size: 15px; color: rgba(255,255,255,0.6); line-height: 1.45; margin-top: 8px; margin-bottom: 22px; }
.ob-field { margin-bottom: 16px; }
.ob-field-label { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.ob-input, .ob-select, .ob-textarea {
  width: 100%; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px;
  color: #fff; font-family: var(--font-rounded); font-size: 16px; padding: 14px 16px;
}
.ob-input::placeholder, .ob-textarea::placeholder { color: rgba(255,255,255,0.4); }
.ob-input:focus, .ob-select:focus, .ob-textarea:focus { outline: none; border-color: rgba(138,92,255,0.5); }
.ob-textarea { min-height: 120px; resize: vertical; line-height: 1.4; }
.ob-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.5) 50%), linear-gradient(135deg, rgba(255,255,255,0.5) 50%, transparent 50%);
  background-position: right 18px center, right 13px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.ob-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; margin: auto 0; }
.ob-hero img { width: 150px; filter: drop-shadow(-10px 10px 18px rgba(255,105,199,0.24)) drop-shadow(10px 12px 18px rgba(46,162,255,0.24)); }
.ob-hero-title { font-size: 34px; font-weight: 800; }
.ob-hero-sub { font-size: 16px; color: rgba(255,255,255,0.66); line-height: 1.45; max-width: 320px; }
.ob-feature { display: flex; gap: 13px; align-items: flex-start; padding: 14px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; margin-bottom: 10px; }
.ob-feature-icon { font-size: 20px; width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: rgba(255,255,255,0.07); border-radius: 12px; }
.ob-feature-title { font-size: 15px; font-weight: 700; }
.ob-feature-desc { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 3px; line-height: 1.35; }
.ob-note { font-size: 13px; color: rgba(255,255,255,0.5); line-height: 1.45; background: rgba(255,255,255,0.045); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 14px; }
.ob-nav { flex: 0 0 auto; display: flex; gap: 12px; padding-top: 10px; }
.ob-back, .ob-next { flex: 1; height: 52px; border-radius: 999px; font-family: var(--font-rounded); font-size: 16px; font-weight: 700; cursor: pointer; border: none; }
.ob-back { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); flex: 0 0 40%; }
.ob-back:disabled { opacity: 0.35; cursor: default; }
.ob-next { background: #fff; color: #000; }
.ob-next:active, .ob-back:active { transform: scale(0.98); }
.ob-import-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; background: linear-gradient(135deg, var(--love-pink), var(--violet), var(--ocean)); color: #fff; font-weight: 700; font-size: 15px; padding: 13px 16px; border-radius: 14px; margin-top: 8px; }
.ob-import-btn.busy { opacity: 0.7; pointer-events: none; }

@media (max-width: 480px) {
  .ob {
    padding: max(12px, env(safe-area-inset-top)) 18px calc(10px + env(safe-area-inset-bottom));
  }
  .ob-top { padding-top: 0; }
  .ob-brand { font-size: 18px; }
  .ob-step-label { margin-top: 4px; }
  .ob-progress { margin-top: 8px; }
  .ob-body { padding: 14px 2px 10px; }
  .ob-title { font-size: 25px; }
  .ob-sub { font-size: 14px; line-height: 1.36; margin-top: 6px; margin-bottom: 14px; }
  .ob-field { margin-bottom: 12px; }
  .ob-feature { gap: 10px; padding: 10px; border-radius: 13px; margin-bottom: 8px; }
  .ob-feature-icon { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
  .ob-feature-title { font-size: 14px; }
  .ob-feature-desc { font-size: 12px; line-height: 1.3; }
  .ob-import-btn { width: 100%; padding: 12px 14px; margin-top: 4px; }
  .ob-nav { gap: 10px; padding-top: 8px; }
  .ob-back, .ob-next { height: 48px; font-size: 15px; }
}

/* ===================== CHARACTERS ===================== */
.space-bg, .chat-bg {
  position: absolute; inset: 0; z-index: 0;
}
.space-bg { background: linear-gradient(150deg, var(--deep-space), #150d1f 50%, var(--deep-space)); }

.chars-header { padding: 26px 18px 4px; }
.chars-title { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; }
.chars-sub { margin-top: 7px; font-size: 15px; color: rgba(255, 255, 255, 0.62); line-height: 1.4; }

.scroll > * { position: relative; z-index: 1; }
.companion-card, .search, .discover-row, .char-grid { margin: 0 18px; }

.companion-card {
  display: flex; align-items: center; gap: 15px; width: calc(100% - 36px);
  margin-top: 18px; padding: 14px; cursor: pointer; text-align: left;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 24px; color: #fff; font-family: var(--font-rounded);
  transition: transform 0.08s ease, background 0.15s ease;
}
.companion-card:active { transform: scale(0.99); }
.companion-avatar {
  width: 68px; height: 68px; flex: none;
  display: grid; place-items: center; font-size: 27px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  background-size: cover; background-position: center;
}
.companion-meta { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.companion-name { font-size: 19px; font-weight: 600; }
.companion-role { font-size: 13px; font-weight: 500; color: rgba(255, 105, 199, 0.9); }
.companion-blurb { font-size: 13px; color: rgba(255, 255, 255, 0.56); line-height: 1.35; }
.chevron { margin-left: auto; font-size: 24px; color: rgba(255, 255, 255, 0.34); align-self: center; }

.search {
  display: flex; align-items: center; gap: 11px; margin-top: 18px;
  height: 52px; padding: 0 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}
.search-icon { font-size: 20px; color: rgba(255, 255, 255, 0.45); }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-family: var(--font-rounded); font-size: 16px; font-weight: 500;
}
.search-input::placeholder { color: rgba(255, 255, 255, 0.4); }

.discover-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 22px; }
.discover-title { font-size: 18px; font-weight: 700; }
.discover-tag { font-size: 12px; font-weight: 600; color: var(--violet); }

.char-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 22px 14px;
  margin-top: 16px; padding-bottom: 36px;
}
.char-card { cursor: pointer; display: flex; flex-direction: column; gap: 8px; text-align: left; background: none; border: none; padding: 0; color: inherit; font-family: var(--font-rounded); }
.char-card:active { transform: scale(0.99); }
.char-photo {
  width: 100%; height: 206px; object-fit: cover;
  border-radius: 18px; background: rgba(255, 255, 255, 0.05);
}
.char-titterow { display: flex; align-items: baseline; gap: 6px; }
.char-name { font-size: 20px; font-weight: 800; }
.char-age {
  font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, 0.72);
  padding: 3px 7px; background: rgba(255, 255, 255, 0.09); border-radius: 999px;
}
.char-tagline {
  font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, 0.64);
  min-height: 32px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.char-original { font-size: 11px; font-weight: 600; color: rgba(138, 92, 255, 0.9); display: flex; align-items: center; gap: 4px; }

.char-empty { grid-column: 1 / -1; text-align: center; color: rgba(255,255,255,0.5); padding: 44px 0; font-size: 15px; font-weight: 500; }

/* ===================== SETTINGS / SUB-SCREENS ===================== */
.chars-header { position: relative; }
.chars-settings {
  position: absolute; top: 26px; right: 18px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
  color: #fff; font-size: 19px; font-family: var(--font-rounded);
}
.chars-settings:active { transform: scale(0.94); }
.sub-header {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 14px 16px 12px; padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(11,11,16,0.72); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sub-title { font-size: 20px; font-weight: 800; }
#settings-scroll, #paywall-scroll { padding: 12px 18px calc(30px + env(safe-area-inset-bottom)); }

.settings-group { margin-bottom: 22px; }
.settings-group-title { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.5px; margin: 0 4px 10px; }
.settings-card {
  background: rgba(255,255,255,0.055); border: 1px solid rgba(255,255,255,0.09);
  border-radius: 18px; overflow: hidden;
}
.settings-field { padding: 13px 16px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.settings-field:last-child { border-bottom: none; }
.settings-field-label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.5); margin-bottom: 7px; }
.settings-input, .settings-select, .settings-textarea {
  width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 11px;
  color: #fff; font-family: var(--font-rounded); font-size: 15px; padding: 11px 13px;
}
.settings-input:focus, .settings-select:focus, .settings-textarea:focus { outline: none; border-color: rgba(138,92,255,0.5); }
.settings-textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
.settings-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.5) 50%), linear-gradient(135deg, rgba(255,255,255,0.5) 50%, transparent 50%);
  background-position: right 15px center, right 10px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.settings-action { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; padding: 15px 16px; cursor: pointer; background: none; border: none; color: #fff; font-family: var(--font-rounded); font-size: 15px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.06); }
.settings-action:last-child { border-bottom: none; }
.settings-action:active { background: rgba(255,255,255,0.04); }
.settings-action .sa-icon { font-size: 18px; width: 24px; text-align: center; }
.settings-action .sa-sub { display: block; font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.5); margin-top: 2px; }
.settings-action.danger { color: #ff6b6b; }
.settings-action.danger .sa-icon { filter: none; }
.settings-hint { font-size: 12px; color: rgba(255,255,255,0.45); line-height: 1.4; margin: 8px 4px 0; }
.appearance-slots { display: flex; gap: 12px; }
.appearance-slot { flex: 1; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.appearance-img { width: 100%; aspect-ratio: 1; border-radius: 14px; background: rgba(255,255,255,0.06); border: 1px dashed rgba(255,255,255,0.22); display: grid; place-items: center; overflow: hidden; color: rgba(255,255,255,0.5); font-size: 13px; font-weight: 600; text-align: center; }
.appearance-img img { width: 100%; height: 100%; object-fit: cover; }
.appearance-slot:active .appearance-img { transform: scale(0.98); }
.appearance-cap { font-size: 12px; color: rgba(255,255,255,0.6); }
.settings-status { font-size: 12px; margin: 8px 4px 0; }
.settings-status.ok { color: rgba(52,199,89,0.95); }
.settings-status.err { color: #ff6b6b; }
.account-email { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.account-password-label { margin-top: 12px; }
.account-actions { padding: 12px; display: grid; gap: 8px; }
.account-google { margin-top: 0; }
.account-cta { height: 46px; margin-top: 0; }
.account-secondary { justify-content: center; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 12px; }
.settings-saved-toast {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(52,199,89,0.95); color: #fff; font-size: 13px; font-weight: 700; padding: 9px 18px; border-radius: 999px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 20; pointer-events: none;
}
.settings-saved-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* memory & continuity */
#memory-scroll { padding: 16px 18px calc(30px + env(safe-area-inset-bottom)); }
.mem-loading, .mem-empty { color: rgba(255,255,255,0.5); font-size: 14px; line-height: 1.45; text-align: center; padding: 12px 0; }
.mem-empty { text-align: left; }
.mem-days {
  text-align: center; padding: 26px 18px; margin-bottom: 20px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(138,92,255,0.25), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.1); border-radius: 22px;
}
.mem-days-flame { font-size: 34px; }
.mem-days-num { font-size: 52px; font-weight: 800; line-height: 1; margin-top: 4px; background: linear-gradient(135deg, var(--love-pink), var(--violet), var(--ocean)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.mem-days-label { font-size: 15px; font-weight: 700; color: rgba(255,255,255,0.75); margin-top: 6px; }
.mem-days-best { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 6px; }
.mem-text { font-size: 14px; color: rgba(255,255,255,0.82); line-height: 1.5; }
.mem-timeline-title { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.mem-core-row { display: flex; align-items: flex-start; gap: 10px; }
.mem-core-row .mem-text { flex: 1; }
.mem-core-actions { display: flex; gap: 4px; flex: none; }
.mem-mini { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.06); color: #fff; cursor: pointer; font-size: 13px; }
.mem-mini.danger { color: #ff6b6b; border-color: rgba(255,69,58,0.3); }
.mem-mini:active { transform: scale(0.92); }
.mem-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mem-chip { font-size: 12px; background: rgba(138,92,255,0.18); border: 1px solid rgba(138,92,255,0.3); color: #fff; padding: 5px 10px; border-radius: 999px; }

/* paywall / billing */
.pw-hero { text-align: center; padding: 24px 8px 8px; }
.pw-crown { font-size: 44px; }
.pw-title { font-size: 26px; font-weight: 800; margin-top: 10px; }
.pw-sub { font-size: 14px; color: rgba(255,255,255,0.6); margin-top: 8px; line-height: 1.45; }
.pw-plan { background: rgba(255,255,255,0.055); border: 1px solid rgba(255,255,255,0.1); border-radius: 18px; padding: 18px; margin-top: 16px; }
.pw-plan.featured { border-color: rgba(138,92,255,0.6); box-shadow: 0 0 0 1px rgba(138,92,255,0.3); }
.pw-plan-name { font-size: 18px; font-weight: 800; }
.pw-badge { font-size: 12px; font-weight: 800; color: #fff; background: rgba(255,105,199,0.22); border: 1px solid rgba(255,105,199,0.35); border-radius: 999px; padding: 3px 8px; margin-left: 6px; vertical-align: middle; }
.pw-plan-price { font-size: 15px; color: var(--love-pink); font-weight: 700; margin-top: 4px; }
.pw-plan-features { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.pw-plan-feature { font-size: 14px; color: rgba(255,255,255,0.8); display: flex; gap: 8px; }
.pw-cta { width: 100%; height: 54px; border-radius: 999px; border: none; margin-top: 20px; cursor: pointer; font-family: var(--font-rounded); font-size: 17px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--love-pink), var(--violet), var(--ocean)); box-shadow: 0 6px 16px rgba(138,92,255,0.35); }
.pw-cta:active { transform: scale(0.98); }
.pw-cta:disabled, .auth-primary:disabled, .auth-secondary:disabled { opacity: 0.62; cursor: default; transform: none; }
.pw-note { text-align: center; font-size: 12px; color: rgba(255,255,255,0.45); margin-top: 14px; }
.pw-section-title { margin: 24px 2px 10px; font-size: 15px; font-weight: 800; color: rgba(255,255,255,0.9); }
.pw-addon-list { display: flex; flex-direction: column; gap: 12px; }
.pw-addon { background: rgba(255,255,255,0.045); border: 1px solid rgba(255,255,255,0.085); border-radius: 16px; padding: 15px; }
.pw-addon-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pw-addon-sub { margin-top: 8px; font-size: 13px; line-height: 1.35; color: rgba(255,255,255,0.56); }
.pw-cta-small { height: 44px; margin-top: 13px; font-size: 15px; box-shadow: 0 4px 12px rgba(138,92,255,0.28); }

/* ===================== CHAT ===================== */
.chat-bg {
  background:
    radial-gradient(360px 360px at 8% 6%, rgba(138, 92, 255, 0.26), transparent 70%),
    radial-gradient(300px 300px at 6% 96%, rgba(255, 105, 199, 0.14), transparent 70%),
    radial-gradient(360px 360px at 96% 96%, rgba(46, 162, 255, 0.20), transparent 70%),
    linear-gradient(150deg, var(--deep-space), #000 55%, #070a1c);
}
.chat-header {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px; padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(11, 11, 16, 0.72);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.chat-back {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 30px; line-height: 1; width: 30px; margin-right: 2px; font-family: var(--font-rounded);
}
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,0.08); }
.chat-header-meta { display: flex; flex-direction: column; }
.chat-name { font-size: 17px; font-weight: 700; }
.chat-status { font-size: 12px; color: rgba(52, 199, 89, 0.9); font-weight: 500; }
.chat-gear, .chat-call {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.10);
  color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 17px; line-height: 1; font-family: var(--font-rounded);
}
.chat-call { margin-left: auto; }
.chat-gear { margin-left: 6px; font-size: 20px; }
.chat-gear:active, .chat-call:active { transform: scale(0.94); }

/* voice call overlay */
.call-overlay { position: absolute; inset: 0; z-index: 60; display: flex; }
.call-bg { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, rgba(138,92,255,0.4), transparent 60%), linear-gradient(160deg, #0b0b10, #000 70%); }
.call-inner { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 40px 24px calc(48px + env(safe-area-inset-bottom)); }
.call-avatar { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,0.08); box-shadow: 0 0 0 0 rgba(138,92,255,0.5); animation: callpulse 2s ease-out infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 rgba(138,92,255,0.45); } 70% { box-shadow: 0 0 0 26px rgba(138,92,255,0); } 100% { box-shadow: 0 0 0 0 rgba(138,92,255,0); } }
.call-name { font-size: 26px; font-weight: 800; }
.call-status { font-size: 15px; color: rgba(255,255,255,0.65); }
.call-timer { font-size: 20px; font-weight: 700; color: rgba(52,199,89,0.95); font-variant-numeric: tabular-nums; }
.call-error { font-size: 14px; color: #ff8a8a; text-align: center; line-height: 1.45; max-width: 320px; background: rgba(255,69,58,0.12); border: 1px solid rgba(255,69,58,0.3); padding: 12px 16px; border-radius: 14px; }
.call-controls { display: flex; gap: 26px; margin-top: 18px; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer; font-size: 24px; color: #fff; }
.call-mute { background: rgba(255,255,255,0.14); }
.call-mute.muted { background: rgba(255,69,58,0.3); }
.call-end { background: #ff453a; }
.call-btn:active { transform: scale(0.92); }

/* ---- settings sheet ---- */
.sheet-scrim {
  position: absolute; inset: 0; z-index: 9; background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #16131f; border-top: 1px solid rgba(255,255,255,0.10);
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column; gap: 16px;
}
.sheet.is-open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.22); margin: 4px auto 2px; }
.sheet-title { font-size: 20px; font-weight: 800; }
.sheet-section { display: flex; flex-direction: column; gap: 8px; }
.sheet-label { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.4px; }
.sheet-hint { font-size: 13px; color: rgba(255,255,255,0.5); line-height: 1.4; }
.model-select {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: 14px;
  color: #fff; font-family: var(--font-rounded); font-size: 16px; font-weight: 600;
  padding: 13px 16px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255,255,255,0.5) 50%), linear-gradient(135deg, rgba(255,255,255,0.5) 50%, transparent 50%);
  background-position: right 18px center, right 13px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.model-select:disabled { opacity: 0.6; cursor: default; }
.import-btn {
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: linear-gradient(135deg, var(--love-pink), var(--violet), var(--ocean));
  color: #fff; font-weight: 700; font-size: 15px; padding: 13px 16px; border-radius: 14px;
  box-shadow: 0 6px 14px rgba(138,92,255,0.3);
}
.import-btn:active { transform: scale(0.98); }
.import-btn.busy { opacity: 0.7; pointer-events: none; }
.import-status { font-size: 13px; font-weight: 500; line-height: 1.4; }
.import-status.ok { color: rgba(52, 199, 89, 0.95); }
.import-status.err { color: #ff6b6b; }
.import-status .clear-mem { color: rgba(255,255,255,0.5); text-decoration: underline; cursor: pointer; margin-left: 8px; }
.sheet-done {
  margin-top: 4px; background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-family: var(--font-rounded); font-size: 16px; font-weight: 700;
  height: 50px; border-radius: 999px; cursor: pointer;
}
.sheet-done:active { transform: scale(0.98); }
.clear-chat-btn {
  background: rgba(255,69,58,0.14); border: 1px solid rgba(255,69,58,0.4);
  color: #ff6b6b; font-family: var(--font-rounded); font-size: 15px; font-weight: 700;
  padding: 13px 16px; border-radius: 14px; cursor: pointer;
}
.clear-chat-btn:active { transform: scale(0.98); }
.clear-chat-btn.busy { opacity: 0.6; pointer-events: none; }

/* voice message bubble */
.bubble audio { display: block; margin-top: 6px; width: 240px; max-width: 60vw; height: 38px; }
.bubble .audio-label { font-size: 12px; opacity: 0.75; display: flex; align-items: center; gap: 6px; }
.reaction-badge {
  align-self: flex-end; margin: -8px 8px 0; font-size: 15px; line-height: 1;
  background: var(--ai-gray); border-radius: 999px; padding: 3px 6px; border: 2px solid var(--deep-space);
}
.row.user .reaction-badge { align-self: flex-start; }
.bubble { cursor: default; user-select: text; }
.row .bubble { position: relative; }

/* reply preview inside a bubble */
.reply-preview {
  font-size: 12px; opacity: 0.8; border-left: 2px solid rgba(255,255,255,0.5);
  padding: 2px 0 2px 8px; margin-bottom: 5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* message action menu (right-click / long-press) */
.msg-menu {
  position: fixed; z-index: 400; background: #201b2c; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px; padding: 6px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 4px; min-width: 150px;
}
.msg-menu-reactions { display: flex; gap: 2px; padding: 4px; }
.msg-menu-reactions button { background: none; border: none; cursor: pointer; font-size: 21px; padding: 4px; border-radius: 8px; line-height: 1; }
.msg-menu-reactions button:hover, .msg-menu-reactions button.active { background: rgba(255,255,255,0.12); transform: scale(1.15); }
.msg-menu-action { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; color: #fff; font-family: var(--font-rounded); font-size: 15px; font-weight: 500; padding: 10px 12px; border-radius: 10px; text-align: left; }
.msg-menu-action:hover { background: rgba(255,255,255,0.08); }
.msg-menu-scrim { position: fixed; inset: 0; z-index: 399; }

/* reply banner above composer */
.reply-banner {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: rgba(11,11,16,0.9); border-top: 1px solid rgba(255,255,255,0.06);
}
.reply-banner-bar { width: 3px; align-self: stretch; background: var(--violet); border-radius: 2px; }
.reply-banner-text { flex: 1; font-size: 13px; color: rgba(255,255,255,0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-banner-close { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 15px; }

/* connecting overlay */
.connecting {
  position: absolute; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  background: rgba(11,11,16,0.85); backdrop-filter: blur(6px); color: rgba(255,255,255,0.7);
  font-size: 14px; font-weight: 600;
}
.connecting.is-open { display: flex; }
.connecting .spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.2); border-top-color: var(--violet); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chat-error-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,69,58,0.9); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 14px; text-align: center;
}

.messages {
  position: relative; z-index: 1;
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 14px 8px;
}

/* Intro card shown for an empty conversation */
.chat-intro { text-align: center; padding: 24px 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.chat-intro img { width: 118px; height: 118px; border-radius: 26px; object-fit: cover; }
.chat-intro-name { font-size: 22px; font-weight: 800; }
.chat-intro-back { font-size: 14px; color: rgba(255,255,255,0.6); line-height: 1.5; max-width: 320px; }

.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.ai { justify-content: flex-start; }
.bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 20px;
  font-size: 16px; line-height: 1.38; white-space: pre-wrap; word-wrap: break-word;
}
.row.user .bubble { background: var(--ios-blue); color: #fff; border-bottom-right-radius: 6px; }
.row.ai .bubble { background: var(--ai-gray); color: #fff; border-bottom-left-radius: 6px; }

/* tic-tac-toe game card */
.ttt-card { align-self: flex-start; max-width: 300px; background: var(--ai-gray); border-radius: 18px; padding: 14px; margin: 2px 0; }
.ttt-title { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.7); margin-bottom: 2px; }
.ttt-stats { font-size: 11px; color: rgba(255,255,255,0.45); margin-bottom: 8px; min-height: 13px; }
.ttt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ttt-cell { aspect-ratio: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; font-size: 30px; font-weight: 800; color: #fff; cursor: pointer; font-family: var(--font-rounded); display: grid; place-items: center; }
.ttt-cell:hover:not(.filled) { background: rgba(138,92,255,0.2); }
.ttt-cell.filled { cursor: default; }
.ttt-status { font-size: 14px; font-weight: 600; margin-top: 10px; text-align: center; }
.ttt-again { margin-top: 10px; width: 100%; padding: 9px; border-radius: 10px; border: none; background: rgba(255,255,255,0.1); color: #fff; font-family: var(--font-rounded); font-weight: 600; font-size: 13px; cursor: pointer; }
.ttt-again:active { transform: scale(0.98); }

/* typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.bubble.typing-label { font-size: 14px; color: rgba(255,255,255,0.75); display: flex; align-items: center; gap: 6px; }
.bubble.typing-label .typing { padding: 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.55);
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.composer {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(11, 11, 16, 0.72);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.composer-attach { width: 38px; height: 44px; flex: none; display: grid; place-items: center; cursor: pointer; color: rgba(255,255,255,0.55); }
.composer-attach:active { transform: scale(0.9); }
.attach-preview { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: rgba(11,11,16,0.9); border-top: 1px solid rgba(255,255,255,0.06); }
.attach-preview img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.attach-label { flex: 1; font-size: 13px; color: rgba(255,255,255,0.7); }
.attach-remove { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 15px; }
.composer-input {
  flex: 1; height: 44px; padding: 0 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px; color: #fff; font-family: var(--font-rounded); font-size: 16px;
}
.composer-input::placeholder { color: rgba(255, 255, 255, 0.4); }
.composer-input:focus { outline: none; border-color: rgba(138, 92, 255, 0.5); }
.composer-send {
  width: 44px; height: 44px; flex: none; border: none; cursor: pointer;
  border-radius: 50%; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--love-pink), var(--violet), var(--ocean));
  box-shadow: 0 6px 14px rgba(138, 92, 255, 0.35);
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.composer-send:active { transform: scale(0.92); }
.composer-send:disabled { opacity: 0.5; cursor: default; }

/* ===================== DESKTOP / TABLET EXPANSION ===================== */
@media (min-width: 900px) {
  .landing-content {
    display: grid;
    grid-template-columns: minmax(320px, 440px) minmax(340px, 430px);
    grid-template-areas:
      "logo headings"
      "logo actions"
      "logo auth";
    align-content: center;
    justify-content: center;
    align-items: center;
    column-gap: clamp(56px, 8vw, 130px);
    row-gap: 16px;
    min-height: 100%;
    padding: 32px clamp(48px, 7vw, 120px);
    text-align: left;
  }

  .landing-logo-wrap { grid-area: logo; margin-top: 0; }
  .landing-headings { grid-area: headings; width: 100%; }
  .landing-actions { grid-area: actions; max-width: 430px; margin-top: 0; }
  .auth-panel { grid-area: auth; max-width: 430px; }
  .landing-logo { width: clamp(230px, 24vw, 330px); }
  .landing-title { font-size: clamp(58px, 5vw, 78px); }
  .landing-tagline { max-width: 430px; font-size: 18px; }

  .ob {
    width: min(860px, calc(100% - 72px));
    margin: 0 auto;
    padding: 26px 0 calc(20px + env(safe-area-inset-bottom));
  }
  .ob-body, .ob-nav { width: min(760px, 100%); align-self: center; }
  .ob-title { font-size: 34px; }

  .chars-header,
  .companion-card,
  .search,
  .discover-row,
  .char-grid {
    width: min(1220px, calc(100% - 72px));
    margin-left: auto;
    margin-right: auto;
  }
  .chars-header { padding-top: 42px; }
  .chars-settings { right: max(36px, calc((100% - 1220px) / 2)); top: 42px; }
  .chars-title { font-size: 42px; }
  .companion-card { margin-top: 22px; border-radius: 18px; }
  .search { margin-top: 20px; }
  .discover-row { margin-top: 28px; }
  .char-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 30px 20px;
    padding-bottom: 52px;
  }
  .char-photo { height: auto; aspect-ratio: 3 / 4; border-radius: 16px; }

  .sub-header,
  .chat-header,
  .reply-banner,
  .attach-preview,
  .composer {
    padding-left: max(22px, calc((100vw - 1040px) / 2));
    padding-right: max(22px, calc((100vw - 1040px) / 2));
  }

  .sub-header {
    min-height: 70px;
    padding-top: 16px;
  }
  .sub-title { font-size: 24px; }

  #settings-scroll,
  #paywall-scroll,
  #memory-scroll,
  #credits-scroll {
    width: min(1120px, calc(100% - 72px));
    margin: 0 auto;
    padding: 26px 0 56px;
  }

  #settings-scroll {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
    align-content: start;
  }
  .settings-group { margin-bottom: 0; }
  .settings-card { border-radius: 14px; }
  .appearance-slots { max-width: 520px; }

  #paywall-scroll {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
  }
  .pw-hero,
  .pw-section-title,
  .pw-addon-list,
  #pw-credits,
  #pw-manage,
  #pw-status {
    grid-column: 1 / -1;
  }
  .pw-hero { padding: 18px 0 6px; }
  .pw-plan { margin-top: 0; border-radius: 14px; }
  .pw-addon-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .pw-addon { border-radius: 14px; }

  #credits-scroll {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
  }
  #credits-scroll .pw-hero,
  #credits-scroll .settings-status {
    grid-column: 1 / -1;
  }

  #memory-scroll {
    max-width: 920px;
  }
  .mem-days { border-radius: 16px; }

  .chat-header {
    min-height: 72px;
    padding-top: 16px;
  }
  .chat-avatar { width: 44px; height: 44px; }
  .chat-name { font-size: 18px; }
  .messages {
    padding: 24px max(22px, calc((100vw - 1040px) / 2)) 12px;
    gap: 12px;
  }
  .chat-intro { padding-top: 42px; }
  .bubble { max-width: min(68%, 690px); }
  .bubble audio { max-width: 420px; }

  .composer {
    min-height: 70px;
    padding-top: 12px;
    padding-bottom: 14px;
  }
  .composer-input { height: 46px; }

  .sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    width: min(540px, calc(100% - 48px));
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.10);
    transform: translate(-50%, calc(100% + 40px));
    padding-bottom: 24px;
  }
  .sheet.is-open { transform: translate(-50%, 0); }

  .call-inner {
    width: min(560px, 100%);
    margin: auto;
    flex: none;
  }

  .chat-error-banner {
    top: 84px;
    left: 50%;
    right: auto;
    width: min(760px, calc(100% - 48px));
    transform: translateX(-50%);
    border-radius: 14px;
  }
}

@media (min-width: 1200px) {
  #settings-scroll {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* scrollbars (desktop) */
.scroll::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 0; }

/* =============================================================
   POLISH & MOTION LAYER
   Additive refinements on top of the ported design: ambient motion,
   entrance choreography, hover/focus feedback, and small fixes.
   Same tokens, same theme — everything below only layers on.
   ============================================================= */

:root {
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- shared keyframes ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes logoFloat { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1.5deg); } }
@keyframes glowBreathe { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes blobDriftA { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(7vmax, 5vmax, 0) scale(1.12); } }
@keyframes blobDriftB { from { transform: translate3d(0, 0, 0) scale(1.08); } to { transform: translate3d(-6vmax, -5vmax, 0) scale(0.96); } }

/* ---- global refinements ---- */
::selection { background: rgba(138, 92, 255, 0.45); color: #fff; }
button, label, select { touch-action: manipulation; }
button:focus-visible, label:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid rgba(138, 92, 255, 0.65);
  outline-offset: 2px;
}
.scroll, .messages { overscroll-behavior: contain; }

body {
  background:
    radial-gradient(900px 600px at 50% -10%, rgba(138, 92, 255, 0.10), transparent 65%),
    radial-gradient(700px 500px at 85% 110%, rgba(46, 162, 255, 0.07), transparent 60%),
    #050507;
}
@media (min-width: 480px) and (max-width: 699px) {
  .device {
    box-shadow:
      0 30px 90px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(255, 255, 255, 0.05),
      0 0 80px rgba(138, 92, 255, 0.12);
  }
}

/* screen switch: a touch more travel, same spring */
.screen.is-active { animation: screenIn 0.34s var(--ease-spring); }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px) scale(0.992); } to { opacity: 1; transform: none; } }

/* consistent focus ring + smooth borders on every text control */
.name-field, .auth-input, .ob-input, .ob-select, .ob-textarea,
.settings-input, .settings-select, .settings-textarea,
.composer-input, .model-select, .search {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.name-field:focus, .auth-input:focus, .ob-input:focus, .ob-select:focus, .ob-textarea:focus,
.settings-input:focus, .settings-select:focus, .settings-textarea:focus,
.composer-input:focus, .model-select:focus, .search:focus-within {
  border-color: rgba(138, 92, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(138, 92, 255, 0.16);
}

/* base transitions so hover/active feedback animates both ways */
.auth-google, .auth-primary, .auth-secondary, .ob-back, .ob-next, .pw-cta, .sheet-done,
.import-btn, .ob-import-btn, .settings-action, .clear-chat-btn, .ttt-again, .call-btn,
.mem-mini, .mem-chip, .reply-banner-close, .attach-remove, .composer-attach,
.msg-menu-reactions button, .msg-menu-action {
  transition: transform 0.16s var(--ease-spring), background 0.18s ease, box-shadow 0.2s ease,
    filter 0.2s ease, color 0.18s ease, border-color 0.18s ease;
}
.chars-settings, .chat-gear, .chat-call, .chat-back {
  transition: transform 0.25s var(--ease-spring), background 0.2s ease, color 0.2s ease;
}
.companion-card { transition: transform 0.22s var(--ease-spring), background 0.2s ease, border-color 0.2s ease, box-shadow 0.25s ease; }
.chevron { transition: transform 0.22s var(--ease-spring), color 0.2s ease; }
.char-photo { transition: transform 0.3s var(--ease-spring), box-shadow 0.3s ease, filter 0.3s ease; }
.pw-plan, .pw-addon { transition: transform 0.25s var(--ease-spring), border-color 0.25s ease, box-shadow 0.25s ease; }
.appearance-img { transition: border-color 0.2s ease, background 0.2s ease; }
.search-icon { transition: color 0.2s ease; }
.search:focus-within .search-icon { color: var(--violet); }

/* ---- ambient drifting glow blobs behind every screen ---- */
.landing-bg::before, .landing-bg::after,
.space-bg::before, .space-bg::after,
.chat-bg::before, .chat-bg::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}
.landing-bg::before {
  width: 55vmax; height: 55vmax; left: -18vmax; top: -18vmax;
  background: radial-gradient(circle, rgba(138, 92, 255, 0.16), transparent 65%);
  animation: blobDriftA 26s ease-in-out infinite alternate;
}
.landing-bg::after {
  width: 48vmax; height: 48vmax; right: -16vmax; bottom: -16vmax;
  background: radial-gradient(circle, rgba(46, 162, 255, 0.13), transparent 65%);
  animation: blobDriftB 32s ease-in-out infinite alternate;
}
.space-bg::before {
  width: 50vmax; height: 50vmax; left: -20vmax; top: -12vmax;
  background: radial-gradient(circle, rgba(138, 92, 255, 0.13), transparent 65%);
  animation: blobDriftA 30s ease-in-out infinite alternate;
}
.space-bg::after {
  width: 44vmax; height: 44vmax; right: -18vmax; bottom: -14vmax;
  background: radial-gradient(circle, rgba(255, 105, 199, 0.08), transparent 65%);
  animation: blobDriftB 36s ease-in-out infinite alternate;
}
.chat-bg::before {
  width: 46vmax; height: 46vmax; left: -16vmax; top: -14vmax;
  background: radial-gradient(circle, rgba(138, 92, 255, 0.12), transparent 65%);
  animation: blobDriftB 34s ease-in-out infinite alternate;
}
.chat-bg::after {
  width: 44vmax; height: 44vmax; right: -16vmax; bottom: -14vmax;
  background: radial-gradient(circle, rgba(46, 162, 255, 0.10), transparent 65%);
  animation: blobDriftA 40s ease-in-out infinite alternate;
}

/* ---- landing ---- */
.landing-content > * { animation: fadeUp 0.55s var(--ease-spring) backwards; }
.landing-content > :nth-child(1) { animation-delay: 0.05s; }
.landing-content > :nth-child(2) { animation-delay: 0.13s; }
.landing-content > :nth-child(3) { animation-delay: 0.21s; }
.landing-content > :nth-child(4) { animation-delay: 0.29s; }
.landing-content > :nth-child(5) { animation-delay: 0.37s; }
.landing-logo { animation: logoFloat 7s ease-in-out infinite; }
.glow--violet { animation: glowBreathe 6s ease-in-out infinite; }
.glow--ocean { animation: glowBreathe 6s ease-in-out 3s infinite; }
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .landing-title {
    background: linear-gradient(100deg, #fff 12%, #ffd6ef 32%, var(--love-pink) 48%, var(--violet) 66%, var(--ocean) 86%, #bfe2ff 98%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--violet);
    animation: titleSheen 9s ease-in-out infinite alternate;
  }
}
@keyframes titleSheen { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
.auth-panel { backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }

/* ---- onboarding ---- */
#ob-body > * { animation: fadeUp 0.45s var(--ease-spring) backwards; }
#ob-body > :nth-child(2) { animation-delay: 0.05s; }
#ob-body > :nth-child(3) { animation-delay: 0.1s; }
#ob-body > :nth-child(4) { animation-delay: 0.15s; }
#ob-body > :nth-child(5) { animation-delay: 0.2s; }
#ob-body > :nth-child(6) { animation-delay: 0.25s; }
#ob-body > :nth-child(7) { animation-delay: 0.3s; }
#ob-body > :nth-child(8) { animation-delay: 0.35s; }
.ob-hero img { animation: logoFloat 7s ease-in-out infinite; }
.ob-progress-fill { position: relative; overflow: hidden; }
.ob-progress-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, 0.55) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: progressSheen 2.8s ease-in-out infinite;
}
@keyframes progressSheen { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }

/* ---- character gallery ---- */
.chars-header { animation: fadeUp 0.5s var(--ease-spring) backwards; }
.companion-card { animation: fadeUp 0.5s 0.06s var(--ease-spring) backwards; }
.search { animation: fadeUp 0.5s 0.12s var(--ease-spring) backwards; }
.discover-row { animation: fadeUp 0.5s 0.18s var(--ease-spring) backwards; }
.char-card { animation: fadeUp 0.45s var(--ease-spring) backwards; }
.char-card:nth-child(1) { animation-delay: 0.06s; }
.char-card:nth-child(2) { animation-delay: 0.1s; }
.char-card:nth-child(3) { animation-delay: 0.14s; }
.char-card:nth-child(4) { animation-delay: 0.18s; }
.char-card:nth-child(5) { animation-delay: 0.22s; }
.char-card:nth-child(6) { animation-delay: 0.26s; }
.char-card:nth-child(7) { animation-delay: 0.3s; }
.char-card:nth-child(8) { animation-delay: 0.34s; }
.char-empty {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 36px 16px;
}
.char-empty::before { content: "🔭"; display: block; font-size: 34px; margin-bottom: 10px; }

/* ---- chat ---- */
.messages .row:last-child { animation: bubbleIn 0.32s var(--ease-pop) backwards; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
.row.user { transform-origin: 90% 100%; }
.row.ai { transform-origin: 10% 100%; }
.row.user .bubble {
  background: linear-gradient(180deg, #1a95ff, var(--ios-blue));
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.28);
}
.row.ai .bubble {
  background: linear-gradient(180deg, #32323a, var(--ai-gray));
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.row.ai .bubble.err {
  background: rgba(255, 69, 58, 0.14);
  border-color: rgba(255, 69, 58, 0.4);
  color: #ffb4ae;
  box-shadow: none;
}
.chat-intro { animation: fadeUp 0.5s var(--ease-spring); }
.chat-intro img { box-shadow: 0 16px 40px rgba(138, 92, 255, 0.25); }
.chat-avatar { border: 1.5px solid rgba(255, 255, 255, 0.14); box-shadow: 0 0 0 2px rgba(138, 92, 255, 0.18); }
.chat-status { display: inline-flex; align-items: center; gap: 5px; }
.chat-status::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 6px rgba(48, 209, 88, 0.8);
  animation: onlinePulse 2.6s ease-in-out infinite;
}
@keyframes onlinePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.typing span { animation: typingBounce 1.2s infinite both; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.reply-banner:not([hidden]), .attach-preview:not([hidden]) { animation: fadeUp 0.25s var(--ease-spring); }
.msg-menu { animation: popIn 0.18s var(--ease-pop); }
.chat-error-banner { animation: popIn 0.3s var(--ease-spring); }
.composer-send svg { transition: transform 0.2s var(--ease-pop); }
.sheet { box-shadow: 0 -24px 70px rgba(0, 0, 0, 0.55); }

/* ---- voice call overlay ---- */
.call-inner > * { animation: fadeUp 0.5s var(--ease-spring) backwards; }
.call-inner > :nth-child(2) { animation-delay: 0.07s; }
.call-inner > :nth-child(3) { animation-delay: 0.14s; }
.call-inner > :nth-child(4) { animation-delay: 0.21s; }
.call-inner > :nth-child(5) { animation-delay: 0.28s; }
.call-inner > :nth-child(6) { animation-delay: 0.35s; }

/* ---- settings / paywall / memory ---- */
#settings-scroll > .settings-group { animation: fadeUp 0.45s var(--ease-spring) backwards; }
#settings-scroll > .settings-group:nth-child(2) { animation-delay: 0.04s; }
#settings-scroll > .settings-group:nth-child(3) { animation-delay: 0.08s; }
#settings-scroll > .settings-group:nth-child(4) { animation-delay: 0.12s; }
#settings-scroll > .settings-group:nth-child(5) { animation-delay: 0.16s; }
#settings-scroll > .settings-group:nth-child(6) { animation-delay: 0.2s; }
#settings-scroll > .settings-group:nth-child(7) { animation-delay: 0.24s; }
#settings-scroll > .settings-group:nth-child(8) { animation-delay: 0.28s; }
#settings-scroll > .settings-group:nth-child(9) { animation-delay: 0.32s; }
#settings-scroll > .settings-group:nth-child(10) { animation-delay: 0.36s; }
#paywall-scroll, #credits-scroll, #memory-scroll { animation: fadeUp 0.45s 0.05s var(--ease-spring) backwards; }
.pw-plan.featured { position: relative; }
.pw-plan.featured::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 30px rgba(138, 92, 255, 0.35), inset 0 0 22px rgba(138, 92, 255, 0.12);
  animation: featuredGlow 3.2s ease-in-out infinite;
}
@keyframes featuredGlow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.pw-crown { display: inline-block; animation: crownFloat 5s ease-in-out infinite; }
@keyframes crownFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.mem-days-flame { display: inline-block; animation: flameFlicker 2.8s ease-in-out infinite; }
@keyframes flameFlicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  30% { transform: scale(1.08) rotate(2deg); }
  60% { transform: scale(0.98) rotate(-1deg); }
}

/* ---- connecting overlay: fade instead of snap ---- */
.connecting {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.connecting.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}
@supports (mask: radial-gradient(#000, transparent)) or (-webkit-mask: radial-gradient(#000, transparent)) {
  .connecting .spinner {
    border: none;
    background: conic-gradient(from 0deg, rgba(138, 92, 255, 0), var(--violet) 55%, var(--love-pink) 85%, rgba(255, 105, 199, 0));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  }
}

/* ---- hover feedback (mouse/trackpad only — keeps touch clean) ---- */
@media (hover: hover) and (pointer: fine) {
  .btn:hover, .auth-google:hover, .auth-primary:hover, .ob-next:hover,
  .import-btn:hover, .ob-import-btn:hover, .sheet-done:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
  }
  .pw-cta:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow: 0 10px 24px rgba(138, 92, 255, 0.45);
  }
  .auth-google:hover { box-shadow: 0 8px 20px rgba(255, 255, 255, 0.12); }
  .auth-secondary:hover:not(:disabled), .ob-back:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
  .composer-send:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 8px 22px rgba(138, 92, 255, 0.5);
  }
  .composer-send:hover:not(:disabled) svg { transform: translateX(1px) translateY(-1px); }
  .composer-attach:hover { color: #fff; transform: scale(1.08); }
  .chars-settings:hover { background: rgba(255, 255, 255, 0.14); transform: rotate(45deg); }
  .chat-gear:hover, .chat-call:hover { background: rgba(255, 255, 255, 0.14); transform: scale(1.06); }
  .chat-back:hover { transform: translateX(-2px); }
  .companion-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(138, 92, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  }
  .companion-card:hover .chevron { transform: translateX(3px); color: rgba(255, 255, 255, 0.6); }
  .char-card:hover .char-photo {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 18px 36px rgba(138, 92, 255, 0.25);
    filter: brightness(1.06) saturate(1.06);
  }
  .settings-action:hover { background: rgba(255, 255, 255, 0.05); }
  .settings-action.danger:hover { background: rgba(255, 69, 58, 0.08); }
  .mem-mini:hover { background: rgba(255, 255, 255, 0.12); }
  .mem-chip:hover { background: rgba(138, 92, 255, 0.3); transform: translateY(-1px); }
  .pw-plan:hover, .pw-addon:hover {
    transform: translateY(-3px);
    border-color: rgba(138, 92, 255, 0.4);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  }
  .appearance-slot:hover .appearance-img { border-color: rgba(138, 92, 255, 0.55); background: rgba(138, 92, 255, 0.08); }
  .reply-banner-close:hover, .attach-remove:hover { color: #fff; }
  .call-mute:hover { background: rgba(255, 255, 255, 0.22); }
  .call-end:hover { filter: brightness(1.1); transform: scale(1.05); }
  .ttt-again:hover { background: rgba(255, 255, 255, 0.16); }
  .clear-chat-btn:hover { background: rgba(255, 69, 58, 0.2); }

  /* slim, theme-matched scrollbars on pointer devices */
  .scroll, .messages { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
  .scroll::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 9px; }
  .scroll::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track { background: transparent; }
  .scroll::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    border: 3px solid transparent;
    background-clip: content-box;
  }
  .scroll::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.28);
  }
}

/* ---- reduced motion: everything appears instantly, nothing drifts ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
