/* Shared generator widgets: stepper, progress, dist, KST, story combo.
   generate.html page layout is appended below. */

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.step-chip {
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.step-chip.is-done { background: #dcfce7; color: #166534; 
}
.step-chip.is-running { background: #fef3c7; color: #92400e; 
}
.step-chip.is-await { background: #dbeafe; color: #1e40af; 
}
.step-chip.is-stale { background: #fee2e2; color: #991b1b; 
}
.step-chip.is-failed { background: #fecaca; color: #7f1d1d; 
}
.step-chip.is-current { outline: 2px solid var(--ink); 
}

.progress-strip {
  margin: 0.35rem 0 0.75rem;
  font-size: var(--fs-label);
  font-weight: 700;
}

.progress-strip[hidden] { display: none; 
}

.dist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
}

.dist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.4rem 0.55rem;
  background: var(--paper);
}

.dist-item label {
  flex: 1;
  font-size: var(--fs-label);
  font-weight: 700;
}

.dist-item input {
  width: 3.2rem;
  padding: 0.3rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  text-align: center;
  font-weight: 800;
}

.dist-label-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.dist-label-row .field-label { margin-bottom: 0; 
}

.dist-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: var(--r-full);
  border: 1.5px solid var(--line-strong);
  font-size: var(--fs-caption);
  font-weight: 900;
  color: var(--ink-muted);
  cursor: help;
  line-height: 1;
  user-select: none;
}

.dist-total {
  margin-left: auto;
  font-size: var(--fs-label);
  font-weight: 800;
  color: var(--ink-muted);
}

.dist-total.is-over { color: var(--danger, #b42318); 
}

.kst-selected,
.picker-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  min-height: 2rem;
  margin-bottom: 0.4rem;
  padding: 0.35rem 0.5rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--card);
}

.kst-selected.is-empty,
.picker-selected.is-empty {
  color: var(--ink-muted);
  font-size: var(--fs-label);
  font-weight: 600;
}

.kst-selected-count,
.picker-count {
  font-size: var(--fs-label);
  font-weight: 800;
  color: var(--ink);
  margin-right: 0.15rem;
}

.kst-selected-note {
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--ink-muted);
}

.kst-selected-note.is-error { color: var(--error); 
}

.kst-list,
.story-list,
.picker-list {
  max-height: 12rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0.4rem;
  background: var(--paper);
}

.kst-list label,
.story-list label {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: var(--fs-label);
  font-weight: 600;
  padding: 0.25rem 0.2rem;
}

.kst-add,
.picker-add {
  display: flex;
  width: 100%;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.3rem 0.4rem;
  border: 0;
  border-radius: var(--r-sm, 4px);
  background: transparent;
  font: inherit;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.kst-add::before,
.picker-add::before {
  content: "+";
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
  font-weight: 800;
  color: var(--mint-deep);
}

.kst-add:hover,
.kst-add:focus-visible,
.picker-add:hover,
.picker-add:focus-visible {
  background: var(--card);
  outline: none;
}

.kst-add:focus-visible,
.picker-add:focus-visible { box-shadow: inset 0 0 0 1.5px var(--ink); 
}

.kst-add .kst-add-fit,
.picker-add .picker-hint {
  margin-left: auto;
  color: var(--mint-deep);
  font-weight: 800;
}

.picker-empty {
  padding: 0.4rem;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--ink-muted);
}

.call-log {
  margin-top: 1.25rem;
  border-top: 1.5px solid var(--line);
  padding-top: 0.85rem;
}

.call-log h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: var(--fs-body-lg);
}

/* Compact data tables: the call log here, the batch plan in generate-batch.css
   (which sets its own cell padding and alignment). */
.call-log-table,
.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-label);
  font-weight: 600;
}

.call-log-table th,
.call-log-table td,
.batch-table th,
.batch-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.4rem;
  vertical-align: middle;
}

.call-log-table th,
.batch-table th {
  color: var(--ink-muted);
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.call-log-summary {
  margin: 0.85rem 0 0;
  font-size: var(--fs-label);
  font-weight: 700;
}

.call-log-summary p {
  margin: 0 0 0.45rem;
}

.call-log-total {
  font-size: 1rem;
}

.call-log-cache {
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.call-log-table td.num,
.call-log-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cache-chip {
  font-variant-numeric: tabular-nums;
}

.cache-chip--hit {
  background: var(--badge-success-bg);
  color: var(--badge-success-fg);
}

.cache-chip--write,
.cache-chip--miss {
  background: var(--badge-danger-bg);
  color: var(--badge-danger-fg);
}

.cache-chip--zero {
  background: var(--ink-inset);
  color: var(--ink-muted);
}

.call-log-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin-top: 0.75rem;
}

.cost-chart {
  margin: 0;
}

.cost-chart figcaption {
  font-size: var(--fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 0.4rem;
}

.cost-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.cost-bar {
  display: grid;
  grid-template-columns: 10.5rem 1fr 5.5rem 3rem;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-label);
}

.cost-bar-head {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.cost-bar-meta {
  font-size: var(--fs-caption);
  font-weight: 600;
}

.cost-bar-track {
  height: 0.7rem;
  border-radius: 0.35rem;
  background: var(--ink-inset);
  overflow: hidden;
}

.cost-bar-fill {
  display: block;
  height: 100%;
  border-radius: 0.35rem;
  background: var(--sky-deep);
}

.cost-bar-fill--cache-read { background: var(--mint-deep); 
}
.cost-bar-fill--input { background: var(--sky-deep); 
}
.cost-bar-fill--cache-write { background: var(--sun-deep); 
}
.cost-bar-fill--output { background: var(--coral-deep); 
}

.cost-bar-fill--agent-planner { background: var(--sky-deep); 
}
.cost-bar-fill--agent-author { background: var(--coral-deep); 
}
.cost-bar-fill--agent-enricher { background: var(--mint-deep); 
}
.cost-bar-fill--agent-reviewer { background: var(--berry); 
}
.cost-bar-fill--agent-converter { background: var(--ink-muted); 
}
.cost-bar-fill--agent-imagePlanner { background: var(--violet, #7c5cff);
}
.cost-bar-fill--agent-imageResources { background: var(--sun-deep);
}
.cost-bar-fill--agent-imagePromptWriter { background: var(--berry);
}
.cost-bar-fill--agent-imageGenerator { background: var(--coral-deep);
}
.cost-bar-fill--agent-imageReviewer { background: var(--mint-deep);
}

.cost-bar-value,
.cost-bar-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cost-bar-pct {
  font-weight: 600;
}

.usage-runs {
  margin-top: 0.85rem;
}

.trace-overlay[hidden] { display: none; 
}

.trace-modal {
  width: min(72rem, 100%);
  max-height: min(90vh, 56rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.trace-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1.5px solid var(--line);
}

.trace-modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title);
}

.trace-modal-meta {
  padding: 0.45rem 1rem;
  font-size: var(--fs-label);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.trace-modal-body {
  padding: 0.85rem 1rem 1.1rem;
  overflow: auto;
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .trace-modal-body { grid-template-columns: 1fr 1fr; 
}
}

.trace-pane h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: var(--fs-body);
}

.trace-pane pre {
  margin: 0;
  max-height: 28rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 1.4;
  padding: 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-deep);
}

/* ─── generate.html — Agentic feladat generálás page layout ──────────────── */
.gen-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.gen-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .gen-layout { grid-template-columns: 1fr; 
}
}

.runs-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 70vh;
  overflow: auto;
}

.run-item {
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
}

.run-item:hover, .run-item.is-active {
  border-color: var(--line-strong);
  background: var(--paper-deep);
}

.run-item .meta {
  display: block;
  margin-top: 0.2rem;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--ink-muted);
}

/* Plain text rather than an .id-chip: the row itself is a <button>. */
.run-item-id {
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.field-group { margin-bottom: 0.85rem; 
}

/* .field-group owns the vertical rhythm on both generator pages, and their
   textareas hold JSON and id lists, so they keep a monospace face. Scoped to
   the page shells because design-system.html loads this sheet too; :where()
   keeps the weight of the old page-level rules. */
:where(.gen-shell, .batch-shell) .field-input,
:where(.gen-shell, .batch-shell) .field-select,
:where(.gen-shell, .batch-shell) .field-textarea { margin-bottom: 0; 
}

:where(.gen-shell, .batch-shell) .field-textarea {
  font-family: ui-monospace, monospace;
  font-size: var(--fs-label);
}

.field-textarea.tall { min-height: 14rem; 
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

/* Stamp CTAs are sized for heroes; the agentic generator's toolbars are dense
   (#runActions alone holds a button per stage). */
.gen-shell .actions .btn-stamp {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  gap: 0.35rem;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--fs-label);
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}

.task-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.task-tab {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.35rem 0.6rem;
  font-size: var(--fs-label);
  font-weight: 800;
  background: var(--paper);
  cursor: pointer;
}

.task-tab.is-active { background: var(--ink); color: var(--paper); 
}
.task-tab.is-fail { border-color: #b91c1c; color: #b91c1c; 
}

.preview-frame {
  width: 100%;
  min-height: 28rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper-deep);
}

.view { display: none; 
}
.view.is-visible { display: block; 
}

.accept-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
  font-weight: 700;
  font-size: var(--fs-label);
}

.err-list {
  color: #b91c1c;
  font-size: var(--fs-label);
  margin: 0.5rem 0;
  padding-left: 1.1rem;
}

.warn-list {
  color: #b45309;
  font-size: var(--fs-label);
  margin: 0.5rem 0;
  padding-left: 1.1rem;
}

.md-preview {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
  padding: 0.85rem 1rem;
  margin: 0.5rem 0 0.75rem;
  max-height: 28rem;
  overflow: auto;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.md-preview h1,
.md-preview h2,
.md-preview h3 {
  font-family: var(--font-display);
  margin: 0.75rem 0 0.35rem;
  line-height: 1.25;
}

.md-preview h1 { font-size: var(--fs-title); 
}
.md-preview h2 { font-size: var(--fs-body-lg); 
}
.md-preview h3 { font-size: 1rem; 
}
.md-preview p { margin: 0.4rem 0; 
}
.md-preview ul, .md-preview ol { margin: 0.4rem 0; padding-left: 1.25rem; 
}
.md-preview code {
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
  background: var(--paper-deep);
  padding: 0.1em 0.35em;
  border-radius: var(--r-sm);
}
.md-preview pre {
  background: var(--paper-deep);
  padding: 0.65rem 0.75rem;
  border-radius: var(--r-md);
  overflow: auto;
  font-size: var(--fs-label);
}
.md-preview pre code { background: none; padding: 0; 
}

.help-panel {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-deep);
  padding: 0.75rem 0.9rem;
  margin: 0.5rem 0 0.75rem;
}

.help-panel h4 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: var(--fs-body);
}

.help-row {
  margin: 0.35rem 0;
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 1.4;
}

.help-row .help-key {
  display: block;
  font-size: var(--fs-caption);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 0.1rem;
}

.run-inputs {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-deep);
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
}

.run-inputs-title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: var(--fs-body);
}

.run-input-chip {
  margin: 0.15rem 0.35rem 0.15rem 0;
  border: 1px solid var(--line);
  background: var(--paper);
}

.run-input-details {
  margin-top: 0.55rem;
}

.run-input-details summary {
  cursor: pointer;
  font-size: var(--fs-label);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.run-input-pre {
  white-space: pre-wrap;
  margin: 0.4rem 0 0;
  max-height: 10rem;
  overflow: auto;
  font-size: var(--fs-label);
  font-family: var(--font-mono, ui-monospace, monospace);
}

.review-card {
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  padding: 0.75rem 0.9rem;
  margin: 0.5rem 0 0.85rem;
}

.review-card.is-pass { border-color: #166534; background: #f0fdf4; 
}
.review-card.is-fail { border-color: #b91c1c; background: #fef2f2; 
}

.review-batch {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.65rem 0.85rem;
  margin: 0.5rem 0 0.75rem;
  background: var(--paper-deep);
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 1.4;
}

.review-badge {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1.5px solid var(--line-strong);
  margin-right: 0.4rem;
}

.review-badge.is-pass { background: #dcfce7; color: #166534; border-color: #166534; 
}
.review-badge.is-fail { background: #fecaca; color: #7f1d1d; border-color: #b91c1c; 
}

.review-scores { margin: 0 0 0.4rem; font-size: var(--fs-label); 
}
.review-score { white-space: nowrap; cursor: help; 
}
.review-score.is-low { color: #7f1d1d; font-weight: 700; 
}

.review-card h4 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: var(--fs-body);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.review-card ul {
  margin: 0.35rem 0;
  padding-left: 1.15rem;
  font-size: var(--fs-label);
  font-weight: 600;
}

.review-notes {
  margin: 0.45rem 0 0;
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--ink-muted);
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}

/* ── Image workbench (art stage) ─────────────────────────────────────────── */

.art-workbench {
  margin-top: 1.25rem;
  border-top: 1.5px solid var(--line);
  padding-top: 0.85rem;
}

.art-workbench h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.art-workbench-head {
  margin-bottom: 0.65rem;
}

.art-pic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.55rem;
  margin: 0.55rem 0 0.75rem;
}

.art-pic-card {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  text-align: left;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  padding: 0.45rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.art-pic-card.is-selected {
  outline: 2px solid var(--ink);
}

.art-pic-card.is-failed {
  border-color: #b91c1c;
  background: #fef2f2;
}

.art-pic-card.is-done {
  border-color: #166534;
}

.art-pic-card.is-running {
  border-color: #92400e;
  background: #fffbeb;
}

.art-pic-thumb {
  width: 3.25rem;
  height: 3.25rem;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--paper-deep);
  display: grid;
  place-items: center;
}

.art-pic-thumb img,
.art-preview img,
.art-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.art-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-sm);
}

.art-thumb-placeholder {
  color: var(--ink-muted);
  font-weight: 800;
}

.art-pic-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  font-size: var(--fs-label);
}

.art-pic-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.art-pic-error {
  color: #991b1b;
  font-size: var(--fs-caption);
}

.art-sub-stepper {
  flex-wrap: wrap;
  margin: 0.35rem 0 0.55rem;
}

.art-sub-chip {
  cursor: pointer;
  font: inherit;
}

.art-sub-chip.is-selected {
  outline: 2px solid var(--ink);
}

.art-stage-detail {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-deep);
  padding: 0.75rem 0.9rem;
}

.art-preview {
  margin-top: 0.55rem;
  max-width: 18rem;
}

.art-preview img {
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: #fff;
}

.art-resource-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.art-resource-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-label);
  font-weight: 600;
}
