/* AI Case Moderator: styled from the MIBC Case Dialogues program deck (theme "MIBC").
   Deck colours: title green #284f40 (accent3 at 75%), green #366956, teal #598a88, light teal #a0cdce,
   copper #c78a4d, peach #f5ce9c, sage #c9cd8c, stone #e4ded0 (decision-point boxes). */
:root {
  --ink: #284f40;
  --green: #366956;
  --teal: #598a88;
  --teal-light: #a0cdce;
  --teal-wash: #e7f1f1;
  --copper: #c78a4d;
  --peach: #f5ce9c;
  --peach-wash: #fdf3e6;
  --sage: #c9cd8c;
  --stone: #e4ded0;
  --paper: #f4f5f2;
  --card: #ffffff;
  --line: #dcdfd9;
  --text: #22302a;
  --muted: #66716b;
  --good: #366956;
  --good-bg: #e2eee8;
  --bad: #9c4a30;
  --bad-bg: #f8ebe5;
  --radius: 12px;
  --font: 'Open Sans', Arial, Helvetica, sans-serif;
  --gradient: url('../img/gradient.jpg');
  --wave: url('../img/wave-left.png');
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--paper); font-size: 15px; line-height: 1.5; }
h1, h2, h3, h4 { font-family: var(--font); font-weight: 700; margin: 0 0 .5em; line-height: 1.25; color: var(--ink); }
p { margin: 0 0 .6em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.ok { color: var(--good); font-weight: 600; }
a.link { color: #fff; }

/* buttons & inputs */
.btn { font: 600 14px var(--font); border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--teal); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--green); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.45); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 8px; }
input, select, textarea { font: 15px var(--font); width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-light); border-color: var(--teal); }
textarea { resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
label input, label select { margin-top: 5px; font-weight: normal; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 380px; margin: 0 auto; }
.center-card { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--gradient) center / cover; }
.pill { font-size: 12px; background: var(--stone); border-radius: 99px; padding: 2px 8px; }

/* top bar: deck title green with the program gradient as an underline */
.topbar { background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; flex-wrap: wrap; position: relative; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--gradient) center / cover; }
.brand { font-weight: 700; font-size: 17px; }
.brand .muted { color: var(--teal-light); font-size: 14px; font-weight: 600; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.45); border-radius: 8px; overflow: hidden; }
.seg button { font: 600 14px var(--font); background: transparent; color: #fff; border: 0; padding: 8px 14px; cursor: pointer; }
.seg button.on { background: var(--peach); color: var(--ink); }

/* sessions page */
.wrap { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: end; }
.grid-form label:first-child { grid-column: 1 / -1; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--ink); }
@media (max-width: 700px) { .grid-form { grid-template-columns: 1fr; } }

/* presenter console */
body.presenter { background: var(--paper) var(--wave) left top / auto 100vh no-repeat fixed; }
.console { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); gap: 16px; padding: 20px 16px 16px; align-items: start; }
@media (max-width: 1000px) { .console { grid-template-columns: 1fr; } }
.slide-frame { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; position: relative; box-shadow: 0 2px 10px rgba(40,79,64,.12); }
.slide-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slide-overlay { position: absolute; overflow: hidden; }
.slide-overlay video { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-nav { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.slide-nav #slidePos { flex: 1; text-align: center; }
.slide-nav select { width: auto; padding: 7px; }
.dp-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip { font: 600 13px var(--font); border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px; padding: 6px 12px; cursor: pointer; }
.chip.on { background: var(--peach); border-color: var(--copper); }
.notes { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.notes summary { font-weight: 700; color: var(--ink); cursor: pointer; }
#notes { margin-top: 8px; font-size: 14px; max-height: 260px; overflow: auto; }
.side h3 { font-size: 16px; }
.qcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.qcard.active { border-color: var(--copper); box-shadow: 0 0 0 2px rgba(199,138,77,.3); }
.qcard p { margin: 6px 0; }
.qmeta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; border-radius: 5px; padding: 2px 7px; background: var(--stone); color: var(--ink); }
.badge.science { background: var(--ink); color: #fff; }
.badge.discussion { background: var(--teal); color: #fff; }
.badge.lvl1 { background: var(--teal-wash); }
.badge.lvl2 { background: #eef0d9; }
.badge.lvl3 { background: var(--peach); }
.badge.draft { background: #fff; border: 1px dashed var(--muted); color: var(--muted); }
.badge.flag { background: var(--peach-wash); color: #7a4a17; cursor: help; }
.badge.mode { background: #fff; border: 1px solid var(--line); }
.run { border: 2px solid var(--copper); }
.run-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.run-head .state { margin-left: auto; font-weight: 700; font-size: 13px; }
.state.open { color: var(--good); }
.state.closed { color: var(--muted); }
.state.revealed { color: #8a5a1f; }
.run-q { font-weight: 700; font-size: 16px; color: var(--ink); }
.flagnote { font-size: 13px; background: var(--peach-wash); border-radius: 8px; padding: 6px 10px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cons { margin: 8px 0; }
.key { font-weight: 700; color: var(--ink); }
.texts { max-height: 220px; overflow: auto; }
.txt { background: var(--teal-wash); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; font-size: 14px; }
.reveal { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 14px; }
.reveal ul { padding-left: 18px; margin: 0 0 8px; }
.ask { display: flex; gap: 8px; }
.ai-box { background: var(--teal-wash); border-left: 4px solid var(--teal); border-radius: 8px; padding: 10px 14px; margin-top: 10px; }
.ai-box.pending { color: var(--muted); }
.ai-box.error { border-left-color: var(--bad); background: var(--bad-bg); }
.ai-box h4 { font-size: 15px; margin: 8px 0 4px; }
.ai-box ul { padding-left: 18px; margin: 0 0 6px; }
.ai-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--teal); margin-bottom: 4px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--copper); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { margin: 0; width: 140px; }
.thumb img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb figcaption { font-size: 11px; color: var(--muted); text-align: center; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--bad); color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* result bars (presenter + screen) */
.bars { margin: 8px 0; }
.bar-row { margin-bottom: 8px; }
.bar-label { display: flex; gap: 8px; align-items: baseline; }
.bar-label .letter { font-weight: 700; min-width: 1.2em; color: var(--ink); }
.bar-label .opt { flex: 1; }
.bar-label .pct { font-weight: 700; color: var(--ink); }
.bar-track { height: 10px; background: var(--stone); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 99px; transition: width .5s; }
.bar-row.correct .bar-fill { background: var(--green); }
.bar-row.correct .bar-label, .bar-row.correct .bar-label .pct { color: var(--good); font-weight: 700; }
.bar-row.dim { opacity: .55; }
.bar-row.chosen .bar-label .letter::after { content: ' ●'; color: var(--copper); }

/* ---------- projector ---------- */
body.screen { background: #000; overflow: hidden; height: 100vh; }
.slide-view { position: fixed; inset: 0; display: grid; place-items: center; }
.slide-box { position: relative; width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; }
.slide-box img { width: 100%; height: 100%; display: block; }
.fs-btn { position: fixed; right: 10px; bottom: 10px; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 6px; font-size: 18px; padding: 4px 9px; cursor: pointer; opacity: .4; }
.fs-btn:hover { opacity: 1; }
.join-overlay { position: fixed; inset: 0; background: var(--gradient) center / cover; display: grid; place-items: center; text-align: center; }
.join-card { background: rgba(255,255,255,.92); border-radius: 3vh; padding: 4vh 5vh; box-shadow: 0 1vh 4vh rgba(40,79,64,.18); }
.join-card h2 { font-size: 4.4vh; color: var(--ink); }
.join-card #joinQR { background: #fff; padding: 2vh; border-radius: 1.5vh; width: 46vh; margin: 0 auto; border: 1px solid var(--line); }
.join-url { font-size: 3vh; font-weight: 700; margin-top: 1.5vh; color: var(--ink); }
.join-card .muted { font-size: 2.4vh; }
.q-view { position: fixed; inset: 0; background: var(--paper) var(--wave) left top / auto 100% no-repeat; padding: 3.5vh 4vw 3.5vh max(4vw, 17vh); display: flex; flex-direction: column; overflow: hidden; font-size: 2.3vh; }
#qContent { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.q-avatar { position: fixed; z-index: 2; border-radius: 1.8vh; overflow: hidden; background: var(--teal-light) center / cover no-repeat; border: .6vh solid var(--teal-light); box-shadow: 0 .8vh 2.4vh rgba(40,79,64,.16); transition: left .25s, top .25s, width .25s, height .25s; }
.q-avatar video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Portrait beside the question text */
.q-lead { display: flex; gap: 2.4vw; align-items: center; margin-bottom: 2.5vh; }
.q-lead .q-text { margin-bottom: 0; }
.q-portrait-slot { flex: 0 0 auto; width: 21vh; aspect-ratio: 3 / 4; }
.q-body.revealed .q-lead { margin-bottom: 1.4vh; gap: 1.6vw; }
.q-body.revealed .q-portrait-slot { width: 9vh; }
.q-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2vh; }
.q-head .patient { font-weight: 700; color: var(--teal); font-size: 2.4vh; }
.q-head .kind { background: var(--peach); color: var(--ink); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 1.8vh; padding: .5vh 1.2vw; border-radius: 99px; }
.q-body { display: grid; grid-template-columns: 1fr; gap: 3vw; min-height: 0; flex-shrink: 0; }
.q-body.revealed .bars { font-size: 2vh; margin: .4vh 0; }
.q-body.revealed .bar-row { margin-bottom: .7vh; }
.q-body.revealed .bar-track { height: 1.1vh; }
.q-body.revealed .bar-label .letter { min-width: 3.2vh; height: 3.2vh; }
.q-body.revealed .opts li { padding: .9vh 1.2vw; margin-bottom: .8vh; font-size: 2.1vh; }
.q-body.revealed .opts li .letter { min-width: 3.4vh; height: 3.4vh; }
.q-body.with-side { grid-template-columns: 1fr 30vh; }
.q-text { font-size: 4vh; color: var(--ink); margin-bottom: 2.5vh; }
.q-body.revealed .q-text { font-size: 3vh; margin-bottom: 1.5vh; }
.opts { list-style: none; padding: 0; margin: 0; }
.opts li { display: flex; gap: 1.2vw; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 1.2vh; padding: 1.4vh 1.4vw; margin-bottom: 1.2vh; font-size: 2.6vh; }
.opts li .letter, .q-view .bar-label .letter { background: var(--ink); color: #fff; border-radius: 50%; min-width: 4.2vh; height: 4.2vh; display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.opts li.correct { border-color: var(--green); background: var(--good-bg); }
.opts li.correct .letter { background: var(--green); }
.opts li.dim { opacity: .5; }
.opts li.chosen { opacity: 1; border: 2px solid var(--copper); }
.opts li.chosen.correct { border-color: var(--green); }
.opts li .tag { margin-left: auto; background: var(--peach); color: var(--ink); border-radius: 99px; font-size: 1.6vh; font-weight: 700; padding: .3vh .8vw; white-space: nowrap; }
.q-view .bars { font-size: 2.4vh; }
.q-view .bar-label { align-items: center; }
.q-view .bar-track { height: 1.6vh; }
.q-view .bar-row { margin-bottom: 1.4vh; }
.scan { background: var(--ink); color: #fff; border-radius: 2vh; padding: 2.5vh; text-align: center; align-self: start; position: relative; overflow: hidden; }
.scan::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: .8vh; background: var(--gradient) center / cover; }
.scan-title { font-weight: 700; font-size: 2.8vh; margin-bottom: 1.5vh; }
.scan #qQR { background: #fff; padding: 1.4vh; border-radius: 1vh; width: 100%; }
.scan .join-url { font-size: 1.7vh; margin-top: 1vh; word-break: break-all; color: #fff; }
.scan .count { font-size: 2.4vh; margin-top: 1.5vh; }
.scan .count strong { font-size: 5vh; color: var(--peach); display: block; }
.scan.consensus p { font-size: 2.2vh; }
.disc-wait p { font-size: 3vh; color: var(--muted); }
.reveal-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 2.5vw; margin-top: 1.6vh; min-height: 0; flex: 1; overflow: hidden; font-size: 1.85vh; line-height: 1.45; }
.reveal-grid { align-items: start; }
.reveal-grid > * { min-height: 0; max-height: 100%; overflow: auto; scrollbar-width: none; }
.reveal-grid.disc { grid-template-columns: 1.2fr 1fr; }
.reveal-grid .rationale { background: var(--card); border: 1px solid var(--line); border-radius: 1.4vh; padding: 1.8vh 1.4vw; }
.reveal-grid .rationale h3 { font-size: 2.4vh; color: var(--green); margin-bottom: .8vh; }
.reveal-grid .rationale > p { margin-bottom: 1vh; }
.reveal-grid.disc .rationale { background: var(--stone); border-color: #d5cdb9; }
.reveal-grid.disc .rationale h3 { color: var(--ink); }
.reveal-grid .why p { font-size: 1.55vh; color: var(--muted); margin-bottom: .5vh; line-height: 1.4; }
.reveal-grid ul { padding-left: 1.4em; margin: 0; }
.reveal-grid li { margin-bottom: .8vh; }
.q-view .ai-box { margin-top: 0; font-size: 2vh; }
.q-view .ai-box h4 { font-size: 2.3vh; }
.q-view .thumb { width: 22vh; }

/* ---------- phone ---------- */
body.phone { background: var(--paper); }
.phone-top { background: var(--gradient) center / cover; color: var(--ink); padding: 14px 16px; text-align: center; font-weight: 700; }
#phone { max-width: 520px; margin: 0 auto; padding: 16px; }
#phone h1 { font-size: 24px; }
.standby { text-align: center; padding: 30px 6px; }
.standby h2 { color: var(--ink); }
.standby.small { padding: 14px 0; }
.q-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--teal); margin-bottom: 6px; }
#phoneView .q-text { font-size: 19px; }
.choices { display: grid; gap: 10px; margin: 12px 0; }
.choice { display: flex; gap: 12px; align-items: flex-start; text-align: left; font: 16px var(--font); background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; color: var(--text); }
.choice .letter { background: var(--ink); color: #fff; border-radius: 50%; min-width: 30px; height: 30px; display: inline-grid; place-items: center; font-weight: 700; }
.choice.picked { border-color: var(--copper); background: var(--peach-wash); }
.verdict { font-weight: 700; font-size: 17px; padding: 10px 12px; border-radius: 10px; background: var(--stone); color: var(--ink); }
.verdict.right { background: var(--good-bg); color: var(--good); }
.verdict.wrong { background: var(--bad-bg); color: var(--bad); }
.rat { font-size: 15px; }

/* QR codes are generated large, then scaled to fill their white box exactly (equal padding on every side) */
#joinQR img, #joinQR canvas, #qQR img, #qQR canvas { width: 100% !important; height: auto !important; display: block; aspect-ratio: 1; }
.blackout { position: fixed; inset: 0; background: #000; z-index: 40; cursor: none; }
