:root {
  --navy-950: #101d32;
  --navy-900: #172b49;
  --navy-800: #213f68;
  --navy-700: #31577f;
  --gold-600: #b98a35;
  --gold-500: #cfaa5d;
  --gold-200: #ead7aa;
  --gold-100: #f5ecd8;
  --red-700: #8f202a;
  --red-600: #a72a35;
  --blue-100: #e8eef5;
  --blue-50: #f3f6f9;
  --ink: #20252b;
  --muted: #5c6672;
  --line: #d5dbe2;
  --surface: #ffffff;
  --canvas: #f2f3f4;
  --success: #2d6b4f;
  --warning: #8d5f17;
  --danger: #a12b35;
  --shadow: 0 24px 70px rgba(16, 29, 50, 0.12);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(49, 87, 127, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

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

button,
a,
input,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: -9999px;
  z-index: 1000;
  padding: 0.65rem 0.9rem;
  background: #fff;
  color: var(--navy-900);
  border: 2px solid var(--navy-900);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 0.75rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 0.65rem clamp(1rem, 3vw, 2.5rem);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 50px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(145deg, #ece9e1, #cfcac1);
  border: 1px solid #d6d0c5;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-kicker,
.brand-title {
  margin: 0;
}

.brand-kicker {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-title {
  color: var(--navy-900);
  font-size: 1.18rem;
  font-weight: 750;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-status {
  color: var(--success);
  font-size: 0.82rem;
}

.text-button,
.exit-link {
  border: 0;
  background: transparent;
  color: var(--navy-800);
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}

.text-button:hover,
.exit-link:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 2rem);
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.stage-panel {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 1.4rem;
  background: var(--navy-950);
  color: #fff;
  border-top: 4px solid var(--gold-500);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stage-panel .eyebrow {
  color: var(--gold-500);
}

.stage-panel-heading h1,
.stage-panel-heading p {
  margin-top: 0;
}

.stage-panel-heading h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.12;
}

.stage-panel-heading p:last-child {
  margin-bottom: 1.2rem;
  color: #dce5ef;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--gold-600);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stage-nav ol {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-nav li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem;
  color: #bdc9d7;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.stage-nav li.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(207, 170, 93, 0.55);
}

.stage-nav li.is-complete {
  color: #e6edf5;
}

.stage-nav li.is-complete .stage-number {
  background: var(--gold-500);
  color: var(--navy-950);
}

.stage-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  font-weight: 800;
}

.stage-nav strong,
.stage-nav small {
  display: block;
}

.stage-nav small {
  margin-top: 0.05rem;
  color: inherit;
  opacity: 0.78;
}

.stage-note {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.2rem;
  padding: 0.9rem;
  color: #e5eaf1;
  background: rgba(207, 170, 93, 0.1);
  border-left: 3px solid var(--gold-500);
  border-radius: 6px;
  font-size: 0.86rem;
}

.main-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mobile-progress {
  display: none;
}

#prototypeForm {
  min-height: 720px;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: clamp(1.35rem, 4vw, 3.2rem);
  animation: screen-in 180ms ease-out;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen[hidden] {
  display: none !important;
}

.screen h2 {
  margin: 0;
  color: var(--navy-900);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.1;
  max-width: 850px;
}

.step-label {
  margin: 0 0 0.45rem;
  color: var(--red-700);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.screen-intro,
.lead {
  max-width: 780px;
  color: var(--muted);
}

.screen-intro {
  margin: 0.7rem 0 1.7rem;
  font-size: 1.02rem;
}

.lead {
  font-size: 1.16rem;
  line-height: 1.55;
}

.welcome-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.7fr);
  align-items: center;
  gap: 1.5rem;
}

.welcome-logo {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 1rem;
  background: radial-gradient(circle at center, #eee9df 0, #dedbd5 55%, #c9c5be 100%);
  border: 1px solid #d7d1c7;
  border-radius: 18px;
}

.welcome-logo img {
  width: min(100%, 390px);
  height: auto;
}

.outcome-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 2rem 0 1.2rem;
}

.outcome-grid article {
  min-height: 165px;
  padding: 1rem;
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy-800);
  border-radius: var(--radius-md);
}

.outcome-grid article span {
  color: var(--red-700);
  font-weight: 850;
}

.outcome-grid h3 {
  margin: 0.45rem 0 0.4rem;
  color: var(--navy-900);
}

.outcome-grid p {
  margin: 0;
  color: var(--muted);
}

.boundary-box,
.prompt-banner,
.resume-notice {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
}

.boundary-box {
  background: var(--gold-100);
  border: 1px solid var(--gold-500);
}

.boundary-box p {
  margin: 0.3rem 0 0;
}

.boundary-box.compact {
  margin-top: 1.25rem;
}

.prompt-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  margin-bottom: 1.25rem;
  background: var(--blue-100);
  border-left: 4px solid var(--navy-800);
}

.resume-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
  background: #edf6f1;
  border: 1px solid #b7d8c6;
}

.resume-notice div {
  display: grid;
}

.form-grid {
  display: grid;
  gap: 1.1rem;
}

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

.full-width {
  grid-column: 1 / -1;
}

.field,
.choice-field {
  min-width: 0;
}

.field label,
.choice-field legend {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--navy-900);
  font-weight: 750;
}

.choice-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-help {
  margin: -0.1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="text"],
textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #bfc7d1;
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input[type="text"] {
  min-height: 46px;
  padding: 0.7rem 0.8rem;
}

textarea {
  min-height: 96px;
  padding: 0.75rem 0.8rem;
  line-height: 1.45;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--navy-700);
  box-shadow: var(--focus);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fff8f8;
}

.character-count {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.choice-field:not(.horizontal-choices):not(.risk-grid):not(.artifact-grid) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 0.65rem;
}

.choice-field:not(.horizontal-choices):not(.risk-grid):not(.artifact-grid) legend,
.choice-field:not(.horizontal-choices):not(.risk-grid):not(.artifact-grid) .field-help {
  grid-column: 1 / -1;
}

.horizontal-choices,
.risk-grid,
.artifact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.horizontal-choices legend,
.horizontal-choices .field-help,
.risk-grid legend,
.artifact-grid legend {
  width: 100%;
}

.risk-grid .choice-card,
.artifact-grid .choice-card {
  flex: 1 1 210px;
}

.choice-card {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  min-height: 48px;
  margin: 0 !important;
  padding: 0.7rem 0.8rem;
  color: var(--ink) !important;
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600 !important;
}

.choice-card:hover {
  border-color: var(--navy-700);
}

.choice-card:has(input:checked) {
  color: var(--navy-950) !important;
  background: var(--gold-100);
  border-color: var(--gold-600);
}

.choice-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--red-700);
}

.conditional-field {
  margin-top: 0.9rem;
}

.promise-field {
  margin-bottom: 1.2rem;
}

.feature-list {
  overflow: hidden;
  margin: 1rem 0 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.feature-list-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1rem;
  background: var(--navy-900);
  color: #fff;
}

.feature-list-heading h3,
.feature-list-heading p {
  margin: 0;
}

.feature-list-heading p {
  margin-top: 0.15rem;
  color: #d9e2ec;
  font-size: 0.86rem;
}

.limit-badge {
  padding: 0.28rem 0.65rem;
  color: var(--navy-950);
  background: var(--gold-500);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.feature-row {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--line);
}

.optional {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.saved-ideas-field {
  padding: 1rem;
  background: var(--gold-100);
  border: 1px solid var(--gold-500);
  border-radius: var(--radius-md);
}

.decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.decision-card {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-top-width: 4px;
  border-radius: var(--radius-md);
}

.decision-card.continue { border-top-color: #397353; }
.decision-card.revise { border-top-color: var(--gold-600); }
.decision-card.narrow { border-top-color: #5b6680; }
.decision-card.stop { border-top-color: var(--red-700); }

.acknowledgment,
.connection-check label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem;
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.acknowledgment input,
.connection-check input {
  width: 19px;
  height: 19px;
  margin-top: 0.12rem;
  accent-color: var(--red-700);
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.2rem;
}

.review-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.85rem;
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-top: 4px solid var(--navy-800);
  border-radius: var(--radius-md);
}

.review-card h3 {
  margin: 0 0 0.5rem;
  color: var(--navy-900);
  font-size: 1rem;
}

.review-card p {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.87rem;
  overflow-wrap: anywhere;
}

.review-card button {
  margin-top: auto;
  align-self: flex-start;
}

.connection-check {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 1rem;
  background: var(--gold-100);
  border: 1px solid var(--gold-500);
  border-radius: var(--radius-md);
}

.connection-check legend {
  padding: 0 0.25rem;
  color: var(--navy-900);
  font-weight: 800;
}

.connection-check label {
  background: rgba(255, 255, 255, 0.72);
}

.summary-output {
  display: grid;
  gap: 1rem;
}

.summary-hero {
  padding: 1.1rem;
  color: #fff;
  background: var(--navy-900);
  border-top: 4px solid var(--gold-500);
  border-radius: var(--radius-md);
}

.summary-hero h3,
.summary-hero p {
  margin: 0;
}

.summary-hero p {
  margin-top: 0.35rem;
  color: #dce5ef;
}

.summary-section {
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.summary-section h3 {
  margin: 0 0 0.7rem;
  color: var(--navy-900);
}

.summary-section dl {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(0, 1fr);
  gap: 0.45rem 0.8rem;
  margin: 0;
}

.summary-section dt {
  color: var(--navy-800);
  font-weight: 750;
}

.summary-section dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.summary-section ul {
  margin: 0;
  padding-left: 1.2rem;
}

.after-test-panel {
  margin-top: 1rem;
  background: var(--blue-50);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.after-test-panel summary {
  padding: 0.9rem 1rem;
  color: var(--navy-900);
  cursor: pointer;
  font-weight: 750;
}

.after-test-content {
  display: grid;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.summary-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
}

.error-summary {
  margin: 1rem clamp(1.35rem, 4vw, 3.2rem) 0;
  padding: 0.9rem 1rem;
  color: #7c1e28;
  background: #fff1f2;
  border: 1px solid #e7aab0;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
}

.error-summary ul {
  margin: 0.4rem 0 0;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(110px, 0.3fr) minmax(120px, 1fr) minmax(110px, 0.3fr);
  align-items: center;
  gap: 0.8rem;
  padding: 1rem clamp(1.35rem, 4vw, 3.2rem);
  background: #fafbfc;
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button,
.edit-button {
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  padding: 0.7rem 1.15rem;
  color: #fff;
  background: var(--red-700);
  border: 1px solid var(--red-700);
}

.primary-button:hover {
  background: #7f1922;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  padding: 0.7rem 1rem;
  color: var(--navy-900);
  background: #fff;
  border: 1px solid #9da9b7;
}

.secondary-button:hover:not(:disabled) {
  background: var(--blue-50);
}

.edit-button {
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  color: var(--navy-800);
  background: #fff;
  border: 1px solid #9da9b7;
  font-size: 0.82rem;
}

.screen-count {
  display: grid;
  justify-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.screen-count span:first-child {
  color: var(--navy-900);
  font-weight: 750;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 2.5rem 2rem;
  color: var(--muted);
  font-size: 0.83rem;
}

.site-footer p {
  margin: 0;
}

.noscript-message {
  position: fixed;
  inset: auto 1rem 1rem;
  z-index: 100;
  padding: 1rem;
  color: #fff;
  background: var(--danger);
  border-radius: var(--radius-md);
}

@media (max-width: 1120px) {
  .review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .site-header {
    position: static;
  }

  .save-status,
  .text-button {
    display: none;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .stage-panel {
    display: none;
  }

  .main-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-progress {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1rem;
    color: var(--navy-900);
    background: var(--blue-50);
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .mobile-progress-track {
    height: 6px;
    overflow: hidden;
    background: #d9e0e8;
    border-radius: 99px;
  }

  .mobile-progress-track span {
    display: block;
    width: 10%;
    height: 100%;
    background: var(--red-700);
    border-radius: inherit;
    transition: width 180ms ease;
  }

  .site-footer {
    display: grid;
    padding: 1rem;
  }
}

@media (max-width: 720px) {
  .site-header {
    align-items: flex-start;
  }

  .brand-kicker {
    display: none;
  }

  .brand-mark {
    width: 46px;
    height: 40px;
  }

  .exit-link {
    font-size: 0.86rem;
  }

  .screen {
    padding: 1.25rem 1rem 1.6rem;
  }

  .welcome-grid,
  .form-grid.two-column,
  .feature-row,
  .decision-grid,
  .summary-section dl {
    grid-template-columns: 1fr;
  }

  .welcome-logo {
    min-height: 160px;
  }

  .welcome-logo img {
    width: min(75%, 280px);
  }

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

  .outcome-grid article {
    min-height: 0;
  }

  .choice-field:not(.horizontal-choices):not(.risk-grid):not(.artifact-grid) {
    grid-template-columns: 1fr;
  }

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

  .review-card:last-child {
    grid-column: auto;
  }

  .form-actions {
    grid-template-columns: 1fr 1fr;
    padding: 0.85rem 1rem;
  }

  .screen-count {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  #backButton {
    grid-column: 1;
  }

  #nextButton {
    grid-column: 2;
  }

  .summary-actions {
    flex-direction: column;
  }

  .site-footer {
    padding-bottom: 1.5rem;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .stage-panel,
  .mobile-progress,
  .form-actions,
  .site-footer,
  .summary-actions,
  .after-test-panel,
  .error-summary {
    display: none !important;
  }

  .app-shell,
  .main-panel,
  #prototypeForm {
    display: block;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .screen {
    display: none !important;
  }

  .summary-screen {
    display: block !important;
    padding: 0;
  }

  .summary-output {
    gap: 0.65rem;
  }

  .summary-section,
  .summary-hero {
    break-inside: avoid;
  }
}
