/* xsnapshot local tools (workbench.js, gguf-view.js, model-benchmark-view.js).
   Grammar: an "Inputs" panel on a quiet fill, then a black "Readout" frame
   whose figures are large tabular numerals, then quiet notes that name the
   assumption or source. Nothing here is a score or a recommendation feed. */

.workbench {
  margin: 0 0 40px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg);
}
/* inside the publish card the workbench is a section, not a nested box */
.publish .workbench {
  margin: 30px 0 0;
  padding: 30px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.workbench > h2 {
  margin-bottom: 12px;
  font-size: 26px;
  line-height: 29px;
  letter-spacing: -0.03em;
  word-spacing: -0.3em;
}
.workbench > p {
  max-width: 64ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}
.workbench h3 {
  margin: 30px 0 12px;
  font-size: 22px;
  line-height: 26px;
  letter-spacing: -0.02em;
}
.workbench h4 {
  margin: 24px 0 8px;
}
.workbench p,
.workbench li {
  max-width: 72ch;
  font-size: 13px;
  line-height: 20px;
}
.workbench label {
  display: block;
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

/* ---------- tabs: the record's strip, a 4px lime bar under the selected ---------- */
.workbench-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin: 24px 0 0;
  border-bottom: 1px solid var(--line);
}
.workbench-tabs [role="tab"] {
  min-height: 44px;
  padding: 0 12px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.workbench-tabs [role="tab"]::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 4px;
  border-radius: var(--r-pill);
  background: transparent;
}
.workbench-tabs [role="tab"]:hover:not(:disabled) {
  background: var(--fill);
  border-color: transparent;
  color: var(--text);
}
.workbench-tabs [aria-selected="true"],
.workbench-tabs [aria-selected="true"]:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
  font-weight: 700;
}
.workbench-tabs [aria-selected="true"]::before {
  background: var(--accent);
}
.workbench-tabs [role="tab"]:active:not(:disabled) {
  transform: none;
}
.workbench [role="tabpanel"] {
  padding-top: 8px;
}
.workbench [role="tabpanel"]:focus-visible {
  outline-offset: 4px;
}
.workbench [role="tabpanel"] > h3:first-child {
  margin-top: 24px;
}
.workbench-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-block: 12px;
}

/* ---------- inputs ---------- */
.tool-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 4px 16px;
  margin: 16px 0;
  padding: 16px 20px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-field);
  background: var(--fill);
}
.tool-fields::before {
  content: "Inputs";
  content: "Inputs" / "";
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tool-field {
  min-width: 0;
}
.tool-field input,
.tool-field select,
.tool-field textarea {
  width: 100%;
  max-width: 100%;
}
.tool-field input[type="file"] {
  padding: 4px 0;
}
/* long choices get the whole row, so nothing is clipped at any width */
.tool-field:has(> input[type="file"]),
.tool-field:has(> select[id$="-compare-direction"]) {
  grid-column: 1 / -1;
}

/* ---------- readouts ---------- */
.calculation-result,
.benchmark-result:not(:empty),
.benchmark-comparison,
.comparison-summary:not(:empty),
.gguf-result:not(:empty),
.model-benchmark-result:not(:empty),
.game-reference:not(:empty) {
  margin: 20px 0;
  padding: 20px 24px;
  border: 1px solid var(--line-control);
  border-radius: var(--r-field);
}
/* a readout's first line sits on its frame; notes-only states stay unframed */
.calculation-result > :first-child,
.benchmark-result > :first-child,
.benchmark-comparison > :first-child,
.comparison-summary > :first-child,
.gguf-result > :first-child,
.model-benchmark-result > :first-child,
.game-reference > :first-child {
  margin-top: 0;
}
.calculation-result > :last-child,
.benchmark-result > :last-child,
.benchmark-comparison > :last-child,
.comparison-summary > :last-child,
.gguf-result > :last-child,
.model-benchmark-result > :last-child,
.game-reference > :last-child {
  margin-bottom: 0;
}
.comparison-summary:not(:has(> .tool-facts)) {
  padding: 0;
  border: 0;
}
.calculation-result::before,
.benchmark-result:not(:empty)::before,
.gguf-result:not(:empty)::before,
.model-benchmark-result:not(:empty)::before {
  content: "Readout";
  content: "Readout" / "";
  display: block;
  margin-bottom: 8px;
  color: var(--muted-raised);
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.workbench .estimate-state {
  margin: 0 0 4px;
  color: var(--text-strong);
  font-size: 17px;
  line-height: 20px;
  font-weight: 700;
}
.tool-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0 24px;
  margin: 12px 0 16px;
}
.tool-facts > div {
  min-width: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.tool-facts dt {
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tool-facts dd {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
/* figures read like an instrument: large tabular numerals */
.calculation-result .tool-facts dd,
.benchmark-result .tool-facts dd,
.benchmark-delta .tool-facts dd {
  font-size: 22px;
  line-height: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.comparison-summary .tool-facts dd {
  font-size: 17px;
  line-height: 20px;
  font-weight: 700;
}
/* assumptions and sources: visible, quiet, labelled */
.tool-note {
  max-width: 72ch;
  margin: 12px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
}
.workbench .tool-note {
  font-size: 12px;
  line-height: 17px;
}
.tool-note::before {
  content: "Note · ";
  content: "Note · " / "";
  color: var(--muted-raised);
  font-weight: 700;
}
.insight {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.insight h4 {
  margin: 0 0 4px;
}
.insight p {
  margin: 0;
  color: var(--muted);
}
/* numbered checklists read like the landing's steps */
.workbench ol {
  margin: 8px 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.workbench ol > li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  counter-increment: step;
}
.workbench ol > li::before {
  content: counter(step, decimal-leading-zero);
  content: counter(step, decimal-leading-zero) / "";
  color: var(--muted);
  font-size: 11px;
  line-height: 20px;
  font-weight: 700;
}
.memory-check {
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.methodology {
  margin: 20px 0;
  border-block: 1px solid var(--line);
}

/* bars: model memory and frame-time distribution */
.model-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  margin: 12px 0 24px;
}
.model-row {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.model-row-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 20px;
}
.model-row-heading strong {
  font-variant-numeric: tabular-nums;
}
.workbench .model-row .muted {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 17px;
}
/* model memory against the budget: ink within it, danger beyond it, a 1px mark */
.memory-bar {
  display: block;
  width: 100%;
  height: 10px;
  overflow: visible;
}
.memory-track {
  fill: var(--surface);
}
.memory-fill {
  fill: var(--text);
}
.memory-over {
  fill: var(--danger);
}
.memory-budget {
  stroke: var(--text-strong);
  stroke-width: 1px;
}
.workbench .model-row .over-budget::before {
  content: "× ";
  content: "× " / "";
  color: var(--danger);
  font-weight: 700;
}
.workbench progress {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--surface);
  accent-color: var(--accent);
}
.workbench progress::-webkit-progress-bar {
  background: var(--surface);
  border-radius: var(--r-pill);
}
.workbench progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: var(--r-pill);
}
.workbench progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: var(--r-pill);
}
.frame-distribution {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}
.frame-bin {
  display: grid;
  grid-template-columns: 116px minmax(40px, 1fr) 56px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  line-height: 17px;
  font-variant-numeric: tabular-nums;
}
.frame-bin span:last-child {
  color: var(--muted);
  text-align: right;
}

/* gaming: run comparison */
.benchmark-compare-tools {
  margin-top: 30px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.workbench .benchmark-confirm {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
}
.workbench .benchmark-confirm input {
  margin-top: 0;
}
.benchmark-comparison:not(:has(> .tool-facts)) {
  padding: 0;
  border: 0;
}
.benchmark-delta {
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.benchmark-delta h4 {
  margin: 0 0 4px;
}
.benchmark-comparison .tool-facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.benchmark-comparison > .tool-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* changes: comparison rows */
.comparison-row {
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.comparison-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.comparison-heading .eyebrow {
  margin: 0;
}
.comparison-row h4 {
  margin: 8px 0 4px;
  overflow-wrap: anywhere;
}
.comparison-row .tool-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}
.comparison-row dd {
  white-space: pre-wrap;
}
.comparison-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.comparison-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* model files and measured model speed */
.gguf-inspector,
.model-benchmark-inspector {
  margin-top: 40px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.gguf-result h5 {
  margin: 20px 0 8px;
}
.model-benchmark-result h5 {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 20px;
  overflow-wrap: anywhere;
}
.model-benchmark-result .eyebrow {
  margin-bottom: 4px;
}

/* rebuild: the checklist reads as a printout */
.workbench .rebuild-plan {
  min-height: 20rem;
  background: var(--bg);
  font-size: 13px;
  line-height: 20px;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .workbench {
    padding: 20px 16px;
  }
  .calculation-result,
  .benchmark-result:not(:empty),
  .benchmark-comparison,
  .comparison-summary:not(:empty),
  .gguf-result:not(:empty),
  .model-benchmark-result:not(:empty),
  .game-reference:not(:empty) {
    padding: 16px;
  }
  .tool-fields {
    padding: 12px 16px 4px;
  }
}
/* the tab strip wraps into an even grid instead of scrolling sideways;
   order, roles and arrow-key behaviour are unchanged */
@media (max-width: 600px) {
  .workbench-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
  }
  .workbench-tabs [role="tab"] {
    padding-inline: 4px;
    border-bottom: 1px solid var(--line);
  }
  .workbench-tabs [role="tab"]::before {
    left: 8px;
    right: 8px;
  }
  .model-comparison,
  .comparison-row .tool-facts,
  .benchmark-comparison .tool-facts,
  .benchmark-comparison > .tool-facts,
  .tool-facts {
    grid-template-columns: minmax(0, 1fr);
  }
  .frame-bin {
    grid-template-columns: 104px minmax(20px, 1fr) 48px;
    gap: 8px;
  }
  .comparison-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
@media (max-width: 420px) {
  .workbench-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* at the 320px floor a select and a native file input keep their whole text */
  .tool-fields {
    padding-inline: 12px;
  }
  .tool-field select {
    padding-inline: 8px;
    font-size: 13px;
  }
  .workbench input[type="file"] {
    font-size: 12px;
  }
  .workbench input[type="file"]::file-selector-button {
    margin-right: 8px;
    padding-inline: 12px;
  }
}
@media (forced-colors: active) {
  .workbench,
  .tool-fields,
  .calculation-result {
    border-color: CanvasText;
  }
  .workbench-tabs [role="tab"] {
    border: 1px solid ButtonText;
  }
  .workbench-tabs [aria-selected="true"],
  .workbench-tabs [aria-selected="true"]:hover:not(:disabled) {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
    border: 2px solid Highlight;
  }
  .memory-track {
    fill: Canvas;
    stroke: CanvasText;
  }
  .memory-fill {
    fill: CanvasText;
  }
  .memory-over {
    fill: Highlight;
  }
  .memory-budget {
    stroke: CanvasText;
  }
  .workbench progress {
    forced-color-adjust: none;
    background: Canvas;
    color: Highlight;
    accent-color: Highlight;
  }
  .workbench progress::-webkit-progress-bar {
    background: Canvas;
    border: 1px solid CanvasText;
  }
  .workbench progress::-webkit-progress-value {
    background: Highlight;
  }
  .workbench progress::-moz-progress-bar {
    background: Highlight;
  }
  .comparison-row:focus-visible {
    outline-color: Highlight;
  }
}
