/* GrowCert Learn — app styles. Phone: bottom tab bar. Tablet/desktop: side navigation, wider layouts,
   lesson and trainer side by side. Light and dark follow the device setting. No external fonts (works offline). */
:root {
  --page: #E6ECE3; --bg: #F3F6F0; --surface: #FFFFFF; --surface-2: #F8FAF6; --ink: #18271F; --ink2: #4B5B52; --line: #D7E0D5;
  --brand: #1F5C3F; --brand-2: #2E7A55; --brand-ink: #FFFFFF; --accent: #E2A12B; --accent-ink: #2A1D00; --soft: #E3EDE0;
  --good: #1F7A4D; --bad: #B3402A; --soil: #8A6A4B; --seed: #6B4A2B; --leaf: #3E8E5E;
  --shadow: 0 1px 2px rgb(16 40 26 / 0.06), 0 8px 24px -12px rgb(16 40 26 / 0.18);
  --radius: 18px;
  --font: "Noto Sans", "Noto Sans Devanagari", "Mukta", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0B110D; --bg: #101813; --surface: #18231C; --surface-2: #1D2A22; --ink: #E9F0E8; --ink2: #A9B9AE; --line: #2B3A31;
    --brand: #6FCB97; --brand-2: #5FBF88; --brand-ink: #0C2417; --accent: #E8B04A; --accent-ink: #241800; --soft: #22322A;
    --good: #6FCB97; --bad: #F08A72; --soil: #7A5C3F; --seed: #C9A070; --leaf: #5FBF88;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 28px -14px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--page); color: var(--ink); font-size: 18px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.noscript { padding: 2rem; text-align: center; }

/* Splash while the app starts */
.splash { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 1rem; background: var(--bg); font-weight: 800; font-size: 1.3rem; color: var(--brand); z-index: 50; transition: opacity .35s; }
.splash img { border-radius: 24px; box-shadow: var(--shadow); }
.splash.is-done { opacity: 0; pointer-events: none; }

/* ---------- App frame ---------- */
.app { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); padding-top: env(safe-area-inset-top, 0); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 1.1rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; color: var(--brand); text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.brand small { display: block; font-size: .68rem; font-weight: 600; color: var(--ink2); letter-spacing: .02em; line-height: 1.1; }
.top-actions { display: flex; align-items: center; gap: .5rem; }
.lang { display: flex; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--surface); }
.lang button { background: none; border: 0; padding: .3rem .85rem; font-size: .95rem; font-weight: 700; color: var(--ink2); min-height: 40px; }
.lang button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.chip-btn { display: inline-flex; align-items: center; gap: .35rem; border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: .35rem .8rem; font-size: .9rem; font-weight: 700; color: var(--brand); min-height: 40px; }
.offline { display: none; background: var(--accent); color: var(--accent-ink); text-align: center; font-size: .9rem; font-weight: 700; padding: .3rem; }
.is-offline .offline { display: block; }
.preview-bar { background: #7A2E8E; color: #fff; text-align: center; font-size: .85rem; font-weight: 700; padding: .3rem; }

.layout { display: block; min-width: 0; }
main { padding: 1.1rem 1.1rem 6.5rem; max-width: 1240px; margin-inline: auto; width: 100%; animation: in .28s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Navigation: bottom tabs on phones, side rail on wider screens */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0); box-shadow: 0 -8px 24px -18px rgb(0 0 0 / .3); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .55rem .2rem .65rem; font-size: .78rem; font-weight: 700; color: var(--ink2); text-decoration: none; min-height: 64px; }
.nav a svg { width: 26px; height: 26px; }
.nav a[aria-current="page"] { color: var(--brand); }
.nav a[aria-current="page"] svg { transform: translateY(-1px); }
.nav .nav-extra { display: none; }

@media (min-width: 900px) {
  .app { grid-template-rows: auto 1fr; }
  .layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .nav { position: sticky; top: 61px; height: calc(100dvh - 61px); flex-direction: column; gap: .25rem; padding: 1.25rem .9rem; border-top: 0; border-right: 1px solid var(--line); box-shadow: none; background: var(--surface-2); }
  .nav a { flex: none; flex-direction: row; gap: .8rem; padding: .7rem .9rem; border-radius: 12px; font-size: 1rem; min-height: 0; }
  .nav a:hover { background: var(--soft); }
  .nav a[aria-current="page"] { background: var(--soft); }
  .nav a svg { width: 22px; height: 22px; }
  .nav .nav-extra { display: block; margin-top: auto; font-size: .8rem; color: var(--ink2); padding: .9rem; border-top: 1px solid var(--line); }
  .nav .nav-extra a { display: inline; padding: 0; font-size: .8rem; color: var(--brand); }
  main { padding: 2rem 2.25rem 3rem; }
}

/* ---------- Building blocks ---------- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 1.1rem + .9vw, 1.75rem); line-height: 1.25; font-weight: 800; }
h3 { font-size: 1.12rem; line-height: 1.3; font-weight: 750; }
.muted { color: var(--ink2); }
.small { font-size: .9rem; }
.eyebrow { font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 54px; border-radius: 14px; border: 2px solid var(--brand); background: var(--brand); color: var(--brand-ink); font-size: 1.05rem; font-weight: 750; padding: .6rem 1.2rem; text-align: center; text-decoration: none; transition: transform .12s, filter .12s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn.alt { background: transparent; color: var(--brand); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; font-size: .95rem; padding: .4rem .9rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--ink2); text-decoration: underline; font-size: .95rem; min-height: 44px; }
.back { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; font-weight: 750; color: var(--brand); min-height: 44px; text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font-size: .8rem; font-weight: 700; border: 1px solid var(--line); color: var(--ink2); padding: .05rem .6rem; border-radius: 99px; background: var(--surface); }
.chip.soon { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.draft { background: #7A2E8E; border-color: #7A2E8E; color: #fff; }
.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; transition: width .5s ease; }

/* Home dashboard */
.hero { display: grid; gap: 1.2rem; align-items: center; background: linear-gradient(135deg, var(--soft), var(--surface)); border: 1px solid var(--line); border-radius: 24px; padding: 1.4rem; box-shadow: var(--shadow); }
.hero .plant { width: 150px; height: 150px; justify-self: center; }
.hero-text { display: flex; flex-direction: column; gap: .6rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.trainer-card { display: flex; gap: 1rem; align-items: center; color: inherit; text-decoration: none; }
.trainer-card h3 { color: var(--ink); }
@media (min-width: 700px) {
  .hero { grid-template-columns: 200px 1fr; padding: 2rem; }
  .hero .plant { width: 190px; height: 190px; }
}

/* Course cards and rows */
.course { display: flex; flex-direction: column; gap: .6rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.course:hover { transform: translateY(-2px); }
.course-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); color: var(--brand); }
.course.locked { opacity: .78; }
.row { display: flex; align-items: center; gap: .9rem; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .85rem 1rem; color: inherit; text-decoration: none; min-height: 66px; }
.row:hover { border-color: var(--brand-2); }
.row .grow { flex: 1; min-width: 0; }
.num { width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-weight: 800; color: var(--brand); }
.num.done { background: var(--brand); color: var(--brand-ink); }

/* Lesson + trainer side by side on wide screens */
.lesson-layout { display: grid; gap: 1.25rem; }
@media (min-width: 1180px) { .lesson-layout { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; } .lesson-layout .trainer-panel { position: sticky; top: 85px; } }
.point { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: 1rem 1.15rem; font-size: 1.15rem; line-height: 1.55; transition: background .25s, border-color .25s, transform .25s; }
.point.is-speaking { background: var(--soft); border-left-color: var(--brand); transform: translateX(4px); }
.teach-bar { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Trainer avatar */
.avatar { width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); position: relative; }
.avatar svg { width: 30px; height: 30px; }
.avatar.sm { width: 38px; height: 38px; }
.avatar.sm svg { width: 22px; height: 22px; }
.avatar.is-talking::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--accent); animation: pulse 1.2s ease-out infinite; }
@keyframes pulse { from { opacity: 1; transform: scale(.9); } to { opacity: 0; transform: scale(1.25); } }

/* Trainer chat */
.trainer-panel { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; min-height: 420px; }
.trainer-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.trainer-head .grow { flex: 1; }
.ai-tag { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--soft); color: var(--brand); border-radius: 6px; padding: .05rem .4rem; }
.msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; max-height: 58dvh; min-height: 220px; }
.trainer-view .msgs { max-height: none; min-height: 50dvh; }
.msg { max-width: 88%; padding: .7rem .95rem; border-radius: 18px; font-size: 1.02rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: var(--soft); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.msg.err { align-self: center; background: transparent; color: var(--bad); font-size: .92rem; text-align: center; }
.msg .speak { display: inline-flex; margin-top: .35rem; background: none; border: 0; color: var(--brand); font-size: .85rem; font-weight: 700; gap: .25rem; align-items: center; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.suggest { display: flex; gap: .4rem; overflow-x: auto; padding: 0 1rem .6rem; scrollbar-width: none; }
.suggest button { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--brand); border-radius: 99px; padding: .35rem .8rem; font-size: .88rem; font-weight: 700; }
.composer { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: .6rem .8rem; min-height: 50px; max-height: 140px; background: var(--bg); font-size: 1rem; }
.icon-btn { width: 50px; height: 50px; flex: none; border-radius: 14px; border: 0; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.icon-btn.alt { background: var(--soft); color: var(--brand); }
.icon-btn.is-listening { background: var(--bad); color: #fff; animation: pulseBg 1s infinite; }
@keyframes pulseBg { 50% { filter: brightness(1.2); } }
.icon-btn[disabled] { opacity: .5; }
.toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 700; color: var(--ink2); background: none; border: 0; min-height: 40px; }
.toggle .sw { width: 34px; height: 20px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.toggle .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle[aria-pressed="true"] .sw { background: var(--brand); }
.toggle[aria-pressed="true"] .sw::after { transform: translateX(14px); }
.trainer-off { padding: 1.25rem; text-align: center; }

/* Quiz */
.opt { display: flex; justify-content: space-between; gap: .75rem; align-items: center; width: 100%; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: .9rem 1rem; font-size: 1.08rem; min-height: 62px; }
.opt:hover:not([disabled]) { border-color: var(--brand-2); }
.opt[disabled] { cursor: default; }
.opt.correct { border-color: var(--good); background: var(--soft); }
.opt.wrong { border-color: var(--bad); }
.opt small { font-size: .85rem; font-weight: 800; }
.opt.correct small { color: var(--good); }
.opt.wrong small { color: var(--bad); }
.why { background: var(--soft); border-radius: 14px; padding: .9rem 1rem; }
.score { font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; }

/* Progress */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; font-weight: 800; color: var(--brand); }
.plant .soil { fill: var(--soil); } .plant .seed { fill: var(--seed); } .plant .stem { stroke: var(--brand); stroke-width: 5; fill: none; stroke-linecap: round; }
.plant .leaf { fill: var(--leaf); } .plant .flower { fill: var(--accent); }

.note { font-size: .85rem; color: var(--ink2); }
.toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 14px; font-size: .95rem; z-index: 60; max-width: calc(100% - 2rem); text-align: center; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { *, *::after { animation: none !important; transition: none !important; } }

/* Visually hidden, still read by screen readers */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Small phones: keep the top bar on one line */
.brand span { white-space: nowrap; }
@media (max-width: 520px) {
  .brand small, .chip-btn .lbl { display: none; }
  .topbar { padding: .6rem 1rem; }
  .hero { padding: 1.2rem; }
  .hero .plant { width: 110px; height: 110px; }
}
/* The "read answers aloud" switch gets its own row so the trainer name has room */
.trainer-head { flex-wrap: wrap; }
.trainer-head .toggle { flex-basis: 100%; justify-content: flex-start; }

/* "Coming soon" page shown while the app is hidden */
.soon { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 2rem 1.2rem; text-align: center; }
.soon img { border-radius: 22px; box-shadow: var(--shadow); }
.soon h1 { color: var(--brand); margin-top: .6rem; }
.soon-lead { font-size: 1.4rem; font-weight: 800; }
.soon .btn { margin-top: 1rem; }
