:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --ink: #1e252b;
  --muted: #67727e;
  --border: #ddd8ce;
  --primary: #214e45;
  --primary-dark: #163a33;
  --accent: #9b7a35;
  --danger: #a33c32;
  --shadow: 0 18px 55px rgba(30, 37, 43, 0.1);
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--primary-dark);
  font-size: 20px;
  font-weight: 800;
}

.top-nav,
.row-actions,
.checks-inline {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page {
  margin: 0 auto;
  max-width: 1280px;
  padding: 32px 24px 56px;
}

.product-hero,
.page-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.product-hero {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.product-hero h1,
.page-title h1 {
  font-size: 38px;
  line-height: 1.08;
  margin: 0;
  max-width: 760px;
}

.hero-copy {
  color: var(--muted);
  font-size: 17px;
  margin: 12px 0 0;
  max-width: 720px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.panel,
.wizard-card,
.live-preview,
.document-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.panel-header h2,
.project-row h3,
.wizard-card h3,
.live-preview h3 {
  margin: 0;
}

.button {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 9px 16px;
  white-space: nowrap;
}

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

.button-secondary {
  background: #ffffff;
  color: var(--primary-dark);
}

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

.button-small {
  min-height: 34px;
  padding: 6px 12px;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-row {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.project-row p {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 6px 0 0;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 28px;
}

.empty-state p,
.step-copy {
  color: var(--muted);
}

.editor-shell {
  display: grid;
  gap: 22px;
  grid-template-columns: 300px minmax(0, 1fr);
  max-width: 1500px;
}

.wizard-sidebar {
  align-self: start;
  background: #172620;
  border-radius: 8px;
  color: #ffffff;
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding: 20px;
  position: sticky;
  top: 88px;
}

.back-link {
  color: #d5c89d;
  display: inline-block;
  font-weight: 700;
  margin-bottom: 18px;
}

.wizard-brand h1 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.wizard-brand span {
  color: #d8dfdc;
  font-size: 13px;
}

.step-nav {
  display: grid;
  gap: 7px;
  margin-top: 20px;
}

.step-group {
  color: #d5c89d;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-top: 10px;
  text-transform: uppercase;
}

.step-tab {
  align-items: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #e7ece9;
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 10px;
  grid-template-columns: 28px 1fr;
  padding: 9px;
  text-align: left;
}

.step-tab span {
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.step-tab strong {
  font-size: 13px;
}

.step-tab.active {
  background: #ffffff;
  color: var(--primary-dark);
}

.wizard-workspace {
  min-width: 0;
}

.editor-toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.editor-toolbar h2 {
  margin: 0;
}

.editor-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.82fr);
}

.wizard-card,
.live-preview {
  padding: 22px;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: grid;
  gap: 18px;
}

.wizard-actions {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 22px;
  padding-top: 18px;
}

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

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

.grid.compact {
  gap: 10px;
}

label,
fieldset {
  display: grid;
  gap: 8px;
}

label,
legend {
  color: #2d383f;
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #cfc8ba;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  max-width: 100%;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(155, 122, 53, 0.18);
}

.field-missing {
  border-color: var(--danger);
  outline: 3px solid rgba(163, 60, 50, 0.12);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.check {
  align-items: center;
  display: flex;
  font-weight: 500;
  gap: 10px;
}

.check input {
  min-height: auto;
  width: auto;
}

.founders-list {
  display: grid;
  gap: 12px;
}

.founder-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.founder-card-head,
.preview-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.preview-head {
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

#previewBadge {
  background: #ecf4ef;
  border: 1px solid #c8dfd0;
  border-radius: 999px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 10px;
}

.live-preview {
  max-height: calc(100vh - 116px);
  overflow: auto;
  position: sticky;
  top: 88px;
}

.document-preview {
  font-family: "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.62;
  padding: 48px;
}

.compact-preview {
  box-shadow: none;
  font-size: 14px;
  max-height: none;
  padding: 20px;
}

.print-layout {
  margin: 0 auto;
  max-width: 900px;
}

.document-preview h2 {
  font-size: 24px;
  margin: 0 0 28px;
  text-align: center;
  text-transform: uppercase;
}

.document-preview h3 {
  font-size: 18px;
  margin: 28px 0 12px;
  text-transform: uppercase;
}

.document-preview h4 {
  font-size: 17px;
  margin: 18px 0 8px;
}

.document-preview p {
  margin: 0 0 12px;
  text-align: justify;
  white-space: pre-wrap;
}

mark {
  background: #fff1a8;
  border-radius: 3px;
  color: #7a3b00;
  padding: 1px 3px;
}

.validation-bar {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7c2d12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
}

.validation-bar span {
  background: #ffedd5;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 9px;
}

.stats-strip {
  align-items: center;
  background: #eef4ef;
  border: 1px solid #cdded4;
  border-radius: 8px;
  color: #173e36;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
}

.stats-strip span {
  background: #ffffff;
  border: 1px solid #d8e4dc;
  border-radius: 999px;
  font-size: 13px;
  padding: 5px 10px;
}

.stats-strip strong {
  color: var(--primary-dark);
}

.compact-stats {
  margin-top: -6px;
}

.analysis-panel {
  background: #fffdf7;
  border: 1px solid #e4d7b5;
  border-left: 5px solid #9b7a35;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px;
}

.analysis-head h2 {
  margin: 0 0 6px;
}

.analysis-grid,
.analysis-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-grid span,
.analysis-mini span,
.analysis-mini strong {
  background: #ffffff;
  border: 1px solid #e2d8bf;
  border-radius: 999px;
  color: #173e36;
  font-size: 13px;
  padding: 6px 10px;
}

.analysis-grid strong {
  color: var(--primary-dark);
  font-size: 18px;
}

.analysis-mini {
  background: #fffdf7;
  border: 1px solid #e4d7b5;
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px;
}

.library-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.compact-library {
  max-height: 520px;
}

.library-option {
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto 1fr;
  padding: 12px;
}

.library-option input {
  margin-top: 4px;
  min-height: auto;
  width: auto;
}

.library-option strong,
.library-option small {
  display: block;
}

.library-option small {
  color: var(--muted);
  font-weight: 500;
  margin-top: 3px;
}

details {
  background: #fffdf7;
  border: 1px solid #e7dcbf;
  border-radius: 8px;
  padding: 12px;
}

summary {
  color: var(--primary-dark);
  cursor: pointer;
  font-weight: 800;
}

.inline-hint {
  background: #f8f7f3;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.is-hidden {
  display: none;
}

.narrow {
  max-width: 620px;
}

.form-panel {
  display: grid;
  gap: 18px;
}

@media (max-width: 1180px) {
  .editor-shell,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .wizard-sidebar,
  .live-preview {
    max-height: none;
    position: static;
  }

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

@media (max-width: 760px) {
  html {
    scroll-padding-top: 84px;
  }

  .app-header,
  .product-hero,
  .page-title,
  .project-row,
  .editor-toolbar,
  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    gap: 12px;
    min-height: auto;
    padding: 18px;
  }

  .top-nav {
    align-items: stretch;
    width: 100%;
  }

  .top-nav a,
  .row-actions a,
  .row-actions button,
  .button {
    width: 100%;
  }

  .page {
    padding: 14px;
  }

  .product-hero h1,
  .page-title h1 {
    font-size: 28px;
  }

  .product-hero,
  .panel,
  .wizard-card,
  .live-preview {
    padding: 16px;
  }

  .editor-shell {
    gap: 14px;
  }

  .wizard-sidebar {
    border-radius: 8px;
    margin: -2px 0 0;
    padding: 14px;
  }

  .wizard-brand h1 {
    font-size: 18px;
  }

  .step-nav {
    display: flex;
    gap: 8px;
    margin-left: -2px;
    margin-right: -2px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scroll-snap-type: x proximity;
  }

  .step-tab {
    flex: 0 0 190px;
    scroll-snap-align: start;
  }

  .step-tab strong {
    font-size: 12px;
  }

  .editor-toolbar {
    gap: 12px;
  }

  .editor-toolbar .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

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

  .founder-card {
    padding: 12px;
  }

  .founder-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .checks-inline {
    align-items: stretch;
    flex-direction: column;
  }

  .wizard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .live-preview {
    display: block;
  }

  .preview-head {
    align-items: flex-start;
  }

  .document-preview {
    font-size: 16px;
    padding: 18px;
  }

  .compact-preview {
    font-size: 13px;
    padding: 14px;
  }

  .document-preview h2 {
    font-size: 20px;
  }

  .document-preview h3 {
    font-size: 16px;
  }

  .document-preview h4 {
    font-size: 15px;
  }
}

@media (max-width: 430px) {
  .editor-toolbar .row-actions,
  .wizard-actions {
    grid-template-columns: 1fr;
  }

  .step-tab {
    flex-basis: 170px;
  }

  .product-hero h1,
  .page-title h1 {
    font-size: 24px;
  }
}
