/* ============================================================
   Litheca — Direction B: Precision White
   Design tokens from DESIGN.md:
     bg:         #ffffff
     foreground: #171717
     accent:     #ff5b4f  (primary actions, emphasis)
     surface:    #e3ecf6  (cards, panels)
     muted:      #4d4d4d  (secondary text)
     border:     #eaeaea
     link-blue:  #0072f5  (secondary actions)
   Font: Inter → system-ui fallback
   Radius: 8px · Border: 1px · Grid: 8px baseline
   ============================================================ */

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:           #ffffff;
  --bg-subtle:    #fafafa;
  --fg:           #171717;
  --fg-muted:     #4d4d4d;
  --fg-faint:     #999999;
  --accent:       #ff5b4f;
  --accent-bg:    #fff2f1;
  --accent-hover: #e04840;
  --blue:         #0072f5;
  --blue-bg:      #ebf5ff;
  --surface:      #e3ecf6;
  --border:       #eaeaea;
  --border-med:   #d4d4d4;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
          Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --r:    8px;
  --r-sm: 5px;
  --r-lg: 12px;

  --container: 1120px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  color: var(--fg);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

img { display: block; max-width: 100%; }

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

/* ── Container ───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--r-sm);
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
  white-space: nowrap;
}
.btn-primary:hover {
  background: #333;
  border-color: #333;
  color: var(--bg);
  text-decoration: none;
}

.btn-sm { padding: 7px 14px; font-size: 12px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
  border-color: var(--fg);
  color: var(--fg);
  text-decoration: none;
}

/* ── HEADER ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 100%;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.site-logo:hover { text-decoration: none; }
.logo-mark { display: block; flex-shrink: 0; }
.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.03em;
  line-height: 1;
}

/* Nav links */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover {
  color: var(--fg);
  background: var(--bg-subtle);
  text-decoration: none;
}
.nav-link.active { color: var(--fg); }

.header-right { margin-left: auto; }

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
}
.hamburger-line {
  display: block;
  width: 20px; height: 1.5px;
  background: var(--fg);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── HERO ────────────────────────────────────────────────── */
.hero {
  border-bottom: 1px solid var(--border);
  padding: 0 0 56px;
}

/* Status strip — the Direction B signature */
.hero-stats {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hero-stats::-webkit-scrollbar { display: none; }

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 32px;
  flex-shrink: 0;
}
.hero-stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}
.hero-stat-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hero-stat-val em {
  font-style: normal;
  color: var(--accent);
}
.free-val { color: var(--accent); }
.hero-stat-label {
  font-size: 11px;
  color: var(--fg-faint);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Hero body */
.hero-body { max-width: 680px; }

.hero-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
  font-family: var(--font-mono);
}

.hero-heading {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.06;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}

.hero-sub {
  font-size: 16px;
  color: var(--fg-muted);
  line-height: 1.65;
  margin-bottom: 32px;
  max-width: 520px;
}

/* Search bar */
.hero-search {
  display: flex;
  align-items: center;
  max-width: 520px;
  border: 1.5px solid var(--border-med);
  border-radius: var(--r);
  background: var(--bg-subtle);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
}
.hero-search:focus-within {
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(23,23,23,0.06);
  background: var(--bg);
}
.hero-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  color: var(--fg);
  padding: 12px 16px;
  outline: none;
  min-width: 0;
}
.hero-search-input::placeholder { color: var(--fg-faint); }
.hero-search-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--bg);
  background: var(--fg);
  border: none;
  padding: 10px 18px;
  margin: 4px;
  border-radius: calc(var(--r) - 3px);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.hero-search-btn:hover { background: #333; }

/* Quick-pick tags */
.hero-picks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.picks-label {
  font-size: 12px;
  color: var(--fg-faint);
  font-weight: 500;
}
.pick-tag {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pick-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── TOOLS SECTION ───────────────────────────────────────── */
.tools-section {
  padding: 56px 0;
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
}
.section-sub {
  font-size: 13px;
  color: var(--fg-faint);
  margin-top: 2px;
}

/* Tool grid — 4 columns */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Tool card */
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease),
              transform 0.15s var(--ease);
  cursor: pointer;
  min-height: 160px;
}
.tool-card:hover {
  border-color: var(--border-med);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.tool-card:hover .tool-card-arrow { opacity: 1; color: var(--fg); }

/* Featured card — subtle accent top border */
.tool-card--featured { border-top: 2px solid var(--accent); }

.tool-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.tool-card-icon {
  width: 34px; height: 34px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}
.tool-card--featured .tool-card-icon {
  background: var(--accent-bg);
  border-color: #ffd0cc;
  color: var(--accent);
}

.tool-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 6px;
  line-height: 1;
}
.tool-badge--hot {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: #ffd0cc;
}

.tool-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.tool-card-desc {
  font-size: 13px;
  color: var(--fg-faint);
  line-height: 1.55;
  flex: 1;
}

.tool-card-arrow {
  position: absolute;
  top: 18px; right: 18px;
  font-size: 13px;
  color: var(--border-med);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, transform 0.15s;
}
.tool-card:hover .tool-card-arrow { transform: translate(1px, -1px); }

/* ── AFFILIATE STRIP ─────────────────────────────────────── */
.affiliate-strip {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.affiliate-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.affiliate-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.affiliate-icon {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.affiliate-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}
.affiliate-text span {
  font-size: 12px;
  color: var(--fg-faint);
}

.affiliate-btn {
  background: var(--accent);
  border-color: var(--accent);
  flex-shrink: 0;
}
.affiliate-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
  text-decoration: none;
}

/* ── TOOL PAGES ──────────────────────────────────────────── */
.tool-page {
  padding: 48px 0 80px;
}

.tool-page-header {
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-faint);
  margin-bottom: 16px;
}
.breadcrumb a {
  color: var(--fg-faint);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--fg); }
.breadcrumb-sep { color: var(--border-med); }

.tool-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.035em;
  margin-bottom: 8px;
}
.tool-page-desc {
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* Form */
.tool-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--fg);
  background: var(--bg-subtle);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(23,23,23,0.06);
  background: var(--bg);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--fg-faint); }
.form-textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

/* Depth / segmented control */
.depth-control {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-med);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-subtle);
  width: fit-content;
}
.depth-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.depth-btn:last-child { border-right: none; }
.depth-btn.active {
  background: var(--fg);
  color: var(--bg);
}
.depth-btn:hover:not(.active) { background: var(--border); }

/* Result area */
.result-area {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px;
  min-height: 200px;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 0;
  gap: 10px;
}
.result-placeholder-icon {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-faint);
  margin-bottom: 4px;
}
.result-placeholder p {
  font-size: 13px;
  color: var(--fg-faint);
}

/* Loading state */
.result-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 0;
  font-size: 13px;
  color: var(--fg-faint);
}
.spinner {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-med);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-output {
  font-size: 15px;
  line-height: 1.75;
  color: var(--fg);
  white-space: pre-wrap;
}

/* Accent-tinted section headings inside AI summaries — applies to both the
   dynamic summarizer page and static /summary/<slug>/ book pages. */
.ai-output h2 {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  white-space: normal;
}
.ai-output h2:first-of-type { margin-top: 0; }
.ai-output h3 {
  font-size: 14px;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
  opacity: 0.85;
  white-space: normal;
}

.result-error {
  font-size: 13px;
  color: #c0392b;
  background: #fff5f5;
  border: 1px solid #fdd;
  border-radius: var(--r-sm);
  padding: 12px 16px;
}

/* Transparency notice on static book pages: what generated this page, what
   it's grounded in, and when. Deliberately plain/quiet — a trust signal,
   not a decoration. */
.ai-disclosure-notice {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  margin: 20px 0 32px;
}
.ai-disclosure-notice strong { color: var(--fg); font-weight: 600; }

/* ── BOOK PAGE ───────────────────────────────────────────── */
.book-page { padding: 48px 0 80px; }

.book-hero {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 40px;
  align-items: start;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.book-cover {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.book-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: -0.04em;
}

.book-genre {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.book-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}
.book-author {
  font-size: 16px;
  color: var(--fg-muted);
  margin-bottom: 20px;
}
.book-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.book-meta-tag {
  font-size: 12px;
  color: var(--fg-faint);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 10px;
}

/* Book tabs */
.book-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.book-tab {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 20px;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.book-tab:hover { color: var(--fg); }
.book-tab.active { color: var(--fg); border-bottom-color: var(--fg); }

.book-panel { display: none; }
.book-panel.active { display: block; }

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: 80px;
}

.footer-inner {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 64px;
  padding: 48px 24px 40px;
}

.footer-logo { margin-bottom: 10px; }
.footer-tagline {
  font-size: 13px;
  color: var(--fg-faint);
  line-height: 1.5;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.footer-col-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.footer-col a {
  display: block;
  font-size: 13px;
  color: var(--fg-faint);
  margin-bottom: 8px;
  text-decoration: none;
  transition: color 0.15s;
}
.footer-col a:hover { color: var(--fg); text-decoration: none; }
.footer-disclosure {
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.6;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 24px;
}
.footer-bottom-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-bottom p {
  font-size: 12px;
  color: var(--fg-faint);
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  /* Tighter gutters + header spacing on phones. The desktop 24px gutters
     and 32px header gap overflow narrow viewports (≤360px), which let the
     whole page scroll sideways and clipped the hamburger/search button. */
  .container { padding: 0 16px; }
  .header-inner { gap: 12px; }
  .site-nav { display: none; }
  .header-right {
    display: flex !important;
    margin-left: auto;
    gap: 8px;
  }
  .header-right .btn-primary {
    display: none;
  }
  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    gap: 2px;
    z-index: 99;
  }
  .nav-toggle {
    display: flex;
    margin-left: 4px;
  }

  /* Hero */
  .hero-stat { padding: 14px 20px; }
  .hero-stat-val { font-size: 22px; }
  .hero-heading { font-size: 32px; }
  .hero-sub { font-size: 15px; }
  .hero-search { flex-direction: column; align-items: stretch; }
  .hero-search-btn { margin: 0 4px 4px; width: calc(100% - 8px); justify-content: center; }

  /* Tools */
  .tools-grid { grid-template-columns: repeat(2, 1fr); }

  /* Affiliate */
  .affiliate-inner { flex-direction: column; align-items: flex-start; }

  /* Book */
  .book-hero { grid-template-columns: 130px 1fr; gap: 24px; }

  /* Footer */
  .footer-inner { grid-template-columns: 1fr; gap: 32px; padding: 32px 24px; }
  .footer-nav { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr; }
  .book-hero { grid-template-columns: 1fr; }
  .footer-nav { grid-template-columns: 1fr; }
  .hero-stats { flex-wrap: wrap; }
  .hero-stat-divider { display: none; }
}

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

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

/* ── THEME SWITCHER & DARK MODE OVERRIDES ────────────────── */
html[data-theme="dark"] {
  --bg:           #0b0f19;
  --bg-subtle:    #111827;
  --fg:           #f9fafb;
  --fg-muted:     #9ca3af;
  --fg-faint:     #6b7280;
  --accent:       #ff5b4f;
  --accent-bg:    #2d1918;
  --accent-hover: #ff7368;
  --blue:         #3b82f6;
  --blue-bg:      #1e293b;
  --surface:      #1f2937;
  --border:       #1f2937;
  --border-med:   #374151;
}

/* Adjust header backdrop in dark mode */
html[data-theme="dark"] .site-header {
  background: rgba(11, 15, 25, 0.85);
}

/* Flip logo colors in dark mode */
html[data-theme="dark"] .logo-mark rect {
  fill: #0b0f19;
}
html[data-theme="dark"] .logo-mark rect:first-child {
  fill: #f9fafb;
}

/* Theme Toggle Button Styles */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-med);
  color: var(--fg-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  padding: 0;
}

.theme-toggle-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
  background: var(--bg-subtle);
}

.theme-icon {
  display: block;
}

/* Fallback/Default Light theme overrides if attribute is missing */
.theme-icon.sun-icon { display: none; }
.theme-icon.moon-icon { display: block; }

html[data-theme="dark"] .sun-icon { display: block; }
html[data-theme="dark"] .moon-icon { display: none; }

html[data-theme="light"] .sun-icon { display: none; }
html[data-theme="light"] .moon-icon { display: block; }

/* ── Toasts (window.bhToast in main.js) ─────────────────── */
#bh-toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; max-width: min(92vw, 480px);
}
.bh-toast {
  background: var(--fg); color: var(--bg);
  font-size: 13px; font-weight: 600; line-height: 1.45;
  padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.bh-toast.show { opacity: 1; transform: translateY(0); }
.bh-toast-success { background: #1d7a50; color: #fff; }
.bh-toast-error   { background: #b3261e; color: #fff; }

/* ── Accessibility: consistent keyboard focus ───────────── */
/* :focus-visible only — mouse clicks stay outline-free. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
