/* ============================================================================
   Reslate — "The Tailor's Bench"
   Editorial, precise, 2026. Instrument Serif display + Hanken Grotesk UI,
   warm ink canvas (dark) / paper (light), one disciplined iris accent.
   ========================================================================= */

/* --- Self-hosted fonts (CSP-safe, no external calls) --- */
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

/* ===================== Design tokens — dark (default) ===================== */
:root {
  --bg: #0a0b0e;
  --bg-2: #0d0f13;
  --card: #131519;
  --card-2: #181b21;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ecedef;
  --muted: #8b919c;
  --faint: #6b717c;

  --accent: #6c8cff;
  --accent-2: #57bdff;
  --accent-soft: rgba(108, 140, 255, 0.14);
  --accent-line: rgba(108, 140, 255, 0.35);
  --on-accent: #07080c;

  --add-bg: #0f2b20;
  --add-fg: #6fe0a3;
  --del-bg: #321521;
  --del-fg: #ff90a6;
  --warn-fg: #ecc04a;

  --inset: #0c0e12;
  --chip: #1b1e25;
  --hover: #1c2029;
  --code-bg: #0a0c10;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 60px -28px rgba(0, 0, 0, 0.85);
  --radius: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Page width — caps the centered content; fluid below via side padding. */
  --page-w: 1120px;

  --display: "Instrument Serif", ui-serif, Georgia, serif;
  --ui: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* atmosphere */
  --grid-dot: rgba(255, 255, 255, 0.035);
  --glow: rgba(108, 140, 255, 0.16);
  --grain-opacity: 0.04;
}

/* ===================== Design tokens — light "paper" ===================== */
:root[data-theme="light"] {
  --bg: #efece3;
  --bg-2: #f4f1ea;
  --card: #fbfaf6;
  --card-2: #fffefb;
  --border: rgba(28, 26, 22, 0.12);
  --border-strong: rgba(28, 26, 22, 0.22);
  --text: #1b1a17;
  --muted: #5f5c54;
  --faint: #8a8678;

  --accent: #3a52d6;
  --accent-2: #2f86c9;
  --accent-soft: rgba(58, 82, 214, 0.1);
  --accent-line: rgba(58, 82, 214, 0.3);
  --on-accent: #ffffff;

  --add-bg: #e7f6ec;
  --add-fg: #1a7a45;
  --del-bg: #fceaee;
  --del-fg: #b42441;
  --warn-fg: #9a6a00;

  --inset: #f1eee6;
  --chip: #eceadf;
  --hover: #f5f2ea;
  --code-bg: #f3f0e7;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 20px 50px -30px rgba(60, 50, 30, 0.4);

  --grid-dot: rgba(40, 35, 25, 0.05);
  --glow: rgba(58, 82, 214, 0.1);
  --grain-opacity: 0.03;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layered atmosphere: dot grid + a soft accent glow up top. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    radial-gradient(circle at top, var(--glow), transparent 60%),
    radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px;
  background-position: center top, center;
  pointer-events: none;
}

/* Fine grain overlay for tactile depth. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

a { color: var(--accent); }

/* ============================== Header / nav ============================== */
.site-header,
header {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 26px 24px 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.brand-mark svg { width: 17px; height: 17px; display: block; }
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* keep legacy header-row working if present */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---- Hero ---- */
.hero { padding: 56px 0 30px; max-width: 760px; }
.eyebrow {
  margin: 0 0 18px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--accent-line);
}

h1, .hero-title {
  font-family: var(--display);
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.01em;
}
.hero-title {
  font-size: clamp(2.9rem, 8vw, 5.2rem);
  line-height: 0.98;
  margin: 0 0 20px;
}
.hero-title em { font-style: italic; color: var(--accent); }

.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 1.08rem;
  max-width: 56ch;
  line-height: 1.6;
}
.hero-micro {
  color: var(--muted);
  margin: 12px 0 0;
  font-size: 0.95rem;
  max-width: 56ch;
  line-height: 1.5;
  opacity: 0.85;
}

/* Staggered entrance */
.hero-rule {
  display: block;
  height: 2px;
  width: 140px;
  margin-top: 30px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* ------------------------------ Buttons ---------------------------------- */
.bmc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffdd00;
  color: #1a1a1a;
  border-radius: 10px;
  padding: 8px 14px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease,
    box-shadow 0.15s ease;
}
.bmc-btn:hover {
  transform: translateY(-1px);
  background: #ffe533;
  box-shadow: 0 8px 22px -10px #ffdd00;
}
.header-actions .bmc-btn,
.header-row .bmc-btn { padding: 7px 13px; font-size: 0.82rem; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
}
.lang-toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 11px;
  font-family: var(--ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.lang-toggle button:hover { color: var(--text); }
.lang-toggle button.active { background: var(--accent); color: var(--on-accent); }

.theme-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 36px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: border-color 0.15s, transform 0.15s;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ------------------------------ Saved CV --------------------------------- */
.saved-cv {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--add-fg);
}
.saved-cv code { color: var(--text); }
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
  padding: 0 0 0 4px;
}
.link-btn:hover { color: var(--accent); }

code {
  background: var(--chip);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: var(--mono);
}

/* ------------------------------- Layout ---------------------------------- */
main { max-width: var(--page-w); margin: 0 auto; padding: 16px 24px 80px; }

.card {
  background:
    linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 24px; }

/* "I don't have a job offer" toggle: a plain inline checkbox + label, not the
   bold block style the default `label` rule applies. */
.nojob-toggle {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 400;
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
}
.nojob-toggle input {
  margin: 0;
  /* nudge down so the box optically centres on the first line of the label,
     and stays aligned to that first line when the text wraps on narrow screens. */
  margin-top: 4px;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
/* When ticked, the JD/strength sections hide and this hint becomes the last
   thing before the submit button — give it room so they don't collide. */
#noJobHint { margin-bottom: 24px; }
label {
  display: block;
  font-weight: 600;
  margin-bottom: 9px;
  letter-spacing: 0.005em;
}
.field-label { display: block; font-weight: 600; margin-bottom: 9px; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  margin: 0;
  color: var(--text);
  cursor: pointer;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.radio-row label:hover { border-color: var(--border-strong); }
.radio-row label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.radio-row input { margin: 0; accent-color: var(--accent); }
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }

/* ------------------------------ Dropzone --------------------------------- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  padding: 40px 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--inset);
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.18s;
  overflow: hidden;
}
.dropzone::before {
  content: "↑";
  display: block;
  font-size: 1.4rem;
  color: var(--accent);
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.dropzone:hover::before, .dropzone.drag::before { transform: translateY(-3px); }
.dropzone.has-file {
  border-style: solid;
  border-color: var(--add-fg);
  color: var(--text);
  background: var(--add-bg);
}
.dropzone.has-file::before { content: "✓"; color: var(--add-fg); }
.dropzone.disabled { cursor: not-allowed; opacity: 0.55; pointer-events: none; }

/* ------------------------------ Inputs ----------------------------------- */
textarea,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: var(--inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  font-family: inherit;
  font-size: 0.96rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.6; }
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --------------------------- Primary button ------------------------------ */
button#submit,
#loginForm button[type="submit"] {
  width: 100%;
  position: relative;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-family: var(--ui);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 30px -12px var(--accent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
button#submit:hover:not(:disabled),
#loginForm button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px -12px var(--accent);
  filter: saturate(1.1);
}
button#submit:active:not(:disabled),
#loginForm button[type="submit"]:active:not(:disabled) { transform: translateY(0); }
button#submit:disabled,
#loginForm button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------ Status ----------------------------------- */
.status { margin: 18px 0 0; color: var(--muted); }
.status.error { color: var(--del-fg); }

.limit-rule {
  text-align: center;
  color: var(--faint);
  font-size: 0.82rem;
  margin: 12px 0 0;
}

/* ----------------------------- Progress ---------------------------------- */
.progress[hidden] { display: none; }
.progress {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 18px 0 0;
  padding: 20px 20px 18px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 14px;
  animation: revealUp 0.5s var(--ease) backwards;
}
.spinner {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-text { display: flex; align-items: center; gap: 12px; min-width: 0; }
.progress-copy { min-width: 0; }
.progress-msg { font-weight: 600; }
.progress-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .progress { animation: none; }
}

/* ---- Live pipeline tracker (read → tailor → compile), event-driven ------ */
.tracker {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tracker-stage {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}
.tracker-dot {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--border-strong);
  background: var(--card);
  color: var(--on-accent);
  flex: 0 0 auto;
  transition: border-color 0.35s var(--ease), background 0.35s var(--ease);
}
.tracker-dot::before {
  /* solid inner core for the active state */
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.35s var(--ease);
}
.tracker-check {
  position: absolute;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}
.tracker-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--faint);
  transition: color 0.35s var(--ease);
  white-space: nowrap;
}
.tracker-link {
  flex: 1 1 auto;
  height: 2px;
  min-width: 14px;
  border-radius: 2px;
  background: var(--border-strong);
  overflow: hidden;
}
.tracker-link i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.6s var(--ease);
}

/* state: active — pulsing ring, lit core + label */
.tracker-stage.is-active .tracker-dot {
  border-color: var(--accent);
  animation: pulseRing 1.6s ease-out infinite;
}
.tracker-stage.is-active .tracker-dot::before { transform: scale(1); }
.tracker-stage.is-active .tracker-label { color: var(--text); }

/* state: done — filled dot + drawn check */
.tracker-stage.is-done .tracker-dot {
  border-color: var(--accent);
  background: var(--accent);
}
.tracker-stage.is-done .tracker-dot::before { transform: scale(0); }
.tracker-stage.is-done .tracker-check { animation: drawCheck 0.45s var(--ease) forwards; }
.tracker-stage.is-done .tracker-label { color: var(--text); }
.tracker-link.is-filled i { width: 100%; }

@keyframes drawCheck { to { stroke-dashoffset: 0; } }
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Overall determinate bar */
.tracker-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--border-strong);
  overflow: hidden;
}
.tracker-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.6s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  .tracker-stage.is-active .tracker-dot { animation: none; }
  .tracker-stage.is-done .tracker-check { animation: none; stroke-dashoffset: 0; }
  .tracker-link i, .tracker-bar i, .tracker-dot,
  .tracker-dot::before, .tracker-label { transition: none; }
}

/* ============================ Motion system ============================= */
/* Sections are shown immediately (no scroll-triggered reveal animation). */
[data-reveal] { opacity: 1; transform: none; filter: none; }

@keyframes revealUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Result reveal choreography */
.results.revealing { animation: revealUp 0.6s var(--ease) backwards; }
.results.revealing .results-header { animation: revealUp 0.55s var(--ease) backwards 0.08s; }
.results.revealing .actions .btn { animation: revealUp 0.5s var(--ease) backwards; }
.results.revealing .actions .btn:nth-child(1) { animation-delay: 0.16s; }
.results.revealing .actions .btn:nth-child(2) { animation-delay: 0.24s; }
.results.revealing .actions .btn:nth-child(3) { animation-delay: 0.32s; }
.results.revealing .tabs { animation: revealUp 0.5s var(--ease) backwards 0.34s; }

.results-title { display: flex; align-items: center; gap: 12px; }
.result-check {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  transform: scale(0);
}
.result-check svg {
  width: 17px; height: 17px;
  fill: none; stroke: var(--on-accent);
  stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 26; stroke-dashoffset: 26;
}
.results.revealing .result-check { animation: popIn 0.45s var(--ease) forwards 0.1s; }
.results.revealing .result-check svg { animation: drawCheck 0.5s var(--ease) forwards 0.3s; }
@keyframes popIn { to { transform: scale(1); } }

/* Dropzone confirm pulse the moment a file is accepted */
.dropzone.has-file { animation: confirmPulse 0.5s var(--ease); }
@keyframes confirmPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--add-fg) 45%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

/* Submit button reads as actively "working" during a run */
button#submit.working { position: relative; overflow: hidden; }
button#submit.working::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.22) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  animation: sheen 1.4s linear infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  .results.revealing,
  .results.revealing * { animation: none; }
  .result-check { transform: scale(1); }
  .result-check svg { stroke-dashoffset: 0; }
  .dropzone.has-file { animation: none; }
  button#submit.working::after { animation: none; display: none; }
}

/* --- Sticky privacy banner: always-on PII-masking reassurance, top of page -- */
.pii-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-2));
  border-bottom: 1px solid var(--accent-line);
}
.pii-banner-icon { flex: none; }
@media (max-width: 600px) {
  .pii-banner { font-size: 0.78rem; padding: 8px 12px; }
}

/* ----------------------- Notes / banners (cards) ------------------------- */
.orphan-banner,
.pdf-note,
.compile-note {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin: 14px 0 0;
  border: 1px solid var(--border);
}
.orphan-banner { background: var(--add-bg); color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn-fg) 35%, transparent); }
.orphan-banner code { background: rgba(0, 0, 0, 0.25); }
.pdf-note { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.compile-note { background: var(--del-bg); color: var(--del-fg); border-color: color-mix(in srgb, var(--del-fg) 35%, transparent); white-space: pre-wrap; }

.privacy-note { margin: 12px 0 0; font-size: 0.82rem; color: var(--faint); }

/* ------------------------------ Cards: limit/review ---------------------- */
.limit-card { margin-top: 28px; text-align: center; }
.limit-card h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 1.7rem; }
.limit-card p { margin: 6px 0; color: var(--muted); }
.limit-card .bmc-btn { margin-top: 12px; font-size: 1rem; padding: 13px 22px; }
#limitCountdown { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }

/* --------------------------- Maintenance page ---------------------------- */
/* Used by the standalone maintenance.html the server serves while down. */
.maintenance-card {
  margin-top: 48px;
  text-align: center;
  padding: 48px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.maintenance-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.maintenance-icon svg { width: 32px; height: 32px; }
.maintenance-card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
}
.maintenance-msg {
  margin: 4px 0 18px;
  color: var(--muted);
  max-width: 44ch;
  line-height: 1.6;
}
.maintenance-hint { margin: 14px 0 0; color: var(--faint); font-size: 0.88rem; }

.review-body h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--accent); }
.review-body p { margin: 6px 0; }
.review-body ul { margin: 6px 0; padding-left: 22px; }
.review-body li { margin: 4px 0; }
.review-body .muted, .muted { color: var(--muted); }
.review-body .error { color: var(--del-fg); }

/* ------------------------------ Results ---------------------------------- */
.results { margin-top: 32px; }
.results-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-header h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chip);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 15px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.danger { background: var(--del-bg); color: var(--del-fg); border-color: color-mix(in srgb, var(--del-fg) 35%, transparent); }
.btn.danger:hover { border-color: var(--del-fg); }

/* Confirmation modal (admin actions) */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  animation: modalFade 0.18s var(--ease);
}
.modal-card {
  position: relative;
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: modalPop 0.2s var(--ease);
}
.modal-title { margin: 0 0 10px; font-size: 1.15rem; }
.modal-msg { margin: 0 0 22px; color: var(--muted); line-height: 1.55; font-size: 0.95rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modalFade { from { opacity: 0; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-card { animation: none; }
}

.file-summary { color: var(--muted); font-size: 0.9rem; margin: 14px 0 0; }

/* -------------------------------- Tabs ----------------------------------- */
.tabs { display: flex; gap: 2px; margin: 22px 0 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  padding: 11px 15px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 0.92rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panelIn 0.42s var(--ease) backwards; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(5px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@media (prefers-reduced-motion: reduce) { .tab-panel.active { animation: none; } }

/* ----------------------------- Code / diff ------------------------------- */
/* Two-column diff view: a per-file sidebar (multi-file .zip) + the diff pane. */
.diff-layout {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.diff-nav {
  flex: 0 0 220px;
  max-width: 240px;
  border-right: 1px solid var(--border);
  background: var(--inset);
  max-height: 640px;
  overflow-y: auto;
  padding: 6px;
}
.diff-file {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--ui);
  transition: background 0.15s, color 0.15s;
}
.diff-file:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.diff-file.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.diff-file-name {
  font-size: 0.84rem;
  font-weight: 600;
  word-break: break-all;
  font-family: var(--mono);
}
.diff-file-stat { font-size: 0.74rem; display: flex; gap: 8px; }
.diff-file.unchanged .diff-file-stat { font-style: italic; opacity: 0.7; }
.add-count { color: var(--add-fg); font-weight: 600; }
.del-count { color: var(--del-fg); font-weight: 600; }

.diff-pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.diff-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-2);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.diff-head-name { font-weight: 700; color: var(--text); word-break: break-all; }
.diff-head-stat { display: flex; gap: 10px; white-space: nowrap; }

pre.diff {
  background: var(--code-bg);
  padding: 18px;
  overflow: auto;
  max-height: 600px;
  font-size: 0.82rem;
  font-family: var(--mono);
  line-height: 1.55;
  white-space: pre;
  margin: 0;
  flex: 1 1 auto;
}
.diff .add { color: var(--add-fg); background: var(--add-bg); display: block; }
.diff .del { color: var(--del-fg); background: var(--del-bg); display: block; }
.diff .hunk {
  color: var(--accent);
  display: block;
  margin: 8px 0 2px;
  opacity: 0.85;
  font-size: 0.78rem;
}
.diff .ctx { display: block; color: var(--muted); }
.diff-empty { display: block; color: var(--muted); font-style: italic; }

@media (max-width: 720px) {
  .diff-layout { flex-direction: column; }
  .diff-nav {
    flex-basis: auto;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    max-height: none;
  }
  .diff-file { flex: 0 0 auto; min-width: 140px; }
}

.pdf {
  width: 100%;
  height: 720px;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  background: #fff;
}

/* -------------------------------- Modal ---------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  animation: modalFade 0.18s var(--ease);
}
.modal[hidden] { display: none; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  max-width: 440px;
  width: 100%;
  padding: 26px 26px 22px;
  animation: modalPop 0.22s var(--ease);
}
@keyframes modalPop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-title { margin: 0 0 8px; font-size: 1.12rem; font-weight: 700; color: var(--text); }
.modal-title[hidden] { display: none; }
.modal-body { margin: 0; color: var(--muted); line-height: 1.55; font-size: 0.95rem; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 22px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
@media (prefers-reduced-motion: reduce) {
  .modal, .modal-card { animation: none; }
}

/* ===================== How it works + FAQ (editorial) ==================== */
.seo-content { margin-top: 56px; }
.seo-content > h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.01em;
  margin: 40px 0 22px;
}
.seo-content > h2::after {
  content: "";
  display: block;
  width: 48px;
  height: 2px;
  margin-top: 12px;
  background: var(--accent);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  counter-reset: step;
}
.step {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 22px 22px;
  counter-increment: step;
  transition: border-color 0.18s, transform 0.18s;
}
.step:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.step::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  font-family: var(--display);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 14px;
  opacity: 0.9;
}
.step h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.step p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

.faq { display: flex; flex-direction: column; gap: 10px; }
.faq details {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 18px;
  transition: border-color 0.15s;
}
.faq details[open] { border-color: var(--border-strong); }
.faq summary {
  cursor: pointer;
  padding: 15px 0;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  color: var(--accent);
  font-weight: 400;
  font-size: 1.3rem;
  transition: transform 0.2s ease;
}
.faq details[open] summary::after { content: "+"; transform: rotate(45deg); }
.faq details p { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }

/* ------------------------------- Footer ---------------------------------- */
.site-footer {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 32px 24px;
  color: var(--faint);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* =============================== Admin =================================== */
.admin-tag {
  font-family: var(--ui);
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 6px;
  padding: 2px 8px;
  vertical-align: middle;
  margin-left: 8px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 22px;
  font-size: 0.85rem;
  color: var(--muted);
}
.status-strip strong { color: var(--text); font-weight: 600; }
.strip-spacer { flex: 1 1 auto; }
.strip-sep { opacity: 0.4; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--add-fg); font-weight: 600; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--add-fg);
  animation: livepulse 2s ease-out infinite;
}
@keyframes livepulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--add-fg) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

.group-title {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin: 26px 0 12px;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}
.stat {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.stat:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-head { display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 0; }
.stat-ic {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.stat-label { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-num { font-family: var(--display); font-size: 2.3rem; font-weight: 400; letter-spacing: -0.01em; line-height: 1; }

.stat[data-tone="ok"]::before   { background: var(--add-fg); }
.stat[data-tone="ok"]   .stat-num, .stat[data-tone="ok"]   .stat-ic { color: var(--add-fg); }
.stat[data-tone="warn"]::before { background: var(--warn-fg); }
.stat[data-tone="warn"] .stat-num, .stat[data-tone="warn"] .stat-ic { color: var(--warn-fg); }
.stat[data-tone="bad"]::before  { background: var(--del-fg); }
.stat[data-tone="bad"]  .stat-num, .stat[data-tone="bad"]  .stat-ic { color: var(--del-fg); }
.stat[data-tone="info"]::before { background: var(--accent); }
.stat[data-tone="info"] .stat-num, .stat[data-tone="info"] .stat-ic { color: var(--accent); }

.admin-section { margin-bottom: 22px; }
.admin-section .results-header { margin-bottom: 8px; }
.admin-section:first-of-type { margin-top: 24px; }

.pill {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 10px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
  background: var(--add-bg);
  color: var(--add-fg);
}
.pill[data-on="1"] { background: var(--del-bg); color: var(--del-fg); }

.config-card { padding: 0; }
.config-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.config-card > summary::-webkit-details-marker { display: none; }
.config-card > summary h2 { margin: 0; font-family: var(--display); font-weight: 400; }
.config-card > summary::after { content: "▸"; color: var(--muted); margin-left: auto; transition: transform 0.15s; }
.config-card[open] > summary::after { transform: rotate(90deg); }
.config-card .config-table { margin: 0 24px 24px; width: calc(100% - 48px); }

.limited-list { margin-top: 12px; }
.limited-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.limited-row code { flex: 1; }
.limited-row .muted { font-size: 0.85rem; }

.config-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.config-table th, .config-table td {
  text-align: left;
  padding: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.config-table th { color: var(--muted); font-weight: 600; width: 40%; }
.config-table td { font-family: var(--mono); }

.admin-meta { margin-top: 16px; font-size: 0.82rem; }

/* admin h1 stays serif-display like everything else */
h2 { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; }

/* --------------------------- Responsive ---------------------------------- */
@media (max-width: 600px) {
  .hero { padding: 40px 0 24px; }
  .card { padding: 22px; }
  .brand-name { display: none; }

  /* Tighter page gutters so cards get more usable width on phones. */
  header,
  .site-header,
  .site-footer { padding-left: 16px; padding-right: 16px; }
  main { padding: 12px 16px 64px; }

  /* Header controls stay on one row; let the support button shrink gracefully. */
  .header-actions { gap: 6px; }

  /* Download / view actions: full-width, stacked, comfortable tap targets. */
  .results-header { gap: 14px; }
  .results-header .actions { width: 100%; }
  .results-header .actions .btn { flex: 1 1 auto; justify-content: center; }
  .doc-view { flex: 1 1 100%; }
  .doc-view button { flex: 1 1 0; text-align: center; }

  /* Pipeline tracker: shrink dots, gaps and labels so the three French stage
     names (Lecture · Adaptation · Compilation) never overflow the card. */
  .tracker { gap: 4px; }
  .tracker-stage { gap: 6px; }
  .tracker-dot { width: 22px; height: 22px; }
  .tracker-check { width: 13px; height: 13px; }
  .tracker-label { font-size: 0.78rem; }
  .tracker-link { min-width: 8px; }

  .progress { padding: 16px 16px 14px; }

  /* Tabs scroll horizontally instead of wrapping into a tall stack. */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 11px 13px; }

  .pdf { height: 60vh; }
}

/* Very small phones — drop the tracker labels to icons-only so the row of
   dots can't overflow even at ~320px wide. The status line below the tracker
   still names the current stage in full. */
@media (max-width: 360px) {
  .tracker-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* --- Live .docx preview + track-changes --- */
.doc-pane {
  margin-top: 14px;
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #e7e7ec;
  padding: 12px;
}
.doc-pane .docx-wrapper { background: transparent; padding: 0; box-shadow: none; }
.doc-pane p.rc-changed { transition: background 0.4s; }
.rc-del { color: #b4233a; text-decoration: line-through; }
.rc-add { color: #0c7a3b; background: #d6f5e2; border-radius: 2px; }

.doc-view {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.doc-view button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.doc-view button.active { background: var(--accent); color: var(--on-accent); }

.doc-analysis { margin-top: 14px; }
.doc-analysis summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 0;
}
#dlDocx:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- PDF live read-only preview --- */
.pdf-page {
  display: block;
  max-width: 100%;
  margin: 0;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  background: #fff;
}
/* A page + its in-place text overlay, sized to the rendered canvas. */
.pdf-page-wrap {
  position: relative;
  margin: 0 auto 16px;
}
.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: visible;
}
/* One box per source line, at the line's real position. Invisible by default so
   the canvas render shows through; visible (and masking) once the line changes. */
.pdf-ovl-line {
  position: absolute;
  margin: 0;
  padding: 0;
  line-height: 1;
  white-space: nowrap;
  color: transparent;
  pointer-events: none;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.pdf-ovl-line.serif { font-family: Georgia, "Times New Roman", Times, serif; }
.pdf-ovl-line.bold { font-weight: 700; }
.pdf-ovl-line.italic { font-style: italic; }
.pdf-ovl-line.rc-changed {
  color: #1a1a1a;
  background: #fff;            /* mask the original glyphs underneath */
  pointer-events: auto;
  box-shadow: 0 0 0 3px #fff;  /* hide antialiased edges of the original */
  border-radius: 2px;
  /* A track-changes line (strike + insert) is longer than the original; let it
     wrap within the line's width and lift above neighbours instead of running
     off the page. The clean corrected text is in the downloadable PDF. */
  white-space: normal;
  line-height: 1.15;
  z-index: 2;
  min-width: 8em;
}
.pdf-ovl-line .rc-add { padding: 0 1px; }
.pdf-changes {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--inset);
}
.pdf-change-line { margin: 0 0 9px; line-height: 1.55; }
.pdf-change-line:last-child { margin-bottom: 0; }
