:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #637083;
  --line: #d9e1ec;
  --accent: #1e6bff;
  --accent-dark: #124dcc;
  --success: #0f8a5f;
  --warning: #b7791f;
  --danger: #ba2d3f;
  --shadow: 0 16px 45px rgba(24, 39, 75, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  min-height: 112px;
  padding: 28px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.app-header h1,
.panel h2,
.job-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 30px;
  line-height: 1.1;
}

.app-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.ghost-link,
.actions a,
.link-button {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.layout {
  width: min(1420px, calc(100vw - 48px));
  margin: 32px auto;
  display: grid;
  grid-template-columns: minmax(460px, 560px) 1fr;
  gap: 24px;
  align-items: start;
}

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

.panel {
  padding: 24px;
}

.panel h2 {
  font-size: 20px;
  margin-bottom: 18px;
}

.preset-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid #c9defc;
  border-radius: 8px;
  background: #eef6ff;
}

.preset-card b {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.preset-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.form-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: -8px -8px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7f9fc;
}

.tab-button {
  border-radius: 0;
  background: transparent;
  color: #233044;
  font-weight: 800;
}

.tab-button:hover,
.tab-button.active {
  background: #151126;
  color: #ffffff;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c8d2df;
  border-radius: 7px;
  padding: 11px 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 107, 255, 0.12);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compact-field {
  width: min(100%, 240px);
}

.checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.check-label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: #344054;
  font-weight: 700;
}

.check-label input {
  width: auto;
  margin: 0;
}

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

.inline-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.compact-button {
  height: 41px;
  padding-inline: 18px;
}

.form-section {
  display: grid;
  gap: 12px;
  padding-top: 8px;
}

.form-section h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: 0;
}

.form-section p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.prompt-preview-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.prompt-preview-panel h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.prompt-preview-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.prompt-preview-code {
  display: block;
  min-height: 360px;
  max-height: 520px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 7px;
  border: 1px solid #1f2937;
  background: #101828;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-text-fill-color: #f8fafc;
}

.prompt-preview-code:focus {
  border-color: #6ea8ff;
  box-shadow: 0 0 0 3px rgba(30, 107, 255, 0.18);
}

.section-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}

.switch {
  display: inline-flex;
  width: 58px;
  height: 28px;
  padding: 0;
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  display: block;
  width: 58px;
  height: 28px;
  border: 1px solid #abb8ca;
  border-radius: 999px;
  background: #ffffff;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 2px;
  left: 3px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #98a4b8;
  box-shadow: 0 1px 4px rgba(23, 32, 51, 0.18);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
}

.switch input:checked + span::before {
  transform: translateX(28px);
  border-color: #ffffff;
}

.name-replacements {
  display: grid;
  gap: 10px;
}

.name-replacements.is-disabled {
  opacity: 0.55;
}

.name-pair {
  display: grid;
  grid-template-columns: 1fr 24px 1fr;
  gap: 10px;
  align-items: end;
}

.arrow {
  display: grid;
  place-items: center;
  height: 41px;
  color: var(--muted);
  font-weight: 900;
}

input:disabled,
textarea:disabled,
select:disabled {
  background: #f3f6fb;
  color: #98a4b8;
  cursor: not-allowed;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 12px 16px;
  background: linear-gradient(90deg, #1e6bff, #9b35f4);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: linear-gradient(90deg, var(--accent-dark), #7c20d8);
}

button.secondary {
  background: #e8eef7;
  color: #233044;
}

button.secondary:hover {
  background: #dce5f2;
}

button.link-button {
  border-radius: 4px;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
}

button.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
}

button.link-button:disabled {
  color: var(--muted);
  cursor: progress;
}

.section-head,
.job-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.jobs-list {
  display: grid;
  gap: 14px;
}

.job-card {
  padding: 18px;
  box-shadow: none;
}

.job-card h3 {
  font-size: 16px;
}

.job-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.job-card .cost-line {
  color: #344054;
  font-weight: 700;
}

.status {
  border-radius: 999px;
  background: #eef4ff;
  color: #2451a6;
  padding: 6px 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef4ff;
  color: #2451a6;
  font-size: 12px;
  font-weight: 800;
}

.mode-pill.localize {
  background: #e8f8f1;
  color: var(--success);
}

.mode-pill.analysis {
  background: #fff5df;
  color: var(--warning);
}

.job-card.completed .status {
  background: #e8f8f1;
  color: var(--success);
}

.job-card.failed .status {
  background: #fdecef;
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.metrics span {
  border-radius: 7px;
  background: #f3f6fb;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.metrics b {
  display: block;
  color: var(--text);
  font-size: 18px;
  margin-bottom: 2px;
}

.actions {
  margin-top: 14px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.muted,
.empty {
  color: var(--muted);
}

.error {
  color: var(--danger) !important;
}

@media (max-width: 860px) {
  .app-header {
    padding: 22px;
    display: block;
  }

  .layout {
    width: calc(100vw - 28px);
    margin: 20px auto;
    grid-template-columns: 1fr;
  }

  .grid-2,
  .metrics,
  .name-pair,
  .inline-action,
  .preset-card {
    grid-template-columns: 1fr;
  }

  .arrow {
    height: auto;
  }

  .form-tabs {
    margin-inline: 0;
  }
}
