:root {
  --ink: #171713;
  --muted: #6f6b61;
  --paper: #f4efe5;
  --panel: #fffdf8;
  --line: #d9d2c4;
  --accent: #df5b35;
  --accent-dark: #b84020;
  --lime: #c7e65a;
  --shadow: 0 24px 70px rgba(35, 28, 15, 0.12);
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", Arial, system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 8%, rgba(199, 230, 90, .22), transparent 24rem),
    linear-gradient(180deg, #f7f2e9 0%, var(--paper) 100%);
}

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

.site-header {
  height: 76px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 23, 19, .14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.03em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  font-family: "DM Mono", monospace;
  font-size: 14px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #69a53a;
  box-shadow: 0 0 0 4px rgba(105, 165, 58, .12);
}

.app-shell {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(56px, 8vw, 112px) 0 72px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr);
  gap: 48px;
  align-items: end;
  margin-bottom: 52px;
}

.eyebrow, .section-number {
  margin: 0;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .11em;
  color: var(--accent-dark);
}

.intro .eyebrow { grid-column: 1 / -1; margin-bottom: -25px; }

h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(54px, 7.4vw, 112px);
  line-height: .88;
  letter-spacing: -.072em;
  font-weight: 800;
}

h1 em {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 600;
  letter-spacing: -.055em;
  color: var(--accent);
}

.lede {
  margin: 0 0 7px;
  max-width: 490px;
  color: var(--muted);
  font-size: clamp(16px, 1.45vw, 21px);
  line-height: 1.65;
}

.generator-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(620px, 100%);
  border: 1px solid var(--ink);
  border-bottom: 0;
  background: var(--panel);
}

.generator-tab {
  min-height: 62px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 0;
  border-right: 1px solid var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.generator-tab:last-child { border-right: 0; }
.generator-tab span { color: var(--accent-dark); font-family: "DM Mono", monospace; font-size: 10px; }
.generator-tab.is-active { color: #fff; background: var(--ink); }
.generator-tab.is-active span { color: var(--lime); }
.generator-tab:focus-visible { position: relative; z-index: 1; outline: 3px solid var(--accent); outline-offset: 2px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(400px, .74fr) minmax(540px, 1.26fr);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-panel, .preview-panel { min-width: 0; }

.control-panel {
  padding: clamp(26px, 3.2vw, 48px);
  border-right: 1px solid var(--line);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(26px, 3.2vw, 48px);
  background: #ebe5d9;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 34px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -.04em;
}

.text-button {
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 25px 0 30px;
  border: 0;
  border-top: 1px solid var(--line);
}

legend {
  padding: 0 14px 0 0;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

[hidden] { display: none !important; }
.field-grid { display: grid; gap: 13px; }
.sequence-grid { grid-template-columns: .6fr 1.7fr .7fr; }
.compact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.static-fields { display: block; }

.static-array-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 13px;
}

.static-array-heading p {
  margin: 0;
  max-width: 330px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.add-entry-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--lime);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

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

.static-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 36px;
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid #d8d0c2;
  background: #f8f4eb;
}

.static-entry .field input { background: #fff; }

.remove-entry-button {
  width: 36px;
  height: 44px;
  border: 1px solid #cfc7b8;
  border-radius: 3px;
  color: var(--muted);
  background: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.remove-entry-button:hover:not(:disabled) { border-color: #a72626; color: #a72626; }
.remove-entry-button:disabled { opacity: .35; cursor: not-allowed; }

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field > span, .page-select > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field small { font-size: .9em; font-weight: 500; }

.field input, .page-select select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #cfc7b8;
  border-radius: 3px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-family: "DM Mono", monospace;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .page-select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(223, 91, 53, .12);
}

.color-field input {
  padding: 6px;
  cursor: pointer;
}

.gap-field.is-disabled { opacity: .48; }
.gap-field.is-disabled input { cursor: not-allowed; }

.shape-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 17px;
}

.shape-picker label { cursor: pointer; }
.shape-picker input { position: absolute; opacity: 0; pointer-events: none; }

.shape-card {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid #cfc7b8;
  border-radius: 4px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  transition: .15s ease;
}

.shape-picker input:checked + .shape-card {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--lime);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.shape-icon {
  display: block;
  width: 35px;
  height: 17px;
  border: 2px solid currentColor;
}

.shape-icon.pill { border-radius: 99px; }
.shape-icon.grid {
  position: relative;
  width: 38px;
  background: linear-gradient(90deg, transparent 47%, currentColor 47%, currentColor 53%, transparent 53%);
}
.shape-icon.grid::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  border-top: 2px solid currentColor;
}

.error-message {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 3px solid #a72626;
  background: #fde9e5;
  color: #741a1a;
  font-size: 12px;
  line-height: 1.5;
}

.summary-card {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
  margin-top: 2px;
  padding: 18px;
  border: 1px solid var(--ink);
  background: #f7f2e7;
}

.summary-card > div { min-width: 0; }
.summary-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.summary-card strong { display: block; overflow: hidden; text-overflow: ellipsis; font-family: "DM Mono", monospace; font-size: 12px; white-space: nowrap; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.button {
  min-height: 48px;
  padding: 0 17px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
}

.button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(23, 23, 19, .12); }
.button:disabled { opacity: .55; cursor: wait; }
.button-primary { display: flex; align-items: center; justify-content: space-between; color: #fff; background: var(--ink); }
.button-secondary { background: var(--lime); }
.button-quiet { grid-column: 1 / -1; border-color: #bdb5a6; background: transparent; }

.progress { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }

.preview-heading { align-items: center; }
.page-select { display: flex; align-items: center; gap: 9px; }
.page-select select { width: 74px; height: 36px; }

.paper-stage {
  flex: 1;
  min-height: 600px;
  display: grid;
  place-items: center;
  padding: clamp(15px, 2.6vw, 38px);
  border: 1px solid rgba(23, 23, 19, .14);
  background-color: #d8d2c6;
  background-image:
    linear-gradient(45deg, #c9c3b8 25%, transparent 25%),
    linear-gradient(-45deg, #c9c3b8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c9c3b8 75%),
    linear-gradient(-45deg, transparent 75%, #c9c3b8 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.paper-shadow {
  width: min(100%, 570px);
  aspect-ratio: 210 / 297;
  box-shadow: 0 20px 45px rgba(23, 23, 19, .24);
}

#sheet {
  display: block;
  width: 100%;
  height: 100%;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
  color: #666056;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

footer {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 36px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid rgba(23, 23, 19, .14);
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 1040px) {
  .intro { grid-template-columns: 1fr; gap: 30px; }
  .intro .eyebrow { margin-bottom: -12px; }
  .lede { max-width: 680px; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .paper-stage { min-height: 720px; }
}

@media (max-width: 620px) {
  .site-header { height: 64px; }
  .header-meta span:last-child { display: none; }
  .app-shell { width: min(100% - 24px, 1540px); padding-top: 48px; }
  .intro { margin-bottom: 44px; }
  h1 { font-size: clamp(49px, 16vw, 76px); }
  .control-panel, .preview-panel { padding: 24px 18px; }
  .generator-tabs { width: 100%; }
  .generator-tab { min-height: 58px; padding: 0 13px; font-size: 11px; }
  .sequence-grid { grid-template-columns: .65fr 1.35fr; }
  .sequence-grid .field:last-child { grid-column: 1 / -1; }
  .static-array-heading { align-items: flex-start; flex-direction: column; }
  .static-entry { grid-template-columns: minmax(0, 1fr) 76px 36px; padding: 10px; }
  .compact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shape-card { font-size: 10px; }
  .summary-card, .actions { grid-template-columns: 1fr; }
  .button-quiet { grid-column: auto; }
  .paper-stage { min-height: 470px; padding: 13px; }
  .spec-row { justify-content: flex-start; }
  footer { width: calc(100% - 24px); flex-direction: column; gap: 5px; }
}

@media print {
  body { background: #fff; }
  .site-header, .intro, .generator-tabs, .control-panel, .preview-heading, .spec-row, footer { display: none !important; }
  .app-shell, .workspace, .preview-panel, .paper-stage, .paper-shadow { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
  #sheet { width: 210mm; height: 297mm; }
  @page { size: A4 portrait; margin: 0; }
}
