:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #eef4f8;
  --ink: #17212b;
  --muted: #607080;
  --line: #d6e0e7;
  --brand: #1769aa;
  --brand-dark: #0b4979;
  --accent: #2b8a7e;
  --danger: #a23b3b;
  --shadow: 0 18px 50px rgba(20, 45, 70, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.app-header {
  background: #0d395f;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.step-kicker {
  margin: 0 0 6px;
  color: #5c7894;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #b8d7ef;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  line-height: 1.25;
}

.subtitle {
  max-width: 680px;
  margin-bottom: 0;
  color: #d7e7f4;
}

.header-actions,
.form-actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 40px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 18px;
}

.progress-card,
.safety-note,
.workspace,
.step-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-card {
  padding: 16px;
  margin-bottom: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-track {
  height: 9px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe8ef;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.step-list {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.step-button {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 9px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.step-button.active {
  border-color: var(--brand);
  background: #edf6fc;
  color: var(--brand-dark);
}

.step-button.complete .step-index {
  background: var(--accent);
  color: #fff;
}

.step-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e5edf3;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.step-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.safety-note {
  padding: 14px 16px;
  border-left: 5px solid #d0a84f;
  box-shadow: none;
}

.safety-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.workspace {
  padding: 0;
  overflow: hidden;
}

.step-panel,
.result-panel {
  display: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 28px;
}

.step-panel.active,
.result-panel.active {
  display: block;
}

.panel-heading {
  max-width: 780px;
  margin-bottom: 22px;
}

.panel-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 16px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.field span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.help-button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #9bb8cb;
  background: #eef6fb;
  color: var(--brand-dark);
  font-size: 0.82rem;
  line-height: 1;
}

.help-button:hover {
  background: #dceef8;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c8d6df;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

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

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

.checklist-box {
  display: grid;
  gap: 9px;
  padding: 16px;
  margin-top: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checklist-box label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checklist-box input {
  width: auto;
}

.scenario-grid {
  display: grid;
  gap: 14px;
}

.screen-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.screen-toolbar h3,
.screen-toolbar p {
  margin-bottom: 0;
}

.screen-toolbar p {
  margin-top: 4px;
  color: var(--muted);
}

.screens-container {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.screen-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.screen-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #f7fafc;
  border-bottom: 1px solid var(--line);
}

.screen-card-title {
  margin: 0;
  font-size: 1rem;
  color: var(--brand-dark);
}

.screen-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.screen-card-body {
  padding: 16px;
}

.remove-screen-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--danger);
  background: #fff;
  border: 1px solid #e0b9b9;
}

.remove-screen-button:hover {
  background: #fff4f4;
}

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

.form-actions {
  justify-content: space-between;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  background: #f7fafc;
}

button {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

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

.ghost-button {
  background: #fff;
  color: var(--brand-dark);
  border-color: #b9cfdd;
}

.ghost-button:hover {
  background: #edf6fc;
}

.danger-button {
  background: #fff;
  color: var(--danger);
  border-color: #e0b9b9;
}

.danger-button:hover {
  background: #fff4f4;
}

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

.hidden {
  display: none !important;
}

#resultText {
  min-height: 520px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(460px, calc(100% - 32px));
  padding: 12px 16px;
  background: #123b5c;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 28, 42, 0.48);
}

.help-dialog {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1.25rem;
}

.help-section {
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}

.help-section + .help-section {
  margin-top: 14px;
}

.help-section h3 {
  color: var(--brand-dark);
}

@media (max-width: 900px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .sidebar {
    position: static;
  }

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

@media (max-width: 620px) {
  .header-inner,
  .layout {
    width: min(100% - 20px, 1180px);
  }

  .step-list,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .screen-toolbar,
  .screen-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .screen-card-actions {
    justify-content: flex-start;
  }

  .step-panel,
  .result-panel {
    padding: 20px;
  }

  .form-actions {
    padding: 14px 20px;
  }
}

@media print {
  .app-header,
  .sidebar,
  .form-actions,
  .result-actions,
  .field span {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .layout,
  .workspace {
    display: block;
    width: 100%;
    margin: 0;
    box-shadow: none;
    border: 0;
  }

  .step-panel {
    display: none !important;
  }

  .result-panel {
    display: block !important;
    padding: 0;
  }

  #resultText {
    border: 0;
    min-height: auto;
  }
}
