:root {
  --bg: #f6f4ff; --surface: #ffffff; --surface2: #f0ecff; --text: #1d1640; --muted: #6b6490;
  --brand: #5b2ee6; --brand2: #8b5cf6; --accent: #ff8a3d; --ok: #16a34a; --bad: #dc2626;
  --line: #e4defb; --shadow: 0 10px 30px rgba(60, 30, 160, .12); --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0b24; --surface: #19143a; --surface2: #231c4d; --text: #f1edff; --muted: #a59ed0;
    --line: #2f2766; --shadow: 0 10px 30px rgba(0, 0, 0, .4); }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html, body { overflow-x: hidden; }
body { font-family: 'Poppins', 'Noto Sans Devanagari', 'Nirmala UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); }

/* brand */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 2px; font-size: 22px; }
.logo .mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-size: 24px;
  background: linear-gradient(135deg, var(--brand), var(--brand2) 60%, var(--accent)); box-shadow: 0 6px 18px rgba(91, 46, 230, .4); }
.logo small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .5px; color: var(--muted); }

/* hero / auth */
.hero { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.hero-art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(circle at 20% 20%, #8b5cf6 0, transparent 45%), radial-gradient(circle at 80% 70%, #ff8a3d 0, transparent 40%), linear-gradient(140deg, #2a0f8f, #5b2ee6); }
.hero-art .logo { color: #fff; } .hero-art .logo small { color: #e6dcff; }
.hero-art h1 { font-size: 44px; line-height: 1.15; margin: 0 0 14px; }
.hero-art p { font-size: 17px; opacity: .9; max-width: 460px; line-height: 1.6; }
.bubbles { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.bubbles span { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); padding: 8px 14px; border-radius: 999px; font-size: 14px; backdrop-filter: blur(4px); }
.feat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.feat div { background: rgba(255, 255, 255, .12); border-radius: 14px; padding: 14px; font-size: 13px; line-height: 1.4; }
.feat b { display: block; font-size: 22px; margin-bottom: 4px; }
.auth { display: grid; place-items: center; padding: 32px 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 420px; }
.card h2 { margin: 0 0 6px; font-size: 24px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 1.5; }
.tabs { display: flex; background: var(--surface2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--surface); color: var(--brand); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); outline: none; transition: border .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand2); }
.btn { width: 100%; border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; color: #fff; margin-top: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); box-shadow: 0 8px 20px rgba(91, 46, 230, .35); transition: transform .15s; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--surface2); color: var(--brand); box-shadow: none; }
.btn[disabled] { opacity: .6; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1.5px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: 13px; }
.chips button.on { border-color: var(--brand); background: var(--surface2); color: var(--brand); font-weight: 600; }

/* simple page shell */
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.steps { display: flex; gap: 6px; margin: 4px 0 18px; } .steps i { flex: 1; height: 5px; border-radius: 9px; background: var(--line); } .steps i.on { background: linear-gradient(90deg, var(--brand), var(--accent)); }

/* language picker */
.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.lang { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: left; color: var(--text); transition: transform .15s, border .15s; }
.lang:hover { transform: translateY(-2px); }
.lang.on { border-color: var(--brand); box-shadow: var(--shadow); }
.lang .big { font-size: 30px; font-weight: 800; background: linear-gradient(135deg, var(--brand), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lang .nm { font-weight: 700; margin-top: 6px; } .lang .mr { color: var(--muted); font-size: 13px; }
.lang .tag { position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: #dcfce7; color: #166534; }
.lang.soon { opacity: .55; cursor: not-allowed; } .lang.soon .tag { background: var(--surface2); color: var(--muted); }

/* main app */
.app { max-width: 820px; margin: 0 auto; padding: 16px 16px 96px; }
.hello { background: linear-gradient(135deg, #3a17b8, var(--brand) 55%, var(--brand2)); color: #fff; border-radius: 22px; padding: 22px; position: relative; overflow: hidden; }
.hello::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; right: -40px; top: -60px; background: radial-gradient(circle, rgba(255, 138, 61, .7), transparent 70%); }
.hello h2 { margin: 0 0 4px; font-size: 22px; } .hello p { margin: 0; opacity: .9; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; position: relative; z-index: 1; }
.stats div { background: rgba(255, 255, 255, .14); border-radius: 14px; padding: 10px; text-align: center; font-size: 12px; }
.stats b { display: block; font-size: 22px; }
.bar { height: 8px; background: var(--line); border-radius: 9px; overflow: hidden; } .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 9px; }
.sec-title { font-size: 17px; font-weight: 700; margin: 24px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; text-align: left; color: var(--text); box-shadow: 0 2px 10px rgba(60, 30, 160, .05); }
.tile .ic { font-size: 26px; } .tile b { display: block; margin-top: 6px; } .tile span { color: var(--muted); font-size: 12px; }
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left; color: var(--text); width: 100%; }
.lesson-item .num { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--surface2); color: var(--brand); }
.lesson-item.done .num { background: var(--ok); color: #fff; }
.lesson-item .t { flex: 1; } .lesson-item .t b { display: block; } .lesson-item .t span { color: var(--muted); font-size: 12px; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.nav div { display: flex; width: 100%; max-width: 820px; }
.nav button { flex: 1; border: 0; background: none; padding: 10px 4px 12px; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav button .ic { display: block; font-size: 22px; margin-bottom: 2px; }
.nav button.on { color: var(--brand); }
.view { display: none; } .view.on { display: block; animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* lesson reader */
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; overflow-x: auto; }
.reader h1 { font-size: 22px; color: var(--brand); margin: 0 0 10px; }
.reader h2 { font-size: 17px; color: var(--brand); margin: 22px 0 8px; }
.reader table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 6px 0 12px; }
.reader th { background: var(--brand); color: #fff; text-align: left; padding: 7px 8px; }
.reader td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.reader tr:nth-child(even) td { background: var(--surface2); }
.reader td:first-child { font-weight: 600; }
.reader tr.neg td { background: rgba(220, 38, 38, .06); } .reader tr.w td { font-size: 12px; color: var(--muted); font-style: italic; }
.reader blockquote { margin: 8px 0; padding: 10px 12px; border-left: 4px solid var(--accent); background: rgba(255, 138, 61, .1); border-radius: 0 10px 10px 0; font-size: 14px; }
.speak { border: 0; background: var(--surface2); border-radius: 8px; padding: 2px 6px; margin-left: 6px; font-size: 12px; }
.back { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 6px 0; margin-bottom: 8px; }

/* AI tutor */
.modes { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.modes button { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; }
.modes button.on { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-color: transparent; }
.chat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; height: calc(100vh - 290px); min-height: 320px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; line-height: 1.55; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.msg.ai { background: var(--surface2); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.me { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg .tools { margin-top: 6px; } .msg .tools button { border: 0; background: rgba(91, 46, 230, .12); color: var(--brand); border-radius: 8px; padding: 3px 8px; font-size: 12px; }
.typing { color: var(--muted); font-size: 13px; padding: 4px 8px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.starters button { border: 1px dashed var(--brand2); background: transparent; color: var(--brand); border-radius: 12px; padding: 7px 12px; font-size: 13px; }
.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer textarea { resize: none; height: 48px; border-radius: 14px; }
.composer button { flex: none; width: 48px; height: 48px; border-radius: 14px; border: 0; color: #fff; font-size: 20px; background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.composer button.mic { background: var(--surface2); color: var(--brand); } .composer button.mic.rec { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, .2); } }
.pf { display: grid; gap: 10px; }
.pf div { display: flex; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.pf span { color: var(--muted); }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art, .auth { min-width: 0; }
  .bubbles span { font-size: 13px; }
  .hero-art { padding: 28px 20px; min-height: auto; gap: 22px; }
  .hero-art h1 { font-size: 30px; }
  .feat { grid-template-columns: repeat(3, 1fr); }
  .chat { height: calc(100vh - 300px); }
}
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } .feat div { padding: 10px; font-size: 11px; } }
