*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-heading: clamp(1.5rem, 2.3vw, 1.9rem);
  --text-body: 1rem;
  --text-sm: 0.875rem;
  --ground: #f2f5f8;
  --surface: #e6ecf2;
  --sheet: #ffffff;
  --ink: #0b1f33;
  --muted: #46586b;
  --line: #cfd8e3;
  --line-strong: #9fb0c3;
  --accent: #0f4c81;
  --pass-ink: #0b5d41;
  --pass-bg: #eefbf5;
  --pass-border: #12805c;
  --warn-ink: #8a4b08;
  --warn-bg: #fff9eb;
  --warn-border: #c87a19;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
  transition: color 160ms var(--ease);
}

a:hover {
  color: var(--ink);
}

/* Single-line architectural masthead */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(242, 245, 248, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

.site-header.is-scrolled {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: var(--line);
  box-shadow: 0 4px 20px rgba(11, 31, 51, 0.04);
}

.header-inner,
.footer-inner,
main {
  max-width: 1220px;
  margin: 0 auto;
  padding-inline: clamp(18px, 4vw, 48px);
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.identity {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-decoration: none;
}

.identity img {
  border-radius: 7px;
  flex-shrink: 0;
}

header nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

header nav a {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

header nav a:hover {
  color: var(--ink);
}

/* Opening document header & immediate workspace */
main {
  padding-top: clamp(16px, 2.2vw, 28px);
  padding-bottom: clamp(48px, 6vw, 84px);
}

.crumb {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 10px;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

h1, h2, h3 {
  color: var(--ink);
  text-wrap: balance;
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 4.3vw, 3.55rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  max-width: 22ch;
  margin-bottom: 12px;
}

.opening {
  margin-bottom: clamp(20px, 2.6vw, 28px);
}

.lead {
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--muted);
  max-width: 64ch;
  margin: 0;
}

/* Interactive controls & CTA discipline */
button, .button, select, input, textarea {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-variant-numeric: tabular-nums;
}

[data-cta]::after { content: attr(data-cta); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease), box-shadow 160ms var(--ease);
}

button:hover:not(:disabled), .button:hover {
  border-color: var(--ink);
  background: #f8fafc;
}

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

button:disabled {
  opacity: 0.44;
  cursor: not-allowed;
}

button.primary, .button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 76, 129, 0.22);
}

button.primary:hover:not(:disabled), .button.primary:hover {
  background: #0b3962;
  border-color: #0b3962;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(15, 76, 129, 0.28);
}

.full-width {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Live two-pane archival workbench */
#workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 48px -16px rgba(11, 31, 51, 0.09), 0 1px 3px rgba(11, 31, 51, 0.04);
}

.controls, .result {
  padding: clamp(20px, 2.8vw, 32px);
  min-width: 0;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--sheet);
}

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border-left: 1px solid var(--line);
}

/* Tactile archive dropzone */
#drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  padding: 20px 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}

#drop:hover, #drop:has(:focus-visible) {
  border-color: var(--accent);
  background: #f0f6fc;
}

#drop:has(:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.drop-icon {
  color: var(--accent);
  margin-bottom: 2px;
}

#drop strong {
  font-size: var(--text-body);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

#drop span, small {
  display: block;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--muted);
  line-height: 1.45;
}

#queue {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

#queue:empty {
  display: none;
}

#queue li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

label, output {
  display: block;
}

label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

label > input:not([type=radio]),
label > select,
label > textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  accent-color: var(--accent);
}

input:not([type=range], [type=file], [type=radio]),
select,
textarea {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--sheet);
  color: var(--ink);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

input:not([type=range], [type=file], [type=radio]):hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

select {
  padding-right: 30px;
  text-overflow: ellipsis;
}

.settings-drawer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.settings-drawer summary {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  list-style-position: inside;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.actions, .chips, .sliders {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.controls > .actions {
  margin-top: auto;
  padding-top: 6px;
}

.controls > .actions #run {
  flex: 1 1 auto;
}

.sliders > label { flex: 1 1 40%; }
.sliders output { display: inline; }

fieldset {
  border: 0;
  padding: 0;
  margin: 12px 0;
}

.chips label span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
}

.chips input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0f6fc;
}

/* Verification ledger & Folio preview desk */
.pass-badges {
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.pass-pill {
  padding: 9px 13px;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.45;
  color: var(--pass-ink);
  background: var(--pass-bg);
  border-left: 3.5px solid var(--pass-border);
  white-space: pre-line;
}

.pass-pill + .pass-pill {
  border-top: 1px solid var(--line);
}

.pass-pill[data-warning] {
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-left-color: var(--warn-border);
}

#preview {
  flex: 1 1 auto;
  min-height: 330px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: auto;
  box-shadow: inset 0 1px 2px rgba(11, 31, 51, 0.04);
}

#preview:empty {
  background-color: #eef2f6;
  background-image:
    linear-gradient(to right, rgba(159, 176, 195, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(159, 176, 195, 0.18) 1px, transparent 1px);
  background-size: 24px 24px;
  position: relative;
}

#preview:empty::after {
  content: " Paginated US Letter / A4 exhibit preview renders here locally ";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}

#preview img, #preview iframe, #game {
  width: 100%;
  border: 0;
  display: block;
}

#preview img {
  max-height: 430px;
  object-fit: contain;
}

#preview iframe {
  height: 360px;
}

#game {
  aspect-ratio: 16 / 9;
  background: #0b1f33;
}

#status {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.result > .actions #premium {
  flex: 1 1 auto;
}

/* Embed snippet drawer & rescue flow */
.embed-box, .rescue-flow {
  margin-top: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.embed-box summary, .rescue-flow summary {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.embed-box label {
  display: block;
  margin-top: 10px;
}

.embed-box input, .embed-box textarea {
  display: block;
  width: 100%;
}

#export-history {
  margin: 14px 0 0;
  padding-left: 20px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.ad-slot { margin-top: 156px; padding: 1rem; border-top: 1px solid var(--line); font-size: var(--text-sm); color: var(--muted); }

/* Editorial prose rhythm below the fold (strict 3-size hierarchy & <=65ch) */
article, .prose-sheet {
  max-width: 65ch;
  margin: clamp(52px, 7vw, 84px) auto 0;
}

.prose-sheet {
  margin-top: 24px;
}

article section {
  padding-top: clamp(32px, 4.5vw, 48px);
  margin-top: clamp(32px, 4.5vw, 48px);
  border-top: 1px solid var(--line);
}

article section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

article h2, .price h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-heading);
  line-height: 1.16;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}

article h3, .directory h3, .dialog-head h3 {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin: 24px 0 8px;
}

article p, .prose-sheet p, article li, .price li {
  font-size: var(--text-body);
  line-height: 1.68;
  color: var(--ink);
  margin: 0 0 16px;
}

article ol, article ul {
  padding-left: 22px;
  margin: 16px 0 20px;
}

article li {
  margin-bottom: 10px;
}

.answer {
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: #eaf0f6;
  border-radius: 0 8px 8px 0;
  color: var(--ink);
}

article nav[aria-label="Further reading"] {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

/* Clean architectural comparison & diagnostic tables */
.table-wrap {
  margin: 22px 0 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sheet);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-body);
  background: var(--sheet);
}

caption {
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-body);
  line-height: 1.5;
}

tr:last-child th, tr:last-child td {
  border-bottom: 0;
}

thead th {
  background: #f1f5f9;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

tbody th[scope="row"] {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* Editorial related tools directory (1px dividers, zero card-in-card cages) */
.directory {
  max-width: 65ch;
  margin: clamp(48px, 6vw, 72px) auto 0;
  padding-top: 28px;
  border-top: 2px solid var(--ink);
}

.directory h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.related {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.related > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  transition: color 160ms var(--ease), padding-left 160ms var(--ease);
}

.related > a:hover {
  color: var(--accent);
  padding-left: 10px;
}

.related [data-cta] {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

/* Pricing layout */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 24px;
  margin-top: 28px;
}

.price {
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.price.featured {
  border-color: var(--accent);
  box-shadow: 0 14px 34px -12px rgba(15, 76, 129, 0.16);
}

.price-amount {
  margin: 4px 0 6px;
}

.price-amount strong {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 600;
}

.price-amount span, .price-allowance {
  font-size: var(--text-sm);
  color: var(--muted);
}

.price ul {
  padding-left: 20px;
  margin: 16px 0 24px;
  flex: 1 1 auto;
}

/* Checkout & license unlock modal */
dialog {
  width: min(540px, 94vw);
  max-height: 90dvh;
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(11, 31, 51, 0.24);
}

dialog::backdrop {
  background: rgba(11, 31, 51, 0.56);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.dialog-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-heading);
}

#google {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 14px;
}

.license-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.license-row label {
  flex: 1 1 auto;
}

.plans {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.plans legend {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: 8px;
}

.plans > label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.plans > label input[type="radio"] {
  margin-top: 4px;
  accent-color: var(--accent);
}

.plans label:has(:checked) {
  border-color: var(--accent);
  background: #f2f7fc;
}

.plan-body {
  display: block;
  flex: 1 1 auto;
}

.plan-price {
  font-weight: 600;
  color: var(--accent);
}

#quote {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
  margin: 8px 0 14px;
}

.checkout-note, #gate-status {
  margin-top: 10px;
  text-align: center;
  font-size: var(--text-sm);
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  background: var(--sheet);
}

.footer-inner {
  min-height: 68px;
  padding-block: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--muted);
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

footer nav a {
  color: var(--muted);
  text-decoration: none;
}

footer nav a:hover {
  color: var(--ink);
}

/* Embedded compact mode */
.embedded main, .embedded .header-inner, .embedded .footer-inner { padding-block: 10px; padding-inline: 16px; }
.embedded h1 { font-size: var(--text-heading); }
.embedded .crumb { display: none; }
.embed-credit { margin: 0; }

[hidden] { display: none !important; }

button:focus-visible, .button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  #workbench {
    grid-template-columns: 1fr;
  }
  .result {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  #preview {
    min-height: 320px;
  }
  #preview iframe {
    height: 340px;
  }
}

@media (max-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
  .license-row {
    flex-direction: column;
    align-items: stretch;
  }
  .controls > .actions button,
  .result > .actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
