:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657087;
  --line: #dce3ec;
  --primary: #3157d5;
  --primary-dark: #2444ad;
  --primary-soft: #edf1ff;
  --success: #117a55;
  --success-soft: #eaf8f2;
  --warning: #8a4a00;
  --warning-soft: #fff5e8;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 45px rgba(26, 43, 74, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

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

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: none;
  margin: 0;
  padding: 14px max(16px, calc((100vw - 1480px) / 2 + 32px));
  border-bottom: 1px solid rgba(125, 149, 192, 0.22);
  background: #101827;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.16);
  color: #fff;
}

.topbar > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.subtitle {
  max-width: 780px;
  margin-bottom: 0;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.version {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 999px;
  background: rgba(49, 87, 213, 0.22);
  color: #bfdbfe;
  font-size: 0.78rem;
  font-weight: 800;
}

.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 24px;
  align-items: start;
}

#builder-form {
  display: grid;
  gap: 24px;
}

.card {
  min-width: 0;
  padding: 24px;
  border: 1px solid rgba(220, 227, 236, 0.9);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.output-card {
  position: sticky;
  top: 22px;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.card-heading > div:first-child {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.step {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  margin: 0;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 850;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 20px;
  padding: 5px;
  border-radius: 14px;
  background: #eef2f7;
}

.segment {
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.segment.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(32, 51, 84, 0.08);
}

.scenario-groups {
  display: grid;
  gap: 18px;
}

.scenario-group {
  display: grid;
  gap: 10px;
}

.scenario-group h3 {
  margin: 0;
  color: #2c374b;
  font-size: 0.94rem;
}

.scenario-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scenario-option {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: #33415c;
  font-weight: 720;
  overflow-wrap: anywhere;
  text-align: left;
}

.scenario-option.active {
  border-color: rgba(49, 87, 213, 0.65);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.1);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.field-grid:first-child {
  margin-top: 0;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

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

.field > span {
  color: #2c374b;
  font-size: 0.9rem;
  font-weight: 740;
}

.field b {
  color: var(--danger);
}

.field small {
  color: var(--muted);
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: #fbfcfe;
  color: var(--text);
  padding: 11px 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(49, 87, 213, 0.12);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.hidden {
  display: none !important;
}

.form-error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #f1bbb4;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 650;
}

.output-wrap {
  min-height: 230px;
  overflow: auto;
  border: 1px solid #1e293b;
  border-radius: 14px;
  background: #111827;
}

pre {
  max-width: 100%;
  min-width: 100%;
  min-height: 230px;
  margin: 0;
  padding: 18px;
  color: #dbeafe;
  font: 0.9rem/1.65 "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.button {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 760;
  overflow-wrap: anywhere;
  white-space: normal;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.button-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover {
  border-color: #b8c3d2;
  background: #f7f9fc;
}

.button-ghost {
  min-height: 38px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
}

.switch-row {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: normal;
}

.switch-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.switch-row-card {
  align-self: end;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  color: #2c374b;
}

.status {
  min-height: 21px;
  margin: 10px 0 0;
  color: var(--success);
  font-size: 0.86rem;
  font-weight: 700;
}

.clipboard-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

summary {
  cursor: pointer;
  color: #33415c;
  font-weight: 750;
}

.details-content {
  padding-top: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.details-content p:last-child {
  margin-bottom: 0;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 32px 28px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .output-card {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar,
  .layout,
  footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  h1 {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.86rem;
  }

  .field-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .card {
    padding: 18px;
  }

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

  footer {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .topbar {
    flex-direction: column;
    padding-bottom: 20px;
  }

  h1 {
    font-size: 1.25rem;
    line-height: 1.1;
  }

  h2 {
    font-size: 1rem;
  }

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

  .scenario-options {
    grid-template-columns: 1fr;
  }

  .output-wrap,
  pre {
    min-height: 180px;
  }
}

@media (max-width: 380px) {
  .topbar,
  .layout,
  footer {
    padding-left: 10px;
    padding-right: 10px;
  }

  .card {
    padding: 14px;
  }

  .step {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }
}
