/* BetterLife AI course. White-led, navy structure, blue interaction, green for done.
   Mobile first: one column, big touch targets, bottom tab bar. */
:root {
  --navy: #001F63; --navy2: #0A2A66; --blue: #2456B3; --bright: #347FF0;
  --pale: #E7EEFF; --pale2: #EDF5FF; --green: #0B9B45; --green-ink: #0B6B39; --green-soft: #E9F5EE;
  --ink: #16233F; --body: #2E3A4B; --muted: #6B7688; --line: #D9DEE8; --line2: #E8ECF3;
  --page: #F7FAFC; --white: #fff; --orange: #C46A06; --cream: #FCF1E1; --red: #C2483C; --red-soft: #FBEAE8;
  --radius: 16px; --shadow: 0 6px 20px rgba(16, 35, 80, .07);
  /* Level accent (top bar, level header, course map, progress). Green and red keep done/warning in every level. */
  --level: #2456B3; --level-bright: #347FF0; --level-soft: #E7EEFF;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--body); font: 16px/1.6 var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3 { color: var(--ink); line-height: 1.3; margin: 0 0 .4em; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); } .small { font-size: 14px; } .tiny { font-size: 12.5px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }
:root[data-level="2"] { --level: #0B9B45; --level-bright: #0E9F52; --level-soft: #E9F5EE; }
:root[data-level="3"] { --level: #B4610A; --level-bright: #E8850C; --level-soft: #FCF1E1; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.wordmark { display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; }
.wordmark b { color: var(--navy); font-weight: 800; letter-spacing: -.2px; font-size: 18px; }
.wordmark span { color: var(--green); font-weight: 700; letter-spacing: 2px; font-size: 12px; }

/* shell */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line2); box-shadow: inset 0 3px 0 var(--level-bright); }
.top .in { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.top .back { border: 0; background: none; padding: 6px 8px 6px 0; color: var(--navy); font-size: 22px; line-height: 1; cursor: pointer; }
.top .title { flex: 1; min-width: 0; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.testbar { background: var(--cream); color: #7A4706; font-size: 12.5px; text-align: center; padding: 4px 12px; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; }
main.wide { max-width: 1100px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line2);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; max-width: 150px; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; padding: 8px 0 7px; }
.tabs a .ic { display: block; font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--navy); font-weight: 700; }
.tabs a.on .ic { filter: none; opacity: 1; }

/* cards & buttons */
.card { background: #fff; border: 1px solid var(--line2); border-radius: var(--radius); padding: 18px; margin: 0 0 14px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.navy { background: var(--navy); color: #fff; border: 0; }
.card.navy h2, .card.navy h3 { color: #fff; }
.card.pale { background: var(--pale2); border-color: #D6E4FB; box-shadow: none; }
.card.green { background: var(--green-soft); border-color: #CBE8D6; box-shadow: none; }
.card.cream { background: var(--cream); border-color: #F1DFC3; box-shadow: none; }
.kicker { font-size: 12.5px; font-weight: 700; letter-spacing: 1px; color: var(--green-ink); margin-bottom: 6px; }
.card.navy .kicker { color: #8FE0B0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px;
  font-weight: 700; cursor: pointer; text-decoration: none; min-height: 48px; background: var(--blue); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.green { background: var(--green); }
.btn.navy { background: var(--navy); }
.btn.ghost { background: #fff; color: var(--blue); border: 1.5px solid #C9D7F2; }
.btn.light { background: var(--pale); color: var(--navy); }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--pale); color: var(--navy); vertical-align: middle; }
.badge.green { background: var(--green-soft); color: var(--green-ink); }
.badge.cream { background: var(--cream); color: #7A4706; }
.badge.grey { background: var(--line2); color: var(--muted); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* forms */
label.f { display: block; font-weight: 600; color: var(--ink); margin: 12px 0 6px; font-size: 15px; }
input.in, textarea.in, select.in { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; font-size: 16px; }
input.in:focus, textarea.in:focus, select.in:focus { outline: none; border-color: var(--bright); box-shadow: 0 0 0 3px rgba(52,127,240,.15); }
textarea.in { min-height: 110px; resize: vertical; line-height: 1.55; }
.err { color: var(--red); font-size: 14px; margin-top: 8px; }
.ok { color: var(--green-ink); font-size: 14px; margin-top: 8px; }

/* login */
.auth { max-width: 420px; margin: 0 auto; padding: 48px 20px; }
.auth .wordmark b { font-size: 26px; } .auth .wordmark span { font-size: 14px; }
.auth h1 { margin-top: 26px; }

/* progress */
.bar { height: 10px; background: var(--line2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--level), var(--level-bright)); border-radius: 99px; transition: width .6s; }
.card.navy .bar > i { background: linear-gradient(90deg, var(--level-bright), #7FB0FF); }
.level-kicker { color: var(--level); }
.card.navy .level-kicker { color: #9CC2FF; }
.card.navy .bar { background: rgba(255,255,255,.18); }
.big-num { font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1; }
.card.navy .big-num { color: #fff; }
.streak { display: flex; gap: 6px; margin-top: 10px; }
.streak i { width: 26px; height: 26px; border-radius: 8px; background: var(--line2); display: grid; place-items: center; font-style: normal; font-size: 13px; }
.streak i.on { background: #FFE7C2; }
.streak i.free { background: #fff; border: 1.5px dashed #E8B66A; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line2); }
.list li:first-child { border-top: 0; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 2px; text-decoration: none; color: var(--body); }
.item .ic { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 16px; background: var(--pale2); }
.item.done .ic { background: var(--green-soft); }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; color: var(--ink); font-weight: 600; }
.item .chev { color: var(--muted); }
.week-head { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.week-head .num { width: 40px; height: 40px; border-radius: 12px; background: var(--level); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.week-head.done .num { background: var(--green); }

/* lesson */
.steps-dots { display: flex; gap: 6px; margin: 10px 0 2px; }
.steps-dots i { flex: 1; height: 5px; border-radius: 9px; background: var(--line2); }
.steps-dots i.on { background: var(--green); }
.opt { display: block; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 8px 0; cursor: pointer; }
.opt:hover { border-color: #B7C9EE; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.picked { border-color: var(--bright); background: var(--pale2); }
.who { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; background: var(--blue); }
.avatar.ml { background: var(--green); }
.build { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.build li { position: relative; padding: 0 0 14px 40px; }
.build li::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--pale); color: var(--navy); font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.build li b { color: var(--ink); display: block; }
.recap ol { margin: 6px 0 0; padding-left: 22px; }
.recap li { margin: 6px 0; }
.video-box { background: #0B1230; border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.video-box video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.video-coming { aspect-ratio: 16 / 9; display: grid; place-items: center; text-align: center; color: #DCE6FF; padding: 20px;
  background: radial-gradient(120% 120% at 20% 0%, #163E9A 0%, #001F63 60%); border-radius: var(--radius); margin-bottom: 8px; }
.video-coming b { display: block; color: #fff; font-size: 18px; margin-bottom: 4px; }
/* the video stops for 猜一猜 / 试一试: thumb-sized choices right under the picture */
.video-stop { border: 2px solid var(--level-bright); background: var(--level-soft); border-radius: 14px; padding: 14px; margin: 0 0 10px; }
.video-stop .q { font-weight: 700; color: var(--ink); font-size: 17px; margin: 2px 0 6px; }
.video-stop .opt { display: flex; gap: 12px; align-items: center; min-height: 54px; font-size: 16px; margin: 8px 0 0; }
.video-stop .opt .letter { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--level-soft); color: var(--level); font-weight: 800; }
.video-stop .opt.picked .letter { background: var(--level-bright); color: #fff; }
.video-stop .picked-note { font-weight: 800; color: var(--level); font-size: 18px; text-align: center; padding: 10px 0; }
.speed { display: flex; gap: 6px; flex-wrap: wrap; }
.speed button { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 12px; font-size: 14px; cursor: pointer; }
.speed button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.material-img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; cursor: zoom-in; background: #fff; }
.msg-quote { background: #E9FBE4; border-radius: 12px 12px 12px 4px; padding: 10px 12px; color: #1B2A1B; white-space: pre-wrap; max-width: 92%; }
.compare { display: grid; gap: 10px; }
@media (min-width: 720px) { .compare { grid-template-columns: repeat(3, 1fr); } }

/* challenge */
.tries { display: inline-flex; gap: 5px; vertical-align: middle; }
.tries i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.tries i.used { background: var(--orange); }
.tries i.pass { background: var(--green); }
.score { display: flex; align-items: center; gap: 14px; }
.score .ring { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 24px; flex: none;
  background: conic-gradient(var(--c, var(--green)) calc(var(--p) * 1%), var(--line2) 0); position: relative; color: var(--ink); }
.score .ring::before { content: ""; position: absolute; inset: 7px; background: #fff; border-radius: 50%; }
.score .ring span { position: relative; }
.crit { margin: 10px 0; }
.crit .h { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink); font-weight: 600; }
.crit .bar { height: 7px; margin: 4px 0; }
.crit .n { font-size: 13.5px; color: var(--muted); }
.hint { border-left: 4px solid #E8B66A; background: #FFF8EC; padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.hint.locked { border-left-color: var(--line); background: var(--page); color: var(--muted); }
.sort-item { border: 1px solid var(--line2); border-radius: 12px; padding: 10px 12px; margin: 8px 0; background: #fff; }
.seg { display: flex; gap: 6px; margin-top: 8px; }
.seg button { flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 6px; font-size: 14px; cursor: pointer; }
.seg button.on0 { border-color: var(--green); background: var(--green-soft); color: var(--green-ink); font-weight: 700; }
.seg button.on1 { border-color: var(--red); background: var(--red-soft); color: var(--red); font-weight: 700; }
.seg.four { flex-wrap: wrap; }
.seg.four button { flex: 1 1 45%; }
.seg.four button.on0, .seg.four button.on1, .seg.four button.on2, .seg.four button.on3 { border-color: var(--navy); background: var(--pale); color: var(--navy); font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; cursor: pointer; background: #fff; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.check.on { border-color: var(--bright); background: var(--pale2); }
.why { font-size: 14px; margin-top: 4px; }
.why.ok { color: var(--green-ink); } .why.no { color: var(--red); }

/* ---------- chat box: four looks, one structure ---------- */
.chat { --c-bg: #fff; --c-text: var(--body); --c-user: var(--pale); --c-user-text: var(--ink); --c-ai-bg: transparent; --c-input: #fff;
  --c-border: var(--line); --c-send: var(--blue); --c-send-text: #fff; --c-dot: var(--green); --c-font: var(--font);
  background: var(--c-bg); color: var(--c-text); border: 1px solid var(--c-border); border-radius: 20px; overflow: hidden; font-family: var(--c-font); }
.chat .log { padding: 14px 14px 4px; max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat.full .log { max-height: none; min-height: 50vh; }
.chat .m { margin: 0 0 12px; display: flex; }
.chat .m.user { justify-content: flex-end; }
.chat .m .b { max-width: 88%; padding: 10px 14px; border-radius: 18px; word-break: break-word; }
.chat .m.user .b { background: var(--c-user); color: var(--c-user-text); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.chat .m.ai .b { background: var(--c-ai-bg); padding-left: 2px; max-width: 100%; }
.chat .m.ai .who-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; margin: 2px 8px 0 0; background: var(--c-dot); }
.chat .m .b img { max-width: 220px; border-radius: 12px; display: block; margin-bottom: 6px; }
.chat .m.ai .b p { margin: 0 0 .5em; } .chat .m.ai .b ul, .chat .m.ai .b ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.chat .label { font-size: 12px; color: var(--muted); margin: 0 0 4px 2px; }
.chat .typing span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: currentColor; opacity: .35; animation: blink 1.2s infinite; }
.chat .typing span:nth-child(2) { animation-delay: .2s; } .chat .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: .8; } }
.chat .composer { padding: 10px; }
.chat .box { display: flex; align-items: flex-end; gap: 8px; background: var(--c-input); border: 1.5px solid var(--c-border); border-radius: 22px; padding: 6px 6px 6px 12px; }
.chat .box textarea { flex: 1; border: 0; outline: none; resize: none; background: transparent; min-height: 40px; max-height: 180px; padding: 8px 0; line-height: 1.5; font-size: 16px; font-family: var(--c-font); color: var(--c-text); }
.chat .send { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--c-send); color: var(--c-send-text); font-size: 18px; cursor: pointer; flex: none; }
.chat .send:disabled { opacity: .35; }
.chat .tool { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; font-size: 20px; cursor: pointer; flex: none; color: var(--c-text); }
.chat .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); padding: 6px 6px 0; }
.chat .thumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 8px; background: rgba(0,0,0,.05); border-radius: 8px; margin: 0 0 6px 4px; }
.chat .thumb img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.chat .redo { font-size: 13px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 0 0 36px; }

/* "mono": clean black and white, pill input, round dark send button */
.chat.theme-mono { --c-bg: #fff; --c-text: #0d0d0d; --c-user: #f1f1f1; --c-user-text: #0d0d0d; --c-input: #fff; --c-border: #e3e3e3;
  --c-send: #0d0d0d; --c-dot: #0d0d0d; }
.chat.theme-mono .m.ai .who-dot { background: radial-gradient(circle at 50% 50%, #fff 0 34%, #0d0d0d 36%); }
/* "aurora": cool blue-violet light, soft grey-blue input, gradient spark dot */
.chat.theme-aurora { --c-bg: #fff; --c-text: #1f1f1f; --c-user: #e9eef6; --c-user-text: #1f1f1f; --c-input: #f0f4f9; --c-border: #e4e9f2;
  --c-send: #3c64d8; --c-dot: linear-gradient(135deg, #4f7cf7, #9b72cb 55%, #d96570); }
.chat.theme-aurora .box { border-color: transparent; border-radius: 28px; }
.chat.theme-aurora .m.ai .who-dot { background: linear-gradient(135deg, #4f7cf7, #9b72cb 55%, #d96570); border-radius: 40% 60% 55% 45%; }
/* "warm": cream paper, serif answers, terracotta send */
.chat.theme-warm { --c-bg: #faf8f3; --c-text: #2b2a26; --c-user: #efebe1; --c-user-text: #2b2a26; --c-input: #fff; --c-border: #e5dfd2;
  --c-send: #c46848; --c-dot: #c46848; }
.chat.theme-warm .m.ai .b { font-family: ui-serif, Georgia, "Songti SC", "Noto Serif SC", serif; font-size: 16.5px; }
.chat.theme-warm .box { border-radius: 16px; }
.chat.theme-warm .send { border-radius: 10px; }
.chat.theme-warm .m.ai .who-dot { border-radius: 8px; }
/* "brand": BetterLife navy, blue and green */
.chat.theme-brand { --c-user: var(--navy); --c-user-text: #fff; --c-send: var(--blue); --c-dot: var(--green); --c-border: #D6E1F5; }

/* modal (image zoom) */
.zoom { position: fixed; inset: 0; background: rgba(5, 12, 35, .88); z-index: 50; display: grid; place-items: center; padding: 12px; }
.zoom img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* survey */
.choices { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.choice { border: 2px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; cursor: pointer; text-align: left; }
.choice.on { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(0,31,99,.08); }
.choice b { display: block; color: var(--ink); margin-top: 8px; }
.swatch { display: flex; gap: 4px; }
.swatch i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); }

/* admin */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line2); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; border-top: 0; }
.scroll-x { overflow-x: auto; }
.copy { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--page); border: 1px dashed var(--line); padding: 8px; border-radius: 8px; }

@media (min-width: 900px) {
  main { padding-top: 24px; }
  .tabs { top: 0; bottom: auto; left: auto; right: 16px; border: 0; background: transparent; width: auto; height: 52px; align-items: center; gap: 4px; }
  .tabs a { padding: 6px 10px; font-size: 14px; max-width: none; flex: none; }
  .tabs a .ic { display: none; }
  .top .in { max-width: 1100px; }
  .top .in { padding-right: 420px; }
  main { padding-bottom: 60px; }
}
