:root {
  --bg: #F3F5F8;
  --card: #FFFFFF;
  --ink: #16161D;
  --ink2: #5B5E6B;
  --ink3: #9EA2AE;
  --line: #ECEEF2;
  --green: #4CC35A;
  --green-l: #DDF7D9;
  --red: #FF5A5F;
  --red-l: #FFE7E6;
  --orange: #FF8A3D;
  --yellow: #FFD54A;
  --purple: #8B7CFF;
  --dark: #1C1C24;
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --shadow: 0 6px 24px rgba(30, 35, 60, .07);
  --shadow-lg: 0 18px 40px rgba(30, 35, 60, .16);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100vh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: calc(110px + var(--safe-b)); }
@media (min-width: 900px) {
  body { background: radial-gradient(circle at 20% 10%, #E3F8DF 0, transparent 40%), radial-gradient(circle at 80% 80%, #E6E4FF 0, transparent 40%), var(--bg); }
  #app { box-shadow: 0 0 0 1px var(--line); background: var(--bg); }
}

/* ---------- common ---------- */
.page { padding: 18px 18px 0; animation: pageIn .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pageIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: env(safe-area-inset-top, 0); min-height: 52px; }
.topbar h2 { margin: 0; font-size: 18px; font-weight: 800; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow); font-size: 18px; flex: none; }
.icon-btn:active { transform: scale(.94); }
.h1 { font-size: 30px; font-weight: 900; letter-spacing: -.5px; margin: 6px 0 4px; line-height: 1.15; }
.sub { color: var(--ink2); font-size: 14px; }
.muted { color: var(--ink3); font-size: 12px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 26px 2px 12px; font-weight: 800; font-size: 17px; }
.section-title small { font-weight: 600; color: var(--ink3); font-size: 12px; }
.section-title .link { font-size: 13px; color: var(--ink2); font-weight: 600; }
.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.money { font-variant-numeric: tabular-nums; font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 22px; border-radius: 18px; font-weight: 800; font-size: 16px; background: var(--dark); color: #fff; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.green { background: linear-gradient(180deg, #5BD46A, #3DB34C); box-shadow: 0 6px 0 #2E9A3C, 0 10px 20px rgba(61, 179, 76, .3); }
.btn.green:active { transform: translateY(3px); box-shadow: 0 3px 0 #2E9A3C; }
.btn.red { background: linear-gradient(180deg, #FF7B7F, #F2484E); box-shadow: 0 6px 0 #C93338; }
.btn.light { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.btn.ghost { background: #EEF0F4; color: var(--ink); }
.btn.sm { height: 38px; font-size: 14px; padding: 0 14px; border-radius: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: #fff; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.balance-pill { padding: 3px; border-radius: 999px; background: linear-gradient(90deg, #FF7AD9, #FFC542, #6EE7B7); }
.balance-pill > span { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 6px 14px 6px 6px; font-weight: 800; }
.balance-pill i { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #FFD54A, #FF8A3D); display: grid; place-items: center; font-style: normal; font-size: 14px; }
.balance-pill small { display: block; font-size: 10px; color: var(--ink3); font-weight: 600; line-height: 1; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink2); font-weight: 700; margin: 0 0 6px 4px; }
.input { width: 100%; height: 52px; border-radius: 16px; border: 2px solid transparent; background: #F1F3F6; padding: 0 16px; outline: none; font-size: 16px; transition: .15s; }
.input:focus { border-color: #BFE8BF; background: #fff; }
textarea.input { height: auto; min-height: 84px; padding: 12px 16px; resize: vertical; }
.seg { display: flex; background: #ECEEF2; border-radius: 16px; padding: 4px; gap: 4px; }
.seg button { flex: 1; height: 40px; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--ink2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.seg.dark button.on { background: var(--dark); color: #fff; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #FDFBD5 0%, #E8F8D8 45%, var(--bg) 75%); position: relative; overflow: hidden; }
.auth-hero { position: relative; height: 44vh; min-height: 300px; display: grid; place-items: center; }
.auth-hero img.hero { width: 78%; max-width: 360px; border-radius: 40px; animation: floaty 5s ease-in-out infinite; filter: drop-shadow(0 20px 30px rgba(90, 120, 40, .25)); }
.blob { position: absolute; border-radius: 40% 60% 55% 45%; filter: blur(.5px); opacity: .8; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-card { margin: -20px 18px 30px; position: relative; z-index: 2; background: rgba(255, 255, 255, .9); backdrop-filter: blur(14px); border-radius: var(--r-xl); padding: 24px 20px; box-shadow: var(--shadow-lg); }
.logo { font-size: 30px; font-weight: 900; letter-spacing: -1px; text-align: center; }
.logo span { color: var(--orange); }

/* ---------- avatar 3d ---------- */
.av3d { position: relative; display: grid; place-items: center; perspective: 600px; }
.av3d .av-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; animation: floaty 4s ease-in-out infinite; transform-style: preserve-3d; transition: transform .2s; }
.av3d.square .av-img { border-radius: 26%; }
.av3d::after { content: ""; position: absolute; bottom: -8%; left: 20%; right: 20%; height: 10%; border-radius: 50%; background: rgba(0, 0, 0, .14); filter: blur(5px); animation: shadowPulse 4s ease-in-out infinite; z-index: -1; }
.av3d.bounce .av-img { animation: jelly .7s ease, floaty 4s ease-in-out .7s infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-8px) rotate(1.5deg); } }
@keyframes shadowPulse { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.8); opacity: .6; } }
@keyframes jelly { 0% { transform: scale(1); } 25% { transform: scale(1.15, .85); } 45% { transform: scale(.9, 1.1); } 65% { transform: scale(1.05, .95); } 100% { transform: scale(1); } }
.sparkle { position: absolute; color: #fff; font-size: 18px; animation: twinkle 2.4s ease-in-out infinite; pointer-events: none; text-shadow: 0 0 8px rgba(255, 255, 255, .9); }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
.coin-pop { position: fixed; pointer-events: none; z-index: 99; font-size: 26px; animation: coinUp 1.1s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes coinUp { 0% { opacity: 0; transform: translate(0, 0) scale(.4); } 20% { opacity: 1; transform: translate(var(--dx), -40px) scale(1.1); } 100% { opacity: 0; transform: translate(calc(var(--dx) * 2), -170px) scale(.8) rotate(var(--rot)); } }

/* ---------- home ---------- */
.hello-row { display: flex; align-items: center; gap: 10px; }
.hello-row .me { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #FFE08A, #FFB547); display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 18px; box-shadow: var(--shadow); }
.week-nav { display: flex; align-items: center; justify-content: space-between; background: #fff; border-radius: 18px; padding: 6px; box-shadow: var(--shadow); margin-top: 14px; }
.week-nav button { width: 40px; height: 40px; border-radius: 12px; background: #F3F5F8; font-weight: 900; }
.week-nav .wk { text-align: center; font-weight: 800; }
.week-nav .wk small { display: block; color: var(--ink3); font-weight: 600; font-size: 11px; }

.kid-cards { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 18px 18px; margin: 0 -18px; scrollbar-width: none; }
.kid-cards::-webkit-scrollbar { display: none; }
.kid-card { flex: 0 0 78%; max-width: 330px; scroll-snap-align: center; border-radius: var(--r-xl); padding: 16px; color: #fff; position: relative; overflow: hidden; min-height: 230px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.kid-card:only-child { flex-basis: 100%; max-width: none; }
.kid-card .av3d { position: absolute; right: -6px; top: 8px; width: 150px; height: 150px; }
.kid-card .tag { align-self: flex-start; background: rgba(0, 0, 0, .7); padding: 4px 10px; border-radius: 10px; font-size: 11px; font-weight: 900; letter-spacing: 1px; }
.kid-card .name { font-size: 30px; font-weight: 900; margin-top: auto; text-shadow: 0 2px 0 rgba(0, 0, 0, .12); letter-spacing: -.5px; }
.kid-card .bal { font-size: 13px; opacity: .95; font-weight: 700; }
.kid-card .bal b { font-size: 26px; font-weight: 900; margin-left: 2px; }
.kid-card .wk-chips { display: flex; gap: 6px; margin-top: 10px; }
.kid-card .wk-chips span { background: rgba(255, 255, 255, .28); backdrop-filter: blur(6px); border-radius: 10px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
.kid-card.add { background: #fff; color: var(--ink2); border: 2px dashed #D9DCE3; box-shadow: none; align-items: center; justify-content: center; gap: 10px; font-weight: 800; }
.kid-card.add .plus { width: 64px; height: 64px; border-radius: 22px; background: #F1F3F6; display: grid; place-items: center; font-size: 30px; }

.g-orange { background: linear-gradient(145deg, #FFC15E 0%, #FF7A59 100%); }
.g-lemon { background: linear-gradient(145deg, #F6E05E 0%, #8FD45F 100%); }
.g-sky { background: linear-gradient(145deg, #7FB7FF 0%, #A78BFA 100%); }
.g-pink { background: linear-gradient(145deg, #FF9AC8 0%, #FF8A5B 100%); }
.g-mint { background: linear-gradient(145deg, #5EE0B0 0%, #3AA8E0 100%); }
.g-grape { background: linear-gradient(145deg, #C084FC 0%, #F472B6 100%); }

.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ov-tile { background: #fff; border-radius: 20px; padding: 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.ov-tile .emo { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; background: #F3F5F8; flex: none; }
.ov-tile b { display: block; font-size: 18px; font-weight: 900; }
.ov-tile small { color: var(--ink3); font-size: 12px; font-weight: 600; }

/* habit matrix */
.matrix { background: #fff; border-radius: var(--r-lg); padding: 14px 10px 10px; box-shadow: var(--shadow); overflow-x: auto; }
.matrix table { width: 100%; border-collapse: separate; border-spacing: 0 6px; min-width: 330px; }
.matrix th { font-size: 11px; color: var(--ink3); font-weight: 700; text-align: center; padding: 0 2px; }
.matrix th.today { color: var(--green); }
.matrix th.label, .matrix td.label { text-align: left; padding-left: 4px; }
.matrix td.label { font-size: 13px; font-weight: 700; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matrix td.label .mini-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; margin-right: 4px; }
.matrix td { text-align: center; }
.dot { width: 32px; height: 32px; border-radius: 11px; background: #F1F3F6; display: inline-grid; place-items: center; font-size: 13px; transition: transform .12s; }
.dot.on { background: linear-gradient(180deg, #6EDB79, #43BF52); color: #fff; box-shadow: 0 3px 0 #2E9A3C; font-weight: 900; }
.dot.miss { background: var(--red-l); color: var(--red); }
.dot:active { transform: scale(.85); }
.matrix .group-row td { padding-top: 8px; font-size: 12px; font-weight: 800; color: var(--ink2); text-align: left; }

/* day bars */
.daybars { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 120px; padding: 10px 4px 0; }
.daybar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.daybar .stack { width: 100%; max-width: 30px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; flex: 1; }
.daybar .bar { border-radius: 8px; min-height: 0; transition: height .5s cubic-bezier(.2, .9, .3, 1.1); }
.daybar small { font-size: 11px; color: var(--ink3); font-weight: 700; }
.daybar.today small { color: var(--ink); }

/* records */
.rec-day { margin: 18px 4px 8px; font-size: 13px; font-weight: 800; color: var(--ink2); display: flex; justify-content: space-between; }
.rec { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 18px; padding: 12px; margin-bottom: 8px; box-shadow: 0 2px 10px rgba(30, 35, 60, .04); }
.rec .ic { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--green-l); position: relative; }
.rec.penalty .ic, .rec.spend .ic { background: var(--red-l); }
.rec.spend .ic { background: #FFF1D6; }
.rec .ic img.mini-av { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; object-fit: cover; }
.rec .t { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec .n { font-size: 12px; color: var(--ink3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec .thumb { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; }
.rec .amt { font-weight: 900; font-size: 16px; flex: none; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink3); font-weight: 600; }
.empty .big { font-size: 46px; margin-bottom: 6px; }

/* banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 20px; background: linear-gradient(90deg, #FFF4C7, #FFE2C2); margin-top: 14px; }
.banner .emo { font-size: 30px; }
.banner b { display: block; }
.banner.ai { background: linear-gradient(90deg, #E9E5FF, #DDF3FF); }

/* ---------- book detail ---------- */
.book-hero { margin: -18px -18px 0; padding: calc(14px + env(safe-area-inset-top, 0)) 18px 60px; border-radius: 0 0 40px 40px; position: relative; overflow: hidden; color: #fff; }
.book-hero .av3d { width: 210px; height: 210px; margin: 6px auto 0; }
.book-hero .av-img { border: 6px solid rgba(255, 255, 255, .5); }
.book-hero .topbar .icon-btn { background: rgba(255, 255, 255, .9); color: var(--ink); }
.book-hero .cloud { position: absolute; bottom: -30px; left: -10%; right: -10%; height: 80px; background: var(--bg); border-radius: 50% 50% 0 0; }
.book-info { margin-top: -54px; position: relative; z-index: 2; }
.book-info .name-tag { display: inline-block; background: var(--bg); padding: 10px 18px 4px 4px; border-radius: 0 22px 0 0; font-size: 15px; color: var(--ink2); font-weight: 800; }
.book-info .big-name { font-size: 34px; font-weight: 900; letter-spacing: -1px; display: flex; align-items: center; gap: 10px; }
.book-info .big-name .lvl { font-size: 11px; background: var(--dark); color: #fff; padding: 4px 8px; border-radius: 8px; letter-spacing: .5px; }
.motto { background: #fff; border-radius: 18px; padding: 12px 14px; color: var(--ink2); font-size: 14px; margin-top: 10px; }

.goal { background: #fff; border-radius: 22px; padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.progress { position: relative; height: 22px; background: #EAEDF1; border-radius: 999px; margin: 12px 34px 6px 0; }
.progress .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(180deg, #6EDB79, #3DB34C); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .1); transition: width .8s cubic-bezier(.2, .9, .3, 1.1); }
.progress .knob { position: absolute; top: 50%; width: 26px; height: 26px; margin-left: -13px; transform: translateY(-50%); border-radius: 50%; background: #fff; border: 5px solid #3DB34C; transition: left .8s cubic-bezier(.2, .9, .3, 1.1); }
.progress .flag { position: absolute; right: -34px; top: -12px; font-size: 28px; }

.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick { background: #fff; border-radius: 18px; padding: 12px 4px 10px; text-align: center; box-shadow: 0 2px 10px rgba(30, 35, 60, .05); position: relative; transition: transform .1s; }
.quick:active { transform: scale(.93); }
.quick .e { font-size: 26px; line-height: 1.2; }
.quick .q { font-size: 11px; font-weight: 700; color: var(--ink2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.quick .a { font-size: 12px; font-weight: 900; margin-top: 2px; }
.quick.penalty { background: #FFF6F5; }

.tabs-inline { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.tabs-inline::-webkit-scrollbar { display: none; }
.tabs-inline button { flex: none; padding: 8px 14px; border-radius: 12px; background: #fff; font-weight: 700; font-size: 13px; color: var(--ink2); box-shadow: 0 2px 8px rgba(0, 0, 0, .04); }
.tabs-inline button.on { background: var(--dark); color: #fff; }

/* ---------- books list ---------- */
.book-row { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 24px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.book-row .av-wrap { width: 72px; height: 72px; border-radius: 22px; overflow: hidden; flex: none; }
.book-row .av-wrap img { width: 100%; height: 100%; object-fit: cover; }
.book-row .nm { font-size: 20px; font-weight: 900; }

/* ---------- rules ---------- */
.rule-group { margin-top: 18px; }
.rule-group h4 { margin: 0 4px 8px; font-size: 14px; color: var(--ink2); display: flex; align-items: center; gap: 6px; }
.rule { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 18px; padding: 12px; margin-bottom: 8px; box-shadow: 0 2px 10px rgba(30, 35, 60, .04); }
.rule.off { opacity: .45; }
.rule .ic { width: 42px; height: 42px; border-radius: 14px; background: var(--green-l); display: grid; place-items: center; font-size: 20px; flex: none; }
.rule.penalty .ic { background: var(--red-l); }
.rule .t { font-weight: 800; }
.rule .n { font-size: 12px; color: var(--ink3); }
.badge { display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 6px; background: #EEF0F4; color: var(--ink2); font-weight: 800; margin-left: 4px; vertical-align: middle; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); width: min(480px, calc(100% - 28px)); display: flex; align-items: center; gap: 10px; z-index: 40; }
.nav .bar { flex: 1; display: flex; justify-content: space-around; align-items: center; background: var(--dark); border-radius: 26px; height: 64px; padding: 0 6px; box-shadow: 0 14px 30px rgba(20, 20, 30, .3); }
.nav .bar a { flex: 1; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8D8F9C; font-size: 10px; font-weight: 700; gap: 2px; border-radius: 20px; transition: .2s; }
.nav .bar a svg { width: 22px; height: 22px; }
.nav .bar a.on { color: var(--dark); background: #fff; }
.nav .plus { width: 64px; height: 64px; border-radius: 24px; background: linear-gradient(180deg, #6EDB79, #3DB34C); color: #fff; font-size: 34px; font-weight: 400; display: grid; place-items: center; box-shadow: 0 6px 0 #2E9A3C, 0 14px 26px rgba(61, 179, 76, .35); flex: none; }
.nav .plus:active { transform: translateY(3px); box-shadow: 0 3px 0 #2E9A3C; }

/* ---------- sheet ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(15, 15, 25, .45); z-index: 60; animation: fadeIn .2s; backdrop-filter: blur(2px); }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 30px 30px 0 0; z-index: 61; padding: 10px 18px calc(24px + var(--safe-b)); animation: sheetUp .32s cubic-bezier(.2, .9, .3, 1.05); overscroll-behavior: contain; }
.sheet.closing { animation: sheetDown .22s ease-in forwards; }
.sheet-mask.closing { animation: fadeOut .22s forwards; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #D5D8DF; margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 14px; font-size: 20px; font-weight: 900; display: flex; justify-content: space-between; align-items: center; }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheetDown { to { transform: translate(-50%, 100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

.pick-kids { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.pick-kid { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; color: var(--ink2); }
.pick-kid .ring { width: 62px; height: 62px; border-radius: 50%; padding: 3px; background: #E3E6EB; transition: .15s; position: relative; }
.pick-kid .ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #fff; }
.pick-kid.on .ring { background: linear-gradient(135deg, #6EDB79, #3DB34C); transform: scale(1.05); }
.pick-kid.on .ring::after { content: "✓"; position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; font-size: 12px; display: grid; place-items: center; border: 2px solid #fff; }
.pick-kid.on { color: var(--ink); }

.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.chip { background: #fff; border-radius: 16px; padding: 10px 6px; text-align: center; border: 2px solid transparent; transition: .12s; }
.chip .e { font-size: 22px; }
.chip .q { font-size: 12px; font-weight: 700; margin-top: 2px; line-height: 1.25; min-height: 30px; display: flex; align-items: center; justify-content: center; }
.chip .a { font-size: 12px; font-weight: 900; }
.chip.on { border-color: var(--green); background: #F2FCF0; transform: scale(1.02); }
.chip.penalty.on { border-color: var(--red); background: #FFF5F4; }
.cat-label { font-size: 12px; font-weight: 800; color: var(--ink3); margin: 14px 4px 8px; }

.stepper { display: flex; align-items: center; background: #F1F3F6; border-radius: 16px; height: 52px; }
.stepper button { width: 52px; height: 52px; font-size: 22px; font-weight: 800; }
.stepper span { flex: 1; text-align: center; font-weight: 900; font-size: 18px; }
.photo-pick { width: 100%; height: 52px; border-radius: 16px; background: #F1F3F6; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; color: var(--ink2); position: relative; overflow: hidden; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; }
.photo-preview { position: relative; width: 96px; height: 96px; border-radius: 18px; overflow: hidden; margin-top: 8px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; }
.sum-bar { display: flex; justify-content: space-between; align-items: center; margin: 14px 4px; font-weight: 800; }
.sum-bar b { font-size: 26px; }

.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.avatar-grid button { aspect-ratio: 1; border-radius: 18px; overflow: hidden; border: 3px solid transparent; background: #fff; }
.avatar-grid button img { width: 100%; height: 100%; object-fit: cover; }
.avatar-grid button.on { border-color: var(--green); transform: scale(1.04); }
.color-row { display: flex; gap: 10px; }
.color-row button { width: 40px; height: 40px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 0 0 2px transparent; }
.color-row button.on { box-shadow: 0 0 0 2px var(--dark); }
.gen-box { background: linear-gradient(135deg, #EDE9FF, #E1F6FF); border-radius: 22px; padding: 14px; }
.gen-preview { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 10px 0; }
.gen-preview .ph { width: 110px; height: 110px; border-radius: 26px; overflow: hidden; background: rgba(255, 255, 255, .6); display: grid; place-items: center; font-size: 30px; position: relative; }
.gen-preview .ph img { width: 100%; height: 100%; object-fit: cover; }
.gen-preview .arrow { font-size: 22px; }
.loading-shimmer { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .8) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- stats ---------- */
.kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart-card { background: #fff; border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); margin-top: 12px; }
.chart-card h4 { margin: 0 0 10px; font-size: 15px; display: flex; justify-content: space-between; }
.chart-card canvas { width: 100%; display: block; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.rank-item .bar-bg { flex: 1; height: 10px; background: #F1F3F6; border-radius: 6px; overflow: hidden; }
.rank-item .bar-fg { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #6EDB79, #3DB34C); }
.rank-item.neg .bar-fg { background: linear-gradient(90deg, #FF9A9D, #FF5A5F); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--ink2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: #F1F3F6; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-card { background: #fff; border-radius: 18px; padding: 12px 6px; text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, .04); }
.badge-card .e { font-size: 30px; }
.badge-card.lock { filter: grayscale(1); opacity: .4; }
.badge-card b { display: block; font-size: 12px; margin-top: 4px; }
.badge-card small { font-size: 10px; color: var(--ink3); }

/* ---------- ai ---------- */
.md { line-height: 1.7; font-size: 15px; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 16px 0 6px; }
.md p { margin: 6px 0; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md strong { color: var(--ink); }
.ai-box { background: #fff; border-radius: 22px; padding: 16px; min-height: 160px; box-shadow: var(--shadow); }
.typing::after { content: "▍"; animation: blink 1s infinite; color: var(--purple); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- poster ---------- */
.poster-img { width: 100%; border-radius: 20px; box-shadow: var(--shadow-lg); }

/* ---------- toast ---------- */
#toast-root { position: fixed; top: calc(14px + env(safe-area-inset-top, 0)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 16px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .3s cubic-bezier(.2, .9, .3, 1.3); pointer-events: auto; display: flex; gap: 12px; align-items: center; max-width: 90vw; }
.toast button { color: #8BE08B; font-weight: 900; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(.9); } }

.list-item { display: flex; align-items: center; justify-content: space-between; padding: 16px; background: #fff; font-weight: 700; border-bottom: 1px solid var(--line); }
.list { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.list .list-item:last-child { border-bottom: 0; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: #DADDE3; position: relative; transition: .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .15); }
.switch.on { background: var(--green); }
.switch.on::after { left: 23px; }
.spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(0, 0, 0, .1); border-top-color: var(--ink); }
.center-load { display: grid; place-items: center; padding: 60px; }
