:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --panel-strong: #eef3ef;
  --panel-warm: #fff8ec;
  --text: #1f2722;
  --muted: #667069;
  --line: #d7ded8;
  --accent: #0f766e;
  --accent-strong: #0b5d56;
  --accent-soft: #dff3ef;
  --danger: #b4233c;
  --danger-soft: #f8dfe4;
  --warning: #a15c12;
  --warning-soft: #f7ead9;
  --success: #287a3e;
  --success-soft: #e2f3e5;
  --info: #315f9c;
  --info-soft: #e2ebf7;
  --ink: #17212b;
  --ink-soft: #e8edf2;
  --shadow: 0 14px 30px rgba(31, 39, 34, 0.07);
  --radius: 8px;
  --control-height: 42px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(23, 33, 43, 0.055), transparent 300px),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.app-shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(100%, 430px);
}

.login-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-copy {
  margin: 12px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 4px;
}

.full-button {
  width: 100%;
}

.login-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 2px 18px;
  border-bottom: 1px solid rgba(31, 39, 34, 0.08);
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.run-meta,
.button-row,
.panel-header,
.field-row,
.mode-selector {
  display: flex;
  align-items: center;
}

.run-meta {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(430px, 1.42fr) minmax(330px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.config-panel,
.work-panel,
.verdict-panel,
.log-panel {
  padding: 16px;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 14px;
}

.panel-subtitle {
  margin: 5px 0 0;
  max-width: 58ch;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.provider-card,
.security-strip,
.model-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.provider-card {
  min-height: 64px;
  padding: 12px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff, var(--ink-soft));
}

.provider-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.2;
}

.model-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.model-card {
  min-height: 50px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.model-card strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.mini-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.mini-state.neutral {
  background: var(--panel);
  color: var(--muted);
}

.mini-state.secure {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mini-state.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.step-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.step-rail li {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
}

.step-rail li.active {
  border-color: rgba(15, 118, 110, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.step-rail li.completed {
  border-color: rgba(40, 122, 62, 0.28);
  background: var(--success-soft);
  color: var(--success);
}

.run-guide {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid rgba(49, 95, 156, 0.22);
  border-radius: 7px;
  background: var(--info-soft);
}

.run-guide strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.run-guide p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.38;
}

.run-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.run-progress strong {
  display: block;
  color: var(--accent-strong);
}

.run-progress p {
  margin: 4px 0 0;
  color: var(--text);
  line-height: 1.35;
}

.spinner {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(15, 118, 110, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.strategy-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 220px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ffffff;
  color: var(--info);
  border: 1px solid rgba(49, 95, 156, 0.2);
  font-size: 0.78rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.field-group {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.field-row {
  gap: 12px;
  align-items: start;
}

.field-row > .field-group {
  flex: 1 1 0;
  min-width: 0;
}

label,
dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--text);
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

input,
select {
  height: var(--control-height);
  padding: 0 11px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 11px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

input[readonly],
textarea[readonly] {
  background: var(--panel-strong);
  color: var(--muted);
}

textarea[readonly] {
  cursor: default;
}

.prompt-field textarea[readonly] {
  background: #fbfcfb;
  color: var(--text);
}

.mode-selector {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-strong);
  margin: 4px 0 16px;
}

.mode-option {
  flex: 1;
  height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode-option.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 1px 5px rgba(31, 39, 34, 0.08);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 2px 0 14px;
}

.security-strip {
  min-height: 42px;
  padding: 0 12px;
  background: var(--panel-warm);
}

.security-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.security-strip strong {
  color: var(--warning);
  font-size: 0.9rem;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  padding: 0 15px;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
  padding: 0 13px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #aeb8b1;
  background: var(--panel-strong);
}

.secondary-button.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  color: var(--muted);
}

.button-row {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.bottom-actions {
  justify-content: flex-start;
  margin-top: 4px;
}

#generateBtn,
#evaluateBtn,
#mutateBtn {
  min-width: 154px;
}

.prompt-field textarea,
.response-field textarea {
  min-height: 220px;
}

.prompt-output-wrap {
  position: relative;
}

.prompt-busy-overlay {
  position: absolute;
  inset: 1px;
  z-index: 1;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px;
  border-radius: 6px;
  background: rgba(251, 252, 251, 0.92);
  color: var(--accent-strong);
  text-align: center;
}

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

.prompt-busy-overlay span:not(.spinner) {
  color: var(--muted);
  line-height: 1.35;
}

.work-panel.is-busy {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 16px 34px rgba(15, 118, 110, 0.12);
}

.work-panel.is-busy .prompt-output-wrap textarea {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.pill,
.status-dot,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pill.muted {
  background: var(--ink-soft);
  color: var(--ink);
}

.pill.secure {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.pill.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-dot {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
}

.status-dot.running {
  border-color: var(--info);
  background: var(--info-soft);
  color: var(--info);
}

.status-dot.done {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.status-dot.error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.neutral {
  background: var(--panel-strong);
  color: var(--muted);
}

.badge.success {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.failed {
  background: var(--success-soft);
  color: var(--success);
}

.badge.inconclusive {
  background: var(--warning-soft);
  color: var(--warning);
}

.verdict-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0;
}

.verdict-grid > div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.verdict-grid .wide {
  grid-column: 1 / -1;
}

dd {
  margin: 7px 0 0;
  line-height: 1.43;
  overflow-wrap: anywhere;
}

.log-panel {
  min-height: 360px;
}

.log-list {
  display: grid;
  align-content: start;
  gap: 8px;
  height: 306px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-list li {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--text);
  line-height: 1.35;
}

.log-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-message {
  overflow-wrap: anywhere;
}

.log-message strong {
  color: var(--accent-strong);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.3fr);
  }

  .side-stack {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .run-meta {
    justify-content: flex-start;
  }

  .workspace,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-column: auto;
  }

  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .provider-card,
  .security-strip,
  .model-card,
  .run-guide {
    align-items: flex-start;
    flex-direction: column;
  }

  .strategy-pill {
    max-width: 100%;
  }

  .step-rail {
    grid-template-columns: repeat(2, 1fr);
  }

  .button-row {
    justify-content: flex-start;
  }

  .run-progress {
    align-items: flex-start;
  }

  .prompt-field textarea,
  .response-field textarea {
    min-height: 180px;
  }

  .verdict-grid {
    grid-template-columns: 1fr;
  }

  .log-list li {
    grid-template-columns: 1fr;
  }
}
