/* ==========================================================================
   Distill — styled per DESIGN-claude.md
   Cream canvas · Copernicus-style serif display · coral CTAs · dark mockups
   ========================================================================== */

:root {
  /* colors */
  --primary: #cc785c;
  --primary-active: #a9583e;
  --primary-disabled: #e6dfd8;
  --ink: #141413;
  --body: #3d3d3a;
  --body-strong: #252523;
  --muted: #6c6a64;
  --muted-soft: #8e8b82;
  --hairline: #e6dfd8;
  --hairline-soft: #ebe6df;
  --canvas: #faf9f5;
  --surface-soft: #f5f0e8;
  --surface-card: #efe9de;
  --surface-cream-strong: #e8e0d2;
  --surface-dark: #181715;
  --surface-dark-elevated: #252320;
  --surface-dark-soft: #1f1e1b;
  --on-primary: #ffffff;
  --on-dark: #faf9f5;
  --on-dark-soft: #a09d96;
  --accent-teal: #5db8a6;
  --accent-amber: #e8a55a;
  --success: #5db872;
  --error: #c64545;

  /* type */
  --font-display: "Cormorant Garamond", "Tiempos Headline", Garamond, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* spacing */
  --sp-xs: 8px;
  --sp-sm: 12px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-xxl: 48px;
  --sp-section: 96px;

  /* motion */
  --art-cycle: 11s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* A display rule on a component would otherwise beat the hidden attribute,
   which is what kept the empty states on screen once content existed. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--body);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

/* ------------------------------------------------------------- display type */

.display-xl, .display-lg, .display-md, .display-sm {
  font-family: var(--font-display);
  font-weight: 500; /* Cormorant substitute weight per design doc */
  color: var(--ink);
}
.display-xl { font-size: 64px; line-height: 1.05; letter-spacing: -1.5px; }
.display-lg { font-size: 48px; line-height: 1.1; letter-spacing: -1px; }
.display-md { font-size: 36px; line-height: 1.15; letter-spacing: -0.5px; }
.display-sm { font-size: 28px; line-height: 1.2; letter-spacing: -0.3px; }

.display-xl em { font-style: italic; color: var(--primary); }

/* ---------------------------------------------------------------- top nav */

.top-nav {
  background: var(--canvas);
  height: 64px;
  border-bottom: 1px solid var(--hairline-soft);
}
.nav-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.2px;
}
.mark { width: 20px; height: 20px; color: var(--ink); }
.nav-right { display: flex; align-items: center; gap: var(--sp-md); }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.nav-link:active { color: var(--primary-active); }
.nav-link.is-active { color: var(--primary); }
.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--surface-card);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  border-radius: var(--r-pill);
}

/* ------------------------------------------------------------------ badges */

.badge-pill {
  display: inline-block;
  background: var(--surface-card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--r-pill);
  padding: 4px 12px;
}
.kicker { margin-bottom: var(--sp-lg); }

/* -------------------------------------------------------------------- hero */

.hero-band {
  background: var(--canvas);
  padding: var(--sp-section) 0;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xxl);
  align-items: center;
}
.hero-sub {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--body);
  margin-top: var(--sp-lg);
  max-width: 46ch;
}

/* form */
.extract-form {
  display: flex;
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
}
.input-wrap { position: relative; flex: 1; min-width: 0; }
.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-soft);
  pointer-events: none;
}
.text-input {
  width: 100%;
  height: 48px;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 10px 14px 10px 38px;
  outline: none;
}
.text-input::placeholder { color: var(--muted-soft); }
.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

/* buttons */
.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 12px 20px;
  height: 48px;
  cursor: pointer;
  white-space: nowrap;
}
.button-primary:active { background: var(--primary-active); }
.button-primary:disabled {
  background: var(--primary-disabled);
  color: var(--muted);
  cursor: default;
}

.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 20px;
  height: 40px;
  cursor: pointer;
}
.button-secondary:active { background: var(--surface-soft); }

.button-cream {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 24px;
  height: 48px;
  cursor: pointer;
}
.button-cream:active { background: var(--surface-card); }
.button-cream svg { width: 18px; height: 18px; }

/* Ink: the dark counterweight, used for Save and for "Extract another site". */
.button-ink,
.button-dark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--on-dark);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 24px;
  height: 48px;
  cursor: pointer;
}
.button-ink:active,
.button-dark:active { background: var(--surface-dark-elevated); }

/* Teal: the third CTA color, so Download / Save / Copy never read as one block. */
.button-teal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-teal);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 24px;
  height: 48px;
  cursor: pointer;
}
.button-teal:active { background: #4da393; }

/* example chips */
.example-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  margin-top: var(--sp-md);
}
.example-label { font-size: 13px; color: var(--muted); }
.example-chip {
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  cursor: pointer;
}
.example-chip:active {
  background: var(--surface-card);
  color: var(--ink);
}

/* hero art: a DESIGN.md composing itself, on a loop */
.hero-art { min-width: 0; }
.art-window {
  background: var(--surface-dark);
  border-radius: var(--r-xl);
  padding: var(--sp-lg);
  box-shadow: 0 24px 60px -28px rgba(20, 20, 19, 0.45);
}
.art-status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  animation: artPulse 2.4s ease-in-out infinite;
}

/* extraction progress, paced to the line reveal below it */
.art-progress {
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: var(--sp-md);
}
.art-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: var(--r-pill);
  animation: artProgress var(--art-cycle) ease-in-out infinite;
}

.art-code {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--on-dark);
}
.art-line {
  display: block;
  white-space: pre;
  opacity: 0;
  animation: artLineIn var(--art-cycle) ease-out infinite both;
}
.art-line:nth-child(1)  { animation-delay: 0.15s; }
.art-line:nth-child(2)  { animation-delay: 0.50s; }
.art-line:nth-child(3)  { animation-delay: 0.85s; }
.art-line:nth-child(4)  { animation-delay: 1.20s; }
.art-line:nth-child(5)  { animation-delay: 1.55s; }
.art-line:nth-child(6)  { animation-delay: 1.90s; }
.art-line:nth-child(7)  { animation-delay: 2.25s; }
.art-line:nth-child(8)  { animation-delay: 2.60s; }
.art-line:nth-child(9)  { animation-delay: 2.95s; }
.art-line:nth-child(10) { animation-delay: 3.30s; }
.art-line:nth-child(11) { animation-delay: 3.65s; }

.art-caret {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--primary);
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes artLineIn {
  0%   { opacity: 0; transform: translateY(6px); }
  4%   { opacity: 1; transform: translateY(0); }
  84%  { opacity: 1; transform: translateY(0); }
  92%  { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 0; transform: translateY(-4px); }
}
@keyframes artProgress {
  0%   { width: 0; opacity: 1; }
  38%  { width: 100%; opacity: 1; }
  88%  { width: 100%; opacity: 1; }
  96%  { width: 100%; opacity: 0; }
  100% { width: 0; opacity: 0; }
}
@keyframes artPulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* Motion is decoration here, so hold the finished frame when it isn't wanted. */
@media (prefers-reduced-motion: reduce) {
  .art-line, .art-progress-fill, .art-status, .art-caret, .term-caret {
    animation: none;
  }
  .art-line { opacity: 1; transform: none; }
  .art-progress-fill { width: 100%; }
}

.art-titlebar, .code-titlebar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: var(--sp-md);
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface-dark-elevated);
}
.art-titlebar .dot:nth-child(1), .code-titlebar .dot:nth-child(1) { background: #c64545; }
.art-titlebar .dot:nth-child(2), .code-titlebar .dot:nth-child(2) { background: #e8a55a; }
.art-titlebar .dot:nth-child(3), .code-titlebar .dot:nth-child(3) { background: #5db872; }
.art-filename, .code-title {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--on-dark-soft);
  margin-left: var(--sp-xs);
}
.c-key { color: #8fbfd9; }
.c-str { color: #e8a55a; }
.c-num { color: #5db8a6; }
.c-punct { color: var(--on-dark-soft); }
.c-comment { color: var(--on-dark-soft); }
.swatch-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ---------------------------------------------------------------- terminal */

.terminal-section { margin-bottom: var(--sp-section); }

.code-window-card {
  background: var(--surface-dark);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
}
.terminal-body {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--on-dark);
  min-height: 120px;
}
.term-line { display: flex; gap: 10px; }
.term-line .prompt { color: var(--accent-teal); flex: none; }
.term-line.err .prompt { color: var(--error); }
.term-line.err { color: #e09a9a; }
.term-line.ok .prompt { color: var(--success); }
.term-caret {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: var(--on-dark-soft);
  vertical-align: -2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ----------------------------------------------------------------- results */

.results { padding-bottom: var(--sp-section); }
.results-head { margin-bottom: var(--sp-xxl); }
.results-sub { color: var(--muted); margin-top: var(--sp-sm); font-size: 15px; }
.results-sub a { color: var(--primary); text-decoration: none; }

.section-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--sp-xxl) 0 var(--sp-md);
}

/* swatches */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-sm);
}
.swatch {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.swatch-color {
  display: block;
  width: 100%;
  height: 72px;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  position: relative;
}
.swatch-color::after {
  content: "Copy";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}
.swatch-color:hover::after {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.28);
}
/* Held for two seconds after the click, so the confirmation is readable. */
.swatch-color.is-copied::after {
  content: "Copied ✓";
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.42);
}
.swatch-meta { padding: 10px 12px; }
.swatch-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.swatch-hex {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* duo cards */
.duo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-lg);
  margin-top: var(--sp-xxl);
}
.feature-card {
  background: var(--surface-card);
  border-radius: var(--r-lg);
  padding: var(--sp-xl);
}
.feature-card .section-label { margin-top: 0; }

.type-sample-display {
  font-size: 34px;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: var(--sp-sm);
  overflow-wrap: break-word;
}
.type-sample-body { font-size: 15px; color: var(--body); margin-bottom: var(--sp-lg); }
.type-fact {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: 8px 0;
  border-top: 1px solid var(--surface-cream-strong);
  font-size: 14px;
}
.type-fact .k { color: var(--muted); flex: none; }
.type-fact .v {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* shape preview */
.radius-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  margin-bottom: var(--sp-lg);
}
.radius-chip {
  width: 56px;
  height: 56px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
}
.radius-chip .rk { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.radius-chip .rv { font-family: var(--font-mono); font-size: 11px; color: var(--ink); }
.spacing-bars { display: flex; flex-direction: column; gap: 6px; }
.spacing-bar-row { display: flex; align-items: center; gap: 10px; }
.spacing-bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  width: 72px;
  flex: none;
}
.spacing-bar {
  height: 10px;
  background: var(--primary);
  opacity: 0.75;
  border-radius: 3px;
}

/* markdown preview */
.md-preview-card { padding-bottom: 0; overflow: hidden; }
.md-size {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--on-dark-soft);
}
.md-preview {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--on-dark);
  background: var(--surface-dark-soft);
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: var(--sp-lg);
  margin: 0 calc(-1 * var(--sp-lg));
  margin-top: 0;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Long lines wrap instead of scrolling sideways. Each source line is its own
   block with a hanging indent, so a wrapped continuation is visibly a
   continuation and the document's own indentation still reads correctly. */
.md-line {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: 3ch;
  text-indent: -3ch;
}
.md-line:empty { min-height: 1.6em; }

/* coral CTA band */
.cta-band-coral {
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--r-lg);
  padding: var(--sp-xxl);
  margin-top: var(--sp-section);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-xl);
  flex-wrap: wrap;
}
.cta-band-coral .display-sm { color: var(--on-primary); }
.cta-copy { min-width: 0; flex: 1 1 300px; }
.cta-copy p { margin-top: var(--sp-xs); opacity: 0.9; font-size: 15px; }
.cta-actions { display: flex; gap: var(--sp-sm); flex-wrap: wrap; flex: none; }

/* Each CTA is pinned to a width that fits its longest label ("Copy to
   clipboard", "Copied ✓", "Copy failed"), so swapping the label on click can't
   resize the button, reflow the row, or shove the copy beside it. */
.cta-btn { flex: none; }
.cta-btn .btn-text {
  display: block;
  text-align: center;
}
#download-btn { min-width: 168px; }
#save-btn { min-width: 172px; }
#copy-btn { min-width: 188px; }

.cta-note {
  margin-top: var(--sp-sm);
  font-size: 14px;
  color: var(--error);
}

.again-row {
  display: flex;
  justify-content: center;
  margin-top: var(--sp-xl);
}

/* --------------------------------------------------------------- how band */

.how-band {
  background: var(--surface-soft);
  padding: var(--sp-section) 0;
}
.how-title { margin-bottom: var(--sp-xl); }
.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg);
}
.how-band .feature-card { background: var(--canvas); border: 1px solid var(--hairline); }
.how-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary);
  display: block;
  margin-bottom: var(--sp-md);
}
.how-head {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: var(--sp-xs);
}
.how-band p { font-size: 14px; color: var(--body); }

/* ----------------------------------------------------------------- footer */

.footer {
  background: var(--surface-dark);
  color: var(--on-dark-soft);
  padding: 64px 0;
  margin-top: 0;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--on-dark);
  font-size: 16px;
  font-weight: 600;
}
.footer-brand .mark { color: var(--on-dark); }
.footer-note { font-size: 14px; max-width: 62ch; }

/* ------------------------------------------------- saved designs library */

.library-head {
  background: var(--canvas);
  padding: var(--sp-xxl) 0 var(--sp-xl);
}
.library-head .display-lg em { font-style: italic; color: var(--primary); }
.library-head .hero-sub { margin-top: var(--sp-sm); }
.library-main { padding-bottom: var(--sp-section); }

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-lg);
  align-items: start;
}

.saved-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}

/* colors pulled from the site, as a single ribbon across the card top */
.saved-strip { display: flex; height: 64px; }
.saved-band {
  flex: 1;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.saved-band::after {
  content: "Copied";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}
.saved-band.is-copied::after {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.42);
}

.saved-body { padding: var(--sp-lg); }
.saved-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary);
  margin-top: var(--sp-sm);
}
.saved-fonts {
  font-size: 12px;
  color: var(--muted-soft);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  margin-top: var(--sp-lg);
}
.saved-actions button { height: 34px; padding: 8px 14px; font-size: 13px; }

.button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  color: var(--error);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 18px;
  height: 40px;
  cursor: pointer;
}
.button-danger:active { background: var(--surface-soft); }
.saved-actions .button-danger { margin-left: auto; }

.saved-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--on-dark);
  background: var(--surface-dark);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  margin-top: var(--sp-md);
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ------------------------------------------------------------- history page */

.library-head-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-lg);
  flex-wrap: wrap;
}
.clear-btn { flex: none; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.history-row {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-md) var(--sp-lg);
}
.history-row.is-failed { border-color: #eed3d3; background: #fdf8f7; }

.history-strip {
  display: flex;
  width: 56px;
  height: 40px;
  flex: none;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--hairline-soft);
}
.history-band { flex: 1; }

.history-body { flex: 1; min-width: 0; }
.history-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex: none;
}
.history-status {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--success);
  margin-right: var(--sp-xs);
}
.history-status.is-failed { color: var(--error); }
.history-actions .button-secondary,
.history-actions .button-danger {
  height: 36px;
  padding: 10px 16px;
  font-size: 13px;
  text-decoration: none;
}

/* empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--surface-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-section) var(--sp-xl);
}
.empty-mark {
  width: 44px;
  height: 44px;
  color: var(--primary);
  opacity: 0.65;
  margin-bottom: var(--sp-lg);
}
.empty-state p {
  color: var(--muted);
  margin-top: var(--sp-xs);
  font-size: 15px;
}
.empty-state strong { color: var(--body-strong); font-weight: 500; }
.empty-cta { margin-top: var(--sp-lg); text-decoration: none; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1024px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { max-width: 560px; }
  .how-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .display-xl { font-size: 38px; letter-spacing: -0.8px; }
  .display-lg { font-size: 32px; }
  .display-md { font-size: 28px; }
  .hero-band { padding: var(--sp-xxl) 0; }
  .extract-form { flex-direction: column; }
  .button-primary { width: 100%; }
  .duo-grid { grid-template-columns: 1fr; }
  .how-grid { grid-template-columns: 1fr; }
  .cta-band-coral { padding: var(--sp-xl); }
  .terminal-section, .results { padding-left: var(--sp-md); padding-right: var(--sp-md); }

  .cta-actions { width: 100%; }
  .cta-btn { flex: 1 1 100%; }
  #download-btn, #save-btn, #copy-btn { min-width: 0; }

  .history-row { flex-wrap: wrap; }
  .history-body { flex: 1 1 60%; }
  .history-actions { width: 100%; justify-content: flex-end; }
  .library-head-inner { align-items: flex-start; }
}
