/* Kannada for Doctors - styles. Calm sea-green clinic palette, light and dark. */
@font-face { font-family: "GK Kannada"; src: url("../fonts/noto-sans-kannada-kannada-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "GK Kannada"; src: url("../fonts/noto-sans-kannada-kannada-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "GK Latin"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "GK Latin"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "GK Telugu"; src: url("../fonts/noto-sans-telugu-telugu-400-normal.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #f3f6f5; --surface: #ffffff; --surface-2: #e9f0ee; --line: #d3dfdc;
  --text: #15302b; --muted: #55706a; --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #d5ede9;
  --accent: #c2603f; --good: #166534; --good-soft: #dcf2e2; --bad: #a61b1b; --bad-soft: #fbe3e1;
  --warn: #8a4b06; --warn-soft: #fdf0d5; --shadow: 0 1px 3px rgba(20, 50, 45, .10), 0 4px 14px rgba(20, 50, 45, .06);
  --radius: 14px; --nav-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1918; --surface: #162422; --surface-2: #1d302d; --line: #2b4440;
    --text: #e2efec; --muted: #9db5af; --primary: #3fb8a8; --primary-ink: #06201c; --primary-soft: #1d3d39;
    --accent: #e98d6c; --good: #6fd391; --good-soft: #163626; --bad: #ff8f86; --bad-soft: #3d1c1a;
    --warn: #f1bd62; --warn-soft: #3a2c12; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1918; --surface: #162422; --surface-2: #1d302d; --line: #2b4440;
  --text: #e2efec; --muted: #9db5af; --primary: #3fb8a8; --primary-ink: #06201c; --primary-soft: #1d3d39;
  --accent: #e98d6c; --good: #6fd391; --good-soft: #163626; --bad: #ff8f86; --bad-soft: #3d1c1a;
  --warn: #f1bd62; --warn-soft: #3a2c12; --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.45 "GK Latin", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
[lang="kn"], .kn { font-family: "GK Kannada", "Noto Sans Kannada", "Tunga", "Kedage", sans-serif; }
.tr, .mono { font-family: "GK Latin", "Atkinson Hyperlegible", "Verdana", sans-serif; text-transform: none; font-variant-ligatures: none; }
.te-script { font-family: "GK Telugu", "Noto Sans Telugu", sans-serif; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; padding-top: max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px)); }
.screen { padding: 14px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.screen.session { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
/* iPhone notch: an opaque band behind the status bar, so scrolled content never shows under the clock */
body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px)); background: var(--bg); z-index: 50; pointer-events: none; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px 6px; }
.topbar h1 { font-size: 21px; margin: 0; flex: 1; letter-spacing: .1px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand svg { width: 30px; height: 30px; }
.brand.big { justify-content: center; }
.iconbtn { min-width: 48px; min-height: 48px; border: 0; background: transparent; border-radius: 12px; display: inline-grid; place-items: center; cursor: pointer; color: var(--text); }
.iconbtn:active { background: var(--surface-2); }
.iconbtn svg { width: 24px; height: 24px; }

/* bottom navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; }
.nav-inner { display: flex; width: 100%; max-width: 560px; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12.5px; min-height: 48px; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.nav .badge { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--accent); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 5px; min-width: 18px; text-align: center; line-height: 18px; }

/* cards & lists */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 0 0 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
h2 { font-size: 19px; margin: 18px 0 10px; }
h3 { font-size: 16px; margin: 14px 0 6px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 2px 8px; font-weight: 700; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }

/* buttons */
.btn { min-height: 50px; padding: 10px 18px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btnrow { display: flex; gap: 10px; }
.btnrow > * { flex: 1; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: 15px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--text); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

/* Kannada lines */
.kl .tr { font-size: 1.15em; font-weight: 700; letter-spacing: .2px; word-break: break-word; }
.kl .kn { font-size: 1.05em; color: var(--muted); line-height: 1.6; }
.kl.only-kn .kn, .kl.big .kn:first-child { color: var(--text); }
.kl.big .tr { font-size: 27px; line-height: 1.25; }
.kl.big .kn { font-size: 23px; }
.kl.mid .tr { font-size: 21px; }
.kl.mid .kn { font-size: 19px; }
.play { min-width: 52px; min-height: 52px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-ink); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.play svg { width: 26px; height: 26px; }
.play.small { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
.play.small svg { width: 20px; height: 20px; }
.play.slow { background: var(--surface-2); color: var(--text); }
.play.playing { box-shadow: 0 0 0 4px var(--primary-soft); }
.play.huge { width: 112px; height: 112px; }
.play.huge svg { width: 52px; height: 52px; }
.play.nosound { background: var(--surface-2); color: var(--muted); }

/* full item card */
.item-card .head { display: flex; gap: 12px; align-items: flex-start; }
.gloss { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.gloss span { background: var(--surface-2); border-radius: 8px; padding: 3px 8px; font-size: 14.5px; }
.gloss b { font-weight: 700; }
.field { margin: 6px 0; }
.field .lab { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-right: 6px; }
.en { font-size: 18px; font-weight: 700; margin-top: 8px; }
.note { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 15px; margin-top: 8px; }
.flag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 3px 9px; border-radius: 8px; font-weight: 700; margin: 6px 6px 0 0; }
.flag svg { width: 15px; height: 15px; }
.flag.verify { background: var(--warn-soft); color: var(--warn); }
.flag.avoid { background: var(--bad-soft); color: var(--bad); }
.flag.delicate { background: var(--warn-soft); color: var(--warn); }
.flag.corrected { background: var(--good-soft); color: var(--good); }
.flag.region { background: var(--surface-2); color: var(--muted); }
.sub { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; }
.sub-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.kind { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }

/* path (home) */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border-radius: 12px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.goal { display: flex; align-items: center; gap: 14px; }
.ring { width: 56px; height: 56px; flex: none; }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--primary); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { font-size: 15px; font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.stage-title { display: flex; align-items: baseline; gap: 8px; margin: 22px 2px 10px; }
.stage-title b { font-size: 13px; color: var(--primary); letter-spacing: .08em; }
.stage-title span { font-weight: 700; }
.unit { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; text-decoration: none; color: var(--text); min-height: 72px; }
.unit .num { font-size: 13px; color: var(--muted); }
.unit .t { font-weight: 700; }
.unit.locked { opacity: .78; }
.unit.planned { box-shadow: none; border: 1.5px dashed var(--line); background: transparent; color: var(--muted); }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; min-height: 60px; text-decoration: none; color: var(--text); }
.lesson-row .st { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); flex: none; font-weight: 700; }
.lesson-row .st.done { background: var(--good-soft); color: var(--good); }
.lesson-row .st svg { width: 18px; height: 18px; }

/* session */
.sess-top { position: sticky; top: max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px)); z-index: 10; background: var(--bg); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 4px; }
.progress { flex: 1; height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .25s; }
.q-label { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); margin: 8px 0 10px; }
.prompt { margin-bottom: 16px; }
.prompt .en-big { font-size: 22px; font-weight: 700; line-height: 1.3; }
.situation { font-size: 19px; line-height: 1.4; background: var(--surface); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 10px; }
.center { text-align: center; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { text-align: left; width: 100%; min-height: 56px; padding: 12px 14px; border-radius: 13px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; display: flex; align-items: center; gap: 10px; }
.opt .mark { margin-left: auto; flex: none; display: none; }
.opt .mark svg { width: 22px; height: 22px; }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .mark { display: block; color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .mark { display: block; color: var(--bad); }
.opt:disabled, .opt.locked { cursor: default; color: var(--text); }
svg { max-width: 100%; }
.mark svg { width: 22px; height: 22px; }
.opt .play.small { margin-left: auto; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .opt { min-height: 64px; justify-content: center; text-align: center; font-size: 15.5px; }
.match .opt.done { opacity: .35; border-style: dashed; }
.match .opt.flash { border-color: var(--bad); background: var(--bad-soft); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; min-height: 64px; }
.answer-area { min-height: 72px; border-bottom: 2px solid var(--line); padding: 6px 0 10px; margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.tile { min-height: 52px; padding: 6px 12px; border-radius: 11px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 2px 0 var(--line); }
.tile .tr { font-weight: 700; font-size: 17px; }
.tile .kn { font-size: 14px; color: var(--muted); }
.tile.used { visibility: hidden; }
.blank { display: inline-block; min-width: 70px; border-bottom: 3px solid var(--primary); margin: 0 4px; }
.sentence { font-size: 20px; line-height: 1.9; }

/* footer action area (thumb zone) */
.footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: center; pointer-events: none; }
.footer-inner { width: 100%; max-width: 560px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent); pointer-events: auto; }
.sheet { width: 100%; max-width: 560px; max-height: 66vh !important; background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .18); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); pointer-events: auto; max-height: 78vh; overflow-y: auto; }

.sheet > #cont { position: sticky; bottom: 0; box-shadow: 0 -10px 10px var(--surface), 0 14px 0 var(--surface); }
.sheet.good { border-top: 5px solid var(--good); }
.sheet.bad { border-top: 5px solid var(--bad); }
.verdict { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.verdict svg { width: 28px; height: 28px; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.sheet .item-card { box-shadow: none; padding: 0; margin: 0 0 12px; }

/* dialogue */
.bubbles { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.bubble.doc { align-self: flex-end; background: var(--primary-soft); border-bottom-right-radius: 4px; }
.bubble.pat { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble .who { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.bubble .en { font-size: 15px; font-weight: 400; margin-top: 4px; color: var(--muted); }

/* forms */
.input { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 17px; }
textarea.input { min-height: 110px; resize: vertical; }
.search { position: sticky; top: max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px)); z-index: 5; background: var(--bg); padding: 8px 0; }
label.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--line); }
label.toggle input[type=checkbox] { flex: none; width: 26px; height: 26px; accent-color: var(--primary); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 48px; min-width: 48px; border: 0; background: var(--surface); cursor: pointer; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
.result-row { display: flex; gap: 10px; align-items: center; padding: 10px 2px; }
.result-row .grow .en { margin: 2px 0 0; font-size: 15px; font-weight: 400; }
.star { color: var(--muted); }
.star[aria-pressed="true"] { color: var(--accent); }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60; max-width: 90vw; font-size: 15px; box-shadow: var(--shadow); }

/* show-to-patient */
.showview { position: fixed; inset: 0; background: var(--surface); z-index: 70; display: flex; flex-direction: column; padding: calc(20px + max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px))) 18px calc(20px + env(safe-area-inset-bottom)); }
.showview .big-kn { font-size: clamp(30px, 9vw, 46px); line-height: 1.55; flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-family: "GK Kannada", "Noto Sans Kannada", sans-serif; }

/* body map */
.bodymap svg { width: 100%; height: auto; max-height: 76vh; }
.bodymap .region { fill: var(--primary); fill-opacity: .07; stroke: var(--primary); stroke-opacity: .35; stroke-width: 1.5; cursor: pointer; }
.bodymap .region.sel { fill-opacity: .35; stroke-opacity: 1; }
.bodymap .outline { fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* script track */
.letters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.letter { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 4px; text-align: center; border: 0; cursor: pointer; min-height: 88px; }
.letter .kn { font-size: 34px; color: var(--text); line-height: 1.3; }
.letter .te-script { font-size: 20px; color: var(--muted); }
.letter .tr { font-size: 15px; }
.trace { width: 100%; height: 220px; background: var(--surface); border-radius: 14px; border: 1.5px dashed var(--line); touch-action: none; display: block; }

table.key { border-collapse: collapse; width: 100%; font-size: 15px; }
table.key td, table.key th { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
table.key .kn { font-size: 18px; color: var(--text); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 9px; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
@media (min-width: 400px) { .letters { grid-template-columns: repeat(5, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Full / Short choice under each lesson */
.lesson-len { margin: -2px 0 10px 50px; gap: 8px; }
.lesson-len .btn { flex: 1; min-height: 44px; padding: 6px 10px; font-size: 14px; }
.lesson-len { flex-wrap: wrap; }
.lesson-len .btn.audio { flex-basis: 100%; }
details.cs > summary { cursor: pointer; list-style: none; min-height: 44px; }
details.cs > summary::-webkit-details-marker { display: none; }
details.cs[open] > summary { margin-bottom: 8px; }

/* first-run welcome */
.wdots { display: flex; gap: 6px; justify-content: center; padding: 6px 0; }
.wdots span { width: 22px; height: 5px; border-radius: 3px; background: var(--line); }
.wdots span.on { background: var(--primary); }
.brand.big svg { width: 72px; height: 72px; }
.wlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.wlist li { display: flex; gap: 12px; align-items: flex-start; }
.wlist svg { width: 22px; height: 22px; flex: none; color: var(--primary); margin-top: 2px; }
.welcome .opt { align-items: center; }

/* course buttons on home */
.coursebar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 12px; margin: 0 -16px 2px; scrollbar-width: none; }
.coursebar::-webkit-scrollbar { display: none; }
.cchip { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; }
.cchip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.cchip.locked { color: var(--muted); }
.cchip svg { width: 15px; height: 15px; }
