:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d2330; --muted: #5d6677; --line: #d9dde4;
  --accent: #1f5fa8; --accent-text: #ffffff; --done: #2e7d4f; --error: #b3261e; --error-bg: #fdecea;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--accent); }

.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--card);
       border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 600; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.step { font-size: 13px; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); }
.step.done { color: var(--done); border-color: var(--done); }
.step.now { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tools { font-size: 13px; color: var(--muted); }
.tools a.active { font-weight: 700; text-decoration: none; color: var(--text); }
a.step { text-decoration: none; }
.badge { background: #8a4b00; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.adminbar { font-size: 12px; background: #fff4e5; border: 1px dashed #8a4b00; border-radius: 6px; padding: 4px 8px; margin: 0 0 8px; }
.adminbar a.cur { font-weight: 700; color: var(--text); }

main { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.foot { font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; }
.card.narrow { max-width: 460px; margin: 40px auto; width: 100%; }
h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 6px; }
.lead { color: var(--muted); margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); }
.error { background: var(--error-bg); color: var(--error); padding: 8px 10px; border-radius: 6px; }

.field { display: block; margin-bottom: 12px; }
.field input { display: block; width: 100%; padding: 8px; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 9px 18px;
         font: inherit; font-weight: 600; cursor: pointer; margin-top: 8px; }
button:hover { filter: brightness(1.1); }
.autosave-status { margin-left: 12px; font-size: 12px; color: var(--muted); }
.autosave-status.failed { color: var(--error); font-weight: 700; }

fieldset.q { border: 0; border-top: 1px solid var(--line); padding: 10px 0 6px; margin: 0; }
fieldset.q legend { font-weight: 600; padding: 0; float: left; width: 100%; margin-bottom: 4px; }
fieldset.q .opts { clear: both; display: flex; flex-direction: column; gap: 3px; }
fieldset.q.row .opts { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }
fieldset.q.missing legend { color: var(--error); }
.req { color: var(--error); }
.qinfo { font-weight: 600; margin: 14px 0 2px; color: var(--accent); }
.qinfo.long p { margin: 0 0 8px; }
.qinfo.long p:first-child { color: var(--accent); }
.qinfo.long p:not(:first-child) { font-weight: 400; color: inherit; }
fieldset.q.scaled .opts { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.scale-end { font-size: 13px; color: var(--muted); font-style: italic; }
label.na { margin-left: 14px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); }
fieldset.q[hidden] { display: none; }
textarea { width: 100%; clear: both; border: 1px solid var(--line); border-radius: 6px; padding: 6px; font: inherit; }

/* Steps with a viewer or BICTool: step title and description across the top (stephead), short task line in the box */
/* Same inset, frame and corners as the blocks below it (main has 16px padding) */
.stephead { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin: 16px 16px 0; padding: 10px 20px 2px; }
.stephead .newtab-tip { font-size: 13px; color: var(--muted); }
.stephead h1 { font-size: 18px; margin: 0 0 4px; }
.stephead p { margin: 0 0 8px; }
.task { background: #e8f0fa; color: var(--accent); font-weight: 600; padding: 8px 10px; border-radius: 6px; margin: 0 0 10px; }

/* Labelling: viewer left, form right; together they fill the window below the header and the stephead */
body.split { height: 100vh; }
body.split main { flex-direction: row; align-items: stretch; flex: 1 1 auto; min-height: 0; }
.viewer { flex: 1 1 65%; min-width: 0; }
.viewer-frame, .tool-frame { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: 8px; background: #000; }
.side { flex: 0 0 380px; overflow-y: auto; }
.caseno { font-size: 13px; color: var(--muted); margin: 0 0 6px; }

/* Steps with the BICTool window on top */
.frame-wrap { position: relative; height: 72vh; min-height: 480px; }
.newtab { position: absolute; top: -2px; right: 4px; font-size: 12px; background: var(--card); padding: 2px 8px;
          border: 1px solid var(--line); border-radius: 0 8px 0 8px; }
.casebox { border-top: 2px solid var(--line); padding-top: 10px; margin-top: 14px; }
.casestate { padding: 8px 10px; border-radius: 6px; font-weight: 600; margin: 8px 0 12px; }
.casestate.ok { background: #e7f4ec; color: var(--done); }
.casestate.warn { background: var(--error-bg); color: var(--error); }
ul.goals { list-style: none; padding: 0; margin: 0 0 12px; }
li.goal { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
li.goal .mark { width: 1.2em; color: var(--muted); font-weight: 700; }
li.goal.ok .mark { color: var(--done); }
li.goal .text { flex: 1 1 320px; }
li.goal.ok .manual { display: none; }
li.goal .manual { font-size: 12px; color: var(--muted); }
.casebox.missing h2 { color: var(--error); }

@media (max-width: 900px) {
  body.split main { flex-direction: column; height: auto; }
  .viewer { height: 70vh; }
  .side { flex: none; }
}

/* Abbreviations (glossary.js): dotted underline, explanation on hover or tap */
abbr.gl { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; cursor: help; }
abbr.gl:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }
.gl-tip { position: absolute; z-index: 1000; max-width: 320px; padding: 6px 10px; border-radius: 6px;
          background: var(--text); color: #ffffff; font-size: 13px; line-height: 1.35; font-weight: 400;
          box-shadow: 0 2px 8px rgba(0, 0, 0, .25); pointer-events: none; }

/* Admin progress page */
table.progress { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
table.progress th, table.progress td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.progress th { color: var(--muted); font-weight: 600; }
table.progress tr.finished td { color: var(--done); }
table.progress tr.test td { color: var(--muted); }
table.progress .tag { font-size: 11px; border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; }
