/* ==========================================================================
   iPAY participant app — mobile-style web shell
   Same token family as the staff portal (EdUHK green + orange, warm paper),
   tuned for all ages: 17px base, card-first, big touch targets (48px+),
   minimal jargon, bilingual-friendly line-height. Wave-2 agents style ONLY
   with these classes.
   ========================================================================== */

:root {
  --brand: #146B3A; --brand-deep: #0E4F2A; --brand-tint: #E6F2EA; --brand-tint-2: #CDE5D4;
  --action: #146B3A; --action-hover: #0E4F2A; --action-tint: #E6F2EA;
  /* logo orange: tints, borders and rings only; --accent-text is the one that carries text */
  --accent: #F28C1E; --accent-tint: #FDEBD5; --accent-line: #F5B36B; --accent-text: #9A4E00;
  --paper: #FAF7F2; --surface: #FFFFFF; --surface-2: #F3EFE8; --surface-3: #EAE4DA;
  --line: #E2DBD0; --line-strong: #C9C0B3;
  --ink: #1F1B17; --ink-2: #4A433C; --ink-3: #6B635A; --ink-inverse: #FFFFFF;
  --ok: #1E6B3A; --ok-tint: #E3F2E8; --ok-line: #A9D6B8;
  --warn: #6E5A1E; --warn-tint: #F6F0DC; --warn-line: #DCCD9A;
  --danger: #A32020; --danger-tint: #FBE6E6; --danger-line: #EFB3B3;
  --info: #1F4E7A; --info-tint: #E3EEF8; --info-line: #B3CDE8;
  --neutral: #4A433C; --neutral-tint: #EDE8E0; --neutral-line: #D3CBBF;
  --dark: #FFFFFF; --dark-tint: #4A433C; --dark-line: #4A433C;
  --focus: #F5A623;
  --radius: 16px; --radius-sm: 10px; --radius-lg: 22px; --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(31,27,23,.06), 0 6px 20px rgba(31,27,23,.07);
  --shadow-lg: 0 2px 6px rgba(31,27,23,.08), 0 16px 40px rgba(31,27,23,.12);
  --ease: 160ms ease;
  --font-sans: "Public Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "微軟正黑體", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Noto Sans TC", monospace;
  --fs-base: 17px; --lh-base: 1.55;
  --phone-w: 480px; --appbar-h: 64px; --nav-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs-base); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: 1rem; line-height: var(--lh-base); color: var(--ink); background: #EFE9E0; min-height: 100vh; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 .75rem; } p:last-child { margin-bottom: 0; }
a { color: var(--action); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding-left: 1.25rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: .5rem .75rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--ink-3); } .small { font-size: .9rem; } .strong { font-weight: 600; } .center { text-align: center; }
.h2 { font-size: 1.3rem; } .h3 { font-size: 1.1rem; }
.mono, .code { font-family: var(--font-mono); }
.icon { flex: none; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.stack > * + * { margin-top: 1rem; } .stack--sm > * + * { margin-top: .5rem; }
.cluster { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; }
.cluster--between { justify-content: space-between; }
.inline-form { display: inline; margin: 0; }

/* --------------------------------------------------------------------------
   Phone frame + app bar + bottom nav
   -------------------------------------------------------------------------- */
.phone { position: relative; max-width: var(--phone-w); margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--paper); display: flex; flex-direction: column; }
@media (min-width: 600px) { body { padding: 24px 0; } .phone { min-height: calc(100vh - 48px); border-radius: 28px; box-shadow: var(--shadow-lg), 0 0 0 10px #2A2523; overflow: hidden; } }
.demo-badge { position: absolute; top: calc(var(--appbar-h) + 6px); right: 10px; z-index: 40; display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; background: var(--warn-tint); color: var(--warn); border: 1px solid var(--warn-line); border-radius: var(--radius-pill); font-size: .72rem; font-weight: 700; pointer-events: none; }
.app-bar { position: sticky; top: 0; z-index: 30; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; height: var(--appbar-h); padding: 0 1rem; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: var(--ink-inverse); }
.app-brand { font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; color: #fff; text-decoration: none; }
.app-bar-title { font-size: 1.1rem; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-avatar { display: inline-flex; text-decoration: none; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); font-weight: 700; font-size: .95rem; flex: none; }
.avatar--app { background: #fff; border: 2px solid rgba(255,255,255,.75); }
.avatar--lg { width: 64px; height: 64px; font-size: 1.4rem; }
.avatar--sm { width: 32px; height: 32px; font-size: .8rem; }
.app-main { flex: 1; padding: 1.1rem 1rem calc(var(--nav-h) + 1.5rem); }
.bottom-nav { position: sticky; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; color: var(--ink-3); text-decoration: none; font-size: .74rem; font-weight: 600; min-height: 48px; border-top: 3px solid transparent; }
.bottom-tab:hover { color: var(--ink); background: var(--surface-2); }
.bottom-tab.is-active { color: var(--brand); border-top-color: var(--brand); }
.bottom-tab-icon { position: relative; display: inline-flex; }
.tab-badge { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; padding: 0 .3rem; border-radius: var(--radius-pill); background: var(--brand); color: #fff; font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.bottom-tab-label { line-height: 1; }

/* --------------------------------------------------------------------------
   Sections, cards, hero, notices, flash
   -------------------------------------------------------------------------- */
.section { margin-bottom: 1.5rem; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin: 0 .1rem .7rem; }
.section-title h2 { font-size: 1.15rem; }
.section-title .link { font-size: .92rem; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem; box-shadow: var(--shadow); }
.card--tint { background: var(--surface-2); box-shadow: none; }
.card--brand { background: linear-gradient(160deg, #fff, var(--brand-tint)); border-color: var(--brand-tint-2); }
.card--flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: .85rem; }
.hero { padding: 1.2rem 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.hero-greeting { font-size: 1.45rem; font-weight: 700; line-height: 1.3; }
.hero-sub { color: var(--ink-3); margin-top: .2rem; }
.notice { display: flex; gap: .6rem; padding: .85rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--info-line); background: var(--info-tint); color: var(--info); line-height: 1.45; font-size: .95rem; }
.notice--warn { border-color: var(--warn-line); background: var(--warn-tint); color: var(--warn); }
.notice--ok { border-color: var(--ok-line); background: var(--ok-tint); color: var(--ok); }
.notice--danger { border-color: var(--danger-line); background: var(--danger-tint); color: var(--danger); }
.notice--brand { border-color: var(--brand-tint-2); background: var(--brand-tint); color: var(--brand-deep); }
.notice .icon { margin-top: 2px; }
.notice a { color: inherit; font-weight: 600; }
.flash-stack { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.flash { display: flex; gap: .6rem; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; font-size: .95rem; }
.flash--success { background: var(--ok-tint); border-color: var(--ok-line); color: var(--ok); }
.flash--error { background: var(--danger-tint); border-color: var(--danger-line); color: var(--danger); }
.flash--warning { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn); }
.flash--info { background: var(--info-tint); border-color: var(--info-line); color: var(--info); }
.error-list { margin: 0; padding-left: 1.2rem; }
.empty { text-align: center; padding: 2rem 1rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .3rem; }
.empty-art { font-size: 2.4rem; line-height: 1; margin-bottom: .5rem; }

/* --------------------------------------------------------------------------
   Chips, tags, match pill, code
   -------------------------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .7rem; border-radius: var(--radius-pill); font-size: .84rem; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid; }
.chip--lg { font-size: .95rem; padding: .3rem .85rem; }
.chip--ok { background: var(--ok-tint); color: var(--ok); border-color: var(--ok-line); }
.chip--warn { background: var(--warn-tint); color: var(--warn); border-color: var(--warn-line); }
.chip--danger { background: var(--danger-tint); color: var(--danger); border-color: var(--danger-line); }
.chip--info { background: var(--info-tint); color: var(--info); border-color: var(--info-line); }
.chip--neutral { background: var(--neutral-tint); color: var(--neutral); border-color: var(--neutral-line); }
.chip--dark { background: var(--dark-tint); color: var(--dark); border-color: var(--dark-line); }
.chip--brand { background: var(--brand-tint); color: var(--brand); border-color: var(--brand-tint-2); }
.tag { display: inline-flex; align-items: center; padding: .18rem .65rem; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: .84rem; font-weight: 500; }
.tag--matched { background: var(--brand-tint); border-color: var(--brand-tint-2); color: var(--brand); font-weight: 600; }
.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.match-pill { display: inline-flex; align-items: baseline; gap: .3rem; padding: .3rem .75rem; border-radius: var(--radius-pill); border: 1px solid; font-size: .9rem; white-space: nowrap; }
.match-pill strong { font-size: 1.1rem; }
.match-pill--ok { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent-line); }
.match-pill--warn { background: var(--warn-tint); color: var(--warn); border-color: var(--warn-line); }
.match-pill--neutral { background: var(--neutral-tint); color: var(--neutral); border-color: var(--neutral-line); }
.code { font-family: var(--font-mono); font-size: .95em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .45rem; letter-spacing: .02em; white-space: nowrap; }
.code--masked { letter-spacing: .1em; color: var(--ink-2); }
.code--reveal { display: block; text-align: center; font-size: 1.35rem; padding: .7rem .9rem; background: var(--ok-tint); border-color: var(--ok-line); color: var(--ok); user-select: all; white-space: normal; word-break: break-all; }

/* --------------------------------------------------------------------------
   Interest chips (toggle) + segmented tabs
   -------------------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-toggle { position: relative; }
.chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-toggle span { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .45rem 1rem; border-radius: var(--radius-pill); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-weight: 500; cursor: pointer; transition: all var(--ease); font-size: .97rem; }
.chip-toggle input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip-toggle input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chips--static .tag { min-height: 36px; padding: .3rem .8rem; font-size: .95rem; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: var(--radius-pill); margin-bottom: 1rem; }
.segmented a { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .4rem .5rem; border-radius: var(--radius-pill); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.segmented a.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.segmented .count { font-size: .78rem; background: var(--surface-2); color: var(--ink-2); padding: 0 .4rem; border-radius: var(--radius-pill); }
.segmented a.is-active .count { background: var(--brand-tint); color: var(--brand); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 48px; padding: .6rem 1.2rem; border-radius: var(--radius-sm); border: 1.5px solid transparent; font-weight: 600; font-size: 1rem; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--action); color: #fff; border-color: var(--action); }
.btn--primary:hover { background: var(--action-hover); border-color: var(--action-hover); color: #fff; }
.btn--brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--brand:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--action); border-color: var(--line-strong); }
.btn--secondary:hover { background: var(--action-tint); border-color: var(--action); }
.btn--ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.btn--danger:hover { background: var(--danger-tint); border-color: var(--danger); }
.btn--success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn--success:hover { background: #185A30; border-color: #185A30; color: #fff; }
.btn--sm { min-height: 40px; padding: .35rem .85rem; font-size: .92rem; }
.btn--lg { min-height: 56px; font-size: 1.08rem; }
.btn--block { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.actions--split { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--action); text-decoration: underline; cursor: pointer; font-weight: 500; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-stack { display: flex; flex-direction: column; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.label { font-weight: 600; }
.label .req { color: var(--danger); margin-left: .15rem; }
.help { font-size: .9rem; color: var(--ink-3); line-height: 1.4; }
.input, .select, .textarea { width: 100%; min-height: 50px; padding: .6rem .9rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 1.02rem; transition: border-color var(--ease), box-shadow var(--ease); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-tint); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A433C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right .8rem center; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check { display: flex; align-items: flex-start; gap: .65rem; padding: .35rem 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 1px 0 0; accent-color: var(--action); flex: none; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem 1.1rem; margin: 0; }
.fieldset > legend { font-weight: 700; padding: 0 .35rem; color: var(--brand); }

/* --------------------------------------------------------------------------
   Study cards (feed + my studies)
   -------------------------------------------------------------------------- */
.study-list { display: flex; flex-direction: column; gap: .85rem; }
.study-card { display: flex; flex-direction: column; gap: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.05rem 1.1rem; box-shadow: var(--shadow); }
.study-card--muted { opacity: .8; background: var(--surface-2); box-shadow: none; }
.study-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.study-title { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.study-title-zh { font-size: 1.12rem; font-weight: 700; color: var(--ink); text-decoration: none; line-height: 1.35; }
a.study-title-zh:hover { color: var(--brand); }
.study-title-en { font-size: .9rem; color: var(--ink-3); }
.study-title--sm .study-title-zh { font-size: 1rem; }
.study-facts { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .92rem; color: var(--ink-2); }
.study-facts span { display: inline-flex; align-items: center; gap: .3rem; }
.study-facts .reward { font-weight: 700; color: var(--brand); }
.study-desc { font-size: .95rem; color: var(--ink-2); }
.study-card .actions { margin-top: .2rem; }
.progress { height: 10px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--radius-pill); background: var(--brand); }
.progress-bar--brand { background: var(--brand); } .progress-bar--ok { background: var(--ok); } .progress-bar--info { background: var(--info); } .progress-bar--warn { background: var(--warn); } .progress-bar--action { background: var(--action); }
.progress-label { margin-top: .3rem; font-size: .88rem; color: var(--ink-3); display: flex; justify-content: space-between; gap: .5rem; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.steps li { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: var(--ink-3); }
.steps li.is-done { color: var(--ok); }
.steps li.is-current { color: var(--ink); font-weight: 600; }
.step-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.steps li.is-done .step-dot { background: currentColor; }

/* --------------------------------------------------------------------------
   Coupons (wallet)
   -------------------------------------------------------------------------- */
.wallet-total { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.15rem; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: #fff; border-radius: var(--radius-lg); margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.wallet-total strong { font-size: 2rem; font-weight: 800; }
.wallet-total span { opacity: .9; }
.coupon-card { position: relative; display: flex; flex-direction: column; gap: .55rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.coupon-card::before, .coupon-card::after { content: ""; position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--line); transform: translateY(-50%); }
.coupon-card::before { left: -10px; } .coupon-card::after { right: -10px; }
.coupon-card--pending { border-style: dashed; border-color: var(--warn-line); background: var(--warn-tint); }
.coupon-card--pending::before, .coupon-card--pending::after { border-style: dashed; border-color: var(--warn-line); }
.coupon-card--released { border-color: var(--ok-line); }
.coupon-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.coupon-value { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.coupon-card--pending .coupon-value { color: var(--warn); }
.coupon-type { font-weight: 600; }
.coupon-meta { font-size: .9rem; color: var(--ink-3); }
.coupon-code-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .7rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.reveal-box { display: flex; flex-direction: column; gap: .6rem; padding: 1rem 1.1rem; border: 1.5px solid var(--ok-line); background: var(--ok-tint); border-radius: var(--radius); }
.reveal-box .muted { color: var(--ok); }
.chip--sm { font-size: .74rem; padding: .05rem .45rem; }
.break-all { overflow-wrap: anywhere; word-break: break-word; white-space: normal; }

/* --------------------------------------------------------------------------
   Messages (chat)
   -------------------------------------------------------------------------- */
.thread-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.thread-item { display: flex; gap: .8rem; align-items: flex-start; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.thread-item.is-unread { border-color: var(--brand-tint-2); }
.thread-body { flex: 1; min-width: 0; }
.thread-title { display: flex; justify-content: space-between; gap: .5rem; font-weight: 700; }
.thread-sub { font-size: .88rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-preview { color: var(--ink-2); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .15rem; }
.thread-meta { font-size: .8rem; color: var(--ink-3); white-space: nowrap; }
.unread-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); flex: none; margin-top: .45rem; }
.chat { display: flex; flex-direction: column; gap: .55rem; padding: .25rem 0 1rem; }
.chat-day { align-self: center; font-size: .78rem; color: var(--ink-3); background: var(--surface-3); padding: .1rem .6rem; border-radius: var(--radius-pill); margin: .4rem 0; }
.bubble { max-width: 84%; padding: .7rem 1rem; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); line-height: 1.45; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble--mine { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); border-bottom-right-radius: 5px; }
.bubble--theirs { align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble-meta { display: block; margin-top: .3rem; font-size: .78rem; opacity: .75; }
.chat-compose { position: sticky; bottom: calc(var(--nav-h) + .5rem); display: flex; gap: .5rem; align-items: flex-end; padding: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chat-compose .textarea { min-height: 48px; flex: 1; border: 0; padding: .5rem .6rem; background: transparent; }
.chat-compose .textarea:focus { box-shadow: none; }
.chat-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .75rem; }
.chat-head .avatar { flex: none; }

/* --------------------------------------------------------------------------
   Profile + misc lists
   -------------------------------------------------------------------------- */
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.profile-name { font-size: 1.3rem; font-weight: 700; }
.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; }
.kv-row { display: contents; }
.kv dt { color: var(--ink-3); font-weight: 500; } .kv dd { margin: 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-divided > * + * { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: .9rem; padding: .8rem 0; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; }
.list-row-sub { font-size: .9rem; color: var(--ink-3); }
.coming-soon { text-align: center; padding: 2rem 1rem; }
.coming-soon-art { font-size: 3.2rem; line-height: 1; margin-bottom: .75rem; }
.coming-soon h2 { font-size: 1.35rem; margin-bottom: .4rem; }
.feature-list { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-direction: column; gap: .5rem; text-align: left; }
.feature-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.stat-tile { text-align: center; padding: .8rem .4rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stat-tile strong { display: block; font-size: 1.4rem; color: var(--brand); }
.stat-tile span { font-size: .8rem; color: var(--ink-3); }

/* ---- Website layout: body.app--web (same HTML, no phone frame; the prototype's fourth entry) ---- */
/* Opt-in desktop skin over the phone markup. Every rule is scoped to the body
   class, so the phone layout is byte-identical when the class is absent.
   Local tokens: --web-max is the shell band (bar + tabs), --web-main-max the
   reading column, --web-nav-h the height the tab row sticks below the bar. */
body.app--web { --web-max: 1100px; --web-main-max: 960px; --web-nav-h: 54px; --nav-h: 0px; padding: 0; background: var(--paper); } /* --nav-h: 0 - there is no bottom bar here, so anything offset by it (the prototype's pill) sits at the bottom edge */
html:has(> body.app--web) { font-size: 18px; } /* type scale: the sheet is rem-based, but html's size is out of a body class's reach without :has() */
body.app--web .phone { max-width: none; margin: 0; min-height: 100vh; min-height: 100dvh; border-radius: 0; box-shadow: none; overflow: visible; background: var(--paper); }

/* The tab bar sits AFTER <main> in the DOM (on the phone it is a bottom bar).
   .phone is a column flex container, so order lifts it under the app bar.
   Visual order only: DOM and focus order stay bar -> main -> tabs. Also note
   overflow: visible above — the phone frame's overflow: hidden at >=600px would
   otherwise make .phone the scrollport and stop both bars from sticking. */
body.app--web .app-bar { order: 1; }
body.app--web .bottom-nav { order: 2; }
body.app--web .app-main { order: 3; }

/* App bar: gradient stays full-bleed, the max() padding centres its content in
   the band (no wrapper element exists to do it with a margin). */
body.app--web .app-bar { gap: 1rem; padding-inline: max(1rem, calc((100% - var(--web-max)) / 2)); }
body.app--web .app-bar-title { text-align: left; }

/* Tabs: horizontal row directly under the bar, sticky at the bar's height. */
body.app--web .bottom-nav { position: sticky; top: var(--appbar-h); bottom: auto; display: flex; height: var(--web-nav-h); padding: 0; padding-inline: max(1rem, calc((100% - var(--web-max)) / 2)); border-top: 0; border-bottom: 1px solid var(--line); overflow-x: auto; } /* overflow-x keeps the five tabs reachable if a translation makes the row wider than the window */
body.app--web .bottom-tab { flex: none; flex-direction: row; gap: .6rem; padding: 0 1rem; font-size: .95rem; border-top: 0; border-bottom: 3px solid transparent; } /* flex: none — tabs keep their content width and scroll rather than wrap */
body.app--web .bottom-tab.is-active { border-bottom-color: var(--brand); }
body.app--web .tab-badge { top: -6px; right: -6px; } /* keeps the badge over the icon, clear of the now-inline label */

/* Reading column: centred, no --nav-h reservation at the bottom. */
body.app--web .app-main { width: 100%; max-width: var(--web-main-max); margin-inline: auto; padding: 1.9rem 1.5rem 4rem; scroll-margin-top: calc(var(--appbar-h) + var(--web-nav-h)); }

/* Demo badge: fixed bottom-right, exactly where the staff portal keeps it. */
body.app--web .demo-badge { position: fixed; top: auto; right: 16px; bottom: 16px; z-index: 90; }

/* Sticky/measure bits that assumed a bottom nav and a 480px column. */
body.app--web .chat-compose { bottom: 1rem; }
body.app--web .bubble { max-width: 68%; }
body.app--web .segmented { max-width: 520px; }
body.app--web .coming-soon { max-width: 620px; margin-inline: auto; }

/* Two-up cards where a container class already exists: feed + My Studies. */
@media (min-width: 900px) {
  body.app--web .study-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
}

/* Narrow window on the website layout: tighter gutters and a denser tab row. */
@media (max-width: 760px) {
  body.app--web .bottom-nav { padding-inline: .5rem; }
  body.app--web .bottom-tab { padding: 0 .7rem; font-size: .85rem; }
  body.app--web .app-main { padding: 1.25rem 1rem 3rem; }
}
