/* The Tests editor and launch review. Same tokens as the rest of the console. Layout: form on the
   left, the server's Check panel sticky on the right (stacked below 1100px), the launch review
   full width below, and a sticky action bar at the bottom of the viewport. */

.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.test-name a { color: var(--text); text-decoration: none; }
.test-name a:hover { text-decoration: underline; }

.author { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.author-form { display: grid; gap: 16px; min-width: 0; }
.author-sec, .review { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 18px; min-width: 0; }
.sec-head { margin-bottom: 12px; }
.sec-title { margin: 0; font-size: 15px; letter-spacing: -0.005em; outline: none; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field-note { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; max-width: 72ch; }
.field-note .icon { color: var(--warn); }
.field { display: grid; gap: 0; min-width: 0; }
.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.field-row .field-label { margin: 0; }
.field-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 220px)); gap: 12px; margin-top: 12px; }
.input-wide { width: 100%; max-width: 560px; }
.input-field { width: 100%; min-width: 0; }
.input:focus-visible, .code-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input::placeholder, .code-input::placeholder { color: var(--text-faint); opacity: 1; }
.field-errors:empty { display: none; }
.field-errors { margin-top: 10px; display: grid; gap: 4px; }
.field-error { margin: 0; color: var(--bad); font-size: 13px; overflow-wrap: anywhere; }
.sec-tools { display: flex; justify-content: flex-end; margin: -40px 0 8px; }
.upload-btn { cursor: pointer; }
.btn-icon { min-width: 34px; padding: 6px 8px; justify-content: center; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-align: left; text-underline-offset: 3px; }
.link-btn:hover { text-decoration: underline; }

/* Code editor: gutter + textarea with identical metrics (20px lines, 10px padding). */
.code-body { display: flex; border: 1px solid var(--border-control); border-radius: var(--radius-sm); background: var(--inset); overflow: hidden; }
.code-body:focus-within { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus); } /* the textarea outline is clipped by overflow:hidden, so the ring lives on the box */
.code-body:has(.code-input[aria-invalid="true"]) { border-color: var(--bad); }
/* contain: size keeps the gutter from setting the box height: the textarea decides it, the gutter stretches to it and its
   extra lines are clipped (they scroll with the text). shortcut: width is the 44px floor, enough for 3-digit line numbers; widen if 1000+ line scripts become usual. */
.code-gutter { contain: size; flex: none; min-width: 44px; padding: 10px 8px 10px 0; text-align: right; font: 13px/20px var(--mono); color: var(--text-faint); background: var(--panel-2); border-right: 1px solid var(--border-soft); user-select: none; will-change: transform; }
.code-gutter span { display: block; padding-left: 10px; }
.code-gutter span.bad { color: var(--bad); font-weight: 700; background: var(--bad-soft); }
.code-area { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.code-marks { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
.code-mark { position: absolute; left: 0; right: -4000px; height: 20px; background: var(--bad-soft); box-shadow: inset 0 -1px 0 var(--bad); }
.code-input {
  position: relative; display: block; width: 100%; margin: 0; padding: 10px 12px; border: 0; background: transparent; color: var(--text);
  font: 13px/20px var(--mono); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; tab-size: 2; resize: vertical; white-space: pre; overflow: auto; caret-color: var(--accent); outline: none;
}
.code-input::selection { background: var(--accent-soft); }
.code-hint { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 6px 0 0; font-size: 12.5px; color: var(--text-dim); }
.code-caret { font-family: var(--mono); color: var(--text-faint); }

/* Env rows. */
.kv-list { display: grid; gap: 8px; }
.kv-row { display: grid; grid-template-columns: minmax(0, 2fr) auto minmax(0, 3fr) auto; align-items: center; gap: 8px; }
.kv-eq { color: var(--text-faint); font-family: var(--mono); }
.kv-value-wrap { position: relative; display: flex; min-width: 0; }
.kv-value-wrap .input { flex: 1; min-width: 0; }
.kv-value-wrap .btn-icon { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); min-height: 28px; padding: 4px 6px; }
.kv-value-wrap .btn-icon[hidden] + * { padding-right: 0; }
.kv-value-wrap .input[type="password"], .kv-value-wrap .input:has(+ .btn-icon:not([hidden])) { padding-right: 36px; }
.kv-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; font-size: 13px; }
.kv-empty { margin: 0; }

/* Load shape mode switch. */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.seg-opt { position: relative; display: inline-flex; align-items: center; min-height: 34px; padding: 6px 12px; border: 1px solid var(--border-control); border-radius: 999px; background: var(--inset); color: var(--text-dim); font-weight: 600; font-size: 13px; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.shape-body { margin-top: 10px; display: grid; gap: 12px; }
.stage-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 20px auto minmax(70px, 110px) auto minmax(60px, 90px) auto auto; align-items: center; gap: 8px; }
.stage-n { font-family: var(--mono); text-align: right; }
/* Script type switch and the QM SSE visitor form (same pills and stage rows as the load shape). */
.script-kind-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.script-kind .field-note { margin: 8px 0 14px; }
.script-kind .sec-tools { margin: 0; }
.qm-sub { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.qm-sub:first-child { margin-top: 0; }
.qm-wide { max-width: 560px; }
.qm .field-pair { margin-top: 12px; }
.qm .field-note { margin-top: 8px; }
.qm-stage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qm-stage-row .input { flex: none; width: 96px; }
.qm-adv { margin-top: 16px; }
.qm-adv summary { cursor: pointer; width: fit-content; color: var(--text-dim); font-size: 13px; font-weight: 600; }
.qm-adv summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.qm-adv[open] summary { margin-bottom: 8px; color: var(--text); }
.qm-adv .field-error { margin-top: 8px; }
.precedence:empty { display: none; }
.precedence { margin-top: 12px; }

/* Check panel. */
.author-check { position: sticky; top: 72px; max-height: calc(100vh - 150px); overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.check-head { display: flex; gap: 12px; align-items: flex-start; }
.check-icon { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.tone-good .check-icon { background: var(--good-soft); color: var(--good); }
.tone-bad .check-icon { background: var(--bad-soft); color: var(--bad); }
.tone-warn .check-icon { background: var(--warn-soft); color: var(--warn); }
.check-title { margin: 4px 0 2px; font-size: 15px; }
.check-body { margin: 0; color: var(--text-dim); font-size: 13px; }
.check-sub { margin: 16px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.03em; color: var(--text-dim); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13px; }
.check-list li { overflow-wrap: anywhere; }
.check-msg { margin: 2px 0 0; color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.check-stale { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; color: var(--text-dim); font-size: 13px; }
.check-shape { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.check-shape .pill { margin-right: 4px; }
.shape-none, .shape-unknown { color: var(--warn); }
.shape-none .icon, .shape-unknown .icon { color: var(--warn); }
.shape-definition .icon, .shape-script .icon { color: var(--good); }
.shape-refused .icon { color: var(--bad); }
.author-check .btn { margin-top: 12px; }

/* Launch review. */
.review { margin-top: 20px; }
.review-lede { margin: 0 0 12px; color: var(--text-dim); max-width: 80ch; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.review-table th { width: 34%; background: transparent; font-size: 13px; color: var(--text-dim); letter-spacing: 0; border-bottom: 1px solid var(--border-soft); }
.review-table td { font-size: 13.5px; }
.review-table .num { font-family: var(--mono); }
.review-note { font-size: 12.5px; min-width: 160px; }
.big-num { font-size: 18px; }
.review-table .peak-range { display: block; margin-top: 4px; white-space: normal; text-align: right; font-family: var(--sans); font-size: 12.5px; color: var(--text-dim); }
.pill-est { background: var(--warn-soft); color: var(--warn); font-family: var(--sans); font-size: 11.5px; }
.review-scenarios { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13px; }
.review-scenarios li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; overflow-wrap: anywhere; }
.scenario-name { font-weight: 600; }
.review-assume { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* Worker Droplets: the launch option and the review block. */
.fleet-option { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.fleet-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.fleet-check input { width: 16px; height: 16px; accent-color: var(--accent, currentColor); }
.review-fleet { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.fleet-caps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.fleet-caps li { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
.fleet-caps .icon { flex: none; margin-top: 2px; }
.fleet-over { color: var(--bad); }

/* Sticky action bar and its alert. */
.action-bar {
  position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 20px -16px -64px; padding: 12px max(16px, calc((100% - 1208px) / 2)); background: var(--bg-raised); border-top: 1px solid var(--border);
}
.bar-status { margin: 0; color: var(--text-dim); font-size: 13px; }
.bar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bar-alert { flex-basis: 100%; padding: 12px 16px; border: 1px solid var(--warn); border-radius: var(--radius); background: var(--warn-soft); }
.bar-alert p { margin: 0 0 10px; }

@media (max-width: 1100px) {
  .author { grid-template-columns: minmax(0, 1fr); }
  .author-check { position: static; max-height: none; order: -1; }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .author-sec, .review { padding: 14px 12px; }
  .kv-row { grid-template-columns: minmax(0, 1fr) auto; }
  .kv-eq { display: none; }
  .kv-value-wrap { grid-column: 1 / 2; }
  .kv-row > .btn-icon { grid-row: 1 / 3; grid-column: 2; }
  .stage-row { grid-template-columns: 16px auto minmax(0, 1fr) auto minmax(0, 1fr) auto; }
  .stage-row > span.muted:nth-of-type(4) { display: none; }
  .sec-tools { margin: 0 0 8px; justify-content: flex-start; }
  .review-table th { width: auto; }
  .review-table .review-note { display: none; }
  .action-bar { margin: 16px -16px -64px; }
}
.review-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.review, .author-sec { scroll-margin-top: 72px; }
/* Narrow: the sticky header is two rows tall, so anchored jumps clear it. */
@media (max-width: 640px) { .review, .author-sec { scroll-margin-top: 112px; } }
.input:disabled { opacity: 0.55; cursor: not-allowed; }
