:root {
  --bg: #F7F6F2; --surface: #FFFFFF; --ink: #16151A; --muted: #55525C; --faint: #8C8893;
  --line: rgba(22,21,26,0.10); --green: #1F6B4E; --green-bg: #E3F0E8; --purple: #4A3A78; --purple-bg: #ECE6FA;
  --lime: #D9E85A; --amber: #8A5A00; --amber-bg: #FBF0D9; --red: #A3262A; --red-bg: #FBEAEA;
  --serif: Fraunces, Georgia, serif; --sans: Outfit, Arial, sans-serif; --mono: 'JetBrains Mono', Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--green); }
.wrap { max-width: 1160px; margin: 0 auto; padding-inline: clamp(16px, 3vw, 32px); }
main { padding-block: 32px 80px; outline: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(28px, 3.2vw, 38px); line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: rgba(247,246,242,0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand img { height: 26px; display: block; }
.brand-tag { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.mode { font-family: var(--mono); font-size: 11.5px; padding: 4px 10px; border-radius: 999px; }
.mode-mock { background: var(--amber-bg); color: var(--amber); }
.mode-live { background: var(--green-bg); color: var(--green); }

/* banners */
.banner { padding: 12px 0; font-size: 15px; }
.banner-red { background: var(--red); color: #fff; }
.banner-amber { background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid rgba(138,90,0,0.2); }

/* cards and panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.card-tight { padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 24px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .split, .split-wide { grid-template-columns: minmax(0, 1fr); } }
.sticky { position: sticky; top: 76px; }

/* buttons and forms */
button, .btn { font-family: var(--sans); font-size: 15px; font-weight: 500; border-radius: 999px; padding: 10px 18px; min-height: 42px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
button:hover, .btn:hover { background: var(--green); border-color: var(--green); }
button:disabled { opacity: 0.5; cursor: default; }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.ghost:hover { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.danger { background: var(--red); border-color: var(--red); }
.link-btn { background: none; border: none; color: var(--green); padding: 0; min-height: 0; text-decoration: underline; font-size: 14px; }
.link-btn:hover { background: none; color: var(--ink); }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
label { font-size: 14px; font-weight: 500; display: flex; flex-direction: column; gap: 6px; }
input[type=text], input[type=number], textarea, select { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,78,0.15); }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.err { color: var(--red); background: var(--red-bg); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.ok { color: var(--green); background: var(--green-bg); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

/* login */
.login { max-width: 420px; margin: 8vh auto 0; }

/* pills and badges */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill-green { background: var(--green-bg); color: var(--green); border-color: transparent; }
.pill-red { background: var(--red-bg); color: var(--red); border-color: transparent; }
.pill-amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.pill-purple { background: var(--purple-bg); color: var(--purple); border-color: transparent; }
.cat { font-family: var(--mono); font-size: 12px; }

/* progress */
.bar { height: 8px; border-radius: 99px; background: #EDEBE5; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 16px; border-radius: 18px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.msg-text { white-space: pre-wrap; }
.msg-patient { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; }
.msg-rhoe { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.msg-error { align-self: flex-start; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--line); border-radius: 18px; }

/* exercise rows */
.rows { display: flex; flex-direction: column; gap: 8px; }
.ex-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; }
.med-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; }
@media (max-width: 640px) { .ex-row, .med-row { grid-template-columns: minmax(0, 1fr); } }
.timer { font-family: var(--mono); font-size: 20px; font-variant-numeric: tabular-nums; }

/* rubric */
.rubric { display: flex; flex-direction: column; gap: 18px; }
.q { display: flex; flex-direction: column; gap: 8px; border: none; padding: 0; margin: 0; }
.q legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 4px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.opt span { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; }
.opt input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.opt input:focus-visible + span { outline: 3px solid var(--lime); outline-offset: 2px; }
.key { background: var(--purple-bg); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--muted); background: #FBFAF7; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
code { font-family: var(--mono); font-size: 13.5px; background: var(--bg); padding: 2px 6px; border-radius: 6px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.tile b { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
