/* ── Design tokens ── */
:root {
  --ink: #1a1a1a;
  --ink-muted: #6b6b6b;
  --ink-faint: #6d6d6d; /* was #b0b0b0 — failed WCAG contrast on white */
  --surface: #faf9f6;
  --surface-card: #ffffff;
  --surface-hover: #f2f0eb;
  --accent: #9b2226;
  --accent-light: #fce8e8;
  --correct: #2d6a4f;
  --correct-light: #d8f0e6;
  --wrong: #9b2226;
  --wrong-light: #fce8e8;
  --present: #8a6a00;
  --present-light: #fef3cd;
  --border: rgba(26,26,26,0.1);
  --border-strong: rgba(26,26,26,0.2);
  --radius: 4px;
  --radius-lg: 12px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* ── Keyboard focus ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visually hidden but still read by screen readers */
.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;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 246, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.header-logo span { color: var(--accent); }

nav { display: flex; align-items: center; gap: 8px; }
nav a {
  font-size: 0.875rem;
  color: var(--ink-muted);
  text-decoration: none;
  display: inline-block;
  padding: 10px 14px;
  border-radius: 100px;
  transition: all 0.2s var(--ease);
}
nav a:hover { color: var(--ink); background: var(--surface-hover); }

/* ── Hero ── */
.hero {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 48px 48px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero-eyebrow::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.0;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 16px;
}
.hero h1 em { font-style: italic; color: var(--accent); }

.hero-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-muted);
  max-width: 480px;
  font-weight: 300;
}

.hero-rule {
  /* Align with the hero's content column (860px minus 48px gutters) */
  width: calc(100% - 96px);
  max-width: 764px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong) 0%, transparent 100%);
  position: relative;
  z-index: 1;
}

/* ── Main layout ── */
.tool-layout {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 48px 100px;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Sidebar panel ── */
.controls-panel {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: 84px;
}

.panel-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Custom checkbox */
.check-label {
  position: relative;
  display: flex;
  min-height: 28px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink-muted);
  transition: color 0.2s;
}
.check-label:hover { color: var(--ink); }
/* Visually hidden, but still focusable/toggleable from the keyboard
   (display:none removed it from the tab order) */
.check-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.check-label input:focus-visible + .check-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.check-box {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
}
.check-label input:checked + .check-box {
  background: var(--ink);
  border-color: var(--ink);
}
.check-label input:checked + .check-box::after {
  content: '';
  display: block;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.panel-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Main content area ── */
.tool-main { display: flex; flex-direction: column; gap: 16px; }

/* ── Cards ── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-card);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-hover); border-color: var(--ink); }
.btn-icon:active { transform: scale(0.95); }

.btn-ghost {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  padding: 9px 16px;
  min-height: 36px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--ink); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Footer ── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 28px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
footer p { font-size: 0.8rem; color: var(--ink-faint); }
footer a { color: var(--ink-muted); text-decoration: none; font-size: 0.8rem; }
footer a:hover { color: var(--ink); }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Mobile ── */
@media (max-width: 680px) {
  header { padding: 0 20px; }
  .hero { padding: 44px 20px 36px; }
  .hero-rule { width: calc(100% - 40px); }
  .tool-layout {
    grid-template-columns: 1fr;
    padding: 24px 20px 80px;
    gap: 16px;
  }
  .controls-panel { position: static; }
  .form-group { flex-direction: row; flex-wrap: wrap; }
  footer { padding: 24px 20px; }
  .form-group { gap: 6px 16px; }
}

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