/* ── Tokens ────────────────────────────────────────────────────────── */

:root {
  --paper: #f1ede2;
  --paper-raised: #faf8f2;
  --paper-line: #dcd3bd;
  --paper-line-soft: #e8e1d0;
  --ink: #211d16;
  --ink-soft: #6b6355;
  --ink-faint: #a49c8a;
  --stamp: #b23a2e;
  --stamp-dark: #8f2e24;
  --stamp-soft: rgba(178, 58, 46, 0.09);
  --stamp-soft-strong: rgba(178, 58, 46, 0.16);
  --approve: #3f6b4c;

  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(var(--paper-line-soft) 1px, transparent 1px) 0 0 / 100% 32px,
    var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

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

/* ── Masthead ──────────────────────────────────────────────────────── */

.masthead {
  margin-bottom: 40px;
  animation: rise 0.5s ease both;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.eyebrow-prompt {
  color: var(--stamp);
  margin-right: 6px;
}

.cursor {
  display: inline-block;
  width: 7px;
  height: 12px;
  margin-left: 4px;
  background: var(--stamp);
  transform: translateY(1px);
  animation: blink 1.1s steps(1) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
    opacity: 1;
  }
}

h1 {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--ink);
}

.subtitle {
  color: var(--ink-soft);
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  max-width: 54ch;
}

code {
  font-family: var(--font-mono);
  background: var(--stamp-soft);
  color: var(--stamp-dark);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.92em;
}

/* ── Document panels ──────────────────────────────────────────────── */

.card {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--paper-line);
  border-radius: 3px;
  padding: 28px 28px 26px;
  margin-bottom: 22px;
  animation: rise 0.5s ease both;
  animation-delay: 0.08s;
}

.card-tag {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--paper-line-soft);
}

.section-mark {
  color: var(--stamp);
}

.error-tag {
  color: var(--stamp);
  border-bottom-color: var(--stamp-soft-strong);
}

/* ── Form fields ───────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.field-row {
  display: flex;
  gap: 16px;
  margin-top: 18px;
}

label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

input[type="text"],
input[type="number"] {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  color: var(--ink);
  padding: 11px 13px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
}

input[type="text"]::placeholder {
  color: var(--ink-faint);
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 1px;
  border-color: var(--stamp);
}

/* ── Buttons ───────────────────────────────────────────────────────── */

button {
  font-family: var(--font-mono);
  border: none;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

#submit-btn {
  margin-top: 22px;
  width: 100%;
  background: var(--stamp);
  color: var(--paper-raised);
  padding: 13px 20px;
  border-radius: 2px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.15s ease, transform 0.1s ease;
}

#submit-btn:hover:not(:disabled) {
  background: var(--stamp-dark);
}

#submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

#submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* ── Status / progress ────────────────────────────────────────────── */

.progress-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 12px;
}

#progress-count {
  color: var(--ink-soft);
}

.progress-bar {
  height: 6px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    135deg,
    var(--stamp) 0 8px,
    var(--stamp-dark) 8px 16px
  );
  background-size: 200% 100%;
  transition: width 0.25s ease;
  animation: shift 1.4s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    animation: none;
  }
}

.progress-url {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-url:not(:empty)::before {
  content: "› ";
  color: var(--stamp);
}

/* ── Error ─────────────────────────────────────────────────────────── */

.error {
  border-color: var(--stamp-soft-strong);
  background: var(--paper-raised);
}

.error p {
  color: var(--stamp-dark);
  font-family: var(--font-mono);
  font-size: 13.5px;
  margin: 0;
  line-height: 1.6;
}

/* ── Results ───────────────────────────────────────────────────────── */

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

.results-header h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.results-actions {
  display: flex;
  gap: 8px;
}

.results-actions button {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--paper-line);
  border-radius: 2px;
  padding: 8px 12px;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.results-actions button:hover {
  border-color: var(--stamp);
  color: var(--stamp);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.tab-btn {
  background: var(--paper);
  color: var(--ink-faint);
  border: 1px solid var(--paper-line);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  font-size: 12px;
  letter-spacing: 0.03em;
  padding: 9px 16px 8px;
  transition: color 0.15s ease;
}

.tab-btn.active {
  background: var(--ink);
  color: var(--paper-raised);
  border-color: var(--ink);
}

.output-pane {
  background: var(--ink);
  color: #e4dfd0;
  border: 1px solid var(--ink);
  border-radius: 0 3px 3px 3px;
  padding: 18px;
  max-height: 480px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Colophon ──────────────────────────────────────────────────────── */

.colophon {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin: 28px 0 0;
}

/* ── Motion ────────────────────────────────────────────────────────── */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes shift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 32px 0;
  }
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .page {
    padding: 40px 16px 40px;
  }

  h1 {
    font-size: 24px;
  }

  .field-row {
    flex-direction: column;
    gap: 14px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
