:root {
  --page: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #eef6f3;
  --ink: #1d2730;
  --muted: #61707a;
  --line: #d7dfdd;
  --line-strong: #b8c7c3;
  --teal: #008c86;
  --teal-dark: #006c67;
  --coral: #d15c4a;
  --gold: #b88400;
  --indigo: #293a73;
  --green: #34785d;
  --danger: #b53b36;
  --shadow: 0 18px 44px rgba(38, 52, 58, 0.12);
  --heading: "Nunito Sans", "Atkinson Hyperlegible", Arial, sans-serif;
  --body: "Atkinson Hyperlegible", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(0, 140, 134, 0.08), rgba(247, 248, 246, 0) 330px),
    var(--page);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
}

a {
  color: var(--teal-dark);
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

button {
  cursor: pointer;
}

.skip-link {
  background: var(--ink);
  color: #fff;
  left: 1rem;
  padding: 0.65rem 0.9rem;
  position: absolute;
  top: -4rem;
  z-index: 50;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  margin: 0 auto;
  width: min(1160px, calc(100% - 32px));
}

.container.narrow {
  width: min(860px, calc(100% - 32px));
}

.site-header {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(184, 199, 195, 0.7);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  min-height: 66px;
  width: min(1160px, calc(100% - 32px));
}

.brand-mark {
  color: var(--ink);
  display: grid;
  font-family: var(--heading);
  font-weight: 900;
  line-height: 0.92;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark span {
  color: var(--teal-dark);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
}

.brand-mark strong {
  color: var(--indigo);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: flex-end;
}

.nav-links a {
  color: #39454d;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus,
.nav-links a[aria-current="page"] {
  color: var(--teal-dark);
}

.nav-toggle {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  display: none;
  font-weight: 800;
  min-height: 38px;
  padding: 0.45rem 0.7rem;
}

.hero {
  padding: 72px 0 38px;
}

.hero-grid {
  align-items: center;
  display: grid;
  gap: 38px;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
}

h1,
h2,
h3,
legend {
  font-family: var(--heading);
  letter-spacing: 0;
}

h1 {
  color: var(--ink);
  font-size: clamp(2.75rem, 7vw, 6.2rem);
  line-height: 0.94;
  margin: 0;
  max-width: 820px;
}

.page-hero h1 {
  font-size: clamp(2.25rem, 5.2vw, 4.8rem);
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.4rem);
  line-height: 1.05;
  margin: 0 0 0.8rem;
}

h3 {
  font-size: 1.12rem;
  line-height: 1.2;
  margin: 0 0 0.4rem;
}

p {
  margin: 0 0 1rem;
}

.hero-lede {
  color: #40515a;
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  margin-top: 1.2rem;
  max-width: 720px;
}

.hero-actions,
.builder-actions,
.output-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 44px;
  padding: 0.68rem 0.95rem;
  text-decoration: none;
}

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

.button.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button.danger {
  background: #fff5f2;
  border-color: rgba(181, 59, 54, 0.34);
  color: var(--danger);
}

.button:hover,
.button:focus {
  transform: translateY(-1px);
}

.preview-panel,
.output-panel,
.form-shell,
.export-tools {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-panel {
  overflow: hidden;
}

.preview-toolbar {
  align-items: center;
  background: var(--ink);
  color: #fff;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.8rem 0.95rem;
}

.preview-toolbar span {
  font-size: 0.9rem;
}

.preview-toolbar strong {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #f7d574;
  font-size: 0.78rem;
  padding: 0.24rem 0.48rem;
  text-transform: uppercase;
}

.preview-panel pre {
  color: #243239;
  font-size: clamp(0.78rem, 1.7vw, 0.98rem);
  line-height: 1.45;
  margin: 0;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

.signal-band {
  padding: 12px 0 44px;
}

.signal-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signal-grid article,
.network-link,
.path-list a,
.export-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.signal-grid article:nth-child(2) {
  border-top: 4px solid var(--coral);
}

.signal-grid article:nth-child(3) {
  border-top: 4px solid var(--gold);
}

.signal-grid article:first-child {
  border-top: 4px solid var(--teal);
}

.signal-grid p,
.network-link span,
.section-heading p,
.field-hint,
.small-note {
  color: var(--muted);
}

.section {
  padding: 52px 0;
}

.split {
  align-items: start;
  display: grid;
  gap: 32px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.7fr);
}

.path-list {
  display: grid;
  gap: 10px;
}

.path-list a {
  align-items: center;
  color: var(--ink);
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 46px 1fr;
  text-decoration: none;
}

.path-list span {
  align-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--teal-dark);
  display: inline-flex;
  font-weight: 900;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.network-section {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}

.section-heading {
  align-items: end;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 0.75fr) minmax(280px, 1fr);
  margin-bottom: 22px;
}

.network-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.network-link {
  color: var(--ink);
  display: grid;
  min-height: 150px;
  text-decoration: none;
}

.network-link strong {
  color: var(--indigo);
  font-family: var(--heading);
  font-size: 1.2rem;
}

.page-hero {
  padding: 58px 0 18px;
}

.builder-layout {
  align-items: start;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.72fr);
}

.export-layout {
  align-items: start;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1fr);
}

.form-shell,
.export-tools {
  padding: 1rem;
}

.boundary-note {
  align-items: start;
  background: #eef6f3;
  border: 1px solid #c6dfd7;
  border-left: 6px solid var(--teal);
  border-radius: 8px;
  display: grid;
  gap: 0.2rem;
  margin-bottom: 1rem;
  padding: 0.85rem 0.95rem;
}

.boundary-note strong {
  color: var(--teal-dark);
  font-family: var(--heading);
}

.boundary-note span {
  color: #40515a;
}

.boundary-note.clinical {
  background: #fff9ea;
  border-color: #eadaa9;
  border-left-color: var(--gold);
}

.boundary-note.clinical strong {
  color: #7a5600;
}

.boundary-note.tender {
  background: #fff7f0;
  border-color: #efc9b5;
  border-left-color: #c86f53;
}

.boundary-note.tender strong {
  color: #8d412c;
}

.builder-form {
  display: grid;
  gap: 1rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 1rem;
}

legend {
  color: var(--indigo);
  font-size: 1.12rem;
  font-weight: 900;
  padding: 0 0.4rem;
}

.field {
  display: grid;
  gap: 0.38rem;
  margin-top: 0.9rem;
}

.field label,
.field-label {
  color: #26343b;
  font-weight: 900;
}

.field-hint {
  font-size: 0.9rem;
  margin: 0;
}

input[type="text"],
input[type="email"],
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 0.68rem 0.75rem;
  width: 100%;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(0, 140, 134, 0.26);
  outline-offset: 2px;
}

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

.option-grid label,
.single-check {
  align-items: start;
  background: #fafcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.72rem;
}

.option-grid input,
.single-check input {
  flex: 0 0 auto;
  margin-top: 0.25rem;
}

.output-panel {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  position: sticky;
  top: 84px;
}

.output-panel.wide {
  min-width: 0;
}

.output-panel label {
  color: var(--indigo);
  font-weight: 900;
}

.markdown-output {
  background: #172126;
  border-color: #172126;
  color: #e8f3ef;
  font-size: 0.86rem;
  line-height: 1.5;
  min-height: 540px;
  resize: vertical;
}

.pack-output {
  min-height: 680px;
}

.status {
  color: var(--green);
  font-weight: 900;
  min-height: 1.3em;
}

.export-list {
  display: grid;
  gap: 0.8rem;
  margin: 1rem 0;
}

.export-item {
  display: grid;
  gap: 0.25rem;
}

.export-item strong {
  color: var(--indigo);
  font-family: var(--heading);
}

.export-item span {
  color: var(--muted);
}

.export-item a {
  font-weight: 900;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
}

.footer-grid {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.footer-grid p {
  margin: 0;
}

.footer-grid a {
  font-weight: 900;
}

@media (max-width: 920px) {
  .nav {
    align-items: start;
    min-height: 58px;
    padding: 0.6rem 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: none;
    left: 16px;
    padding: 0.8rem;
    position: absolute;
    right: 16px;
    top: 64px;
  }

  .nav-links.is-open {
    display: grid;
  }

  .hero-grid,
  .split,
  .builder-layout,
  .export-layout,
  .section-heading {
    grid-template-columns: 1fr;
  }

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

  .output-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .hero {
    padding-top: 48px;
  }

  .signal-grid,
  .network-grid,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .builder-actions {
    width: 100%;
  }

  .markdown-output {
    min-height: 360px;
  }
}
