/* RoboCheck page, on top of lab.css, foras-labs/sim.css and type.css (RailCheck's skeleton).
   Colours are the graphic identity's fixed meanings (_graphic_identity/colors.md): violet = proved,
   pink = rejected / broken, amber = attention (not formalised, no rules), grey = unknown. */
body.rk { --rk-holds: #8d40a7; --rk-breaks: #e40f6f; --rk-breaks-fill: #f4539c; --rk-attn: #937108; --rk-unknown: #6a6f78; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body.rk { --rk-holds: #8969cf; --rk-breaks: #f4539c; --rk-attn: #f3be18; --rk-unknown: #9a9fa9; }
}
html[data-theme="dark"] body.rk { --rk-holds: #8969cf; --rk-breaks: #f4539c; --rk-attn: #f3be18; --rk-unknown: #9a9fa9; }

.rk .holds { --rk-c: var(--rk-holds); }
.rk .breaks { --rk-c: var(--rk-breaks); }
.rk .attn { --rk-c: var(--rk-attn); }
.rk .unknown { --rk-c: var(--rk-unknown); }

/* labels, ids and chips are mono */
.rk-id { display: inline-block; font: 500 12px/1 var(--mono); color: var(--ink); background: var(--rule-pill); padding: 4px 8px; border-radius: 6px; }
.rk-chip { display: inline-block; font: 500 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 4px 7px;
  border-radius: 6px; color: var(--rk-c); border: 1px solid color-mix(in srgb, var(--rk-c) 55%, transparent); white-space: nowrap; }
.rk-k { display: block; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 3px; }

/* 1. The Rules */
.rk-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rk-card { background: var(--rule-card); border: 1px solid var(--rule-edge); border-left: 3px solid var(--rk-c); border-radius: 12px; padding: 12px 14px; }
.rk-card-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: start; }
.rk-text { font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.rk-x { font: 18px/1 var(--mono); width: 28px; height: 28px; border: 1px solid var(--rule-edge); border-radius: 8px; background: none;
  color: var(--muted); cursor: pointer; }
.rk-x:hover { color: var(--ink); border-color: var(--ink); }
.rk-x:focus-visible, .rk-add textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rk-understood, .rk-why-ai, .rk-fail { margin: 10px 0 0; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.rk-fail { color: var(--rk-breaks); }
.rk-clauses { margin-top: 8px; }
.rk-clauses summary { font: 12px var(--mono); color: var(--muted); cursor: pointer; }
.rk-clauses pre { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rk-deleted h3 { font: 12px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 16px 0 8px; }
.rk-deleted ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rk-deleted li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; }
.rk-add { margin-top: 16px; display: grid; gap: 8px; }
.rk-add label { font-weight: 600; font-size: 14px; }
.rk-add textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--rule-edge); border-radius: 10px; background: var(--rule-card);
  color: var(--ink); resize: vertical; }
.rk-add textarea:disabled, .rk-add button:disabled { opacity: .55; cursor: not-allowed; }
.rk-add button { justify-self: start; }
.rk-add .fl-note { margin: 0; }

/* 2. The Spec and the Code */
.rk-spec, .rk-code { white-space: pre; overflow: auto; }
.rk-spec { margin-bottom: 12px; min-height: 0; }
.rk-clauses pre, #rk-candidate { min-height: 0; }
.rk-code { max-height: 520px; }
.rk-line.marked { background: color-mix(in srgb, var(--rk-breaks-fill) 30%, transparent); box-shadow: inset 3px 0 0 var(--rk-breaks-fill); }

/* Widen: The Spec and the Code takes The Rules' room (⇤), The Verdict's (⇥), or both. A panel that gives up its
   room folds to a 60 px column with its name written down it; clicking the column brings it back. Wide screens
   only: stacked panels are already full width. */
.rk-widen { flex: none; width: 26px; height: 26px; padding: 0; border: 1px solid var(--rule-edge); border-radius: 8px;
  background: none; color: var(--muted); font: 15px/1 var(--mono); cursor: pointer; }
.rk-widen:hover { color: var(--ink); border-color: var(--ink); }
.rk-widen[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.rk-widen:focus-visible, .rk-rail:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.rk-rail { display: none; }
@media (max-width: 980px) { .rk-widen { display: none; } }
@media (min-width: 981px) {
  .rk .fl-verif .fl-panels.rk-wide-r { grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr) 60px; }
  .rk .fl-verif .fl-panels.rk-wide-l { grid-template-columns: 60px minmax(0, 2.1fr) minmax(0, 1fr); }
  .rk .fl-verif .fl-panels.rk-wide-l.rk-wide-r { grid-template-columns: 60px minmax(0, 1fr) 60px; }
  .rk-wide-l > [aria-labelledby="h-rules"], .rk-wide-r > [aria-labelledby="h-verdict"] { padding: 0; overflow: hidden; }
  .rk-wide-l > [aria-labelledby="h-rules"] > :not(.rk-rail),
  .rk-wide-r > [aria-labelledby="h-verdict"] > :not(.rk-rail) { display: none; }
  .rk-rail:not([hidden]) { display: flex; align-items: center; gap: 12px; width: 100%; height: 100%; padding: 16px 0;
    border: 0; background: none; color: var(--ink); cursor: pointer; writing-mode: vertical-rl; font: 600 17px var(--sans); }
  .rk-rail:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
  .rk-rail .fl-step { writing-mode: horizontal-tb; }
  .rk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rk-c, var(--rk-unknown)); }
}

/* 3. The Verdict */
.rk-head { border-color: color-mix(in srgb, var(--rk-c) 60%, transparent); }
.rk-head h3 { color: var(--rk-c); }
.rk-lines { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.rk-lines li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rk-lines .rk-gone { color: var(--muted); }
.rk-why p { margin: 0 0 12px; font-size: 14px; line-height: 1.5; }

/* Battle */
.rk-banner { margin: 0; padding: 10px 18px; font-size: 14px; color: #000; background: var(--rk-breaks-fill); }
.rk-arena { padding: 14px 18px; }
.rk-view[hidden] { display: none; }
.rk-empty { margin: 0; padding: 48px 0; text-align: center; font: 13px var(--mono); opacity: .8; }
.rcv-2d { display: block; width: auto; height: auto; max-width: 100%; max-height: min(68vh, 600px); margin: 0 auto; border-radius: 8px; }
.rcv-2d[hidden], .rcv-3d[hidden] { display: none; }
.rcv-3d > div { aspect-ratio: 4 / 3; width: 100%; max-width: calc(min(68vh, 600px) * 4 / 3); margin: 0 auto; overflow: hidden; border-radius: 8px; background: #0f1e2e; }
.rcv-note, .rcv-mark { margin: 10px auto 0; max-width: 800px; font: 12px var(--mono); }
.rcv-mark { color: #000; background: var(--rk-breaks-fill); padding: 6px 10px; border-radius: 6px; }
.rcv-note[hidden], .rcv-mark[hidden] { display: none; }

/* The Cheats */
.rk-cheats { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.rk-cheats > li > b { font: 500 13px var(--mono); }
.rk-cheats p { margin: 4px 0 6px; font-size: 14px; }
.rk-cheats ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--rk-breaks); }
.rk-cheats code { overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .rk-card-top { grid-template-columns: auto minmax(0, 1fr) auto; }
  .rk-card-top .rk-chip { grid-column: 2; grid-row: 2; justify-self: start; }
  .rk-arena { padding: 10px; }
}

/* More battles: custom battles published from HQ's Lab Config, beside the stored runs. */
.rk-pick { font: 12px var(--mono, ui-monospace, monospace); padding: 4px 8px; border-radius: 8px; border: 1px solid var(--enamel-edge); background: transparent; color: inherit; max-width: 220px; }
.rk-pick[hidden], .fl-sim-sep[hidden] { display: none; }

/* 3D: the arena is 1150 px wide, so the battle box (arena plus its padding and border) leaves the page column. */
.rk-wide3d { width: min(1188px, calc(100vw - 32px)); position: relative; left: 50%; transform: translateX(-50%); }
.rk-wide3d .rcv-3d > div { max-width: 1150px; aspect-ratio: 16 / 9; }

/* Open arena / Urban while a battle with its own arena is showing. */
.rk [data-arena]:disabled { opacity: .4; cursor: not-allowed; }

/* Fullscreen: the whole battle board (toolbar, arena, controls) fills the screen; the arena takes what is left. */
#fold-battle:fullscreen { display: flex; flex-direction: column; width: 100%; max-width: none; height: 100%; margin: 0; border-radius: 0; border: 0; overflow: auto;
  position: static; left: auto; transform: none; }
#fold-battle:fullscreen .rk-arena { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 16px; }
#fold-battle:fullscreen .rk-view { width: 100%; display: flex; align-items: center; justify-content: center; }
#fold-battle:fullscreen .rcv-2d { width: 100%; height: calc(100vh - 130px); max-width: none; max-height: none; object-fit: contain; }
#fold-battle:fullscreen .rcv-3d { width: 100%; }
#fold-battle:fullscreen .rcv-3d > div { max-width: none; width: 100%; height: calc(100vh - 130px); aspect-ratio: auto; border-radius: 0; }
#fold-battle:fullscreen .rk-banner { margin: 0; }
