/* MaliLab Learn — the modules area, drawn like the Android app. */
body.learn { --bar: 4.25rem; background: #fff; padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom, 0px)); }
body.learn main { padding-top: max(1rem, env(safe-area-inset-top, 0px)); padding-bottom: 2rem; }
body.learn main:has(.mod-page), body.learn main:has(.lesson-page) { padding-top: 0; }

/* ---------- bottom bar, like the app ---------- */
.app-tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--bar) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: #fff; border-top: 1px solid rgba(231, 221, 212, .8); font-family: var(--sans); }
.app-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; color: #6b5b55; font-size: .75rem; font-weight: 600; text-decoration: none; }
.app-tabs .pill { display: grid; place-items: center; width: 4rem; height: 2rem; border-radius: 1rem; transition: background .15s; }
.app-tabs svg { width: 1.45rem; height: 1.45rem; fill: currentColor; }
.app-tabs a[aria-current="page"] { color: #0a4a43; font-weight: 800; }
.app-tabs a[aria-current="page"] .pill { background: #d9f0ec; }
@media (min-width: 48rem) { .app-tabs { left: 50%; right: auto; bottom: 1rem; width: 24rem; transform: translateX(-50%); height: 4rem; padding: 0; border: 1px solid rgba(231, 221, 212, .9); border-radius: 1.5rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); } body.learn { padding-bottom: 6rem; } }

/* ---------- install prompt ---------- */
.install-sheet { position: fixed; z-index: 40; left: .75rem; right: .75rem; bottom: calc(var(--bar) + env(safe-area-inset-bottom, 0px) + .75rem); display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; padding: 1rem 1.1rem; border-radius: 22px; background: #fff; box-shadow: 0 16px 40px rgba(0, 0, 0, .22); font-family: var(--sans); color: #3a2f2b; opacity: 0; transform: translateY(1rem); transition: opacity .25s, transform .25s; }
.install-sheet.open { opacity: 1; transform: none; }
.install-icon img { display: block; width: 3.5rem; height: 3.5rem; border-radius: 14px; }
.install-text strong { display: block; font-size: 1.05rem; font-weight: 800; }
.install-text p { margin: .2rem 0 0; color: #6b5b55; font-size: .88rem; line-height: 1.4; }
.install-actions { grid-column: 1 / -1; display: flex; gap: .6rem; margin-top: .5rem; }
.install-actions button { flex: 1; min-height: 2.9rem; border: 0; border-radius: 999px; font: 800 .95rem var(--sans); cursor: pointer; }
.install-go { background: linear-gradient(135deg, #219d92, #0f9688); color: #fff; }
.install-later { background: #f3efe9; color: #6b5b55; }
@media (min-width: 48rem) { .install-sheet { left: auto; right: 1.5rem; bottom: 1.5rem; width: 24rem; } }
@media (prefers-reduced-motion: reduce) { .install-sheet { transition: none; } }

/* ---------- shared bits ---------- */
.back-circle { z-index: 2; }
.premium-screen > .back-circle, .lesson-hero > .back-circle { position: absolute; }
.pill-btn { display: block; width: 100%; margin: 0; padding: .94rem 1rem; border: 0; border-radius: 999px; background: var(--c, #0f9688); color: #fff; font: 800 1.06rem var(--sans); text-align: center; text-decoration: none; cursor: pointer; }
.pill-btn:hover { color: #fff; filter: brightness(1.08); }
.pill-done { background: color-mix(in srgb, #1f7a4d 12%, #fff); color: #1f7a4d; }
.pill-done:hover { color: #1f7a4d; filter: none; }

/* ---------- lesson page ---------- */
.lesson-page { --a-ink: #3a2f2b; }
.lesson-hero { position: relative; margin: 0 calc(-1 * var(--gutter)); padding: 4.25rem 1.25rem 1.4rem; background: color-mix(in srgb, var(--c) 10%, #fff); }
.lesson-hero .back-circle { left: .75rem; top: .75rem; }
@media (min-width: 48rem) { .lesson-hero { margin: 1.5rem 0 0; border-radius: 22px; padding-inline: 2rem; } }
.lesson-label { margin: 0; color: var(--c); font-size: .75rem; font-weight: 800; letter-spacing: .09rem; }
.lesson-where { margin: 0; color: #6b5b55; font-size: .8125rem; }
.lesson-hero h1 { margin: .6rem 0 0; color: #3a2f2b; font: 800 1.75rem/2.125rem var(--sans); letter-spacing: 0; }
.lesson-cover { display: block; width: 100%; margin-top: .75rem; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 14px; }
.lesson-summary { margin: .5rem 0 0; color: #6b5b55; font-size: 1rem; line-height: 1.5rem; }
.lesson-blocks { padding: .5rem .25rem 0; }
.lesson-finish { display: grid; gap: .75rem; padding: 1.5rem .25rem 1rem; }
.lesson-finish form { margin: 0; }
.lesson-prev { color: #6b5b55; font-size: .9rem; font-weight: 600; text-align: center; text-decoration: none; }
.lesson-prev:hover { color: #3a2f2b; }

/* lesson text, exactly as LessonScreen.BlockView draws it */
.app-blocks { font-family: var(--sans); color: #3a2f2b; }
.app-blocks > * { margin: 1rem 0; }
.app-blocks .ab-p { max-width: none; font-size: 1.0625rem; line-height: 1.75rem; overflow-wrap: anywhere; }
.app-blocks .ab-h { margin-top: 1.6rem; color: var(--hc); font: 800 1.4375rem/1.875rem var(--sans); letter-spacing: 0; }
.app-blocks h3.ab-h { font-size: 1.1875rem; line-height: 1.5625rem; }
.app-blocks .ab-list { display: grid; gap: .5rem; padding: 0; list-style: none; counter-reset: ab; }
.app-blocks .ab-list li { position: relative; padding-left: 1.6rem; font-size: 1.0625rem; line-height: 1.625rem; }
.app-blocks ul.ab-list li::before { content: ""; position: absolute; left: .1rem; top: .62rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--hc); }
.app-blocks ol.ab-list li { counter-increment: ab; padding-left: 2.4rem; }
.app-blocks ol.ab-list li::before { content: counter(ab) "."; position: absolute; left: 0; width: 1.65rem; color: var(--hc); font-weight: 800; }
.app-blocks .ab-callout { padding: 1rem; border-radius: 14px; background: color-mix(in srgb, var(--cc) 10%, #fff); }
.app-blocks .ab-callout strong { display: block; color: var(--cc); font-size: .75rem; font-weight: 800; letter-spacing: .09rem; }
.app-blocks .ab-callout p { margin: .375rem 0 0; font-size: 1rem; line-height: 1.5rem; max-width: none; }
.app-blocks .ab-table { overflow-x: auto; border-radius: 12px; background: #fffbf5; }
.app-blocks table { min-width: 100%; border-collapse: collapse; font-size: .875rem; line-height: 1.25rem; }
.app-blocks th { padding: .75rem; background: #d9f0ec; color: #0a4a43; font-weight: 800; text-align: left; white-space: nowrap; }
.app-blocks td { min-width: 8rem; padding: .75rem; border-top: 1px solid #e7ddd4; vertical-align: top; }
.app-blocks mark.hl { color: #3a2f2b; padding: 0 .15em; border-radius: .2em; }
.app-blocks .hl-yellow { background: #fff1a0; } .app-blocks .hl-green { background: #c4ecd2; } .app-blocks .hl-blue { background: #cde2ff; }
.app-blocks .hl-pink { background: #ffd0e2; } .app-blocks .hl-orange { background: #ffd9b3; }
.app-blocks .ab-table:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- "Module complete!" ---------- */
.celebrate { position: fixed; z-index: 60; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; padding: 1.75rem; background: linear-gradient(180deg, var(--c), #16202b); color: #fff; text-align: center; font-family: var(--sans); animation: celebrate-in .35s ease-out; }
@keyframes celebrate-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.celebrate-ring { display: grid; place-items: center; width: 6.9rem; height: 6.9rem; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.celebrate-ring span { display: grid; place-items: center; width: 5rem; height: 5rem; border-radius: 50%; background: #fff; color: var(--c); font-size: 2.75rem; font-weight: 800; }
.celebrate h2 { margin: .5rem 0 0; color: #fff; font: 800 2rem/2.4rem var(--sans); letter-spacing: 0; }
.celebrate p { margin: 0; max-width: 26rem; color: rgba(255, 255, 255, .85); font-size: .94rem; line-height: 1.4; }
.celebrate .celebrate-lead { color: #fff; font-size: 1.06rem; font-weight: 600; }
.celebrate-main, .celebrate-ghost { display: block; width: min(100%, 24rem); padding: 1rem; border-radius: 999px; font-size: 1.06rem; font-weight: 800; text-decoration: none; }
.celebrate-main { margin-top: .75rem; background: #fff; color: var(--c); }
.celebrate-ghost { background: rgba(255, 255, 255, .16); color: #fff; }
.celebrate-main:hover { color: var(--c); } .celebrate-ghost:hover { color: #fff; }
@media (prefers-reduced-motion: reduce) { .celebrate { animation: none; } }

/* ---------- Premium / M-Pesa, like the app's PremiumCard ---------- */
.premium-screen { position: relative; display: grid; place-items: center; min-height: calc(100vh - 8rem); padding: 4rem 0 1rem; }
.premium-screen > .back-circle { left: 0; top: .25rem; }
.premium-card { display: flex; flex-direction: column; align-items: center; gap: .75rem; width: min(100%, 26rem); padding: 1.4rem 1.4rem 1.2rem; border-radius: 24px; background: #fff; box-shadow: 0 12px 40px rgba(10, 74, 67, .16), 0 0 0 1px rgba(231, 221, 212, .7); color: #3a2f2b; font-family: var(--sans); text-align: center; }
.premium-card > div { display: flex; flex-direction: column; align-items: center; gap: .75rem; width: 100%; }
.premium-card h1 { margin: 0; color: #3a2f2b; font: 800 1.125rem/1.5rem var(--sans); letter-spacing: 0; }
.premium-card p { margin: 0; font-size: .875rem; line-height: 1.25rem; }
.premium-card .premium-strong { font-size: .94rem; line-height: 1.3rem; font-weight: 700; }
.premium-kicker { color: #8a5200; font-size: .75rem !important; font-weight: 800; letter-spacing: .09rem; text-transform: uppercase; }
.premium-price { color: #0a4a43; font-size: 1.625rem !important; line-height: 2rem !important; font-weight: 800; }
.mpesa-badge { padding: .375rem .875rem; border-radius: 10px; background: #3fae2a; color: #fff; font-size: 1.06rem; font-weight: 800; letter-spacing: .06rem; }
.premium-field { display: grid; gap: .3rem; width: 100%; text-align: left; }
.premium-field span { color: #6b5b55; font-size: .8rem; font-weight: 600; }
.premium-field input { min-height: 3.2rem !important; border-radius: 12px !important; font-size: 1.05rem !important; }
.premium-field input:focus { border-color: #3fae2a !important; box-shadow: 0 0 0 3px rgba(63, 174, 42, .18) !important; }
.premium-error { width: 100%; padding: .625rem; border-radius: 12px; background: color-mix(in srgb, #b0285a 8%, #fff); color: #b0285a !important; font-size: .8125rem !important; font-weight: 700; }
.premium-test { color: #8a5200; font-size: .75rem !important; font-weight: 700; }
.mpesa-btn { display: block; width: 100%; padding: .81rem 1rem; border: 0; border-radius: 999px; background: #3fae2a; color: #fff; font: 800 1rem var(--sans); text-align: center; text-decoration: none; cursor: pointer; }
.mpesa-btn:hover { color: #fff; filter: brightness(1.06); }
.mpesa-btn:disabled { opacity: .7; cursor: progress; }
.premium-later { padding: .375rem 1.125rem; border-radius: 999px; color: #6b5b55; font-size: .875rem; font-weight: 700; text-decoration: none; }
.premium-later:hover { background: #f3efe9; color: #3a2f2b; }
.spinner { width: 1.75rem; height: 1.75rem; border: 3px solid rgba(63, 174, 42, .2); border-top-color: #3fae2a; border-radius: 50%; animation: spin .9s linear infinite; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.success-ring { display: grid; place-items: center; width: 6.5rem; height: 6.5rem; border-radius: 50%; background: #16c45a; color: #fff; font-size: 3.9rem; font-weight: 800; }
.success-title { color: #16c45a !important; font-size: 1.5rem !important; }
.lock-ring { display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%; background: color-mix(in srgb, #8a5200 12%, #fff); color: #8a5200; }
.lock-ring svg { width: 1.8rem; height: 1.8rem; fill: currentColor; }

/* trial / free-plan line on the modules page */
.learn-strip { margin: .75rem 0 .25rem; padding: .6rem 1rem; border-radius: 14px; background: #fff8e8; color: #8a5200; font-size: .85rem; font-weight: 700; text-align: center; max-width: none; }
.learn-strip a { color: #8a5200; }
.lesson-next { color: var(--c); font-weight: 800; }

/* ---------- offline and messages ---------- */
.learn-message { display: grid; gap: .75rem; justify-items: center; padding: 4rem 0; text-align: center; font-family: var(--sans); }
.learn-message-icon { font-size: 3rem; color: #219d92; }
.learn-message h1 { margin: 0; font: 800 1.5rem var(--sans); color: #3a2f2b; }
.learn-message p { color: #6b5b55; }
.learn-message .mod-cta { --c: #0f9688; width: min(100%, 20rem); }

/* the installed app hides the prompt for good */
.is-app .install-sheet { display: none !important; }
