/* Yumora web app — ported from design/prototype (梦境极光: deep night, aurora
   only on rims, glows and primary buttons). Mobile first: the app fills the
   viewport on phones and becomes a centred 430 px column on wide screens. */
:root {
  --night: #0c0a1c;
  --deep: #17142e;
  --ink: #f3effd;
  --mist: #a8a1c9;
  --aura-v: #a594ff;
  --aura-r: #ff8fc4;
  --aura-t: #7ae6e1;
  --gold: #ffd27d;
  --glass: rgba(255, 255, 255, .07);
  --glass-2: rgba(255, 255, 255, .13);
  --line: rgba(255, 255, 255, .11);
  --aura: linear-gradient(120deg, var(--aura-v), var(--aura-r) 55%, var(--aura-t));
  --f-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --f-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --f-brand: "Cormorant Garamond", Georgia, serif;
  /* clear a tabbed screen's last row past the floating tabbar:
     64px bar + its bottom offset + 16px breathing room */
  --tab-clear: calc(64px + max(14px, env(safe-area-inset-bottom, 0px)) + 16px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { display: grid; place-items: center; overflow: hidden; overscroll-behavior: none; background: radial-gradient(1200px 700px at 70% 10%, #241c4d 0%, transparent 60%), radial-gradient(900px 600px at 10% 90%, #3a1838 0%, transparent 60%), var(--night); color: var(--ink); font: 15px/1.65 var(--f-body); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--aura-t); outline-offset: 2px; border-radius: 10px; }
button:disabled { opacity: .5; }
img { max-width: 100%; display: block; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- app frame ---------- */
/* `overflow: clip` (not `hidden`) matters: with `hidden` the app becomes a
   scroll container, and any focus()/scroll into a translated (hidden) screen
   scrolls it sideways — which shifted every screen ~24px left of the frame. */
.app { position: relative; width: 100%; max-width: 430px; height: 100vh; height: 100dvh; overflow: hidden; overflow: clip; background: var(--night); isolation: isolate; }
@media (min-width: 520px) {
  /* no border: the 1px rim is an inset shadow, so the frame's rect is the
     screen's rect (inset: 0 children cover it exactly, left and width). */
  .app { border-radius: 34px; box-shadow: inset 0 0 0 1px var(--line), 0 40px 110px rgba(0, 0, 0, .6), 0 0 80px rgba(165, 148, 255, .12); }
}

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; opacity: 0; visibility: hidden; transform: translateX(24px); transition: opacity .35s ease, transform .35s ease, visibility 0s .35s; }
.screen::-webkit-scrollbar { display: none; }
.screen.on { opacity: 1; visibility: visible; transform: none; transition: opacity .35s ease, transform .35s ease; }
/* tab screens scroll behind the floating tabbar — clear it at the bottom */
#scr-home, #scr-stories, #scr-me { padding-bottom: var(--tab-clear); }
.pad { padding: 0 18px; }
.safe-top { padding-top: max(18px, env(safe-area-inset-top)); }
.home-body { position: relative; z-index: 1; }
#particles { position: absolute; inset: 0; pointer-events: none; z-index: 0; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 10px; padding-top: max(14px, env(safe-area-inset-top)); background: linear-gradient(var(--night) 40%, rgba(12, 10, 28, 0)); }
.logo { display: flex; align-items: center; gap: 8px; }
.logo img { display: block; height: 36px; width: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 5px 13px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.pill.gold { color: var(--gold); border-color: rgba(255, 210, 125, .35); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.icon-btn svg { width: 19px; height: 19px; }
svg.i { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 12px; }
.section-h h2 { font: 700 19px/1.3 var(--f-display); letter-spacing: .5px; }
.section-h span { color: var(--mist); font-size: 12px; }

/* coverflow (今晚的新故事) */
.flow { position: relative; height: 410px; perspective: 1100px; margin: 4px -18px 0; overflow-x: clip; touch-action: pan-y; user-select: none; }
.flow-card { position: absolute; left: 50%; top: 0; width: 248px; height: 390px; margin-left: -124px; border-radius: 26px; overflow: hidden; transition: transform .55s cubic-bezier(.2, .8, .2, 1), opacity .55s, filter .55s; box-shadow: 0 30px 60px rgba(0, 0, 0, .55); cursor: pointer; transform-style: preserve-3d; text-align: left; }
.flow-card img { width: 100%; height: 100%; object-fit: cover; }
.flow-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 10, 28, 0) 38%, rgba(12, 10, 28, .92) 100%); }
.flow-card .rim { position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--aura); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0; transition: opacity .5s; z-index: 2; }
.flow-card.center .rim { opacity: .9; }
.flow-card .txt { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 3; }
.flow-card h3 { font: 700 22px/1.25 var(--f-display); }
.flow-card p { margin: 6px 0 0; font-size: 13px; color: #ddd7f3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge-new { position: absolute; top: 14px; left: 14px; z-index: 3; font-size: 11px; letter-spacing: 1px; padding: 3px 9px; border-radius: 99px; background: rgba(12, 10, 28, .55); border: 1px solid rgba(122, 230, 225, .5); color: var(--aura-t); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 2px; }
.dots i { width: 6px; height: 6px; border-radius: 99px; background: var(--line); transition: width .3s, background .3s; }
.dots i.on { width: 18px; background: var(--aura); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 18px 4px; margin: 0 -18px; }
.chips::-webkit-scrollbar { display: none; }
.chips-wrap { position: relative; }
.chips-wrap .chips { padding-right: 52px; }
.chips-next { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--night); border: 1px solid var(--line); color: var(--ink); box-shadow: -14px 0 18px var(--night); transition: opacity .25s; }
.chips-next .i { width: 16px; height: 16px; }
.chips-next.gone { opacity: 0; pointer-events: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 7px 15px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; color: var(--mist); }
.chip.on { color: var(--night); background: var(--ink); border-color: var(--ink); font-weight: 500; }
/* 「更多」 — looks like the other chips, with a small chevron that flips up when open. */
.chip-more { gap: 6px; }
.chip-more .chev { width: 7px; height: 7px; margin-top: -3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .22s, margin-top .22s; }
.chip-more.open .chev { margin-top: 3px; transform: rotate(-135deg); }
.chip-sep { flex: none; align-self: center; width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 7px; background: var(--glass-2); color: #e4def8; }
.tag-new { color: var(--aura-t); background: rgba(122, 230, 225, .14); border: 1px solid rgba(122, 230, 225, .4); }

/* archetypes (热门人设) */
.arche { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding: 2px 18px 6px; margin: 0 -18px; }
.arche::-webkit-scrollbar { display: none; }
.arche button { flex: none; width: 72px; min-height: 88px; display: grid; justify-items: center; align-content: start; gap: 7px; font-size: 12px; color: #e4def8; position: relative; }
.arche .ring { width: 64px; height: 64px; border-radius: 50%; padding: 2px; background: var(--aura); box-shadow: 0 10px 22px rgba(0, 0, 0, .45); transition: transform .25s, box-shadow .25s; }
.arche .face { display: block; width: 100%; height: 100%; border-radius: 50%; border: 2px solid var(--night); background: var(--glass-2) center 18% / 240% auto no-repeat; }
.arche button.on .ring { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--ink), 0 0 26px rgba(255, 143, 196, .6); }
.arche button.on { color: var(--ink); font-weight: 700; }
.arche .hot { position: absolute; top: -2px; right: 0; font-size: 9px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: 99px; background: var(--aura-r); color: var(--night); }
/* the final 更多 / 收起 bubble: same ring, a glyph instead of a face */
.arche .arche-more .ring { display: grid; place-items: center; }
.arche .arche-more .face.more-glyph { display: grid; place-items: center; background: var(--glass-2); color: var(--ink); font-size: 20px; line-height: 1; letter-spacing: 1px; }
.arche .arche-more.open .ring { box-shadow: 0 10px 22px rgba(0, 0, 0, .45), 0 0 0 2px var(--line); }

/* ranking */
.rank { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; padding: 4px 18px 8px; margin: 0 -18px; }
.rank::-webkit-scrollbar { display: none; }
.rank-item { flex: none; width: 150px; position: relative; padding-left: 26px; text-align: left; }
.rank-item .num { position: absolute; left: -4px; bottom: 34px; font: italic 600 92px/1 var(--f-brand); color: transparent; -webkit-text-stroke: 1.5px rgba(255, 255, 255, .55); z-index: 0; }
.rank-item .art { position: relative; z-index: 1; aspect-ratio: 5 / 6; border-radius: 18px; overflow: hidden; box-shadow: 0 16px 30px rgba(0, 0, 0, .45); }
.rank-item .art img { width: 100%; height: 100%; object-fit: cover; }
.rank-item b { display: block; margin-top: 8px; font: 700 15px/1.3 var(--f-display); }
.rank-item small { color: var(--mist); font-size: 12px; }

/* tilt grid */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tilt { position: relative; border-radius: 22px; transform-style: preserve-3d; transition: transform .25s ease; text-align: left; will-change: transform; }
.tilt .art { position: relative; aspect-ratio: 3 / 4; border-radius: 22px; overflow: hidden; box-shadow: 0 18px 34px rgba(0, 0, 0, .5); background: var(--deep); }
.tilt .art img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.06); transition: transform .4s; }
.tilt .art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(12, 10, 28, .9)); }
.tilt .glare { position: absolute; inset: 0; border-radius: 22px; background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .28), transparent 55%); opacity: 0; transition: opacity .3s; z-index: 3; pointer-events: none; }
.tilt:hover .glare, .tilt.touching .glare { opacity: 1; }
.tilt .over { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4; transform: translateZ(34px); }
.tilt .over b { display: block; font: 700 16px/1.3 var(--f-display); }
.tilt .over small { display: -webkit-box; font-size: 12px; color: #d9d2f0; margin-top: 3px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tilt .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; color: var(--mist); font-size: 12px; }

/* tabbar */
.tabbar { position: absolute; left: 14px; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 20; height: 64px; display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 24px; background: rgba(23, 20, 46, .72); border: 1px solid var(--line); backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%); box-shadow: 0 18px 40px rgba(0, 0, 0, .5); transition: transform .35s, opacity .35s; }
.tabbar.hide { transform: translateY(120px); opacity: 0; pointer-events: none; }
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--mist); position: relative; min-height: 44px; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--ink); }
.tabbar button.on::before { content: ""; position: absolute; top: 8px; width: 34px; height: 30px; border-radius: 12px; background: radial-gradient(circle, rgba(165, 148, 255, .45), transparent 70%); z-index: -1; }
/* Wide screens only (web/wide.css): the sidebar brand and the chat character card. */
.tabbar .nav-brand, .chat-side { display: none; }

/* ---------- detail ---------- */
.hero { position: relative; height: min(560px, 66vh); overflow: hidden; background: var(--deep); }
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: center top; will-change: transform; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 10, 28, .45) 0%, rgba(12, 10, 28, 0) 22%, rgba(12, 10, 28, 0) 50%, var(--night) 97%); }
.float-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: space-between; padding: 14px 16px; padding-top: max(16px, env(safe-area-inset-top)); }
.detail-body { position: relative; margin-top: -170px; z-index: 2; padding: 0 20px 130px; }
.detail-body h1 { font: 700 32px/1.2 var(--f-display); letter-spacing: 1px; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.detail-body .hook { margin: 10px 0 14px; font: 500 16px/1.7 var(--f-display); color: #e9e3fb; }
.stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 18px 0; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); }
.stats:empty { display: none; }
.stats div { padding: 12px 6px; text-align: center; }
.stats div + div { border-left: 1px solid var(--line); }
.stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--mist); }
.card-glass { border-radius: 20px; background: var(--glass); border: 1px solid var(--line); padding: 16px; margin-top: 14px; }
.card-glass h3 { font: 700 15px/1.4 var(--f-display); margin-bottom: 8px; color: var(--mist); letter-spacing: 1px; }
.card-glass p { margin: 0; color: #e5dff7; }
.memory-callout { display: flex; gap: 12px; align-items: flex-start; }
.memory-callout .orb { flex: none; width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--aura-v) 35%, #3b2b7a 80%); box-shadow: 0 0 24px rgba(165, 148, 255, .6); }
.memory-note { font-size: 13px; color: var(--mist); }
.opening { display: flex; flex-direction: column; gap: 10px; }
.cta-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; padding: 16px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(12, 10, 28, 0), var(--night) 38%); display: flex; gap: 10px; }
.btn-aura { flex: 1; min-height: 54px; border-radius: 18px; background: var(--aura); color: #160f2c; font-weight: 700; font-size: 16px; letter-spacing: 2px; box-shadow: 0 10px 30px rgba(255, 143, 196, .35), 0 0 0 1px rgba(255, 255, 255, .25) inset; position: relative; overflow: hidden; }
.btn-aura::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent); animation: shine 3.6s ease-in-out infinite; }
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.btn-ghost { width: 54px; height: 54px; flex: none; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); display: grid; place-items: center; }
.btn-ghost.on { color: var(--aura-r); border-color: rgba(255, 143, 196, .5); }
.btn-ghost svg { width: 22px; height: 22px; }

.traits { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.trait { font-size: 12px; padding: 4px 11px; border-radius: 99px; background: rgba(165, 148, 255, .16); border: 1px solid rgba(165, 148, 255, .38); color: #ece6fc; }
.voice { margin: 0 !important; font-size: 13px; color: var(--mist) !important; }
.voice b { color: var(--ink); font-weight: 500; }

/* ---------- chat ---------- */
#scr-chat { overflow: hidden; }
.chat-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; background: var(--deep); }
.chat-bg img { width: 100%; height: 100%; object-fit: cover; animation: drift 28s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.04) translateY(0); } to { transform: scale(1.12) translateY(-14px); } }
.chat-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 10, 28, .65) 0%, rgba(12, 10, 28, .1) 16%, rgba(12, 10, 28, .25) 38%, rgba(12, 10, 28, .88) 62%, rgba(12, 10, 28, .97) 100%); }
.chat-head { position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 12px 14px; padding-top: max(14px, env(safe-area-inset-top)); }
.chat-head .who { flex: 1; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 5px 12px 5px 5px; border-radius: 99px; background: rgba(23, 20, 46, .55); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); text-align: left; }
.avatar { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .15); background: var(--deep); }
.avatar img { width: 100%; height: 300%; object-fit: cover; object-position: center 18%; }
.chat-head .who b { display: block; font: 700 15px/1.2 var(--f-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The name/summary column must be able to shrink: the header chips and the
   memory button sit next to it, and a long custom name may not push them out. */
.chat-head .who > span:last-child { min-width: 0; overflow: hidden; }
.chat-head .who small { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--aura-t); }
.chat-head .who small::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--aura-t); box-shadow: 0 0 8px var(--aura-t); }
.log { position: absolute; left: 0; right: 0; top: 0; bottom: 132px; z-index: 2; overflow-y: auto; scrollbar-width: none; padding: 300px 16px 18px; -webkit-mask-image: linear-gradient(transparent 0, #000 260px); mask-image: linear-gradient(transparent 0, #000 260px); display: flex; flex-direction: column; gap: 12px; }
.log::-webkit-scrollbar { display: none; }
.narr { margin: 0; font: 500 15px/1.85 var(--f-display); color: #d8d1ef; text-shadow: 0 1px 12px rgba(0, 0, 0, .6); padding: 0 4px; }
.say { align-self: flex-start; max-width: 88%; }
.say .name { font-size: 12px; color: var(--aura-r); margin: 0 0 4px 12px; letter-spacing: 1px; }
.bub { padding: 10px 15px; border-radius: 6px 20px 20px 20px; background: rgba(30, 26, 58, .72); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 15px; line-height: 1.7; }
.mine { align-self: flex-end; max-width: 82%; }
.mine .bub { border-radius: 20px 6px 20px 20px; background: linear-gradient(135deg, rgba(165, 148, 255, .55), rgba(255, 143, 196, .45)); border-color: rgba(255, 255, 255, .22); }
.mine em, .narr em { color: #f6d9ea; }
.turn { display: flex; flex-direction: column; gap: 10px; cursor: pointer; border-radius: 14px; }
.typing { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--mist); padding: 8px 14px; border-radius: 99px; background: rgba(30, 26, 58, .6); border: 1px solid var(--line); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--aura-v); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; background: var(--aura-r); }
.typing i:nth-child(3) { animation-delay: .4s; background: var(--aura-t); }
@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.unlock { align-self: flex-start; margin-top: 2px; padding: 9px 16px; border-radius: 14px; font-size: 13px; font-weight: 700; color: var(--night); background: var(--aura); box-shadow: 0 6px 20px rgba(255, 143, 196, .35); }
.sys-note { align-self: center; font-size: 12px; color: var(--mist); padding: 4px 12px; border-radius: 99px; background: rgba(23, 20, 46, .6); text-align: center; }
.composer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; padding: 8px 12px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.suggest { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 2px 10px; }
.suggest::-webkit-scrollbar { display: none; }
.suggest button { flex: none; font-size: 13px; min-height: 40px; padding: 7px 13px; border-radius: 99px; background: rgba(23, 20, 46, .65); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #e8e2fa; }
.input-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 24px; background: rgba(23, 20, 46, .78); border: 1px solid var(--line); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.input-row input { flex: 1; min-width: 0; height: 40px; background: none; border: 0; color: var(--ink); font: inherit; font-size: 15px; outline: none; }
.input-row input::placeholder { color: #8d86ad; }
.act-btn { height: 44px; padding: 0 12px; border-radius: 12px; font-size: 12px; color: var(--mist); border: 1px solid var(--line); flex: none; }
.act-btn.on { color: var(--aura-r); border-color: rgba(255, 143, 196, .55); background: rgba(255, 143, 196, .1); }
.send { width: 44px; height: 44px; flex: none; border-radius: 16px; display: grid; place-items: center; background: var(--aura); color: var(--night); box-shadow: 0 6px 18px rgba(165, 148, 255, .4); }
.send svg { width: 20px; height: 20px; }
.quota-hint { text-align: center; font-size: 11px; color: var(--gold); margin-top: 6px; min-height: 16px; }

/* ---------- sheets / overlays ---------- */
.scrim { position: absolute; inset: 0; z-index: 30; background: rgba(6, 4, 16, .55); opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }
.scrim.on { opacity: 1; visibility: visible; transition: opacity .3s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 92%; overflow-y: auto; scrollbar-width: none; border-radius: 30px 30px 0 0; background: linear-gradient(180deg, #211c43, #120f26 55%); border-top: 1px solid rgba(255, 255, 255, .15); box-shadow: 0 -30px 60px rgba(0, 0, 0, .5); transform: translateY(105%); transition: transform .42s cubic-bezier(.2, .8, .2, 1); padding: 10px 20px max(22px, env(safe-area-inset-bottom)); }
.sheet::-webkit-scrollbar { display: none; }
.sheet.on { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .25); margin: 0 auto 14px; }
.sheet h2 { font: 700 22px/1.3 var(--f-display); }
.sheet .sub { color: var(--mist); font-size: 13px; margin: 4px 0 14px; }
.mem-sec { margin-top: 12px; border-radius: 18px; padding: 14px; background: var(--glass); border: 1px solid var(--line); }
.mem-sec h3 { font-size: 12px; letter-spacing: 2px; color: var(--aura-t); margin-bottom: 8px; font-weight: 500; }
.mem-sec ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.mem-sec li { display: flex; gap: 8px; font-size: 14px; }
.mem-sec li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 9px; border-radius: 50%; background: var(--aura-r); }
.mem-free { margin-top: 14px; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; background: rgba(255, 210, 125, .08); border: 1px solid rgba(255, 210, 125, .3); font-size: 13px; color: #f5e3bd; }
.mem-free button { margin-left: auto; flex: none; color: var(--gold); font-weight: 700; min-height: 44px; padding: 0 6px; }

.pw-fan { position: relative; height: 210px; perspective: 900px; margin: 4px 0 10px; }
.pw-fan:empty { display: none; }
.pw-fan img { position: absolute; top: 10px; left: 50%; width: 120px; height: 190px; object-fit: cover; border-radius: 18px; box-shadow: 0 20px 40px rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .2); }
.pw-fan img:nth-child(1) { transform: translateX(-150%) rotateY(28deg) rotateZ(-8deg) translateZ(-40px); }
.pw-fan img:nth-child(2) { transform: translateX(-50%) translateZ(30px); z-index: 2; }
.pw-fan img:nth-child(3) { transform: translateX(50%) rotateY(-28deg) rotateZ(8deg) translateZ(-40px); }
.pw-title { text-align: center; }
.pw-title h2 { font-size: 26px; }
.pw-reason { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--gold); padding: 3px 10px; border-radius: 99px; background: rgba(255, 210, 125, .1); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 10px; align-items: stretch; }
/* flex column + grid stretch: the three cards share one height even when a
   memory label runs to two lines */
.plan { position: relative; display: flex; flex-direction: column; align-items: stretch; text-align: left; padding: 13px 8px; border-radius: 18px; background: var(--glass); border: 1.5px solid var(--line); transition: border-color .25s, background .25s, transform .25s; min-height: 44px; }
.plan.on { border-color: transparent; background: linear-gradient(var(--deep), var(--deep)) padding-box, var(--aura) border-box; transform: translateY(-3px); box-shadow: 0 12px 30px rgba(165, 148, 255, .25); }
.plan b { display: block; font: 700 15px/1.2 var(--f-display); }
/* `US$12.99/月` has to stay on one line in a third of a 375 px phone, so the
   amount is 14 px on every card and the unit rides inline at 10 px */
.plan .price { display: flex; align-items: baseline; gap: 1px; margin-top: 5px; white-space: nowrap; line-height: 1.15; }
.plan .price .amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.plan .price .per { font-size: 10px; font-weight: 400; color: var(--mist); }
.plan .pitch { font-size: 11px; color: #ddd7f3; margin-top: 5px; line-height: 1.4; }
.plan .memo { font-size: 11px; color: var(--aura-t); margin-top: 2px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.plan .ribbon { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 9px; letter-spacing: 1px; padding: 2px 8px; border-radius: 99px; background: var(--aura); color: var(--night); font-weight: 700; }
.pw-note { text-align: center; font-size: 11px; color: var(--mist); margin: 0 0 14px; line-height: 1.6; }
/* compare table: fixed layout so the label column is a real 56 px and the four
   plan columns are equal; the band comes from the selected column's cells */
.compare { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 12px; line-height: 1.35; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.compare col.c-label { width: 56px; }
.compare th { font-weight: 500; color: var(--mist); font-size: 12px; padding: 6px 2px; text-align: center; }
.compare th.c-label, .compare td.c-label { text-align: left; color: var(--mist); white-space: nowrap; padding-left: 0; }
.compare td { padding: 8px 2px; text-align: center; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.compare th.on { color: var(--ink); font-weight: 700; background: rgba(165, 148, 255, .16); border-radius: 14px 14px 0 0; }
.compare td.on { color: var(--ink); background: rgba(165, 148, 255, .16); }
.compare tbody tr:last-child td.on { border-radius: 0 0 14px 14px; }
.pw-fine { text-align: center; font-size: 11px; color: var(--mist); margin-top: 10px; }
.packs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.pack { position: relative; padding: 16px 10px 12px; border-radius: 18px; text-align: center; background: var(--glass); border: 1px solid var(--line); }
.pack .gem { width: 24px; height: 24px; margin: 0 auto 4px; display: block; }
.pack b { display: block; font-size: 15px; color: var(--gold); font-variant-numeric: tabular-nums; }
.pack small { display: block; margin-top: 3px; font-size: 11px; color: var(--mist); font-variant-numeric: tabular-nums; }
.pack-badge { position: absolute; top: -8px; right: 10px; font-size: 9px; letter-spacing: .5px; padding: 2px 7px; border-radius: 99px; background: var(--gold); color: var(--night); font-weight: 700; }

.actions-sheet button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 14px 6px; border-bottom: 1px solid var(--line); font-size: 15px; text-align: left; }
.actions-sheet button svg { width: 20px; height: 20px; color: var(--mist); }
.actions-sheet button.danger { color: #ff9a9a; }
.actions-sheet button:last-child { border-bottom: 0; }

.steps { margin: 4px 0 16px; padding: 0; list-style: none; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: #e5dff7; }
.steps b { color: var(--ink); }
.step-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--glass-2); border: 1px solid var(--line); font-size: 13px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.btn-line { min-height: 48px; padding: 0 20px; border-radius: 15px; border: 1px solid var(--line); background: var(--glass); font-size: 14px; }
.btn-danger { min-height: 48px; padding: 0 20px; border-radius: 15px; background: linear-gradient(120deg, #ff7b7b, #ff8fc4); color: #2a0c16; font-weight: 700; font-size: 14px; }
.wide { width: 100%; }

.toast { position: absolute; left: 50%; bottom: 120px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; padding: 10px 18px; border-radius: 99px; font-size: 13px; background: rgba(30, 26, 58, .92); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: opacity .3s, transform .3s; pointer-events: none; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- stories ---------- */
.story-row { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 12px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); margin-bottom: 10px; min-height: 44px; }
.story-row .thumb { width: 64px; height: 84px; border-radius: 14px; overflow: hidden; flex: none; background: var(--deep); }
.story-row .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.story-row .mid { flex: 1; min-width: 0; }
.story-row b { font: 700 16px/1.3 var(--f-display); }
.story-row p { margin: 3px 0 6px; font-size: 13px; color: var(--mist); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.story-row .foot { display: flex; gap: 8px; align-items: center; font-size: 11px; color: var(--mist); }
.story-row .mem { color: var(--aura-t); }
.unread { width: 9px; height: 9px; border-radius: 50%; background: var(--aura-r); box-shadow: 0 0 10px var(--aura-r); flex: none; }
.big-title { font: 700 28px/1.3 var(--f-display); margin: 6px 0 4px; }
.lead { color: var(--mist); font-size: 13px; margin: 0 0 16px; }

/* ---------- me ---------- */
.profile { display: flex; gap: 14px; align-items: center; margin-top: 6px; }
.profile .ava { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font: 700 26px var(--f-display); background: linear-gradient(135deg, #3b2d77, #6b2f62); box-shadow: 0 0 0 2px rgba(255, 255, 255, .15), 0 0 30px rgba(165, 148, 255, .35); }
.profile b { font: 700 20px/1.3 var(--f-display); }
.profile .badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.upgrade-card { position: relative; margin-top: 16px; border-radius: 24px; padding: 18px; overflow: hidden; background: linear-gradient(130deg, #3a2a7e, #6d2c66 60%, #1f5a66); box-shadow: 0 18px 40px rgba(0, 0, 0, .4); text-align: left; width: 100%; }
.upgrade-card::before { content: ""; position: absolute; right: -40px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .25), transparent 70%); }
.upgrade-card b { font: 700 19px/1.4 var(--f-display); display: block; position: relative; margin-bottom: 12px; }
.upgrade-card span { position: relative; display: inline-block; padding: 7px 16px; border-radius: 99px; background: var(--ink); color: var(--night); font-weight: 700; font-size: 13px; }

/* wallet (梦晶) — the only currency the app shows */
.wallet-card { margin-top: 18px; border-radius: 24px; padding: 16px 18px; background: linear-gradient(135deg, rgba(165, 148, 255, .2), rgba(255, 143, 196, .13) 58%, rgba(122, 230, 225, .12)); border: 1px solid rgba(165, 148, 255, .38); box-shadow: 0 16px 36px rgba(0, 0, 0, .35); }
.wallet-main { display: flex; align-items: center; gap: 12px; }
.wallet-num { flex: 1; min-width: 0; }
.wallet-num b { display: block; font: 700 26px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.wallet-num span { display: block; margin-top: 6px; font-size: 12px; color: #e4def8; }
.wallet-ring { flex: none; width: 76px; text-align: center; }
.wallet-ring svg { width: 62px; height: 62px; display: block; margin: 0 auto; }
.wallet-ring b { display: block; margin-top: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.wallet-ring small { font-size: 10px; color: var(--mist); }
.wallet-plan { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: 12px; color: var(--aura-t); }
/* 我的 → Google account card (js/account.js) */
.acct-card { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); }
.acct-card[hidden] { display: none; }
.acct-copy { flex: 1 1 180px; min-width: 0; }
.acct-copy b { display: block; font-size: 14px; }
.acct-copy span { display: block; margin-top: 4px; font-size: 12px; line-height: 1.5; color: var(--mist); overflow-wrap: anywhere; }
.acct-gbtn { flex: none; min-height: 44px; display: flex; align-items: center; color-scheme: light; } /* Google's button iframe is a light document: a dark parent would paint it an opaque white box */
.acct-out { flex: none; min-height: 44px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; color: var(--mist); }
.acct-note { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--aura-t); }
.acct-note.err { color: #ff9a9a; }
.login-sheet .acct-gbtn { justify-content: center; margin: 4px 0 10px; }
.login-sheet .acct-note { text-align: center; margin-bottom: 10px; }
.list { margin-top: 14px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); overflow: hidden; }
.list button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 14px 16px; text-align: left; font-size: 14px; }
.list button + button { border-top: 1px solid var(--line); }
.list button svg { width: 20px; height: 20px; color: var(--mist); flex: none; }
.list button span { margin-left: auto; color: var(--mist); font-size: 13px; white-space: nowrap; }
.saved-head { margin-top: 18px; }

/* ---------- age gate ---------- */
#scr-age { display: flex; flex-direction: column; justify-content: flex-end; }
.age-bg { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; opacity: .55; filter: blur(2px) saturate(1.1); transform: rotate(-8deg) scale(1.35); }
.age-bg img { width: 100%; height: 220px; object-fit: cover; border-radius: 14px; background: var(--deep); }
.age-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 10, 28, .2), rgba(12, 10, 28, .85) 50%, var(--night) 75%); }
.age-box { position: relative; z-index: 2; padding: 0 24px max(36px, env(safe-area-inset-bottom)); }
.age-box .logo img { height: 56px; }
.age-box h1 { font: 700 24px/1.4 var(--f-display); margin: 16px 0 8px; }
.age-box p { color: var(--mist); font-size: 14px; margin: 0 0 18px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--mist); }
.field input { height: 50px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: inherit; font-size: 17px; padding: 0 16px; letter-spacing: 2px; }
.age-msg { min-height: 22px; font-size: 13px; line-height: 1.5; color: #ff9a9a; margin-top: 10px; text-align: center; }
.age-msg.ok { color: var(--aura-t); }
/* spec §15: the terms link under the birth-year form (44 px tap target) */
.age-box p.age-terms { margin: 12px 0 0; text-align: center; font-size: 13px; }
.age-box p.age-terms a { display: inline-flex; align-items: center; min-height: 44px; color: var(--mist); text-decoration: underline; }

/* ---------- loading / empty / error states ---------- */
.sk { background: linear-gradient(100deg, rgba(255, 255, 255, .05) 30%, rgba(255, 255, 255, .11) 45%, rgba(255, 255, 255, .05) 60%); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }
.sk-card { pointer-events: none; }
.sk-bar { display: block; width: 62%; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .07); }
.state { display: grid; justify-items: center; gap: 10px; padding: 32px 18px; text-align: center; color: var(--mist); border-radius: 20px; background: var(--glass); border: 1px solid var(--line); }
.grid2 .state { grid-column: 1 / -1; }
.state b { color: var(--ink); font: 700 16px/1.3 var(--f-display); }
.state p { margin: 0; font-size: 13px; line-height: 1.6; }
.state .btn-line { margin-top: 4px; }
.grid-foot { min-height: 1px; }
.flow-empty { height: 390px; display: grid; place-items: center; border-radius: 26px; background: var(--glass); border: 1px solid var(--line); color: var(--mist); font-size: 13px; margin: 0 18px; text-align: center; padding: 20px; }
.boot-err { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(6, 4, 16, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.boot-box { max-width: 300px; display: grid; justify-items: center; gap: 12px; text-align: center; }
.boot-box b { font: 700 20px/1.3 var(--f-display); }
.boot-box p { margin: 0; color: var(--mist); font-size: 13px; }
.boot-box .btn-aura { min-width: 160px; flex: none; }

.flow-empty b { display: block; color: var(--ink); font: 700 16px/1.4 var(--f-display); }
.flow-empty p { margin: 6px 0 12px; font-size: 13px; }
.grid-end { text-align: center; padding: 18px 0; font-size: 12px; color: var(--mist); }
.state.small { padding: 14px; gap: 8px; }
.state.small p { font-size: 12px; }

/* ---------- 自订剧本 (creator, spec §11) ---------- */
/* The screen is a flex column: a fixed top bar, the scrolling body and the
   sticky 生成 dock live in normal flow, so the dock never scrolls away. */
#scr-create { display: flex; flex-direction: column; overflow: hidden; }
.cr-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.cr-top-title { font: 700 15px/1.3 var(--f-display); letter-spacing: 1px; }
.cr-top-sp { width: 44px; height: 44px; flex: none; }
.cr-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 4px 18px 24px; }
.cr-body::-webkit-scrollbar { display: none; }
.cr-dock { flex: none; display: grid; gap: 8px; padding: 12px 18px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(12, 10, 28, 0), var(--night) 32%); }
.cr-go { width: 100%; flex: none; }
.cr-dock-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--mist); font-variant-numeric: tabular-nums; }
/* Auto cover + the disabled 公开 switch (spec-m2-web §11.6). The whole row is a
   44 px tap target; aria-disabled greys it instead of a dead native button. */
.cr-pub { display: grid; gap: 2px; min-height: 44px; padding: 8px 14px; border-radius: 18px; background: var(--glass); border: 1px dashed var(--line); color: var(--mist); opacity: .6; cursor: not-allowed; }
.cr-pub-row { display: flex; align-items: center; gap: 8px; min-height: 24px; min-width: 0; }
.cr-pub-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: #d5cfee; }
.cr-pub-badge { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 2px 8px; border-radius: 99px; background: rgba(165, 148, 255, .16); border: 1px solid rgba(165, 148, 255, .38); color: #cfc6f2; }
.cr-pub-switch { flex: none; margin-left: auto; position: relative; width: 40px; height: 24px; border-radius: 99px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); }
.cr-pub-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #8d86ad; }
.cr-pub-sub { font-size: 11px; line-height: 1.5; color: var(--mist); }
.cr-go-sub { margin: -2px 0 0; font-size: 11px; line-height: 1.5; color: var(--mist); text-align: center; }

/* intro + 随机 */
.cr-head { display: flex; align-items: flex-start; gap: 12px; padding-top: 4px; }
.cr-head h1 { font: 700 25px/1.3 var(--f-display); letter-spacing: .5px; }
.cr-head p { margin: 6px 0 0; font-size: 13px; color: var(--mist); }
.cr-random { flex: none; min-height: 44px; padding: 0 15px; border-radius: 99px; font-size: 13px; font-weight: 700; color: var(--aura-t); border: 1px solid rgba(122, 230, 225, .42); background: rgba(122, 230, 225, .1); }

/* one section per menu */
.cr-sec { margin-top: 20px; }
.cr-sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cr-sec-h h3 { font: 700 15px/1.4 var(--f-display); letter-spacing: .5px; }
.cr-sec-note { font-size: 11px; color: var(--aura-r); }
.cr-age-val { font-size: 14px; color: var(--aura-t); font-variant-numeric: tabular-nums; }
.cr-count { font-size: 11px; color: var(--mist); font-variant-numeric: tabular-nums; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-chip { min-height: 44px; padding: 7px 14px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; color: var(--mist); }
.cr-chip.on { color: var(--ink); font-weight: 500; border-color: transparent; background: linear-gradient(var(--deep), var(--deep)) padding-box, var(--aura) border-box; box-shadow: 0 4px 18px rgba(165, 148, 255, .25); }
.cr-sec.bad .cr-sec-h h3 { color: #ff9a9a; }
.cr-sec.bad .cr-chip { border-color: rgba(255, 154, 154, .45); }

/* age slider */
.cr-range { width: 100%; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.cr-range:focus-visible { outline: 2px solid var(--aura-t); outline-offset: 3px; border-radius: 99px; }
.cr-range::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--aura-v), var(--aura-r) 60%, var(--aura-t)); }
.cr-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(165, 148, 255, .3), 0 6px 16px rgba(0, 0, 0, .5); }
.cr-range::-moz-range-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--aura-v), var(--aura-r) 60%, var(--aura-t)); }
.cr-range::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(165, 148, 255, .3); }
.cr-range-ends { display: flex; justify-content: space-between; margin-top: -4px; font-size: 11px; color: var(--mist); }

/* optional note */
.cr-note { width: 100%; min-height: 96px; resize: vertical; border-radius: 18px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.6; padding: 12px 14px; }
.cr-note::placeholder { color: #8d86ad; }
.cr-note-err { min-height: 18px; margin-top: 6px; font-size: 12px; color: #ff9a9a; }
.cr-fine { margin: 18px 0 0; font-size: 11px; color: var(--mist); text-align: center; }
.cr-sk { padding-top: 10px; }
.cr-sk-rows { display: grid; gap: 12px; margin-top: 26px; }
.cr-sk-row { height: 84px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); }

/* upsell (allowed: false) */
.cr-up { padding: 8px 0 28px; }
.cr-up h1 { font: 700 26px/1.35 var(--f-display); margin: 14px 0 10px; }
.cr-up p { margin: 0 0 20px; font-size: 14px; color: var(--mist); }
.cr-up-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.cr-up-list li { padding: 14px 16px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); }
.cr-up-list b { display: block; font: 700 15px/1.4 var(--f-display); }
.cr-up-list span { display: block; margin-top: 3px; font-size: 12px; color: var(--mist); }
.cr-up-btn { width: 100%; flex: none; }

/* result */
.cr-res { padding-top: 4px; }
.cr-cover { position: relative; aspect-ratio: 3 / 4; border-radius: 26px; overflow: hidden; background: var(--deep); border: 1px solid var(--line); box-shadow: 0 22px 44px rgba(0, 0, 0, .45); }
.cr-cover img { width: 100%; height: 100%; object-fit: cover; }
.cr-cover-ph { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #3a2a7e, #6d2c66 58%, #1f5a66); font: italic 600 96px/1 var(--f-brand); color: rgba(255, 255, 255, .8); }
.cr-cover-tag { position: absolute; top: 12px; left: 12px; z-index: 2; font-size: 11px; padding: 3px 10px; border-radius: 99px; background: rgba(12, 10, 28, .55); border: 1px solid rgba(165, 148, 255, .5); color: #ece6fc; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cr-cover-busy { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; align-content: center; justify-items: center; gap: 10px; background: rgba(12, 10, 28, .72); font-size: 13px; color: var(--ink); }
.cr-cover-busy .dotty { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .18); border-top-color: var(--aura-t); animation: cr-spin 1s linear infinite; }
@keyframes cr-spin { to { transform: rotate(360deg); } }
.cr-res-head { margin-top: 16px; }
.cr-name { font: 700 30px/1.25 var(--f-display); letter-spacing: 1px; }
.cr-sub { margin-top: 6px; font-size: 12px; color: var(--aura-t); }
.cr-hook { margin: 10px 0 0; font: 500 16px/1.7 var(--f-display); color: #e9e3fb; }
.cr-intro { margin: 12px 0 0; font-size: 14px; line-height: 1.75; color: #ddd7f3; overflow-wrap: anywhere; }
.cr-res-actions { display: grid; gap: 10px; margin-top: 18px; }
.cr-res-actions .btn-aura, .cr-res-actions .btn-line { width: 100%; }
.cr-img-btn[aria-busy="true"] { opacity: .6; }

/* 我的创作 strip */
.cr-strip { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; padding: 2px 18px 6px; margin: 0 -18px; }
.cr-strip::-webkit-scrollbar { display: none; }
.cr-mini { position: relative; flex: none; width: 104px; }
.cr-mini-open { display: block; width: 100%; text-align: left; }
.cr-mini-cover { position: relative; display: block; width: 104px; height: 138px; border-radius: 16px; overflow: hidden; background: var(--deep); border: 1px solid var(--line); }
.cr-mini-cover img { width: 100%; height: 100%; object-fit: cover; }
.cr-mini b { display: block; margin-top: 7px; font: 700 13px/1.3 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-mini small { display: block; font-size: 11px; color: var(--mist); }
/* 44 px hit area, 30 px visual pill */
.cr-mini-more { position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); }
.cr-mini-more::before { content: "⋯"; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: rgba(12, 10, 28, .62); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-size: 15px; line-height: 1; }
.cr-empty { display: grid; justify-items: center; gap: 10px; padding: 18px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line); color: var(--mist); font-size: 13px; }
.cr-empty p { margin: 0; }
.cr-strip .cr-empty { flex: 1; }

/* placeholders: name's first character on the aurora dusk gradient */
.ph-init { display: grid; place-items: center; width: 100%; height: 100%; background: linear-gradient(160deg, #3a2a7e, #6d2c66 58%, #1f5a66); color: rgba(255, 255, 255, .85); font: italic 700 26px/1 var(--f-brand); }
.avatar.ph::after { content: attr(data-initial); display: grid; place-items: center; width: 100%; height: 100%; background: linear-gradient(160deg, #3a2a7e, #6d2c66 58%, #1f5a66); color: rgba(255, 255, 255, .9); font: italic 700 19px/1 var(--f-brand); }
.hero.ph { background: linear-gradient(160deg, #3a2a7e, #6d2c66 58%, #1f5a66); }
.hero.ph::before { content: attr(data-initial); position: absolute; inset: 0; display: grid; place-items: center; font: italic 600 150px/1 var(--f-brand); color: rgba(255, 255, 255, .55); }
.tag-priv { color: #ece6fc; background: rgba(165, 148, 255, .22); border: 1px solid rgba(165, 148, 255, .5); }

/* Plus badge (我的 → 自订剧本 row, upsell card) */
.plus-badge { flex: none; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 2px 8px; border-radius: 99px; background: var(--aura); color: var(--night); }
.plus-badge.big { display: inline-block; font-size: 12px; padding: 4px 12px; }
.list button .plus-badge { margin-left: auto; color: var(--night); font-size: 10px; }

/* 故事 → 创作 */
.story-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.story-create { flex: none; min-height: 44px; padding: 0 16px; border-radius: 99px; background: var(--glass); border: 1px solid var(--line); font-size: 13px; color: var(--ink); }

/* full-screen generating overlay (non-dismissable) */
.cr-busy { position: absolute; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px; text-align: center; background: rgba(6, 4, 16, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cr-busy-box { display: grid; justify-items: center; gap: 16px; }
.cr-busy-box b { font: 700 19px/1.4 var(--f-display); }
.cr-busy-box p { margin: 0; font-size: 13px; color: var(--mist); }
.aurora-loader { position: relative; width: 96px; height: 96px; filter: drop-shadow(0 0 22px rgba(165, 148, 255, .4)); }
.aurora-loader i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.aurora-loader i:nth-child(1) { border-top-color: var(--aura-v); animation: cr-spin 1.1s linear infinite; }
.aurora-loader i:nth-child(2) { inset: 13px; border-right-color: var(--aura-r); animation: cr-spin 1.7s linear infinite reverse; }
.aurora-loader i:nth-child(3) { inset: 26px; border-bottom-color: var(--aura-t); animation: cr-spin 2.3s linear infinite; }
.aurora-loader::after { content: ""; position: absolute; inset: 40px; border-radius: 50%; background: var(--aura); box-shadow: 0 0 34px rgba(255, 143, 196, .75); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .tilt { transform: none !important; }
  .tilt .art img { transform: none; }
}

/* ---------- payments: #/billing/return (Stripe sends the buyer back here) ---------- */
#scr-bill { background: radial-gradient(900px 520px at 70% 0%, rgba(36, 28, 77, .9) 0%, transparent 62%), var(--night); }
.bill-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.bill-top-title { font: 700 15px/1.3 var(--f-display); letter-spacing: 1px; }
.bill-top-sp { width: 44px; height: 44px; flex: none; }
.bill-body { padding: 10px 18px max(26px, env(safe-area-inset-bottom)); }
.bill-card { margin-top: 16px; border-radius: 24px; padding: 26px 20px; display: grid; justify-items: center; gap: 12px; text-align: center; background: var(--glass); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0, 0, 0, .35); }
.bill-card h1 { font: 700 23px/1.35 var(--f-display); letter-spacing: .5px; }
.bill-card p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--mist); }
.bill-card p:empty { display: none; }
.bill-mark { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; line-height: 1; background: var(--glass-2); border: 1px solid var(--line); color: var(--ink); }
.bill-card.wait .bill-mark { border-color: rgba(165, 148, 255, .45); box-shadow: 0 0 30px rgba(165, 148, 255, .25); }
.bill-card.ok { border-color: rgba(122, 230, 225, .45); background: linear-gradient(150deg, rgba(122, 230, 225, .13), rgba(165, 148, 255, .12)); }
.bill-card.ok .bill-mark { color: var(--aura-t); border-color: rgba(122, 230, 225, .5); box-shadow: 0 0 34px rgba(122, 230, 225, .35); }
.bill-card.warn { border-color: rgba(255, 210, 125, .4); }
.bill-card.warn .bill-mark { color: var(--gold); border-color: rgba(255, 210, 125, .45); }
.bill-card.err { border-color: rgba(255, 154, 154, .4); }
.bill-card.err .bill-mark { color: #ff9a9a; border-color: rgba(255, 154, 154, .45); }
.bill-spin { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .16); border-top-color: var(--aura-v); border-right-color: var(--aura-r); border-bottom-color: var(--aura-t); animation: cr-spin 1s linear infinite; }
.bill-extra { display: grid; gap: 4px; margin-top: 2px; }
.bill-extra p { font: 700 15px/1.5 var(--f-body); color: var(--gold); font-variant-numeric: tabular-nums; }
.bill-actions { display: grid; gap: 10px; margin-top: 20px; }
.bill-actions:empty { display: none; }
.bill-actions .btn-line, .bill-actions .btn-aura { width: 100%; flex: none; }

/* buy in flight: the tapped control keeps its markup and gets a spinner */
#buyBtn.busy { opacity: .82; }
.pack.busy, .plan.busy { position: relative; opacity: .6; }
.pack.busy::after, .plan.busy::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(12, 10, 28, .5); }
.pack.busy::before, .plan.busy::before { content: ""; position: absolute; left: 50%; top: 50%; z-index: 2; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2); border-top-color: var(--aura-t); animation: cr-spin 1s linear infinite; }

/* 我的 → 管理订阅 row (built by app.js; date may be long on a 375 px phone) */
#manageSubBtn span { max-width: 56%; overflow: hidden; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .bill-spin, .pack.busy::before, .plan.busy::before { animation: none !important; }
}


/* ---------- story popularity pill (spec §6, 2026-11-14) ---------- */
/* One pill on the cover of every public story card: how many distinct people
   have played it. It sits over its own soft dark gradient so it reads on any
   cover, and inside the card's overflow:hidden art so it can never widen a
   row (375 px has no horizontal scroll). */
.pill-players { position: absolute; left: 10px; bottom: 10px; z-index: 5; display: inline-flex; align-items: center; gap: 4px; max-width: calc(100% - 20px); padding: 3px 8px; border-radius: 99px; font-size: 11px; line-height: 1.2; color: var(--ink); background: linear-gradient(90deg, rgba(12, 10, 28, .82), rgba(12, 10, 28, .48)); border: 1px solid rgba(255, 255, 255, .16); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none; }
.pill-players svg { width: 12px; height: 12px; flex: none; }
.pill-players b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Cards whose bottom edge carries the title keep the pill at the top-right,
   so it can never cover the name. */
.tilt .pill-players { left: auto; right: 12px; top: 12px; bottom: auto; }
.flow-card .pill-players { left: auto; right: 14px; top: 14px; bottom: auto; }
/* 64 px list thumbnails (saved rows): the same pill, one size down. */
.story-row .thumb { position: relative; }
.pill-players.compact { left: 4px; bottom: 4px; padding: 1px 5px; gap: 2px; font-size: 9px; max-width: calc(100% - 8px); }
.pill-players.compact svg { width: 9px; height: 9px; }
/* Detail hero: the same pill on the big cover. */
.hero .pill-players { left: 16px; bottom: 16px; z-index: 2; font-size: 12px; }

/* ---------- language toggle (i18n contract 2026-11-14) ---------- */
/* The home header holds the wallet pill and the language pill side by side. */
.top-right { display: flex; align-items: center; gap: 8px; }
#langBtn { min-width: 46px; padding: 5px 10px; justify-content: center; font-weight: 600; }
/* 我的 row: the current language sits on the right like the other rows' hints. */
#langRow #langValue { margin-left: auto; color: var(--mist); font-size: 13px; white-space: nowrap; }
/* Row labels are the left-hand text: undo the hint styling .list button span adds. */
.list button .lbl { margin-left: 0; color: inherit; font-size: inherit; white-space: normal; }
/* spec §15: 我的 → the four legal pages (links, not buttons; 44 px targets) */
.list a.legal-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 14px 16px; text-align: left; font-size: 14px; color: var(--ink); text-decoration: none; }
.list a.legal-row + a.legal-row { border-top: 1px solid var(--line); }
.list a.legal-row .chev { margin-left: auto; color: var(--mist); font-size: 18px; }
/* English runs wider than Chinese: tighten the section headers so they still
   fit one line next to their hints on a 375 px phone. */
html[lang="en"] .section-h h2 { font-size: 18px; letter-spacing: 0; }
