/* Colours: no red against green anywhere (the project lead has deuteranopia). Acceptable = blue, attention = orange,
   the offending stretch = amber and thicker, the dome and the chosen point = yellow. */
:root {
  --bg: #f4f3ef; --panel: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #d8d6cf;
  --blue: #1f6fe5; --orange: #f08a00; --amber: #ab5700; --yellow: #f2c200;
  --button: #ecebe6; --button-ink: #1d1d1f;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181a; --panel: #222225; --ink: #ececef; --muted: #a0a0a8; --line: #3a3a40; --button: #303036;
          --button-ink: #ececef; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }
button { font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--button);
  color: var(--button-ink); cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
button.tool.armed { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 0 0 2px #1f6fe555; }
input, textarea, select { font: inherit; width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); }
.login { display: grid; place-items: center; height: 100%; padding: 16px; }
.card { background: var(--panel); padding: 24px; border-radius: 10px; width: min(360px, 100%); display: grid; gap: 10px;
  border: 1px solid var(--line); }
.card h1 { margin: 0; font-size: 20px; }
.workspace { display: grid; grid-template-columns: 250px 1fr 300px; height: 100%; }
.sidebar, .panel { background: var(--panel); padding: 12px; overflow: auto; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.panel { border-right: 0; border-left: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; }
.case-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.case-list li button { width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 6px; }
.case-list li button.current { outline: 2px solid var(--blue); }
.case-list .state { font-size: 11px; color: var(--muted); }
.viewer { position: relative; display: flex; flex-direction: column; min-width: 0; }
.viewport { flex: 1; min-height: 0; position: relative; cursor: grab; }
.viewport.armed { cursor: crosshair; }
.viewport canvas.pivot-mode { cursor: cell; }  /* Option held: a click sets the rotation point */
.viewport canvas { display: block; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--panel); border-top: 1px solid var(--line); }
.toolbar .sep { width: 1px; background: var(--line); margin: 0 4px; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #0006; color: #fff; font-size: 16px; }
.message { padding: 8px; border-radius: 6px; border-left: 4px solid var(--line); background: var(--bg); }
.message:empty { display: none; }
.message.acceptable { border-left-color: var(--blue); }
.message.attention { border-left-color: var(--orange); }
.refusals { margin: 0; padding-left: 18px; }
.refusals li.offending { color: var(--amber); font-weight: 600; }
.box { display: grid; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.measurements { border-collapse: collapse; width: 100%; font-size: 12px; }
.measurements td { padding: 2px 4px; border-bottom: 1px solid var(--line); }
.measurements td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.confidence { display: flex; gap: 6px; }
.confidence button { flex: 1; }
.confidence button.chosen { background: var(--blue); color: #fff; border-color: var(--blue); }
.swatch { display: inline-block; width: 18px; height: 6px; border-radius: 3px; vertical-align: middle; }
.swatch.blue { background: var(--blue); } .swatch.orange { background: var(--orange); }
.swatch.amber { background: var(--amber); height: 9px; }
.help ol { padding-left: 18px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; }
  .sidebar, .panel { border: 0; }
}

/* Structure labelling: neutral regions, yellow, blue on hover; never red against green. */
.region-numbers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.region-number { position: absolute; transform: translate(-50%, -50%); background: var(--yellow); color: #1d1d1f;
  font-weight: 700; font-size: 12px; border-radius: 10px; padding: 1px 7px; border: 1px solid #1d1d1f; }
.region-number.hover { background: var(--blue); color: #fff; }
.structure-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.structure-list li { border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.structure-list li.hover { border-color: var(--blue); box-shadow: 0 0 0 2px #1f6fe555; }
.structure-list .choices { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.structure-list .choices button { font-size: 12px; padding: 3px 6px; }
.structure-list .choices button.chosen { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Timed reading: the model stays hidden behind Start reading / Resume reading; nothing can be done meanwhile. */
.start-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #2b2d31; z-index: 5;
  padding: 16px; }
.start-card { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; width: min(420px, 100%); display: grid; gap: 10px; }
.start-card p { margin: 0; }
body.model-hidden .panel { pointer-events: none; opacity: 0.5; }
.notice { border-left: 4px solid var(--blue); padding: 4px 8px; background: var(--bg); }
.toolbar .spacer { flex: 1; }
.toolbar .hint { flex-basis: 100%; color: var(--muted); }
.cut-controls { display: inline-flex; gap: 10px; align-items: center; font-size: 12px; }
.cut-controls label { display: inline-flex; gap: 4px; align-items: center; }
.cut-controls input[type=range] { width: 110px; padding: 0; }
.cut-controls .value { min-width: 52px; font-variant-numeric: tabular-nums; }
.case-clock { align-self: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
/* The viewer may shrink when the toolbar wraps (the canvas follows through the ResizeObserver). */
.viewer { min-height: 0; overflow: hidden; }
.viewport { overflow: hidden; }
a { color: var(--blue); }

/* startup_check.js: a plain message when the page cannot start (no WebGL, or an error) */
.startup-problem { max-width: 44rem; margin: 3rem auto; padding: 1.2rem 1.5rem; border: 2px solid #f08a00; border-radius: 8px; background: #fff8ec; color: #1d1d1f; font-size: 1rem; line-height: 1.45; }
.startup-problem h2 { margin: 0 0 0.6rem; font-size: 1.15rem; }

#wall-marks { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.mark-key { display: grid; gap: 4px; font-size: 12px; }
.mark-key > div { display: flex; align-items: center; gap: 6px; }
.mark-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.mark-badge { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid #191919;
  border-radius: 50%; color: #111; background: #ffcc51; font: bold 12px/1 sans-serif; }
.mark-badge.branch_origin { background: #92caff; }
.mark-badge.sac_parent_transition { background: #ffa168; border-radius: 4px; }
.mark-badge.uncertain_boundary { border-radius: 50% 50% 4px 4px; }
#wall-marks .mark-badge { position: absolute; transform: translate(-50%, -100%); box-shadow: 0 0 0 1px white; }
#wall-marks .mark-badge::after { content: ''; position: absolute; bottom: -3px; width: 4px; height: 4px;
  background: white; border: 1px solid #111; border-radius: 50%; }
#mark-feedback { position: absolute; bottom: 12px; left: 12px; z-index: 2; pointer-events: none;
  color: white; background: #20232aeb; border-radius: 5px; padding: 6px 10px; font-size: 13px; }
body.model-hidden #mark-feedback, body.model-hidden #wall-marks { visibility: hidden; }

.takeoff-banner { margin: 0; padding: 8px 12px; background: var(--panel); border-bottom: 2px solid var(--blue); }
#no-aneurysm[aria-pressed="true"] { border-color: var(--blue); outline: 1px solid var(--blue); }

body.adjudicating :is(.toolbar .sep, #tool-state, #ring-status, #three-anchor-hint, #refusals, #tool-dome,
  #tool-neck, #remove-last, #remove-selected, #reorder, #clear, #redo, #undo, #side-on, #accept-box,
  #after-accept, #labelling-box, #decision-marks, .sidebar .help) { display:none; }
#adjudication-views:not([hidden]) { display:flex; flex-wrap:wrap; align-items:center; gap:0.35rem; }
#adjudication-panel label { display:grid; gap:0.3rem; margin-block:0.8rem; }
#adjudication-panel select { width:100%; min-width:0; }
body.adjudicating :is(#takeoff-banner, #acquisition-box) { display:none; }
