:root {
  --bg: #f4f6f7; --card: #ffffff; --ink: #172026; --muted: #5b6b74; --line: #dbe2e6;
  --brand: #1f5a6e; --brand-ink: #ffffff; --tint: #e6f0f3;
  --good: #1d7a45; --good-bg: #e5f4ea; --bad: #b23b2c; --bad-bg: #fbe9e6;
  --test: #1f5a6e; --test-bg: #eef5f8; --warn: #8a4c12; --warn-bg: #fdf4ec;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1f; --card: #172429; --ink: #e8eef1; --muted: #9db0b9; --line: #2a3a41;
    --brand: #5fb3cc; --brand-ink: #0f1a1f; --tint: #1c3038;
    --good: #6fd39a; --good-bg: #16302a; --bad: #ff8f80; --bad-bg: #3a1f1c;
    --test: #8fd0e2; --test-bg: #18303a; --warn: #f2b37a; --warn-bg: #36281c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
       -webkit-text-size-adjust: 100%; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
       padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink); }
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: 0; background: transparent; color: inherit; font-size: 30px; line-height: 1; padding: 0 6px 2px 0; cursor: pointer; }
.net { font-size: 12px; background: rgba(0,0,0,.2); padding: 2px 8px; border-radius: 99px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }
h2 { font-size: 20px; margin: 20px 0 10px; }
h3 { font-size: 17px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 16px; margin: 0 0 12px; }
.list { display: grid; gap: 10px; }
.tile { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
        background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
        padding: 14px 16px; text-decoration: none; color: inherit; }
.tile:active { transform: scale(.99); }
.tile[aria-disabled="true"] { opacity: .55; cursor: default; }
.tile .num { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
             background: var(--tint); color: var(--brand); font-weight: 700; }
.tile .body { flex: 1; min-width: 0; }
.tile .t { font-weight: 650; }
.tile .s { color: var(--muted); font-size: 14px; }
.tile .go { color: var(--muted); font-size: 22px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--tint); color: var(--brand); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px;
       padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
       cursor: pointer; font-weight: 600; }
a.btn { text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 8px 0 14px; }
.progress > i { display: block; height: 100%; background: var(--brand); }

/* Learn: lecture content */
.lecture { overflow-wrap: anywhere; }
.lecture h3 { color: var(--brand); }
/* Tables keep whole words and scroll sideways on a narrow phone instead of breaking "Thiazide" into "Thiazi-de". */
.lecture .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0 14px; border-radius: 10px; }
.lecture table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.lecture th, .lecture td { overflow-wrap: normal; word-break: normal; hyphens: manual; }
.lecture th { background: var(--brand); color: var(--brand-ink); text-align: left; padding: 6px 8px; white-space: nowrap; }
.lecture td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; min-width: 7.5em; }
.lecture td:last-child { min-width: 13em; }
.lecture td.k { font-weight: 650; }
.lecture .ontest { background: var(--test-bg); border-left: 4px solid var(--test); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.lecture .ontest .lbl, .lecture .box .lbl { display: block; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--test); margin-bottom: 4px; }
.lecture .ontest .q { font-weight: 600; margin: 6px 0 2px; }
.lecture .ontest .a { color: var(--good); font-weight: 700; }
.lecture .box { background: var(--warn-bg); border-left: 4px solid var(--warn); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.lecture .box .lbl { color: var(--warn); }
.lecture .diawrap { background: #fff; border-radius: 10px; padding: 6px; margin: 10px 0 4px; }
.lecture svg { width: 100%; height: auto; display: block; }
.lecture .cap { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.lecture .two { display: block; }

/* Flashcards */
.flash { position: relative; min-height: 240px; display: grid; place-items: center; text-align: center; cursor: pointer;
         padding: 24px; font-size: 19px; user-select: none; }
.flash .face-label { position: absolute; top: 10px; left: 14px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.flash .front { font-size: 24px; font-weight: 700; }
.flash .back { font-size: 17px; text-align: left; }
.flash .hint { position: absolute; bottom: 10px; left: 0; right: 0; font-size: 13px; color: var(--muted); }

/* Key points */
.kp .q { font-weight: 600; }
.kp .reveal { margin-top: 10px; }
.kp .a { color: var(--good); font-weight: 700; margin: 8px 0 4px; }
.kp .trap { font-size: 15px; color: var(--muted); }

/* Quiz */
.stem { font-size: 18px; font-weight: 600; margin: 4px 0 14px; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; margin: 0 0 10px; padding: 12px 14px;
       border: 2px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; }
.opt .mark { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.opt.sata .mark { border-radius: 7px; }
.opt.sel { border-color: var(--brand); }
.opt.sel .mark { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; color: inherit; }
.feedback { border-radius: 12px; padding: 12px 14px; margin: 6px 0 14px; }
.feedback.good { background: var(--good-bg); }
.feedback.bad { background: var(--bad-bg); }
.feedback b { display: block; margin-bottom: 4px; }
.score { font-size: 44px; font-weight: 800; color: var(--brand); text-align: center; margin: 8px 0; }

.footer-note { font-size: 13px; color: var(--muted); text-align: center; margin: 28px 0 8px; }
