/* Bundled (latin subset) because the CSP only allows same-origin fonts. */
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 400 800; font-display: swap; src: url(fonts/plus-jakarta-sans.woff2) format('woff2'); }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: italic; font-weight: 400 800; font-display: swap; src: url(fonts/plus-jakarta-sans-italic.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 500; font-display: swap; src: url(fonts/fraunces-italic.woff2) format('woff2'); }
:root {
  color-scheme: light;
  --bg: #fbf7f4;
  --surface: #ffffff;
  --surface-2: #f4edf0;
  --text: #2b2232;
  --muted: #7d7183;
  --line: #ece2e6;
  /* Color theme (picked in the account sheet): three gradient stops and a base accent. */
  --g1: #ff8a5c; --g2: #ec4f7f; --g3: #8b52e0; --accent-base: #d6406f;
  --accent: color-mix(in srgb, var(--accent-base) 90%, black);
  --grad: linear-gradient(135deg, var(--g1) 0%, var(--g2) 50%, var(--g3) 100%);
  --accent-shadow: color-mix(in srgb, var(--accent-base) 28%, transparent);
  --on-accent: #ffffff;
  --danger: #c84848;
  --ok: #3fae74;
  --shadow: 0 10px 30px #4a1f3a14;
  --backdrop: #1b102188;
  --glow-a: color-mix(in srgb, var(--g1) 22%, var(--bg));
  --glow-b: color-mix(in srgb, var(--g3) 18%, var(--bg));
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16121c;
    --surface: #211b29;
    --surface-2: #2c2436;
    --text: #f3edf5;
    --muted: #a99cb2;
    --line: #352c40;
    --accent: color-mix(in srgb, var(--accent-base) 62%, white);
    --shadow: 0 10px 30px #00000055;
    --backdrop: #000000aa;
    --glow-a: color-mix(in srgb, var(--g1) 18%, #16121c);
    --glow-b: color-mix(in srgb, var(--g3) 16%, #16121c);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16121c;
  --surface: #211b29;
  --surface-2: #2c2436;
  --text: #f3edf5;
  --muted: #a99cb2;
  --line: #352c40;
  --accent: color-mix(in srgb, var(--accent-base) 62%, white);
  --shadow: 0 10px 30px #00000055;
  --backdrop: #000000aa;
  --glow-a: color-mix(in srgb, var(--g1) 18%, #16121c);
  --glow-b: color-mix(in srgb, var(--g3) 16%, #16121c);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font-size: 15px; line-height: 1.6; overflow: hidden; background: var(--bg); color: var(--text); }
button, textarea, input, select { font: inherit; color: inherit; }
button { cursor: pointer; transition: background .18s, color .18s, border-color .18s, transform .12s; }
button:active:not(:disabled) { transform: scale(.97); }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); }

/* ---------- shared ---------- */
.eyebrow { margin: 0; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.wordmark { margin: 0; font-family: var(--display); font-style: italic; font-weight: 500; font-size: 48px; letter-spacing: -1px; line-height: 1.15;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark.small { font-size: 26px; letter-spacing: -.4px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 20px; border: 0; border-radius: 14px; padding: 14px 18px;
  background: var(--grad); color: var(--on-accent); font-size: 15px; font-weight: 600; box-shadow: 0 8px 20px var(--accent-shadow); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-primary.danger { background: var(--danger); box-shadow: none; }
.btn-google { background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn-google svg { width: 20px; height: 20px; flex: none; }
.btn-secondary { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--surface-2); color: var(--text); font-weight: 500; }
.btn-secondary:hover:not(:disabled) { filter: brightness(.97); }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary.danger { color: var(--danger); }
.btn-ghost { display: inline-block; color: var(--muted); font-size: 13px; text-underline-offset: 4px; margin-top: 16px; }
.icon-btn { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 12px; font-size: 22px; line-height: 1; }
.icon-btn svg { width: 20px; height: 20px; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--surface-2); color: var(--accent); }
.disclosure { flex: none; margin: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); font-size: 11px; text-align: center; color: var(--muted); }
.disclosure a { color: var(--muted); text-underline-offset: 3px; margin-left: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 200; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 11px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 13px; box-shadow: var(--shadow); animation: arrive .2s ease-out both; }

/* ---------- welcome overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; background: var(--bg); }
.overlay.welcome { background: radial-gradient(60% 45% at 15% 10%, var(--glow-a), transparent 70%), radial-gradient(55% 45% at 90% 90%, var(--glow-b), transparent 70%), var(--bg); }
.gate-card { width: 100%; max-width: 400px; padding: 28px 8px; text-align: center; animation: arrive .35s ease-out both; }
.brand-orb { display: flex; justify-content: center; margin-bottom: 18px; }
.brand-orb span { width: 56px; height: 56px; margin: 0 -9px; border-radius: 50%; border: 3px solid var(--bg); box-shadow: var(--shadow); }
.brand-orb span:nth-child(1) { background: linear-gradient(135deg, #ffc46b, #ff7a59); }
.brand-orb span:nth-child(2) { background: var(--grad); transform: translateY(-8px); z-index: 1; }
.brand-orb span:nth-child(3) { background: linear-gradient(135deg, #5ee0c4, #3a8ee6); }
.gate-sub { color: var(--muted); margin: 8px 0 26px; font-size: 15px; }
.login-status { margin: 0; color: var(--muted); font-size: 13px; }
.fine { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.gate-notice { padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: left; box-shadow: var(--shadow); }
.gate-notice p { margin: 0; font-size: 13px; color: var(--muted); }
.gate-notice p + p { margin-top: 8px; }
.gate-notice strong { font-weight: 600; color: var(--text); }

/* ---------- screens ---------- */
.screen { display: flex; flex-direction: column; min-height: 0; height: 100dvh; max-width: 920px; margin: 0 auto; background: var(--bg); }

/* home */
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px; }
.credit-pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
.credit-pill .spark { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.account-initial { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: var(--on-accent); font-size: 14px; }
.home-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px; }
.home-hero { padding: 14px 2px 18px; }
.home-hero h2 { margin: 4px 0 0; font-size: 25px; line-height: 1.25; letter-spacing: -.6px; font-weight: 800; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 14px; padding-bottom: 18px; }
.avatar-card { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: 22px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); animation: arrive .3s ease-out both; }
.card-open { display: flex; flex-direction: column; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.card-photo { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 4 / 5; overflow: hidden;
  background: linear-gradient(160deg, hsl(var(--hue, 330) 75% 74%), hsl(calc(var(--hue, 330) + 50) 55% 48%)); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.card-open:hover .card-photo img { transform: scale(1.04); }
.card-photo[data-initial] { background: radial-gradient(80% 60% at 30% 20%, #ffffff55, transparent 60%), radial-gradient(70% 50% at 80% 100%, hsl(calc(var(--hue, 330) + 80) 70% 60% / .7), transparent 70%),
  linear-gradient(160deg, hsl(var(--hue, 330) 75% 70%), hsl(calc(var(--hue, 330) + 50) 55% 45%)); }
.card-photo[data-initial]::after { content: attr(data-initial); color: #fffffff2; font-family: var(--display); font-style: italic; font-size: 72px; text-shadow: 0 6px 24px #00000033; }
.card-body { flex: 1; padding: 11px 13px 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-head h3 { margin: 0; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head time { flex: none; color: var(--muted); font-size: 11px; }
.card-preview { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-delete { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: #1b102140; color: #ffffffd9; backdrop-filter: blur(6px); opacity: .8; }
.card-delete:hover { opacity: 1; background: var(--danger); }
.card-delete svg { width: 13px; height: 13px; stroke-linecap: round; stroke-linejoin: round; }
.create-card { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; padding: 14px 16px; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); box-shadow: none; text-align: left; color: var(--text); }
.create-card:hover { border-style: solid; }
.create-card .plus { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--grad); color: var(--on-accent); box-shadow: 0 8px 20px var(--accent-shadow); }
.create-card .plus svg { width: 22px; height: 22px; stroke-linecap: round; }
.create-text { display: flex; flex-direction: column; min-width: 0; }
.create-card strong { font-size: 15px; }
.create-text span { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* chat header */
.chat-top { display: flex; align-items: center; flex: none; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px 6px;
  border-bottom: 1px solid var(--line); background: var(--surface); }
.avatar-wrap { position: relative; flex: none; }
.avatar { display: block; width: 44px; height: 44px; object-fit: cover; border-radius: 50%; }
.avatar-monogram { display: grid; place-items: center; color: #fff; font-family: var(--display); font-style: italic; font-size: 22px;
  background: linear-gradient(160deg, hsl(var(--hue, 330) 75% 70%), hsl(calc(var(--hue, 330) + 50) 55% 48%)); }
.presence { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.who { flex: 1; min-width: 0; margin-left: 4px; }
.name { font-size: 17px; font-weight: 650; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 2px; }
#autophoto { display: flex; justify-content: center; gap: 6px; width: auto; padding: 0 10px; }
.toggle-label { font-size: 12px; white-space: nowrap; }
#photo-state { font-weight: 600; }
.strike { display: none; }
#autophoto:not(.active) .strike { display: inline; }

/* conversation */
.log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px 16px 22px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.msg { flex: none; max-width: 80%; padding: 11px 15px 8px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: 15px; animation: arrive .2s ease-out both; }
.msg.her { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: 0 2px 6px #4a1f3a0a; }
.msg.him { align-self: flex-end; background: var(--grad); color: var(--on-accent); border-bottom-right-radius: 6px; box-shadow: 0 6px 16px var(--accent-shadow); }
.msg.err { align-self: center; max-width: 95%; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); border-radius: 12px; font-size: 13px; padding: 8px 14px; }
.cue { color: var(--accent); font-style: italic; font-size: .93em; opacity: .9; }
.msg-time { display: block; margin-top: 2px; text-align: right; font-size: 10.5px; opacity: .6; white-space: nowrap; }
.speech-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; white-space: normal; }
.speech-controls button { display: inline-flex; align-items: center; gap: 5px; flex: none; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--accent); font-size: 11.5px; font-weight: 600; padding: 3px 10px; line-height: 1.6; }
.speech-controls button:hover { filter: brightness(.96); }
.speech-controls button:disabled { opacity: .7; cursor: wait; }
.chip-listen::before, .chip-photo::before { content: ''; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.chip-listen { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 4l13 8-13 8z'/%3E%3C/svg%3E"); }
.chip-photo { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M3 7h4l2-3h6l2 3h4v13H3zM12 9.5a4 4 0 100 8 4 4 0 000-8z'/%3E%3C/svg%3E"); }
.speech-controls .image-generating::before { width: 11px; height: 11px; background: none; -webkit-mask: none; mask: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: image-spin .8s linear infinite; }
@keyframes image-spin { to { transform: rotate(360deg); } }
.speech-controls span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.msg.photo { width: 240px; max-width: 70%; padding: 5px; border-radius: 20px; border-bottom-left-radius: 6px; }
.msg.photo button { display: block; width: 100%; padding: 0; border: 0; border-radius: 15px; background: transparent; cursor: zoom-in; }
.msg.photo img { display: block; width: 100%; height: auto; border-radius: 15px; }
.cap { display: block; color: var(--muted); font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; padding: 6px 8px 3px; }
.typing { display: flex; flex: none; align-self: flex-start; gap: 5px; border: 1px solid var(--line); border-radius: 20px 20px 20px 6px; background: var(--surface); padding: 16px 18px; }
.typing span { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; animation: pulse 1.3s infinite; }
.typing span:nth-child(2) { animation-delay: .16s; }
.typing span:nth-child(3) { animation-delay: .32s; }
@keyframes pulse { 0%, 65%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* composer */
#composer { display: flex; align-items: flex-end; flex: none; gap: 4px; margin: 0 12px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); transition: border-color .2s; }
#composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
#input { flex: 1; width: 0; min-width: 0; max-height: 128px; resize: none; padding: 9px 6px; border: none; outline: none; background: transparent; color: var(--text); line-height: 1.45; font-size: 16px; }
#input::placeholder { color: var(--muted); }
#input:focus-visible { outline: none; }
.composer-btn { width: 40px; height: 40px; border-radius: 50%; }
#send { display: grid; place-items: center; flex: none; width: 42px; height: 42px; background: var(--grad); color: var(--on-accent); border: 0; border-radius: 50%; box-shadow: 0 6px 14px var(--accent-shadow); }
#send svg { width: 20px; height: 20px; stroke-linecap: round; stroke-linejoin: round; }
#send:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; cursor: default; }
.scenes { flex: none; display: flex; gap: 8px; margin: 0 12px 10px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: none; }
.scenes button { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--accent); border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 500; }
.scenes button:hover { background: var(--surface-2); }

/* prompt mode (developer tool) */
.msg.prompt { max-width: 95%; padding: 14px; }
.prompt-block + .prompt-block { margin-top: 14px; }
.prompt-label { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.prompt-label button { margin-left: auto; border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; background: var(--surface-2); color: var(--accent); font-size: 11px; }
.prompt-text { padding: 12px; background: var(--bg); border-radius: 10px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; line-height: 1.6; }

/* ---------- sheets ---------- */
dialog.sheet { width: 100%; max-width: 520px; max-height: 92dvh; margin: auto auto 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); overflow: auto;
  border: 0; border-radius: 26px 26px 0 0; background: var(--surface); color: var(--text); box-shadow: 0 -10px 40px #00000026; }
dialog.sheet[open] { animation: sheet-up .25s ease-out both; }
dialog.sheet::backdrop { background: var(--backdrop); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.sheet h3 { margin: 22px 0 10px; font-size: 14px; font-weight: 650; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.sheet label { display: block; margin: 14px 0 0; font-size: 13px; font-weight: 600; }
.sheet input, .sheet textarea { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); font-weight: 400; font-size: 15px; resize: vertical; }
.sheet input:focus, .sheet textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.sheet-actions.row { flex-direction: row; justify-content: flex-end; }
.sheet-actions.row button { flex: 1; margin-top: 0; }
.sheet.small h2 { margin-bottom: 6px; }
.account-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 8px 0 0; }
.form-error { margin: 8px 0 0; color: var(--danger); font-size: 13px; }
.form-error:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); padding: 6px 12px; font-size: 12.5px; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.balance-card { margin-top: 12px; padding: 16px 18px; border-radius: 18px; background: var(--grad); color: var(--on-accent); }
.balance-card .eyebrow { color: #ffffffcc; }
.balance-card strong { display: block; margin-top: 2px; font-size: 26px; letter-spacing: -.5px; }
.quota-list { display: grid; gap: 12px; margin-top: 16px; }
.quota-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.quota-label span:first-child { font-weight: 600; }
.quota-label span:last-child { color: var(--muted); font-size: 12px; }
.quota-bar { height: 6px; margin-top: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.quota-bar span { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.product { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); text-align: left; }
.product strong { display: block; font-size: 18px; }
.product span { color: var(--muted); font-size: 11.5px; }
.product:disabled { opacity: .55; cursor: not-allowed; }
#ask-input { margin-top: 12px; }

/* lightbox */
.lightbox { background: #0d0812ee; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 88dvh; border-radius: 14px; }
.lb-close { position: absolute; top: calc(18px + env(safe-area-inset-top)); right: 18px; border: 1px solid #ffffff30; border-radius: 50%; width: 42px; height: 42px; background: #ffffff14; color: white; font-size: 26px; line-height: 1; }

@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 26px; padding-bottom: 24px; }
  .home-top, .home-scroll { padding-left: 28px; padding-right: 28px; }
  .home-hero h2 { font-size: 30px; }
  .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
  .log { padding: 22px 28px 26px; }
  .msg { max-width: 70%; }
  #composer { margin: 0 24px; }
  .scenes { margin: 0 24px 10px; }
}
@media (min-width: 1000px) {
  .screen { height: calc(100dvh - 48px); margin: 24px auto; border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); }
}
@media (max-width: 480px) { .toggle-label { display: none; } #autophoto { width: 40px; padding: 0; } }
@media (max-width: 370px) { .avatar-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.speech-controls .msg-time { margin: 0 0 0 auto; color: var(--muted); }

/* locked photo: shown when image credits run out; nothing is generated until paid for */
.msg.photo.locked { position: relative; }
.locked-teaser { aspect-ratio: 3 / 4; border-radius: 15px; overflow: hidden; background: var(--grad); }
.locked-teaser img { display: block; width: 100%; height: 100%; object-fit: cover; filter: blur(22px) saturate(1.25); transform: scale(1.3); }
.locked-overlay { position: absolute; inset: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; border-radius: 15px; text-align: center; color: #fff; background: linear-gradient(180deg, #1b102126, #1b1021a6); }
.locked-overlay strong { font-size: 14px; font-weight: 700; text-shadow: 0 2px 10px #00000066; }
.lock-icon { width: 30px; height: 30px; padding: 8px; box-sizing: content-box; border-radius: 50%; background: #ffffff26; backdrop-filter: blur(6px); stroke-linecap: round; stroke-linejoin: round; }
.locked-buy { width: auto; margin-top: 2px; padding: 10px 16px; font-size: 13px; }
.card-badge { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #1b102180; color: #fff; font-size: 11px; font-weight: 600; backdrop-filter: blur(6px); }
.card-badge::before { content: ''; width: 9px; height: 9px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: image-spin .8s linear infinite; }
.sheet select { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); font-weight: 400; font-size: 15px; }

/* color themes */
:root[data-accent="mango"]  { --g1: #ffd166; --g2: #ff9f43; --g3: #ff5e62; --accent-base: #e8642a; }
:root[data-accent="forest"] { --g1: #b7e66a; --g2: #43c486; --g3: #149c8b; --accent-base: #1f9a6a; }
:root[data-accent="ocean"]  { --g1: #6ee7d8; --g2: #27b5d6; --g3: #2f6fe0; --accent-base: #1b8fb5; }
:root[data-accent="berry"]  { --g1: #ff7eb3; --g2: #e8337a; --g3: #b0195e; --accent-base: #d12a6c; }
:root[data-accent="lilac"]  { --g1: #f5b8e6; --g2: #b88cf0; --g3: #6c5ce7; --accent-base: #8a5ad6; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; border: 0; background: none; font-size: 11.5px; color: var(--muted); }
.swatch span { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px transparent; }
.swatch[aria-pressed="true"] { color: var(--text); font-weight: 600; }
.swatch[aria-pressed="true"] span { box-shadow: 0 0 0 2px var(--text); }

/* pastel personality chips and per-kind allowance bars */
.chips button:nth-child(5n+1) { background: #ffe3d6; color: #9a3d18; border-color: #ffd0bb; }
.chips button:nth-child(5n+2) { background: #ffe0ec; color: #9c1f50; border-color: #ffcadd; }
.chips button:nth-child(5n+3) { background: #d9f5ea; color: #13704f; border-color: #bfeedb; }
.chips button:nth-child(5n+4) { background: #dcefff; color: #1b5e94; border-color: #c3e2ff; }
.chips button:nth-child(5n+5) { background: #fff3c4; color: #7a5a00; border-color: #ffe999; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chips button { background: var(--surface-2); border-color: var(--line); }
  :root:not([data-theme="light"]) .chips button:nth-child(5n+1) { color: #ffb48f; }
  :root:not([data-theme="light"]) .chips button:nth-child(5n+2) { color: #ff9cc2; }
  :root:not([data-theme="light"]) .chips button:nth-child(5n+3) { color: #7fe0b8; }
  :root:not([data-theme="light"]) .chips button:nth-child(5n+4) { color: #8fc8ff; }
  :root:not([data-theme="light"]) .chips button:nth-child(5n+5) { color: #ffd966; }
}
.quota-chat .quota-bar span { background: linear-gradient(90deg, #43c486, #149c8b); }
.quota-voice .quota-bar span { background: linear-gradient(90deg, #ffd166, #ff9f43); }
.quota-image .quota-bar span { background: linear-gradient(90deg, #ff7eb3, #e8337a); }
.swatch span[data-accent="sunset"] { background: linear-gradient(135deg, #ff8a5c, #ec4f7f, #8b52e0); }
.swatch span[data-accent="mango"]  { background: linear-gradient(135deg, #ffd166, #ff9f43, #ff5e62); }
.swatch span[data-accent="forest"] { background: linear-gradient(135deg, #b7e66a, #43c486, #149c8b); }
.swatch span[data-accent="ocean"]  { background: linear-gradient(135deg, #6ee7d8, #27b5d6, #2f6fe0); }
.swatch span[data-accent="berry"]  { background: linear-gradient(135deg, #ff7eb3, #e8337a, #b0195e); }
.swatch span[data-accent="lilac"]  { background: linear-gradient(135deg, #f5b8e6, #b88cf0, #6c5ce7); }
.msg.photo.locked { cursor: pointer; }
.msg.photo.locked:active { transform: scale(.985); }

/* avatar type picker */
.style-picker { margin: 16px 0 0; padding: 0; border: 0; min-width: 0; }
.style-picker legend { padding: 0; font-size: 13px; font-weight: 600; }
.style-options { display: flex; gap: 10px; margin-top: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.sheet label.style-option { position: relative; display: flex; flex: none; flex-direction: column; align-items: center; gap: 6px; width: 76px; margin: 0; font-size: 12px; font-weight: 500; color: var(--muted); text-align: center; cursor: pointer; }
.style-option input { position: absolute; opacity: 0; pointer-events: none; }
.style-art { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; font-size: 28px; border: 2px solid transparent; transition: transform .15s, border-color .15s; }
.style-art[data-style="realistic"] { background: linear-gradient(135deg, #ffd9c2, #e9a17a); }
.style-art[data-style="anime"] { background: linear-gradient(135deg, #ffc6e3, #b9a6ff); }
.style-art[data-style="rpg"] { background: linear-gradient(135deg, #8fd3a8, #3c6e8f); }
.style-art[data-style="cartoon"] { background: linear-gradient(135deg, #ffe38a, #ff9a6b); }
.style-art[data-style="comic"] { background: linear-gradient(135deg, #7fd4ff, #ff6b6b); }
.style-option input:checked + .style-art { border-color: var(--text); transform: translateY(-2px); box-shadow: 0 6px 16px var(--accent-shadow); }
.style-option input:checked ~ span:last-child { color: var(--text); font-weight: 700; }
.style-option input:focus-visible + .style-art { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-type { position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 999px; background: #ffffffe0; color: #2b2232; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.btn-link { border: 0; background: none; padding: 10px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.btn-link.danger { color: var(--danger); }
body.doc-page { overflow: auto; }
.doc { max-width: 560px; margin: 0 auto; padding: 32px 16px 48px; }
.doc h2 { margin: 18px 0 8px; font-size: 24px; }
.doc h3 { margin: 22px 0 4px; font-size: 15px; }
.doc p { color: var(--muted); }
.doc .btn-primary { text-decoration: none; }
.balance-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.balance-buy { flex: none; border: 0; border-radius: 999px; padding: 9px 16px; background: #ffffffeb; color: #2b2232; font-weight: 700; font-size: 13px; }
#buy-message:not(:empty) { margin-bottom: 4px; }

/* relationship switch */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 8px; padding: 4px; border-radius: 16px; background: var(--surface-2); }
.sheet .segmented label { position: relative; margin: 0; font-weight: 600; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 10px 8px; border-radius: 12px; text-align: center; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px #00000014; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* account-wide image generation switch */
.sheet label.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.switch-row strong { font-size: 14px; }
.switch-row small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.switch-row input { appearance: none; flex: none; position: relative; width: 48px; height: 28px; margin: 0; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .2s; }
.switch-row input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px #0003; transition: transform .2s; }
.switch-row input:checked { background: var(--grad); }
.switch-row input:checked::after { transform: translateX(20px); }
/* With image generation off, no photo controls appear anywhere. */
body.photos-off #camera, body.photos-off #autophoto, body.photos-off #scenes,
body.photos-off .chip-photo, body.photos-off .msg.photo.locked { display: none !important; }

/* global character library */
.discover { padding: 6px 0 22px; }
.section-head h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.section-head p { margin: 2px 0 12px; color: var(--muted); font-size: 12.5px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 14px; }
.add-pill { display: inline-block; margin-top: 8px; padding: 4px 11px; border-radius: 999px; background: var(--grad); color: var(--on-accent); font-size: 12px; font-weight: 700; }
.card-open:disabled { opacity: .7; cursor: wait; }
.card-report { font-size: 13px; line-height: 1; }
.share-note { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); color: var(--text); font-size: 12.5px; line-height: 1.5; }
@media (min-width: 640px) { .library-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; } }
.home-scroll > .section-head { padding-top: 2px; }
.card-mine { position: absolute; bottom: 8px; left: 8px; padding: 3px 9px; border-radius: 999px; background: var(--grad); color: var(--on-accent); font-size: 10.5px; font-weight: 700; }
.add-pill.open-pill { background: var(--surface-2); color: var(--accent); }

/* All bots: home preview row and its own paginated page */
.section-head.with-action { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.see-all { flex: none; margin-top: 2px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--accent); font-size: 13px; font-weight: 700; }
.library-preview { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 44%); gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.library-preview > * { scroll-snap-align: start; }
.page-grid { padding-top: 16px; }
.library-sentinel { min-height: 48px; padding: 18px 0 8px; text-align: center; color: var(--muted); font-size: 13px; }
.library-more { display: block; margin: 0 auto 24px; }
#library-screen .chat-top { padding-left: 6px; }
@media (min-width: 640px) { .library-preview { grid-auto-columns: minmax(190px, 30%); } }

/* search */
.search-box { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 0 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.search-box:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.search-box svg { flex: none; width: 18px; height: 18px; color: var(--muted); stroke-linecap: round; }
.search-box input { flex: 1; min-width: 0; padding: 13px 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.search-box input::placeholder { color: var(--muted); }
.search-box.sticky { position: sticky; top: 0; z-index: 2; margin: 12px 0 0; }
.search-empty { grid-column: 1 / -1; margin: 4px 0 8px; color: var(--muted); font-size: 13.5px; }
.library-preview .search-empty { grid-column: auto; }
.doc.legal h1 { margin: 14px 0 2px; font-size: 28px; letter-spacing: -.5px; }
.doc.legal .updated { margin: 0 0 18px; font-size: 13px; }
.doc.legal h2 { margin: 26px 0 6px; font-size: 18px; }
.doc.legal p, .doc.legal li { color: var(--text); opacity: .88; line-height: 1.65; }
.doc.legal ul { padding-left: 20px; }
.doc.legal .contact { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.doc.legal a.wordmark { text-decoration: none; }
.doc.legal mark { background: #ffe38a; color: #4a3700; padding: 0 4px; border-radius: 4px; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0 0; text-align: left; font-size: 12.5px; line-height: 1.5; color: var(--muted); cursor: pointer; }
.consent input { flex: none; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent-base); }
.fine a, .consent a { color: var(--accent); }
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 18px; font-size: 13px; }
.legal-links a { color: var(--muted); text-underline-offset: 3px; }

/* username and password sign-in */
.or-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: var(--muted); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.password-form { display: grid; gap: 10px; margin-top: 10px; }
.password-form input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font-size: 15px; }
.password-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.password-form .btn-primary { margin-top: 2px; }
.password-form .form-error { margin: 0; text-align: left; }
/* Locked while a photo renders */
#composer.generating { opacity: .65; }
#composer.generating .composer-btn, .speech-controls .chip-photo:disabled:not(.image-generating) { cursor: not-allowed; opacity: .5; }
/* Razorpay Checkout open: blur the app behind its window.
   The frame must use the same colour scheme as Razorpay's (light) page, or the
   browser paints the whole frame opaque white over the app. */
body.paying .screen, body.paying .overlay { filter: blur(10px) saturate(1.1); transition: filter .2s; pointer-events: none; }
.razorpay-checkout-frame { color-scheme: light; }
.razorpay-backdrop { background: rgba(16, 10, 22, .55) !important; backdrop-filter: blur(6px); }
