:root {
  --ink: #172134;
  --muted: #667085;
  --navy: #20324f;
  --navy-deep: #14233b;
  --teal: #197c79;
  --teal-dark: #126461;
  --teal-soft: #e8f5f3;
  --gold: #e3ae50;
  --coral: #d86953;
  --paper: #ffffff;
  --canvas: #f3f1ec;
  --line: #d9dedf;
  --line-dark: #bdc7c9;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --shadow: 0 18px 50px rgba(24, 33, 48, 0.1);
  --radius: 8px;
  --sidebar-width: 304px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  padding: 30px 22px 24px;
  color: #fff;
  background:
    linear-gradient(165deg, var(--navy) 0%, var(--navy-deep) 76%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  color: var(--navy-deep);
  background: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #b8d7d5;
}

.progress-block {
  margin: 30px 0 20px;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}

.progress-copy strong {
  color: #f4ca7e;
  font-size: 16px;
}

.progress-track {
  height: 6px;
  margin: 10px 0 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #f1c979);
  transition: width 220ms ease;
}

.progress-block p {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
}

.step-nav {
  display: grid;
  gap: 4px;
}

.step-link {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.65);
  background: transparent;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    color 150ms ease,
    background 150ms ease;
}

.step-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.step-link > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.step-link strong,
.step-link small {
  display: block;
}

.step-link strong {
  color: inherit;
  font-size: 13px;
}

.step-link small {
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 10px;
}

.step-link.is-complete > span {
  border-color: #6ec1bc;
  color: #fff;
  background: var(--teal);
}

.sidebar-note {
  margin-top: auto;
  padding: 22px 9px 0;
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
}

.sidebar-note strong {
  color: #f4ca7e;
  font-size: 12px;
}

.sidebar-note p {
  margin: 5px 0 0;
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 0 clamp(28px, 5vw, 76px) 42px;
}

.topbar {
  display: flex;
  min-height: 105px;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid rgba(23, 33, 52, 0.12);
}

.topbar h2 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(25px, 3vw, 35px);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.text-button,
.mini-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover,
.mini-button:hover {
  color: var(--teal);
}

#charterForm {
  max-width: 1180px;
  margin: 0 auto;
}

.charter-section {
  scroll-margin-top: 24px;
  padding: 58px 0 44px;
  border-bottom: 1px solid rgba(23, 33, 52, 0.13);
}

.charter-section:first-child {
  padding-top: 48px;
}

.charter-section:last-child {
  border-bottom: 0;
}

.section-intro {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(270px, 0.8fr);
  gap: 48px;
  align-items: end;
  margin-bottom: 36px;
}

.section-intro > div {
  position: relative;
  min-width: 0;
  padding-left: 61px;
}

.section-number {
  position: absolute;
  top: -13px;
  left: 0;
  color: rgba(32, 50, 79, 0.12);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 51px;
  font-weight: 700;
  line-height: 1;
}

.section-intro h3 {
  max-width: 650px;
  margin: 6px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 4vw, 43px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.04;
  overflow-wrap: break-word;
}

.section-intro > p {
  max-width: 520px;
  margin: 0;
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: break-word;
}

.form-grid {
  display: grid;
  gap: 20px;
}

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

.field {
  display: block;
  margin-bottom: 24px;
}

.field > span,
.field-heading span {
  display: block;
  margin-bottom: 8px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

.field em,
.field-heading em {
  margin-left: 5px;
  color: var(--teal);
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.field input,
.field select {
  height: 48px;
  padding: 0 14px;
}

.field textarea {
  min-height: 108px;
  padding: 13px 14px;
  line-height: 1.5;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--teal);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(25, 124, 121, 0.12);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #99a2ad;
}

.field > small,
.field-heading small,
.field-footer small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.field-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.char-count {
  flex: 0 0 auto;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}

.field-heading span {
  margin-bottom: 0;
}

.mini-button {
  flex: 0 0 auto;
  color: var(--teal);
}

.stack-list {
  display: grid;
  gap: 9px;
}

.stack-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.78);
}

.stack-row > span {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--teal);
  background: var(--teal-soft);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
}

.stack-row input {
  height: 46px;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #8b949f;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.button:active {
  transform: translateY(1px);
}

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

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

.button.secondary {
  border-color: var(--line-dark);
  color: var(--navy);
  background: rgba(255, 255, 255, 0.7);
}

.button.secondary:hover {
  border-color: var(--teal);
  background: #fff;
}

.button.compact {
  min-height: 38px;
  padding: 0 14px;
}

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

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

.timeline-card {
  display: grid;
  grid-template-columns: minmax(140px, 0.35fr) minmax(260px, 1fr) minmax(170px, 0.45fr) 34px;
  gap: 18px;
  align-items: start;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
}

.timeline-card .field {
  margin: 0;
}

.timeline-card textarea {
  min-height: 82px;
}

.timeline-remove-button {
  margin-top: 25px;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.38fr) minmax(500px, 0.82fr);
  gap: 30px;
  align-items: start;
}

.export-panel {
  position: sticky;
  top: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.panel-heading h4 {
  margin: 4px 0 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 500;
}

.panel-heading > p:last-child {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 12px;
}

.missing-items {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: #f1f3f4;
  font-size: 11px;
}

.missing-items.is-ready {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.missing-items.is-warning {
  color: var(--danger);
  background: var(--danger-soft);
}

.export-actions {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.preview-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preview-label small {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.preview-stack {
  display: grid;
  gap: 30px;
  min-width: 0;
}

.table-stand-preview-shell {
  overflow-x: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #e6e9e7;
  box-shadow: var(--shadow);
}

.table-stand-preview {
  display: grid;
  min-width: 620px;
  aspect-ratio: 11 / 8.5;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto auto auto;
  gap: clamp(8px, 1.2vw, 14px);
  overflow: hidden;
  padding: clamp(16px, 2.4vw, 28px);
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-family: Arial, sans-serif;
}

.stand-preview-hero {
  grid-column: 1 / -1;
  padding: clamp(13px, 2vw, 22px) clamp(16px, 2.4vw, 28px);
  border-radius: 8px;
  color: #fff;
  background: var(--navy);
}

.stand-preview-hero p {
  margin: 0 0 4px;
  color: #b8d7d5;
  font-size: clamp(7px, 0.8vw, 9px);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stand-preview-hero h4 {
  margin: 0;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(23px, 3.6vw, 36px);
  font-weight: 500;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stand-preview-card {
  overflow: hidden;
  padding: clamp(10px, 1.6vw, 17px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.stand-preview-purpose {
  grid-column: span 2;
  background: var(--teal-soft);
}

.stand-preview-label {
  margin: 0 0 7px;
  color: var(--teal-dark);
  font-size: clamp(7px, 0.75vw, 8px);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stand-preview-card h5 {
  margin: 0;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 500;
  line-height: 1.14;
  overflow-wrap: anywhere;
}

.stand-preview-card ul,
.stand-preview-card ol {
  margin: 0;
  padding-left: 17px;
}

.stand-preview-card > p:not(.stand-preview-label) {
  margin: 0;
  font-size: clamp(10px, 1.2vw, 13px);
  line-height: 1.36;
  overflow-wrap: anywhere;
}

.stand-preview-card li {
  margin-bottom: 4px;
  font-size: clamp(9px, 1.1vw, 12px);
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.stand-preview-card span span,
.stand-preview-card h5 span,
.stand-preview-card li span {
  color: #8a939d;
  font-style: italic;
  font-weight: normal;
}

.stand-preview-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: clamp(7px, 0.9vw, 9px);
}

.charter-document {
  min-height: 900px;
  padding: clamp(38px, 6vw, 72px);
  color: #1f2937;
  background: #fff;
  box-shadow: var(--shadow);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1.45;
}

.doc-header {
  padding-bottom: 26px;
  border-bottom: 3px double var(--navy);
  text-align: center;
}

.doc-header .doc-course {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.doc-header h1 {
  margin: 0;
  color: var(--navy);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
}

.doc-slogan {
  margin: 8px 0 0;
  color: var(--muted);
  font-style: italic;
}

.doc-section {
  margin-top: 27px;
}

.doc-section h2 {
  margin: 0 0 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ccd3d8;
  color: var(--teal-dark);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.doc-section h3 {
  margin: 15px 0 4px;
  color: var(--navy);
  font-size: 13px;
}

.doc-section p {
  margin: 0 0 8px;
}

.doc-placeholder {
  color: #99a2ad;
  font-style: italic;
}

.doc-list {
  margin: 6px 0 0;
  padding-left: 19px;
}

.doc-list li {
  margin-bottom: 4px;
}

.doc-table {
  width: 100%;
  margin: 9px 0 15px;
  border-collapse: collapse;
  table-layout: fixed;
}

.doc-table th,
.doc-table td {
  padding: 7px 8px;
  border: 1px solid #bac4ca;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.doc-table th {
  color: var(--navy);
  background: #eef4f4;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.doc-table td {
  font-size: 10px;
}

.doc-footer {
  margin-top: 34px;
  padding-top: 9px;
  border-top: 1px solid #ccd3d8;
  color: var(--muted);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 8px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 12px 30px rgba(20, 35, 59, 0.25);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 238px;
  }

  .sidebar {
    padding-inline: 15px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .step-link {
    grid-template-columns: 28px 1fr;
    padding-inline: 8px;
  }

  .main {
    padding-inline: 30px;
  }

  .section-intro,
  .review-layout {
    grid-template-columns: 1fr;
  }

  .timeline-card {
    grid-template-columns: 1fr;
  }

  .export-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: static;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 18px;
  }

  .progress-block {
    margin: 18px 0 13px;
  }

  .step-nav {
    display: flex;
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    gap: 0;
  }

  .step-link {
    display: block;
    width: 34px;
    min-width: 0;
    flex: 0 0 34px;
    padding: 6px 0;
    text-align: center;
  }

  .step-link > span {
    margin: 0 auto;
  }

  .step-link div,
  .sidebar-note {
    display: none;
  }

  .main {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 0 18px 28px;
  }

  #charterForm,
  .topbar,
  .charter-section,
  .section-intro,
  .section-intro > div,
  .section-intro > p,
  .field,
  .stack-list,
  .timeline-list {
    max-width: 100%;
  }

  .topbar {
    min-height: 88px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .section-intro {
    gap: 18px;
    margin-bottom: 26px;
  }

  .section-intro > div {
    padding-left: 0;
  }

  .section-number {
    position: static;
    display: block;
    margin-bottom: -10px;
    font-size: 42px;
  }

  .section-intro h3 {
    width: 100%;
    max-width: 100%;
    font-size: clamp(28px, 8vw, 31px);
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .timeline-remove-button {
    margin-top: 0;
  }

  .review-layout {
    display: block;
  }

  .preview-wrap {
    margin-top: 28px;
  }

  .charter-document {
    padding: 30px 22px;
  }
}

@media print {
  @page {
    size: letter;
    margin: 0.55in;
  }

  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .section-intro,
  .export-panel,
  .table-stand-preview-wrap,
  .preview-label,
  .toast {
    display: none !important;
  }

  .app-shell,
  .main,
  #charterForm,
  .review-layout,
  .preview-wrap {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .table-stand-preview-wrap {
    display: none !important;
  }

  .charter-section:not(.review-step) {
    display: none !important;
  }

  .review-step {
    display: block !important;
    border: 0;
  }

  .charter-document {
    min-height: 0;
    padding: 0;
    box-shadow: none;
    font-size: 10pt;
  }

  .doc-section,
  .doc-table {
    break-inside: avoid;
  }

}
