:root {
  --background: #070707;
  --foreground: #f2f2f2;
  --border: #2e2e2e;
  --card: #141414;
  --muted: #262626;
  --muted-foreground: #9a9a9a;
  --primary: #e4e4e4;
  --primary-foreground: #141414;
  --ring: #6e6e6e;
  --critical: #3a1518;
  --destructive: #e07058;
  --font-serif: "Instrument Serif", "Times New Roman", serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-sans: "Bai Jamjuree", system-ui, sans-serif;
  --frame: 72rem;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

button,
input,
select {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.drop input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

button {
  cursor: pointer;
}

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

:focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.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;
}

.frame {
  max-width: var(--frame);
  margin: 0 auto;
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  min-height: 4.5rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  border-right: 1px solid var(--border);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0 1.5rem;
}

.nav-link {
  font-size: 1.05rem;
  letter-spacing: 0;
  text-decoration: none;
  transition: letter-spacing 0.25s ease;
}

.nav-link:hover {
  letter-spacing: 0.12em;
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.nav-icon:hover {
  background: var(--muted);
  text-decoration: none;
}

.nav-icon {
  width: 4.5rem;
  border-left: 1px solid var(--border);
}

.hero {
  position: relative;
  min-height: 28rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-texture {
  position: absolute;
  inset: 0;
  background-color: #121212;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.45) 0,
      rgba(0, 0, 0, 0.45) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 4px
    ),
    radial-gradient(circle at 30% 40%, #3a3a3a 0, transparent 42%),
    radial-gradient(circle at 70% 60%, #2a2a2a 0, transparent 38%);
  pointer-events: none;
}

.hero-texture::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    var(--background) 0%,
    transparent 18%,
    transparent 82%,
    var(--background) 100%
  );
}

.hero h1 {
  position: relative;
  margin: 0;
  padding: 3.5rem 2rem 2rem;
  font-family: var(--font-serif);
  font-size: clamp(4.5rem, 10vw, 7.5rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.02em;
}

.hero h1 span {
  display: block;
  padding-left: 18vw;
}

.hero-caption {
  position: relative;
  max-width: 36rem;
  margin: 0 2rem 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--background);
}

.hero-caption p {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.hero-caption p:last-child {
  margin-bottom: 0;
}

.hero-caption em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2em;
}

.kicker {
  margin: 0;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--background);
}

.work {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  align-items: stretch;
}

.pane {
  padding: 1.5rem;
  min-height: 22rem;
}

#submit-pane {
  display: flex;
  flex-direction: column;
}

#job-pane {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#job-pane .job {
  width: 100%;
}

.pane + .pane {
  border-left: 1px solid var(--border);
}

#convert-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 19rem;
}

.turnstile {
  min-height: 65px;
  margin: 1rem 0 0.75rem;
}

.drop {
  position: relative;
  display: grid;
  align-content: center;
  gap: 0.5rem;
  flex: 1;
  min-height: 12rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  cursor: pointer;
}

.drop:hover,
.drop.is-drag,
.drop:focus-within {
  background: var(--muted);
}

.drop:focus-within {
  outline: 1px solid var(--ring);
  outline-offset: 2px;
}

.drop-title {
  font-size: 1.05rem;
}

.drop-meta,
.hint,
.empty,
.caveat,
.stat-label,
.footer,
.meta dt {
  color: var(--muted-foreground);
}

.drop-meta,
.hint,
.caveat {
  font-size: 0.85rem;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.field-row label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

select {
  min-width: 12rem;
  padding: 0.4rem 1.75rem 0.4rem 0.6rem;
  border: 1px solid var(--border);
  background-color: var(--card);
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--foreground) 50%),
    linear-gradient(135deg, var(--foreground) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 3px),
    calc(100% - 9px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.primary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.5rem;
  border: 1px solid var(--border);
  font-weight: 600;
}

.primary {
  width: 100%;
  background: var(--foreground);
  color: var(--primary-foreground);
  border-color: var(--foreground);
}

.primary:hover:not(:disabled) {
  background: var(--primary);
}

.ghost:hover {
  background: var(--muted);
}

.hint {
  margin: 0.75rem 0 0;
}

.empty {
  margin: 0;
  max-width: 28rem;
}

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.badge {
  margin: 0;
  padding: 0.45rem 0.7rem;
  background: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.badge.is-running {
  background: var(--foreground);
  color: var(--background);
}

.badge.is-succeeded {
  background: var(--card);
  border: 1px solid var(--border);
}

.badge.is-failed,
.badge.is-justified {
  background: var(--critical);
}

.badge.is-clean {
  background: var(--muted);
}

.mono,
.hash {
  font-variant-ligatures: none;
  word-break: break-all;
}

.meta {
  display: grid;
  gap: 0.85rem;
  margin: 0 0 1.25rem;
}

.meta div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.meta dt,
.meta dd {
  margin: 0;
  font-size: 0.85rem;
}

.error-line {
  color: var(--destructive);
  font-size: 0.9rem;
}

.job-actions {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.job-actions .primary,
.job-actions .ghost {
  width: auto;
}

#job-file {
  word-break: break-word;
}

.preview {
  border-bottom: 1px solid var(--border);
}

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

#sign .pane {
  min-height: 0;
}

#sign-place {
  display: flex;
  flex-direction: column;
}

#sign-place .job-actions {
  margin-top: auto;
}

.sign-lead {
  margin: 0 0 0.75rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 2rem;
  line-height: 1.1;
}

.sign-modes {
  display: flex;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.sign-modes button {
  flex: 1;
  min-height: 2.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sign-modes button + button {
  border-left: 1px solid var(--border);
}

.sign-modes button.is-active {
  background: var(--foreground);
  color: var(--primary-foreground);
}

.sign-modes button:hover:not(.is-active) {
  background: var(--muted);
}

.sign-pad {
  display: block;
  width: 100%;
  height: 7.5rem;
  background: #fff;
  border: 1px solid var(--border);
  touch-action: none;
  cursor: crosshair;
}

.sign-field {
  display: grid;
  gap: 0.65rem;
}

.sign-field span {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#sign-name {
  width: 100%;
  height: 7.5rem;
  padding: 0 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: #141414;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.65rem;
  line-height: 7.5rem;
}

#sign-name::placeholder {
  color: #b5b5b5;
}

#sign-capture .hint {
  margin: 0.75rem 0 0;
}

.preview-status {
  margin: 0;
  padding: 1.5rem;
}

#pdf-pages {
  container-type: size;
  display: grid;
  justify-items: center;
  align-items: start;
  gap: 1rem;
  height: min(88vh, 64rem);
  padding: 1.5rem;
  overflow: auto;
  background: #1a1a1a;
}

.pdf-page {
  position: relative;
  display: block;
  width: min(100%, calc((100cqh - 2px) / 1.4142));
  min-width: 0;
  padding: 0;
  background: #fff;
  line-height: 0;
  text-align: left;
}

#pdf-pages canvas {
  display: block;
  width: 100%;
  height: auto;
  background: white;
}

.sign-mark {
  position: absolute;
  height: auto;
  pointer-events: none;
}

#pdf-pages.is-placing .pdf-page {
  cursor: crosshair;
}

#pdf-pages.is-placing .pdf-page:hover {
  outline: 1px solid #141414;
  outline-offset: -1px;
}

.report-banner {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.report-banner.is-justified,
.report-banner.is-failed {
  background: var(--critical);
}

.report-banner.is-clean {
  background: var(--muted);
}

.hits {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.hits th,
.hits td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.hits th {
  color: var(--muted-foreground);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.contract {
  display: grid;
  grid-template-columns: 18rem 1fr;
  border-bottom: 1px solid var(--border);
}

.stat {
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 2.5rem 2.5rem,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 2.5rem 2.5rem;
}

.stat-num {
  margin: 2.5rem 0 0.25rem;
  font-family: var(--font-serif);
  font-size: 5rem;
  line-height: 1;
  font-style: italic;
}

.stat-label {
  margin: 0;
  max-width: 10rem;
}

.copy {
  padding: 2rem 1.5rem;
}

.copy p {
  margin: 0 0 1rem;
  max-width: 42rem;
}

.copy p:last-child {
  margin-bottom: 0;
}

.copy code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  font-size: 0.8rem;
  margin-top: auto;
}

.footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.text-link {
  text-decoration: underline;
  text-decoration-color: var(--ring);
  text-underline-offset: 4px;
}

.text-link:hover {
  text-decoration-color: var(--foreground);
}

.faq {
  border-bottom: 1px solid var(--border);
}

.faq-item + .faq-item {
  border-top: 1px solid var(--border);
}

.faq-item summary {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  font-size: 1.05rem;
  list-style: none;
  cursor: pointer;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  color: var(--muted-foreground);
}

.faq-item[open] summary::after {
  content: "\2212";
}

.faq-item summary:hover {
  background: var(--muted);
}

.faq-num {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
}

.faq-answer {
  max-width: 48rem;
  padding: 0 1.5rem 1.5rem 5.5rem;
  color: var(--muted-foreground);
}

.faq-answer p,
.faq-answer ul {
  margin: 0 0 0.75rem;
}

.faq-answer > :last-child {
  margin-bottom: 0;
}

.faq-answer ul {
  padding-left: 1.25rem;
}

.faq-answer code,
.prose code {
  font-size: 0.9em;
  color: var(--foreground);
}

.faq-answer strong {
  color: var(--foreground);
  font-weight: 600;
}

.faq-more {
  margin: 0;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.hero--page {
  min-height: 20rem;
}

.hero--page h1 {
  font-size: clamp(3.5rem, 8vw, 6rem);
}

.hero--page h1 span {
  padding-left: 12vw;
}

.copy em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2em;
}

.doc {
  display: grid;
  grid-template-columns: 18rem 1fr;
  border-bottom: 1px solid var(--border);
}

.toc {
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
}

.toc-title {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.toc ol {
  position: sticky;
  top: 1.5rem;
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.toc a {
  color: var(--muted-foreground);
}

.toc a:hover {
  color: var(--foreground);
}

.prose {
  min-width: 0;
  padding: 2rem 1.5rem 3rem;
}

.prose section {
  max-width: 48rem;
  scroll-margin-top: 1.5rem;
}

.prose section + section {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.prose h2 {
  margin: 0 0 1.25rem;
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 4vw, 3rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 2rem 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.prose p,
.prose ul,
.prose ol,
.prose pre,
.prose table,
.prose blockquote,
.prose dl {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.5rem;
}

.prose em {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2em;
}

.prose a {
  text-decoration: underline;
  text-decoration-color: var(--ring);
  text-underline-offset: 4px;
}

.prose a:hover {
  text-decoration-color: var(--foreground);
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.8rem;
  line-height: 1.6;
}

.prose pre code {
  font-size: inherit;
}

.prose .hits td {
  vertical-align: top;
}

.prose blockquote {
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 1px solid var(--foreground);
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.35;
}

.facts {
  display: grid;
  gap: 0;
}

.facts div {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.facts dt {
  color: var(--muted-foreground);
}

.facts dd {
  margin: 0;
}

.noscript {
  margin: 1rem;
  color: var(--destructive);
}

@media (max-width: 860px) {
  .nav {
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    display: none;
  }

  .hero h1 {
    font-size: 3.5rem;
    padding: 2.5rem 1.25rem 1.5rem;
  }

  .hero h1 span {
    padding-left: 0;
  }

  .hero-caption,
  .pane,
  .copy,
  .stat,
  .footer,
  .kicker {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .work,
  .contract,
  .sign-grid {
    grid-template-columns: 1fr;
  }

  .pane + .pane,
  .stat {
    border-left: 0;
    border-top: 1px solid var(--border);
    border-right: 0;
  }

  .job-actions {
    flex-direction: column;
  }

  .job-actions .primary,
  .job-actions .ghost {
    width: 100%;
  }

  .hero--page h1 span {
    padding-left: 0;
  }

  .doc {
    grid-template-columns: 1fr;
  }

  .toc {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .toc ol {
    position: static;
  }

  .toc,
  .prose,
  .faq-item summary,
  .faq-more {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .faq-item summary {
    grid-template-columns: 2.25rem 1fr auto;
    gap: 0.75rem;
  }

  .faq-answer {
    padding: 0 1.25rem 1.25rem;
  }

  .facts div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-link {
    transition: none;
  }
}
