/* WebFred v2 replica — values taken from .superpowers/sdd/fred.reference.{md,css} */
:root {
  --fred-blue: #004976; --fred-light: #5490CC; --chrome-fg: #FCFCFC;
  --chrome-font: "Open Sans", Verdana, sans-serif;
  --item-font: Arial, Helvetica, sans-serif;
  --nav-font: "Andale Mono", "Lucida Console", Menlo, monospace;
  --item-size: 16px; --item-lh: 1.4;
  --item-bg: linear-gradient(#FCFCFC 30%, #D7DCED 100%);
  --item-fg: #000; --box-bg: #FCFCFC; --box-border: #999;
  --nav-bg: #FCFCFC; --nav-row: rgba(0, 0, 0, 0.1); --nav-fg: #000;
  --hl: #FFFF00; --ok: #1a8f3a; --bad: #c62828; --line: #999;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #FCFCFC; color: #000; font-family: var(--chrome-font); font-size: 13px; }
.hidden { display: none !important; }
.screen { min-height: 100dvh; min-height: 0; }
button { font: inherit; cursor: pointer; }
.icon { width: 30px; height: 26px; fill: var(--chrome-fg); }

/* ---- FRED buttons ---- */
.button-blue {
  height: 27px; padding: 0 8px; border: 1px solid var(--fred-blue); border-radius: 3px; color: #fff;
  background: linear-gradient(var(--fred-light), var(--fred-blue));
  font: 15px var(--chrome-font);
}
.button-blue:hover { background: linear-gradient(var(--fred-blue), var(--fred-light)); }
.button-blue[disabled] { opacity: 0.5; cursor: default; }
.button-gray {
  height: 27px; padding: 0 8px; border: 1px solid var(--fred-blue); border-radius: 3px; color: #000;
  background: linear-gradient(#EEE 43%, #BBB); font: bold 15px var(--chrome-font);
}
.hbtn {
  height: 47px; min-width: 60px; padding: 0 8px; margin-left: 6.5px; background: transparent; color: var(--chrome-fg);
  border: 1px solid var(--fred-blue); border-radius: 3px; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; font: 13px var(--chrome-font); line-height: 13px; white-space: nowrap;
}
.hbtn[disabled] { opacity: 0.4; cursor: default; }
.hbtn.on { background: rgb(64, 118, 153); border: 1px inset var(--fred-blue); }
.hbtn.flat { border: 0; }
.hbtn .icon.arrow { width: 30px; height: 22px; }
#hdr [data-act="lab"] { width: 83px; }
#hdr [data-act="notes"] { width: 60px; }
#hdr [data-act="calc"] { width: 79px; }
#hdr [data-act="reverse"] { width: 102px; }
.zoomgroup { width: 66px; height: 47px; margin-left: 6.5px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.zoomrow { display: flex; align-items: flex-end; height: 34px; }
.zoombtn { width: 22px; height: 28px; background: transparent; color: var(--chrome-fg); border: 1px solid transparent; border-radius: 3px; font-family: var(--chrome-font); line-height: 1; padding: 0; }
.zoombtn:nth-child(3) { height: 34px; }
.zoombtn.sel { border: 1px solid var(--chrome-fg); }
.zoomlabel { font: 13px/13px var(--chrome-font); }

/* ---- start screen (the driver's launch page look) ---- */
#screen-start { background: #FFF; }
.start-wrap { max-width: 700px; margin: 0 auto; padding: 32px 16px 48px; font: 13px var(--chrome-font); color: #222; }
.brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 20px; }
.brand .wordmark { position: relative; width: 40px; height: 40px; border-radius: 8px; background: var(--fred-blue); flex: 0 0 40px; }
.brand .wordmark::after { content: ""; position: absolute; right: 6px; bottom: 6px; width: 14px; height: 14px; border-radius: 3px; background: #F7971D; }
.brand h1 { margin: 0; font-size: 34px; font-weight: bold; color: #1F3A7A; line-height: 1.1; }
.brand .tagline { margin: 3px 0 0; font-size: 12px; color: #777; }
.start-title { text-align: center; font-weight: bold; margin: 0 0 14px; }
.start-instruct { font-weight: bold; margin: 0 0 16px; }
.rule { border: 0; border-top: 1px solid #7A8DB8; margin: 16px 0; }
.resume-box { border: 1px solid #7A8DB8; padding: 10px 12px; margin-bottom: 16px; }
.resume-box p { margin: 0 0 8px; }
.resume-box p:last-child { margin: 0; }
#start-form h2 { font-size: 14px; font-weight: bold; color: #1F3A7A; margin: 18px 0 8px; }
.optlist { list-style: none; margin: 0; padding: 0; }
.optlist li { padding: 4px 6px; margin-bottom: 8px; }
.optlist li:has(input:checked) { background: #DCE6F5; }
.optlist label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.start-actions { text-align: center; margin: 22px 0 0; }
.legal { font-size: 11px; color: #777; text-align: center; margin: 0; }
#banner { position: fixed; top: 0; left: 0; right: 0; background: var(--bad); color: #fff; padding: 10px 16px; z-index: 50; }

/* ---- exam chrome ---- */
#screen-exam { display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
#hdr { flex: 0 0 55px; height: 55px; background: var(--hdr-bg, var(--fred-blue)); color: var(--chrome-fg); padding: 3px 10px 5px; display: flex; align-items: center; gap: 10px; font: 13px var(--chrome-font); }
#hdr .status { width: 99px; height: 36px; padding: 3px 5px; background: transparent; color: var(--chrome-fg); border: 1px outset rgb(88, 114, 196); border-radius: 3px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; font: 13px var(--chrome-font); }
#hdr .status b { font-size: 15px; line-height: 15px; font-weight: normal; white-space: nowrap; }
#hdr .status span { font-size: 13px; line-height: 15px; }
#hdr .mark { width: 70px; height: 41px; margin-left: 10px; display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--fred-blue); border-radius: 3px; padding: 3px 5px; cursor: pointer; font: 13px var(--item-font); }
#hdr .mark .icon { width: 14px; height: 20px; }
#hdr .hnav { display: flex; }
#hdr .hnav .hbtn { width: 60px; }
#hdr .htools { display: flex; align-items: center; }
#hdr .spacer { flex: 1; }

#body { flex: 1; display: flex; min-height: 0; }
#sidebar { flex: 0 0 80px; width: 80px; background: var(--nav-bg); overflow-y: auto; }
#leftnav { list-style: none; margin: 0; padding: 0; }
#leftnav li { height: 18px; line-height: 18px; padding-left: 3px; background: var(--nav-row); color: var(--nav-fg); font: 12px/15px var(--nav-font); white-space: nowrap; cursor: pointer; }
#leftnav li.currentitem { background: var(--nav-current-bg, var(--fred-blue)); color: var(--nav-current-fg, var(--chrome-fg)); }
#leftnav li span.ans_status { display: inline-block; width: 6px; }
#leftnav li span.incomplete::before { content: "\2022"; }
#leftnav li span.index { display: inline-block; min-width: 18px; text-align: center; padding: 1px 1px 0; border: 1px solid transparent; }
#leftnav li span.marked { float: right; width: 10px; height: 14px; margin: 2px 3px 0 0; }
#leftnav li span.marked .icon { width: 10px; height: 14px; }

/* ---- item area ---- */
#item { flex: 1; min-width: 0; overflow: auto; background: var(--item-bg); color: var(--item-fg); font-family: var(--item-font); font-size: var(--item-size); }
.itemwrap { padding: 20px 8px 32px; margin-left: 8px; }
.stem { max-width: 640px; min-width: 0; overflow-wrap: break-word; line-height: var(--item-lh); }
.stem p { margin: 0 0 12px; line-height: var(--item-lh); }
.stem mark { background: var(--hl); color: inherit; }
.answerbox { display: inline-block; max-width: 100%; overflow-wrap: break-word; background: var(--box-bg); border: 1px solid var(--box-border); padding: 8px; margin: 16px 0; }
.answerbox .options { list-style: none; margin: 0; padding: 0; }
.answerbox .options li { position: relative; min-height: 26px; padding: 1.6px 3.2px 1.6px 48px; border-radius: 3px; line-height: var(--item-lh); }
.answerbox .options li input { position: absolute; left: 26px; top: calc(0.7em - 5px); width: 13px; height: 13px; margin: 0; }
.answerbox .options li .text { cursor: pointer; }
.answerbox .options li.struck .text { text-decoration: line-through; opacity: 0.7; }
.answerbox .options li.key .text::after { content: " \2713"; color: var(--ok); font-weight: bold; }
.answerbox .options li.wrong .text::after { content: " \2717"; color: var(--bad); font-weight: bold; }
.answerbox .options li.locked input { pointer-events: none; }
.item-actions { margin: 16px 0 32px 130px; }
.item-actions .button-blue { min-width: 166px; }

/* ---- footer ---- */
#toolbar { flex: 0 0 51px; height: 51px; background: var(--fred-blue); color: var(--chrome-fg); display: flex; align-items: center; padding: 5px 10px 3px; }
#toolbar .timerbox { width: 246px; height: 43px; padding: 3px 5px; border: 1px outset rgb(88, 114, 196); border-radius: 3px; display: flex; align-items: center; }
#toolbar .times { border-collapse: collapse; font: 15px/15px var(--chrome-font); width: 100%; }
#toolbar .times th { text-align: right; font-weight: normal; padding: 0 6px 0 0; }
#toolbar .times td { font-variant-numeric: tabular-nums; }
#toolbar .hbtn { height: 43px; }
#toolbar [data-act="lock"] { width: 73px; }
#toolbar [data-act="end"] { width: 90px; }
#toolbar .hbtn .icon { height: 20px; }
#toolbar .spacer { flex: 1; }

/* ---- docked Lab Values ---- */
#labs { flex: 0 0 448px; width: 448px; background: var(--labs-bg, #FCFCFC); color: var(--labs-fg, #000); border-left: 1px solid #999; overflow: auto; font: 12px var(--item-font); }
.labs-top { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 0; }
.labs-top input[type="search"] { flex: 0 0 143px; height: 20px; margin-left: 5px; font: 12px var(--item-font); padding: 1px 3px; border: 1px solid var(--labs-field-line, #999); background: var(--labs-field-bg, #FFF); color: var(--labs-fg, #000); }
.labs-si { font-size: 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; margin-left: auto; padding-right: 5px; }
.labs-tabs { display: flex; padding: 0; }
.labs-tabs button { font: 12px var(--item-font); padding: 5px; margin-left: 12px; margin-bottom: -1px; border-radius: 3px 3px 0 0; background: var(--labs-tab-bg, transparent); color: inherit; border: 1px solid var(--labs-tab-line, #AAAABB); }
.labs-tabs button.active { font-weight: bold; background: var(--labs-tab-active, #D7DCED); border-color: var(--labs-tab-line, #AAAABB); }
.labs-body { padding: 0 0 12px; border-top: 1px solid var(--labs-line, #666); }
.labs-body table { border-collapse: collapse; width: 100%; font: 12px var(--item-font); }
.labs-body th { text-align: left; font-weight: bold; font-size: 12px; border-bottom: 1px solid var(--labs-line, #666); padding: 3px 3px 3px 10px; }
.labs-body tr { height: 16px; }
.labs-body td { padding: 0 3px 1px 0; vertical-align: top; }
.labs-body td.nm { padding: 0 3px 1px 10px; }
.labs-body tr.group td { font-weight: bold; padding: 4px 3px 1px 5px; }
.labs-body tr.sub td.nm { padding-left: 20px; }

/* ---- floating panels ---- */
.panel { position: fixed; z-index: 40; background: #FCFCFC; color: #000; border: 1px solid #666; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3); }
.panel .title { background: var(--fred-blue); color: var(--chrome-fg); font: 12px var(--chrome-font); padding: 3px 6px; display: flex; cursor: move; }
.panel .title .close { margin-left: auto; background: transparent; border: 0; color: var(--chrome-fg); padding: 0 2px; }
.panel .content { padding: 6px; }
.panel .content:focus { outline: none; }
.panel-notes { width: 389px; /* 375px textarea + 6px panel padding each side + border */ right: 16px; bottom: 60px; }
.panel-settings { width: 260px; right: 16px; bottom: 60px; }
.panel-notes textarea { width: 100%; height: 118px; font: 14px var(--nav-font); border: 1px solid #767676; }
.panel-actions { display: flex; gap: 6px; margin-top: 6px; }
#nt-save { width: 129px; }
#nt-del { width: 115px; }
.panel-settings label { display: block; margin: 4px 0; font: 12px var(--chrome-font); }
.panel-calc { width: 254px; right: 16px; top: 70px; border: 2px solid var(--fred-blue); border-radius: 5px 5px 0 0; background: #D7DCED; }
.panel-calc .content { background: #D7DCED; padding: 8px; }
.calc { display: flex; flex-direction: column; gap: 2px; }
.calc .display { height: 36px; background: #FCFCFC; color: #000; border: 1px solid #181A20; border-radius: 3px; padding: 4px; margin-bottom: 4px; text-align: right; font: 20px/26px var(--nav-font); overflow: hidden; }
.krow { display: flex; gap: 2px; }
.krow button { flex: 1 1 0; height: 31px; padding: 2px 4px; background: #E6E6E6; border: 1px solid #999; border-radius: 3px; font: bold 11px var(--item-font); }
.krow.last button:nth-child(1) { flex-grow: 79; }
.krow.last button:nth-child(2) { flex-grow: 53; }
.krow.last button:nth-child(3) { flex-grow: 78; }


/* ---- lock overlay & confirm ---- */
#lock { position: fixed; inset: 0; z-index: 100; background: var(--fred-blue); color: var(--chrome-fg); display: flex; align-items: center; justify-content: center; text-align: center; }
#lock h1 { font-size: 28px; margin: 0 0 12px; }
#lock h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: 2px; }
#lock p { margin: 0 0 24px; font-size: 15px; }
.confirm { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; z-index: 60; }
.confirm .box { background: #FCFCFC; color: #000; padding: 20px; border: 1px solid #666; min-width: 320px; font: 13px var(--chrome-font); }
.confirm .box button { margin-right: 8px; }

/* ---- break & report ---- */
#screen-break, #screen-report { max-width: 960px; margin: 40px auto; padding: 0 16px; font: 13px var(--chrome-font); }
#screen-break h1, #screen-report h1 { color: var(--fred-blue); }
#screen-report table { border-collapse: collapse; width: 100%; font-size: 13px; }
#screen-report th, #screen-report td { border-bottom: 1px solid #e0e4ea; padding: 4px 8px; text-align: left; }
#screen-report tr.row { cursor: pointer; }
#screen-report tr.row:hover { background: #E6E6E6; }
#screen-report .ok { color: var(--ok); font-weight: bold; } #screen-report .bad { color: var(--bad); font-weight: bold; }
#screen-report .review { border: 1px solid var(--line); padding: 16px; margin-top: 16px; font-family: var(--item-font); font-size: var(--item-size); line-height: 1.5; }
#screen-report .review .options { list-style: none; padding: 0; }
#screen-report .review .options li.key { color: var(--ok); font-weight: bold; }
#screen-report .review .options li.wrong { color: var(--bad); }
#screen-report .review .tr { background: #E6E6E6; padding: 12px; margin-top: 12px; }

/* Layout finishing: retain the driver's desktop geometry, allow content to grow. */
button, input, select, textarea { accent-color: var(--fred-blue); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible { outline: 2px solid #5490CC; outline-offset: 2px; }
#hdr button:focus-visible, #toolbar button:focus-visible { outline-color: #FFF; }
.hbtn, .zoomgroup, #hdr .status, #hdr .mark, #hdr .hnav { flex-shrink: 0; }
.hbtn:not(:disabled):hover { background: rgb(64, 118, 153); }
#hdr .mark input { margin: 0; flex-shrink: 0; }
#hdr .mark .icon { flex-shrink: 0; }
#hdr .status { cursor: default; }
#body { position: relative; }
.itemwrap { max-width: 900px; }
.answerbox .options li .text { display: block; }
.answerbox .options li:has(input:focus-visible) { outline: 2px solid var(--fred-light); }
.answerbox .options li:has(input:checked) { background: rgba(84, 144, 204, 0.12); }
.item-actions { margin-left: min(130px, 15%); }
#leftnav li:focus-visible { outline-offset: -2px; }
#toolbar .timerbox { flex-shrink: 0; }
#toolbar .times th, #toolbar .times td { white-space: nowrap; }
.start-wrap { padding-top: 28px; line-height: 1.55; }
.brand { justify-content: flex-start; margin-bottom: 18px; }
.brand h1 { font-size: clamp(25px, 5vw, 34px); }
.brand .tagline { font-size: 13px; }
.start-title, .start-instruct { text-align: left; font-weight: normal; }
.start-title { color: #526078; margin-bottom: 6px; }
.start-instruct { margin-bottom: 20px; }
#start-form h2 { margin-top: 16px; }
.optlist li { padding: 0; margin-bottom: 4px; border-radius: 3px; }
.optlist label { align-items: flex-start; padding: 6px 10px; line-height: 1.5; }
.optlist input { flex: 0 0 auto; margin: 3px 0 0; }
.start-actions { text-align: left; }
.start-actions .button-blue { height: 36px; min-width: 140px; }
.legal { text-align: left; line-height: 1.6; }
.panel { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow: auto; }
.panel .title { align-items: center; min-height: 28px; }
.panel .title .close { min-width: 24px; min-height: 22px; cursor: pointer; }
.panel-notes textarea { display: block; resize: vertical; }
.labs-tabs { flex-wrap: wrap; gap: 4px; padding: 0 5px; }
.labs-tabs button { margin-left: 0; }
.labs-top { flex-wrap: wrap; }
.labs-body td { line-height: 1.4; }
.confirm { padding: 16px; }
.confirm .box { min-width: 0; width: 440px; max-width: 100%; line-height: 1.6; }
.confirm .box p:first-child { margin-top: 0; }
#lock .lockbox { padding: 24px; }
#screen-break, #screen-report { min-height: calc(100dvh - 80px); line-height: 1.6; }
#screen-report .report-table { overflow-x: auto; }
#screen-report th { background: #EDF2F8; white-space: nowrap; }
#screen-report th, #screen-report td { padding: 8px; }
#screen-report .review { scroll-margin-top: 16px; }
#screen-report .review h3 { margin-top: 0; }
#screen-report .review .options li { margin: 8px 0; overflow-wrap: anywhere; }
#screen-report .review .notes { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1000px) {
  #hdr { height: auto; flex-basis: auto; flex-wrap: wrap; gap: 4px; padding: 4px 8px; }
  #hdr .htools { flex: 1 0 100%; overflow-x: auto; padding: 2px 0; }
  #hdr .htools .hbtn:first-child { margin-left: 0; }
  #labs { position: absolute; inset: 0 0 0 auto; z-index: 20; width: min(448px, calc(100% - 48px)); box-shadow: -3px 0 10px #0002; }
}
@media (max-width: 540px) {
  #sidebar { flex-basis: 44px; width: 44px; }
  #leftnav li { height: 28px; line-height: 26px; }
  #leftnav li span.marked { margin-right: 2px; }
  .itemwrap { margin-left: 0; padding: 16px 12px 24px; }
  .answerbox { padding: 6px; }
  .answerbox .options li { padding-left: 28px; }
  .answerbox .options li input { left: 6px; }
  .item-actions { margin-left: 0; }
  #toolbar { padding: 4px; }
  #toolbar .timerbox { width: 190px; }
  #toolbar .times { font-size: 11px; }
  #toolbar [data-act="lock"] { min-width: 44px; width: 44px; margin-left: 2px; }
  #toolbar [data-act="end"] { min-width: 68px; width: 68px; margin-left: 2px; }
  #toolbar .hbtn { padding: 0 3px; font-size: 11px; }
  .start-wrap { padding-top: 24px; }
  .brand { gap: 10px; }
  .brand .tagline { font-size: 11px; }
  #screen-report, #screen-break { margin: 24px auto; }
  #screen-report .review { padding: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 120ms ease, outline-color 120ms ease; }
  .panel { animation: panel-in 120ms ease-out; }
  @keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
}

.exam-title { margin: 0 0 4px; font-size: 20px; color: #1F3A7A; line-height: 1.3; }
.exam-meta { margin: 0; color: #526078; font-size: 13px; }

.exam-label { display: block; font-weight: bold; color: #1F3A7A; margin-bottom: 6px; }
#exam-select { display: block; width: 100%; max-width: 320px; height: 36px; padding: 0 10px; border: 1px solid #7A8DB8; border-radius: 3px; background: #FFF; color: #222; font: 14px var(--chrome-font); margin-bottom: 8px; }
.block-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.block-group { min-width: 0; border: 0; padding: 0; margin: 0; }
.block-group legend { padding: 0; margin-bottom: 8px; font-weight: bold; color: #526078; }
.block-group small { display: block; color: #526078; font-size: 11px; margin-top: 2px; }
@media (max-width: 420px) { .block-groups { grid-template-columns: 1fr; gap: 12px; } }

/* Controls remain visible at phone widths; changing tools never reflows the question. */
#item, #sidebar { overflow-anchor: none; }
#sidebar { scrollbar-gutter: stable; }
.panel .title { user-select: none; }
.panel-actions { flex-wrap: wrap; }
@media (max-width: 540px) {
  #hdr .htools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; overflow: visible; gap: 2px; }
  #hdr .htools .hbtn, #hdr .zoomgroup { width: 100%; min-width: 0; margin: 0; }
  #hdr .mark { width: 60px; margin-left: 0; padding: 3px; }
  #hdr .hnav .hbtn { min-width: 48px; width: 48px; padding: 0 3px; margin-left: 3px; font-size: 11px; }
  .panel-notes { right: 12px; }
}
