:root {
  --bg: #FFF7EC;
  --card: #FFFFFF;
  --ink: #1E1B3A;
  --muted: #6B6889;
  --line: #EEE6DA;
  --primary: #3B2FC9;
  --primary-soft: #ECEAFF;
  --sun: #FFC93C;
  --sun-soft: #FFF1C7;
  --up: #12A150;
  --up-soft: #DDF6E7;
  --down: #E5484D;
  --down-soft: #FDE4E4;
  --radius: 20px;
  --shadow: 0 2px 0 rgba(30, 27, 58, .06), 0 8px 24px rgba(30, 27, 58, .06);
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); overflow-x: clip; }
body {
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px; line-height: 1.45; min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); } .down { color: var(--down); }
.hidden, [hidden] { display: none !important; }

/* ---------- layout ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.page { padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 6px; }
.topbar .hello { font-size: 14px; color: var(--muted); }
.topbar h1 { font-size: 22px; font-weight: 800; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; flex: none; }
.section-title { font-size: 18px; font-weight: 700; margin: 22px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- hero ---------- */
.hero {
  background: var(--primary); color: #fff; border-radius: 26px; padding: 20px;
  position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(59, 47, 201, .3);
}
.hero::after { content: ''; position: absolute; inset-inline-start: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hero .label { opacity: .8; font-size: 14px; }
.hero .big { font-size: 38px; font-weight: 800; margin: 2px 0 10px; }
.hero .split { display: flex; gap: 10px; position: relative; z-index: 1; }
.hero .split > div { flex: 1; background: rgba(255, 255, 255, .12); border-radius: 14px; padding: 10px 12px; }
.hero .split b { display: block; font-size: 17px; }
.hero .split span { font-size: 12px; opacity: .8; }
.pl-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.hero .pl-chip { background: rgba(255, 255, 255, .95); color: var(--ink); }

/* ---------- lists ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: start; }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: #FAF6F0; }
.item .t { font-weight: 700; }
.item .s { font-size: 13px; color: var(--muted); }
.item .end { text-align: end; flex: none; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; font-size: 17px; }
.chg { font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 999px; display: inline-block; margin-top: 2px; white-space: nowrap; }
.chg.up { background: var(--up-soft); } .chg.down { background: var(--down-soft); } .chg.flat { background: #EFEDF5; color: var(--muted); }

.feat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.feat { min-width: 0; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 12px; text-align: start; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.feat .d { font-size: 12px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feat .p { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-weight: 700; }

/* ---------- search ---------- */
.search { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 8px; }
.search input { width: 100%; border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 13px 44px 13px 14px; font-size: 16px; outline: none; }
.search input:focus { border-color: var(--primary); }
.search .ico { position: absolute; right: 14px; top: 50%; transform: translateY(-30%); opacity: .5; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; justify-content: center;
}
.nav .in { display: flex; width: 100%; max-width: 560px; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 500; }
.nav button .i { font-size: 22px; filter: grayscale(1); opacity: .6; transition: transform .15s; }
.nav button.on { color: var(--primary); font-weight: 700; }
.nav button.on .i { filter: none; opacity: 1; transform: translateY(-2px) scale(1.1); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 16px; font-weight: 700; font-size: 16px; background: var(--primary); color: #fff; box-shadow: 0 3px 0 #2A20A0; transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #2A20A0; }
.btn.block { width: 100%; }
.btn.light { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn.sun { background: var(--sun); color: var(--ink); box-shadow: 0 3px 0 #D9A21A; }
.btn.buy { background: var(--up); box-shadow: 0 3px 0 #0B7A3B; }
.btn.sell { background: var(--down); box-shadow: 0 3px 0 #B02F33; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn.danger { background: var(--down-soft); color: var(--down); box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.sm { padding: 9px 12px; font-size: 14px; border-radius: 12px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--muted); }
.input { width: 100%; border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 14px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 80px; resize: vertical; }
.err { color: var(--down); font-size: 14px; min-height: 20px; margin: 6px 0; text-align: center; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 40px 20px 30px; text-align: center; }
.logo-big { font-size: 72px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .12)); }
.login h1 { font-size: 30px; font-weight: 800; margin-top: 10px; }
.login .sub { color: var(--muted); margin: 4px 0 24px; }
.login form { width: 100%; max-width: 340px; }
.dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 6px; }
.dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--primary); transition: background .1s, transform .1s; }
.dots i.on { background: var(--primary); transform: scale(1.1); }
.dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px) } 40%, 80% { transform: translateX(8px) } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; direction: ltr; }
.keypad button { height: 64px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 26px; font-weight: 700; }
.keypad button:active { background: var(--primary-soft); transform: scale(.96); }
.keypad .fn { background: transparent; box-shadow: none; font-size: 22px; }
.link { color: var(--primary); font-weight: 500; text-decoration: underline; padding: 10px; margin-top: 14px; }
.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash .logo-big { animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) } }

/* ---------- sheet (stock page) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }
.sheet .in { max-width: 560px; margin: 0 auto; padding: 0 16px calc(30px + var(--safe-b)); }
.sheet-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 14px 0 10px; background: var(--bg); }
.back { width: 42px; height: 42px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); font-size: 20px; display: grid; place-items: center; }
.price-big { font-size: 36px; font-weight: 800; }
.ranges { display: flex; gap: 6px; margin-top: 10px; }
.ranges button { flex: 1; padding: 8px 0; border-radius: 12px; font-weight: 700; font-size: 14px; color: var(--muted); background: #fff; }
.ranges button.on { background: var(--ink); color: #fff; }
.chart { position: relative; height: 180px; margin-top: 10px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; touch-action: pan-y; }
.chart .tip { position: absolute; top: -6px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
.chart .empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 14px; background: #fff; border-radius: 16px; }
.desc-box { background: var(--sun-soft); border-radius: 16px; padding: 12px 14px; margin-top: 14px; display: flex; gap: 10px; align-items: flex-start; }
.mine { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.mine div { background: #F7F4EE; border-radius: 14px; padding: 10px 4px; }
.mine b { display: block; font-size: 16px; }
.mine span { font-size: 12px; color: var(--muted); }
.seg { display: flex; background: #EFEBE4; border-radius: 16px; padding: 4px; }
.seg button { flex: 1; padding: 11px 0; border-radius: 12px; font-weight: 700; color: var(--muted); }
.seg button.on.buy { background: var(--up); color: #fff; }
.seg button.on.sell { background: var(--down); color: #fff; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 8px; }
.stepper button { width: 54px; height: 54px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); font-size: 28px; font-weight: 700; }
.stepper input { width: 110px; text-align: center; font-size: 32px; font-weight: 800; border: 0; background: transparent; outline: none; direction: ltr; }
.quick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.quick button { padding: 6px 12px; border-radius: 999px; background: #fff; box-shadow: var(--shadow); font-size: 14px; font-weight: 500; }
.summary { display: flex; justify-content: space-between; padding: 12px 4px; font-size: 15px; }
.summary + .summary { border-top: 1px dashed var(--line); }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(30, 27, 58, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal .box { background: var(--bg); width: 100%; max-width: 560px; border-radius: 26px 26px 0 0; padding: 22px 18px calc(22px + var(--safe-b)); max-height: 92dvh; overflow-y: auto; animation: up .2s ease-out; }
.modal h2 { font-size: 20px; margin-bottom: 14px; }
.modal .actions { display: flex; gap: 10px; margin-top: 8px; }
.modal .actions .btn { flex: 1; }
@media (min-width: 600px) { .modal { align-items: center; } .modal .box { border-radius: 26px; } }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; font-weight: 500; max-width: calc(100% - 32px); width: max-content; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: up .2s; }

/* ---------- misc ---------- */
.empty-state { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty-state .e { font-size: 46px; }
.lesson { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lesson + .lesson { margin-top: 10px; }
.lesson summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px; font-weight: 700; cursor: pointer; }
.lesson summary::-webkit-details-marker { display: none; }
.lesson summary .e { font-size: 28px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--sun-soft); flex: none; }
.lesson summary::after { content: '‹'; margin-inline-start: auto; font-size: 22px; color: var(--muted); transition: transform .2s; }
.lesson[open] summary::after { transform: rotate(-90deg); }
.lesson .body { padding: 0 16px 16px; color: #3B385A; }
.lesson .body p { margin: 0 0 10px; }
.medal { width: 32px; text-align: center; font-size: 20px; flex: none; }
.me-row { background: var(--primary-soft); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--sun-soft); color: #8A6100; }
.tabs { display: flex; gap: 8px; margin: 6px 0 4px; }
.tabs button { flex: 1; padding: 10px 0; border-radius: 14px; font-weight: 700; background: #fff; color: var(--muted); box-shadow: var(--shadow); }
.tabs button.on { background: var(--primary); color: #fff; }
.file-drop { display: block; border: 2px dashed #D8CFC2; border-radius: 16px; padding: 18px; text-align: center; background: #fff; }
.star { font-size: 22px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; }
.star.on { background: var(--sun-soft); }
.note { background: var(--primary-soft); color: #2A2290; border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall 1.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .8; } }

/* value-over-time charts (1.1.0) */
.chart.value { margin: 0 0 18px; }
.chart .empty { text-align: center; padding: 0 16px; line-height: 1.6; }
.chart .cap { position: absolute; bottom: -20px; inset-inline-end: 0; }
.chart .tip b { display: block; }
.chart .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 4px; vertical-align: middle; }
.chart .legend { position: absolute; bottom: -22px; inset-inline-start: 0; inset-inline-end: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }

/* admin overview (1.1.0) */
.tabs button { min-width: 0; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { display: block; font-size: 20px; margin-top: 2px; }
.item.rank .end b { font-size: 16px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 4px; vertical-align: middle; }
.table-wrap { padding: 4px 0; overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
table.stats th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: start; padding: 8px 12px; }
table.stats td { padding: 10px 12px; border-top: 1px solid #F1ECE4; }
.card.hl { font-size: 15px; line-height: 1.6; }

/* lesson calculators (1.1.0) */
.calc { background: var(--sun-soft); border-radius: 14px; padding: 12px; margin: 0 0 12px; }
.calc-row { display: flex; gap: 10px; }
.calc-row label, .calc .range-l { flex: 1; font-size: 13px; font-weight: 600; display: block; }
.calc .input { margin-top: 4px; padding: 10px; }
.calc input[type=range] { width: 100%; margin-top: 6px; accent-color: var(--primary); }
.calc .range-l { margin-top: 10px; }
.calc-out { margin-top: 10px; font-size: 15px; line-height: 1.8; }

/* what's new (1.1.0) */
.whatsnew { display: block; width: 100%; text-align: start; margin-top: 12px; background: var(--primary-soft); line-height: 1.6; }
.whatsnew > span { display: block; }
.release { margin-top: 12px; line-height: 1.65; }
.release.old { opacity: .8; }
.release .rel-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid #F1ECE4; }
.release h3 { font-size: 16px; margin: 16px 0 6px; }
.release p { margin: 0 0 8px; }
.release ul { margin: 0 0 8px; padding-inline-start: 20px; }
.release li { margin-bottom: 4px; }

/* why did I buy / sell (1.2.0) */
.why-title { font-weight: 700; font-size: 16px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #F3EEE6; color: var(--ink); border-radius: 999px; padding: 8px 12px; font-size: 14px; text-align: start; line-height: 1.35; }
.chip.on { background: var(--primary); color: #fff; }
.tx-why { margin-top: 4px; font-size: 13px; color: #4A4670; background: #F7F3EC; border-radius: 10px; padding: 6px 10px; white-space: normal; }

/* team + activity log (1.3.0) */
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; padding: 10px 12px; }
.log-filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 12px; }
.log-filters select { flex: 1; min-width: 160px; padding: 10px; }
.log-filters label { display: flex; align-items: center; gap: 6px; }
.log-row { align-items: flex-start; }
.log-row .end { white-space: nowrap; }
