:root {
  color-scheme: light;
  --paper: #FFF6E4;
  --paper-2: #FDEBC8;
  --card: #FFFFFF;
  --ink: #1B2A22;
  --ink-soft: #52615A;
  --leaf: #2DBE6C;
  --leaf-deep: #0B5D3B;
  --leaf-pale: #DDF5E6;
  --mango: #FFB020;
  --mango-pale: #FFF0CC;
  --beak: #FF6A3D;
  --beak-pale: #FFE2D8;
  --sky: #CFEFFF;
  --line: 2.5px solid var(--ink);
  --pop: 4px 4px 0 var(--ink);
  --pop-sm: 2px 2px 0 var(--ink);
  --r: 18px;
  --display: "Baloo 2", "Mukta", system-ui, sans-serif;
  --body: "Mukta", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(27, 42, 34, .09) 1.2px, transparent 0),
    radial-gradient(1200px 500px at 110% -10%, rgba(45, 190, 108, .16), transparent 60%),
    radial-gradient(900px 500px at -20% 110%, rgba(255, 176, 32, .18), transparent 60%);
  background-size: 22px 22px, auto, auto;
  min-height: 100dvh;
}
h1, h2, h3, .display { font-family: var(--display); line-height: 1.1; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }

/* ---------- shared bits ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: var(--line); border-radius: 999px; background: var(--card);
  padding: 10px 20px; font-family: var(--display); font-weight: 700; font-size: 18px;
  box-shadow: var(--pop-sm); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-leaf { background: var(--leaf); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.btn-mango { background: var(--mango); }
.btn-beak { background: var(--beak); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: rgba(27,42,34,.06); box-shadow: none; transform: none; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: var(--line); background: var(--card);
  display: inline-grid; place-items: center; box-shadow: var(--pop-sm); flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }

.card { background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--pop); }

.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 15px; }
.input {
  width: 100%; border: var(--line); border-radius: 14px; padding: 12px 14px; background: #fff;
  font-size: 18px; outline: none;
}
.input:focus { box-shadow: 0 0 0 4px var(--mango-pale), var(--pop-sm); }

.chip {
  border: var(--line); border-radius: 999px; background: #fff; padding: 8px 16px;
  font-weight: 600; box-shadow: var(--pop-sm); user-select: none;
}
.chip[aria-pressed="true"] { background: var(--leaf); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 99;
  transition: transform .25s cubic-bezier(.2,1.4,.4,1); max-width: calc(100% - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

.mascot { display: block; }
.mascot.bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); padding: 28px 24px 24px; position: relative; }
.login-card .mascot { width: 104px; margin: -86px auto 4px; }
.brand { text-align: center; }
.brand h1 { font-size: 44px; letter-spacing: -.5px; }
.brand h1 span { color: var(--leaf); }
.brand p { margin: 2px 0 20px; }
.login-card form { display: grid; gap: 14px; }
.pin-input { letter-spacing: 10px; text-align: center; font-size: 26px; font-family: var(--display); }
.error { color: #C0341D; font-weight: 600; min-height: 1.4em; margin: 0; }

/* ---------- student app ---------- */
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar .mascot { width: 46px; }
.topbar .title { flex: 1; font-family: var(--display); font-weight: 800; font-size: 24px; }
.topbar .title span { color: var(--leaf); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: var(--line); border-radius: 999px;
  padding: 4px 12px; background: #fff; font-weight: 700; font-size: 15px; box-shadow: var(--pop-sm); white-space: nowrap;
}
.pill.mango { background: var(--mango-pale); }
.pill.leaf { background: var(--leaf-pale); }

.hero { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 22px; margin-bottom: 18px; background: var(--leaf); color: #fff; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero h2 { font-size: 32px; }
.hero p { margin: 4px 0 16px; opacity: .95; }
.hero .btn { position: relative; z-index: 1; font-size: 22px; padding: 12px 26px; }
.ring { width: 110px; height: 110px; position: relative; z-index: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-family: var(--display); line-height: 1; }
.ring .lbl b { font-size: 30px; }
.ring .lbl small { font-size: 13px; opacity: .9; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-title h3 { font-size: 24px; }

.words { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.word { padding: 16px; position: relative; transform: rotate(var(--tilt, 0deg)); }
.word:nth-child(1) { --tilt: -1deg; background: var(--mango-pale); }
.word:nth-child(2) { --tilt: .8deg; background: var(--sky); }
.word:nth-child(3) { --tilt: -.5deg; background: var(--beak-pale); }
.word h4 { font-family: var(--display); font-size: 26px; margin: 0 40px 2px 0; }
.word .hi { font-weight: 600; color: var(--leaf-deep); }
.word p { margin: 6px 0 0; font-size: 15px; }
.word .ex { font-style: italic; }
.word .say { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; }
.word .badge { position: absolute; top: -12px; left: 14px; background: var(--leaf); color: #fff; border: var(--line); border-radius: 999px; padding: 0 10px; font-size: 13px; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 14px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 30px; line-height: 1; }
.stat span { font-size: 14px; color: var(--ink-soft); }

/* level ladder */
.ladder { display: flex; gap: 6px; align-items: flex-end; padding: 16px; }
.ladder .rung { flex: 1; text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.ladder .rung i { display: block; border: var(--line); border-radius: 8px; background: #fff; margin-bottom: 6px; }
.ladder .rung.done i { background: var(--leaf); }
.ladder .rung.now i { background: var(--mango); animation: glow 1.6s ease-in-out infinite; }
.ladder .rung.now { color: var(--ink); }
@keyframes glow { 50% { box-shadow: 0 0 0 5px rgba(255,176,32,.35); } }

/* onboarding */
.onb { padding: 26px 22px; margin-top: 30px; }
.onb .mascot { width: 90px; margin: -70px 0 6px; }
.onb h2 { font-size: 32px; margin-bottom: 6px; }
.onb .choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 24px; }
.onb .choices.big .chip { font-size: 22px; min-width: 60px; text-align: center; }
.onb .choices.stack { flex-direction: column; }
.onb .choices.stack .chip { text-align: left; border-radius: 16px; padding: 14px 18px; font-size: 18px; }
.onb .dots { display: flex; gap: 6px; margin-bottom: 14px; }
.onb .dots i { width: 28px; height: 8px; border-radius: 4px; background: var(--paper-2); border: 1.5px solid var(--ink); }
.onb .dots i.on { background: var(--leaf); }
.onb .row { display: flex; justify-content: space-between; gap: 10px; }

/* chat */
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.chat-head .grow { flex: 1; }
.thread { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 6px 2px 180px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 88%; animation: pop-in .28s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.96); } }
.msg .av { width: 40px; flex: none; }
.bubble { border: var(--line); border-radius: 20px; padding: 10px 16px; box-shadow: var(--pop-sm); font-size: 19px; background: #fff; }
.msg.tutor .bubble { border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; flex-direction: column; align-items: flex-end; }
.msg.me .bubble { background: var(--leaf-pale); border-bottom-right-radius: 6px; }
.bubble .replay { border: 0; background: none; padding: 0 0 0 6px; vertical-align: middle; opacity: .6; }
.bubble .replay:hover { opacity: 1; }
.bubble .replay svg { width: 18px; height: 18px; }

.fix {
  background: var(--mango-pale); border: 2px dashed var(--ink); border-radius: 14px; padding: 8px 12px;
  font-size: 15px; max-width: 100%; transform: rotate(-.6deg); margin-top: 2px;
}
.fix s { color: #B2371A; text-decoration-thickness: 2px; }
.fix b { color: var(--leaf-deep); }
.fix .tip { display: block; color: var(--ink-soft); font-size: 14px; }
.cheer { align-self: center; background: var(--mango); border: var(--line); border-radius: 999px; padding: 4px 14px; font-weight: 700; box-shadow: var(--pop-sm); animation: pop-in .35s cubic-bezier(.2,1.6,.4,1) both; }
.cheer.leaf { background: var(--leaf); color: #fff; }

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: dot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { transform: translateY(-6px); opacity: .4; } }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.dock-inner { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.dock .side { display: flex; gap: 10px; }
.dock .side.right { justify-content: flex-end; }
.live { text-align: center; min-height: 26px; font-size: 16px; color: var(--ink-soft); grid-column: 1 / -1; font-style: italic; }
.mic {
  width: 92px; height: 92px; border-radius: 50%; border: 3px solid var(--ink); background: var(--beak); color: #fff;
  display: grid; place-items: center; box-shadow: var(--pop); position: relative; transition: transform .1s;
}
.mic svg { width: 40px; height: 40px; }
.mic:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.mic.listening { background: var(--leaf); }
.mic.listening::before, .mic.listening::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--leaf); animation: ripple 1.4s ease-out infinite;
}
.mic.listening::after { animation-delay: .7s; }
@keyframes ripple { to { transform: scale(1.7); opacity: 0; } }
.mic.thinking { background: var(--mango); color: var(--ink); }
.mic.speaking { background: var(--sky); color: var(--ink); }
.mic .bars { display: flex; gap: 4px; align-items: center; height: 36px; }
.mic .bars i { width: 6px; border-radius: 3px; background: currentColor; animation: eq .9s ease-in-out infinite; }
.mic .bars i:nth-child(2) { animation-delay: .15s; } .mic .bars i:nth-child(3) { animation-delay: .3s; } .mic .bars i:nth-child(4) { animation-delay: .45s; }
@keyframes eq { 0%,100% { height: 8px; } 50% { height: 32px; } }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--leaf); }
.type-row { grid-column: 1 / -1; display: flex; gap: 8px; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(27,42,34,.55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.overlay .card { padding: 28px 24px; max-width: 420px; width: 100%; text-align: center; animation: pop-in .35s cubic-bezier(.2,1.5,.4,1) both; }
.overlay .mascot { width: 110px; margin: 0 auto 8px; }
.overlay h2 { font-size: 34px; margin-bottom: 6px; }

/* notebook */
.nb-list { display: grid; gap: 10px; }
.skill { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.skill .name { flex: 1; font-weight: 700; }
.pips { display: flex; gap: 4px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.pips i.on { background: var(--leaf); }
.skill.cleared { background: var(--leaf-pale); }
.fix-row { padding: 12px 16px; }
.fix-row s { color: #B2371A; }
.fix-row b { color: var(--leaf-deep); }
.empty { padding: 20px; text-align: center; color: var(--ink-soft); }

/* ---------- dashboard ---------- */
.dash { max-width: 1120px; margin: 0 auto; padding: 16px 16px 60px; }
.dash .topbar { flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; margin: 0 0 18px; flex-wrap: wrap; }
.tabs .chip { cursor: pointer; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.s-card { padding: 16px; cursor: pointer; transition: transform .1s; text-align: left; width: 100%; }
.s-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.s-card h3 { font-size: 22px; }
.s-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.s-card .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.s-card .nums b { display: block; font-family: var(--display); font-size: 24px; line-height: 1; }
.s-card .nums span { font-size: 12px; color: var(--ink-soft); }
.bar { height: 10px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; margin-top: 12px; }
.bar i { display: block; height: 100%; background: var(--mango); }
.s-card.off { opacity: .55; }

.drawer { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; background: rgba(27,42,34,.4); }
.drawer-panel { width: min(640px, 100%); height: 100%; overflow-y: auto; background: var(--paper); border-left: var(--line); padding: 20px 18px 60px; animation: slide .25s ease-out both; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-panel h2 { font-size: 30px; }
.drawer-panel h4 { font-family: var(--display); font-size: 20px; margin: 22px 0 8px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 12px 12px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; color: var(--ink-soft); }
.chart .col i { width: 100%; background: var(--leaf); border: 2px solid var(--ink); border-bottom: 0; border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .col span { margin-top: 2px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td, .tbl th { text-align: left; padding: 8px 10px; border-bottom: 1.5px solid rgba(27,42,34,.15); vertical-align: top; }
.tbl th { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); }
.transcript { max-height: 360px; overflow-y: auto; padding: 12px; display: grid; gap: 6px; font-size: 15px; }
.transcript .t { color: var(--leaf-deep); }
.transcript hr { border: 0; border-top: 2px dashed rgba(27,42,34,.2); width: 100%; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.controls .full { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.modal form { display: grid; gap: 12px; text-align: left; }

.pill.warn { background: var(--beak-pale); }
.key-banner { padding: 14px 18px; margin-bottom: 16px; background: var(--mango-pale); }
.linkish { border: 0; background: none; padding: 0; font-weight: 700; text-decoration: underline; color: var(--leaf-deep); }
.key-box { padding: 16px; }
.key-box summary { cursor: pointer; margin-bottom: 6px; }
.key-box a { color: var(--leaf-deep); font-weight: 700; }
.key-box code { background: var(--paper-2); padding: 0 5px; border-radius: 5px; }
.steps { margin: 8px 0 10px; padding-left: 22px; display: grid; gap: 8px; }
.hi-note { display: block; color: var(--ink-soft); font-size: 14px; }
.key-row { display: flex; gap: 10px; margin-top: 8px; }
.key-row .input { font-size: 16px; }
.key-row .btn { white-space: nowrap; }

@media (max-width: 560px) {
  .key-row { flex-direction: column; }
  body { font-size: 16px; }
  .hero { grid-template-columns: 1fr; }
  .hero .ring { position: absolute; top: 14px; right: 14px; width: 84px; height: 84px; }
  .hero .ring .lbl b { font-size: 22px; }
  .hero h2, .hero p { padding-right: 88px; }
  .hero h2 { font-size: 26px; }
  .section-title { flex-wrap: wrap; gap: 4px 12px; }
  .section-title h3 { font-size: 21px; }
  .brand h1 { font-size: 38px; }
  .mic { width: 80px; height: 80px; }
  .bubble { font-size: 17px; }
  .controls { grid-template-columns: 1fr; }
  .topbar .title { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
