/* CAF Drill Routine Simulator — Copyright (C) 2026 Matthew Dodd */
/* SPDX-License-Identifier: LicenseRef-Proprietary  (see LICENSE for full terms) */

:root {
  /* element identity colours — held STABLE across themes */
  --army: #5b6e4f;
  --navy: #1f3a5f;
  --air: #2f6f8f;
  --cmd: #d8b24a;
  /* dark theme (default) */
  --bg: #0f1216;
  --panel: #171b21;
  --panel2: #1e242c;
  --line: #2a323c;
  --ink: #e6edf3;
  --dim: #93a1b0;
  --accent: #4cc2ff;
  --on-accent: #06121b;
  --ok: #6fbf73;
  --warn: #d8b24a;
  --danger: #e06c6c;
  /* stage */
  --stage: #0b0e12;
  --grid: #161b22;
  --anim: 380ms;
}

/* light theme — warm beiges / browns / light greens / yellows */
:root[data-theme="light"] {
  --bg: #f3ead6;
  --panel: #e9dcc0;
  --panel2: #ddcaa4;
  --line: #c7b186;
  --ink: #3a2e1b;
  --dim: #7a6a4c;
  --accent: #6b8e23;
  --on-accent: #fbf6e7;
  --ok: #4a7c3f;
  --warn: #9a6f15;
  --danger: #a3301f;
  --stage: #efe5cd;
  --grid: #d8c5a0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.4 "Segoe UI",
    system-ui,
    sans-serif;
  display: flex;
  height: 100vh;
}

/* sidebar */
#side {
  width: 320px;
  min-width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

#side h1 {
  font-size: 15px;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

#side h1 .tag {
  font-size: 11px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 700;
  margin-left: 6px;
}

.sec {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.sec h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--dim);
  margin: 0 0 8px;
}

label.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
  font-size: 13px;
}

input,
select,
button {
  font: inherit;
}

/* Visible keyboard focus for all interactive controls (a11y). Uses
       :focus-visible so a mouse click doesn't paint a ring, only keyboard nav. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

input[type="number"],
input[type="text"],
select {
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 28px;
  padding: 0 6px;
}

input[type="number"] {
  width: 64px;
}

input[type="text"] {
  min-width: 0;
}

button {
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  height: 30px;
  padding: 0 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 700;
}

#moves {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.v2-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 4px;
}

/* validation: highlight the move that caused a finding (left accent bar) */
.v2-row.has-warn,
.v2-row.has-error {
  padding-left: 6px;
}

.v2-row.has-warn {
  box-shadow: inset 3px 0 0 var(--warn);
}

.v2-row.has-error {
  box-shadow: inset 3px 0 0 var(--danger);
}

.v2-row .v2-type {
  flex: 1.2;
  min-width: 0;
}

.v2-row .v2-target {
  flex: 1;
  min-width: 0;
}

.v2-row .v2-pace,
.v2-row .v2-start {
  width: 44px;
}

/* the timeline highlights the move row that authored a clicked block */
.v2-row.cmd-selected {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* drag handle to reorder routine steps (compile() reads #moves top-to-bottom,
       so moving a row IS reordering the routine — applied on next Build & Run) */
.v2-row .v2-grip {
  flex: none;
  width: 20px;
  padding: 0;
  color: var(--dim);
  cursor: grab;
  line-height: 1;
}

.v2-row .v2-grip:hover {
  color: var(--ink);
}

.v2-row.dragging {
  opacity: 0.55;
  outline: 1px dashed var(--accent);
  cursor: grabbing;
}

/* units editor (multi-entity builder) */
#units {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unit {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: var(--panel2);
}

.unit .uhead {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.unit .uhead .uid {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.unit .uhead .ukind {
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
}

.unit .uhead .del {
  margin-left: auto;
  width: 26px;
  height: 24px;
  padding: 0;
  color: var(--dim);
}

.unit .staff-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 12px;
}

.unit .staff-roles label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.v2-row .del {
  width: 28px;
  padding: 0;
  color: var(--dim);
}

/* per-move "capture floor selection" button + count badge (shown only when
       the row targets the selection). */
.v2-row .v2-capture {
  width: 40px;
  padding: 0;
  font-size: 12px;
}

.v2-row .v2-capture .v2-count {
  color: var(--accent);
  font-weight: 700;
}

/* stage */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#transport {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
  flex-wrap: wrap;
}

#transport .grp {
  display: flex;
  align-items: center;
  gap: 6px;
}

#scrub {
  flex: 1;
  min-width: 160px;
}

.readout {
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  font-size: 13px;
}

.readout b {
  color: var(--ink);
}

#stage {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--stage);
}

/* #v2-canvas is the scroll-sizer: its box = floor × zoom, so the stage's
       scrollbars stay honest when the floor is transform:scale()d. #v2-floor
       holds the logical (unscaled) pace grid and is scaled for display only. */
#v2-canvas {
  position: relative;
  width: 2500px;
  height: 2500px;
}

#v2-floor {
  position: absolute;
  left: 0;
  top: 0;
  width: 2500px;
  height: 2500px;
  transform-origin: 0 0;
  will-change: transform;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}

.v2-member {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  transition:
    left var(--anim),
    top var(--anim);
  z-index: 2;
  cursor: pointer;
}

/* click-selection ring (B2-UI Slice 2) — cyan accent halo on members the
       user has selected on the floor (the v2 port of v1's .is-selected). Applied
       to the member box itself so it works whether the token is a Phase C fig
       1-1-1 symbol (.v2-token) or the legacy disc (.v2-circle). */
.v2-member.is-selected::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  z-index: -1;
  pointer-events: none;
}

.v2-member.is-selected.v2-appt::before {
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 0 5px var(--cmd);
}

.v2-cmdr {
  z-index: 3;
}

.v2-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.v2-circle.army {
  background: var(--army);
}

.v2-circle.navy {
  background: var(--navy);
}

.v2-circle.air {
  background: var(--air);
}

.v2-cmdr .v2-circle {
  background: var(--cmd);
  color: #1a1407;
  border-color: #fff;
}

/* company appointments (OC/2IC/CSM/CQMS): always-labelled, set apart with a
       gold ring so they read as parade staff, not rank-and-file. Interim until
       the CF-201 fig 1-1-1 symbol SVGs land. */
.v2-appt .v2-circle {
  border-color: var(--cmd);
  box-shadow:
    0 0 0 2px var(--cmd),
    0 1px 3px rgba(0, 0, 0, 0.5);
}

.v2-circle-sm {
  font-size: 8px;
  letter-spacing: -0.3px;
}

/* CF-201 fig 1-1-1 symbol token (Phase C) — the symbol IS the member glyph,
       coloured via currentColor (gold for appointments/commander, element colour
       for the rank and file). */
.v2-token {
  position: absolute;
  inset: 0;
}

.v2-token svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

.v2-token.appt {
  color: var(--cmd);
}
.v2-token.army {
  color: var(--army);
}
.v2-token.navy {
  color: var(--navy);
}
.v2-token.air {
  color: var(--air);
}

/* off-number overlaid inside a service member's square */
.v2-tag.num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 1px 2px var(--stage);
  pointer-events: none;
}

/* appointment label beneath a named symbol (OC / 2IC / CSM / CQMS) */
.v2-tag.lab {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 1px;
  font-size: 9px;
  font-weight: 700;
  color: var(--cmd);
  white-space: nowrap;
  text-shadow: 0 1px 2px var(--stage);
  pointer-events: none;
}

/* accoutrement icon badge, pinned to the member's lower-right (item 8) */
.v2-acc {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 16px;
  height: 16px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px;
  pointer-events: none;
}

.v2-acc svg {
  width: 100%;
  height: 100%;
  display: block;
}

.v2-pip {
  position: absolute;
  inset: 0;
  transform: rotate(var(--facing, 0deg));
  transition: transform var(--anim);
  pointer-events: none;
}

.v2-pip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--accent);
}

/* head/eyes indicator for dressing (item 10 slice 10C) — a gold dot that
       swings off the facing toward the flank the eyes are turned to. Hidden
       until the frame carries head = RIGHT/LEFT (render adds .head-turned). */
.v2-head {
  position: absolute;
  inset: 0;
  transform: rotate(var(--head, 0deg));
  transition:
    transform var(--anim),
    opacity var(--anim);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

.v2-member.head-turned .v2-head {
  opacity: 1;
}

.v2-head::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--cmd);
  box-shadow: 0 0 0 1.5px var(--stage);
}

/* arm indicator for dressing (item 10 slice 10C) — a bar anchored at the
       member's centre (shoulder) that PROJECTS OUTSIDE the token so it reads
       clearly. --arm rotates it toward the flank when raised for interval (0° =
       the member's right; 180° = left). On Eyes Front the arm is CUT IN: it
       retracts to the body along the same line it went out (--arm-scale → 0),
       then clears. Hidden until the frame carries arm = RIGHT/LEFT/DOWN_R/DOWN_L. */
.v2-arm {
  position: absolute;
  inset: 0;
  transform: rotate(var(--arm, 0deg)) scaleX(var(--arm-scale, 1));
  transform-origin: 50% 50%; /* the shoulder — the arm retracts toward here */
  transition:
    transform var(--anim),
    opacity var(--anim);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.v2-member.arm-out .v2-arm {
  opacity: 1;
}

.v2-member.arm-down .v2-arm {
  opacity: 1;
  --arm-scale: 0; /* cut the arm in to the side (retract to the body) */
}

/* the arm itself: a bar from the centre reaching ~an arm's length toward the
       flank (past the 30px token edge, ~halfway to the next file), tipped with a
       fist so the extended arm is unmistakable. */
.v2-arm::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--cmd);
  box-shadow: 0 0 0 1px var(--stage);
}

.v2-arm::after {
  content: "";
  position: absolute;
  left: calc(50% + 20px);
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--cmd);
  box-shadow: 0 0 0 1px var(--stage);
}

/* elbow / close-interval dressing: the hand is on the HIP (elbow forced
       forward), NOT the arm at full length — a short stub with the hand (fist)
       drawn in close to the body instead of reaching toward the next file. */
.v2-member.arm-hip .v2-arm::before {
  width: 9px;
}
.v2-member.arm-hip .v2-arm::after {
  left: calc(50% + 7px);
}

/* salute indicator (10D) — a bent forearm/hand at the brow, shown while the
       frame carries salute = UP. The wrapper rotates with --facing so the hand
       stays at the FRONT of the head whatever way the member faces. */
.v2-salute {
  position: absolute;
  inset: 0;
  transform: rotate(var(--facing, 0deg));
  transition:
    transform var(--anim),
    opacity var(--anim);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

.v2-member.saluting .v2-salute {
  opacity: 1;
}

/* the saluting forearm: a short bar rising from the brow (top of the token)
       and canted inward, tipped with the hand. */
.v2-salute::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -9px;
  width: 4px;
  height: 12px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--cmd);
  box-shadow: 0 0 0 1px var(--stage);
  transform: rotate(32deg);
  transform-origin: bottom center;
}

.v2-salute::after {
  content: "";
  position: absolute;
  left: calc(50% + 5px);
  top: -10px;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--cmd);
  box-shadow: 0 0 0 1px var(--stage);
}

/* headdress indicator (Ch.2 remove/replace) — a small cap mark in the
       ELEMENT colour (army/navy/air, passed via --hd-color). Distinct from the
       gold head/arm/salute indicators so a bare head reads by element identity.
       Worn (unset) = hidden; grasped/placed = sits on the head (top of the
       token); removed = slides down to the chest (centre). */
.v2-headdress {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 13px;
  height: 6px;
  margin-left: -6.5px;
  border-radius: 6px 6px 2px 2px;
  background: var(--hd-color, var(--army));
  box-shadow: 0 0 0 1px var(--stage);
  opacity: 0;
  transform: translateY(0);
  transition:
    transform var(--anim),
    opacity var(--anim);
  pointer-events: none;
  z-index: 5;
}

.v2-member.hd-shown .v2-headdress {
  opacity: 1;
}
.v2-member.hd-off .v2-headdress {
  transform: translateY(20px);
} /* down to the chest */

/* ---- timeline panel (Slice 3) ---- */
#timeline-panel {
  flex: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--panel);
  /* user-resizable via #tl-resize; JS clamps to [header, 40vh]. */
  height: 30vh;
  max-height: 40vh;
  min-height: 32px;
}

/* drag handle along the panel's top edge */
#tl-resize {
  height: 6px;
  flex: none;
  cursor: ns-resize;
  background: var(--line);
  border-bottom: 1px solid var(--panel2);
}

#tl-resize:hover,
#tl-resize.dragging {
  background: var(--accent);
}

#timeline-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
}

#timeline-head .tl-title {
  font-weight: 700;
  font-size: 13px;
}

.badge {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
  margin-left: auto;
}

.badge.err {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
  border: 1px solid var(--danger);
  cursor: pointer;
}

.badge.ok {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
  border: 1px solid var(--ok);
}

#timeline-root {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  --label-w: 220px;
}

.tl-grid {
  position: relative;
  min-width: max-content;
}

.tl-ruler {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 28px;
  margin-left: var(--label-w);
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}

.tl-tick {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid var(--line);
}

.tl-tick.major {
  border-left-color: var(--dim);
}

.tl-tlabel {
  position: absolute;
  top: 6px;
  font-size: 10px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.tl-scrub {
  position: absolute;
  top: 0;
  left: var(--label-w);
  right: 0;
  height: 28px;
  cursor: ew-resize;
  z-index: 8;
}

.tl-track {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tl-track:hover .tl-label {
  background: var(--panel2);
}

.tl-label {
  width: var(--label-w);
  min-width: var(--label-w);
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.tl-label.group {
  font-weight: 700;
  background: var(--panel2);
}

.tl-twirl {
  width: 12px;
  color: var(--dim);
}

.tl-who {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.tl-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  color: #06121b;
  flex: none;
  background: var(--accent);
}
.tl-dot.appt {
  background: var(--cmd);
}

.tl-name {
  color: var(--dim);
}

.tl-meta {
  color: var(--dim);
  font-size: 10px;
  margin-left: auto;
}

.tl-lane {
  position: relative;
  flex: 1;
}

.tl-gl {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid var(--line);
  opacity: 0.5;
}

.tl-blk {
  position: absolute;
  height: 22px;
  top: 3px;
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  line-height: 22px;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.tl-blk.march {
  background: var(--air);
}
.tl-blk.half {
  background: #1f8fa8;
}
.tl-blk.turn {
  background: #1f9e8f;
}
.tl-blk.wheel {
  background: #8957e5;
}
.tl-blk.form {
  background: #b3742b;
}
.tl-blk.halt {
  background: var(--dim);
}
.tl-blk.rest {
  background: #6b7280;
}

.tl-blk.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.tl-blk.sel {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.tl-blk.conflict {
  background: repeating-linear-gradient(
    45deg,
    var(--danger),
    var(--danger) 6px,
    #7a201a 6px,
    #7a201a 12px
  );
  border-color: var(--danger);
}

.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  z-index: 7;
  pointer-events: none;
}

.tl-playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--accent);
}

.vstatus {
  margin-top: 8px;
  font-size: 12px;
  cursor: default;
}

.vstatus[data-level="ok"] {
  color: var(--ok);
}
.vstatus[data-level="warn"] {
  color: var(--warn);
}
.vstatus[data-level="error"] {
  color: var(--danger);
  font-weight: 700;
}

/* small muted helper text (e.g. the flag-party layout note) */
.hint {
  font-size: 12px;
  color: var(--dim);
}

/* sidebar footer — About / License entry points, pinned to the bottom */
#side-foot {
  margin-top: auto;
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
#side-foot button {
  flex: 1;
}

/* About / License modal dialogs (native <dialog>) */
.v2-dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 0;
  max-width: 540px;
  width: calc(100% - 40px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.v2-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.v2-dialog .dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.v2-dialog .dlg-head h2 {
  margin: 0;
  font-size: 16px;
}
.v2-dialog .dlg-body {
  padding: 16px 18px;
  max-height: 62vh;
  overflow: auto;
}
.v2-dialog .dlg-body h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  margin: 16px 0 4px;
}
.v2-dialog .dlg-lead {
  margin-top: 0;
  color: var(--dim);
}
.v2-dialog p {
  margin: 6px 0;
}
.v2-dialog a {
  color: var(--accent);
}
.v2-dialog .dlg-muted {
  color: var(--dim);
  font-size: 12px;
}
.v2-dialog .dlg-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}
.dlg-x {
  background: transparent;
  border: none;
  color: var(--dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.dlg-x:hover {
  color: var(--ink);
}
.dlg-kofi {
  margin-top: 18px;
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
.dlg-kofi p {
  margin: 0 0 10px;
}
.kofi-btn {
  display: inline-block;
  background: #ff5e5b;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 8px;
}
.kofi-btn:hover {
  background: #ff726f;
}

/* :not([hidden]) so the ID selector doesn't override the [hidden] attribute
       (an ID beats the UA `[hidden]{display:none}` rule — without this guard the
       overlay renders unconditionally, on top of a perfectly working app). */
#boot-error:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 10, 13, 0.92);
  display: grid;
  place-items: center;
  padding: 24px;
}

#boot-error[hidden] {
  display: none;
}

#boot-error .be-card {
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

#boot-error h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

#boot-error code {
  background: var(--panel2);
  padding: 1px 5px;
  border-radius: 4px;
}

#boot-error pre {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  overflow: auto;
  color: var(--accent);
}

/* Utility classes — replace inline style="" attributes so the CSP can drop
   style-src 'unsafe-inline' (Wave 4b pt2). */
.mt-6 {
  margin-top: 6px;
}
.mt-8 {
  margin-top: 8px;
}
.mt-10 {
  margin-top: 10px;
}
.w-full {
  width: 100%;
}
.flex-1 {
  flex: 1;
}
.row-flex {
  display: flex;
  gap: 6px;
}
.m-0 {
  margin: 0;
}
