@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --steel:  #15181c;
  --panel:  #1d2229;
  --plate:  #272d35;
  --edge:   #363d47;
  --hv:     #ff6b00;
  --brass:  #c9a227;
  --live:   #4ade80;
  --fault:  #f0523c;
  --chalk:  #e9e7e2;
  --dim:    #8d949e;

  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --body: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--steel);
  color: var(--chalk);
  font: 15px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

/* Hazard stripe: the orange-and-charcoal diagonal on every HV enclosure. */
.hazard {
  height: 6px;
  background: repeating-linear-gradient(
    -45deg,
    var(--hv) 0 14px,
    var(--steel) 14px 28px
  );
}

.wrap {
  max-width: 62rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 2.5rem;
}

.wordmark {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}

.wordmark span { color: var(--hv); }

.masthead nav {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.masthead nav a { color: var(--dim); text-decoration: none; }
.masthead nav a:hover { color: var(--hv); }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 0.9rem;
}

/* ------------------------------------------------------------- nameplates */
/* Every controller ships with a stamped metal plate. The selector mirrors it. */

.plates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

.plate {
  position: relative;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 1.15rem 1.15rem 1rem;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background:
    linear-gradient(155deg, #2e353e 0%, #232931 55%, #1c2128 100%);
  transition: border-color 0.15s, transform 0.15s;
}

.plate:hover { border-color: #4c5563; transform: translateY(-1px); }
.plate:focus-visible { outline: 2px solid var(--hv); outline-offset: 2px; }

.plate[aria-pressed="true"] {
  border-color: var(--hv);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 0, 0.35);
}

/* Corner rivets */
.plate::before,
.plate::after {
  content: '';
  position: absolute;
  top: 0.5rem;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6a737f, #333941);
}
.plate::before { left: 0.5rem; }
.plate::after  { right: 0.5rem; }

.plate h3 {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0.3rem 0 0.35rem;
  line-height: 1.15;
}

.plate p {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--dim);
  line-height: 1.45;
}

.plate .stamp {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--brass);
  border-top: 1px dashed var(--edge);
  padding-top: 0.6rem;
}

.plate .stamp.none { color: var(--dim); }

/* ------------------------------------------------------------------ panel */

.panel {
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: var(--panel);
  padding: 1.5rem;
}

.panel h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 1.1rem;
}

/* Spec readout: label left, monospace value right, dotted leader between. */
.spec {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}
.spec dt { color: var(--dim); }
.spec .leader { border-bottom: 1px dotted var(--edge); transform: translateY(-3px); }
.spec dd { margin: 0; font-family: var(--mono); font-size: 0.82rem; }

/* ----------------------------------------------------------------- fields */

label.field {
  display: block;
  margin-bottom: 1rem;
}

label.field > span {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.35rem;
}

input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  color: var(--chalk);
  background: var(--steel);
  border: 1px solid var(--edge);
  border-radius: 3px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--hv);
}

input[type="file"] { padding: 0.45rem; font-size: 0.82rem; }
textarea { resize: vertical; min-height: 4.5rem; }

.btn {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6rem 1.5rem;
  border: 1px solid var(--hv);
  border-radius: 3px;
  background: var(--hv);
  color: #14161a;
  cursor: pointer;
}
.btn:hover { background: #ff8226; border-color: #ff8226; }
.btn:focus-visible { outline: 2px solid var(--chalk); outline-offset: 2px; }
.btn.ghost { background: none; color: var(--chalk); border-color: var(--edge); }
.btn.ghost:hover { border-color: var(--chalk); background: none; }
.btn.danger { background: none; border-color: transparent; color: var(--fault); padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.btn.danger:hover { background: rgba(240, 82, 60, 0.12); border-color: transparent; }

/* ---------------------------------------------------------------- notices */

.notice {
  padding: 0.75rem 0.95rem;
  border-radius: 3px;
  font-size: 0.85rem;
  border: 1px solid var(--edge);
  background: var(--plate);
  margin: 0 0 1.1rem;
}
.notice.warn { border-color: #6d4b12; background: #2a2113; color: #f0cf8a; }
.notice.bad  { border-color: #6d2a22; background: #2a1815; color: #f5aa9d; }
.notice.good { border-color: #235c3c; background: #13251c; color: #96e6b8; }

/* Only td.mono existed, so inline <span class="mono"> rendered in the body font. */
.mono { font-family: var(--mono); }

/* Body-copy links; previously every anchor inlined its own colour.
   :not(.btn) matters — an element+class selector outranks the plain .btn rule,
   so without it an <a class="btn"> gets orange text on the orange button and
   the label disappears. */
.panel a:not(.btn), .notice a:not(.btn), .toolbox a:not(.btn) { color: var(--hv); }
.panel a:not(.btn):hover, .notice a:not(.btn):hover,
.toolbox a:not(.btn):hover { color: #ff8226; }

.muted { color: var(--dim); font-size: 0.82rem; }

.hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--dim);
  margin-top: 0.35rem;
}

[hidden] { display: none !important; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: left;
  font-weight: 500;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--edge);
}
td { padding: 0.6rem; border-bottom: 1px solid #232931; vertical-align: top; }
td.mono { font-family: var(--mono); font-size: 0.8rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --------------------------------------------------- pre-flash safety gate */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 12, 0.78);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 50;
}
.scrim[hidden] { display: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 4px solid var(--fault);
  max-width: 34rem;
  width: 100%;
  padding: 1.6rem 1.8rem 1.5rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.modal h2 {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fault);
  margin: 0 0 0.9rem;
}
.modal ul { margin: 0 0 1.2rem; padding-left: 1.1rem; color: var(--chalk); }
.modal li { margin-bottom: 0.5rem; line-height: 1.5; }
.modal .ack {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0 0 1.3rem;
  color: var(--chalk);
  cursor: pointer;
}
/* Inputs are width:100% elsewhere in the form styles, which would let the
   checkbox eat the whole row and squeeze the label out of the modal. */
.modal .ack input {
  width: auto;
  flex: none;
  margin-top: 0.25rem;
  accent-color: var(--hv);
}
.modal .ack span { flex: 1; min-width: 0; }
.modal .actions { display: flex; gap: 0.7rem; justify-content: flex-end; }
.modal .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.modal .btn[disabled]:hover { background: var(--hv); border-color: var(--hv); }

/* --------------------------------------------------------------- toolbox */
.toolbox .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
  margin-bottom: 1.1rem;
}
.toolbox .row .field { margin: 0; }
.toolbox .row select { width: auto; min-width: 8rem; }

/* Terminal. One element per line so a page refresh can rewrite only the lines
   that changed — see public/console.js. Fixed height with the scroll on the
   inner div, so a long page never pushes the rest of the page around. */
.term {
  border: 1px solid var(--edge);
  background: #16181c;
  margin-bottom: 0.9rem;
}
.term-out {
  /* Sized in lines, not pixels, and set from the actual page height by
     console.js so the controller's standard output fits without scrolling.
     max-height keeps a tall page from running off a short screen. */
  --lines: 24;
  height: calc(var(--lines) * 1.45em + 1.6rem);
  max-height: 78vh;
  overflow: auto;
  padding: 0.8rem 1rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: #ddd;
}
.term-line {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 1.45em;
}

/* Sits below .term-out, never inside it — the renderer owns every row in the
   output and would destroy an input placed there on the next page refresh. */
.term-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid var(--edge);
  padding: 0.35rem 0.6rem;
  background: #1b1e23;
}
.term-prompt {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--hv);
  flex: none;
}
.term-input input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0.3rem 0;
  font-family: var(--mono);
  font-size: 12px;
  color: #ddd;
}
.term-input input:focus { outline: none; border: 0; }
.term-input input::placeholder { color: #5c636d; }

/* ------------------------------------------------------- desktop flasher */
.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0 0.4rem;
}
.tool {
  border: 1px solid var(--edge);
  background: var(--plate);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.tool[data-current="true"] { border-color: var(--hv); }
.tool h4 {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 1.05rem;
  margin: 0;
  color: var(--chalk);
}
.tool .meta { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }
.tool .btn { margin-top: auto; text-align: center; text-decoration: none; }
.tool .btn.pending {
  background: none;
  border-color: var(--edge);
  color: var(--dim);
  cursor: not-allowed;
}
.tool .btn.pending:hover { background: none; border-color: var(--edge); }
