/* ════════════════════════════════════════════════════════════════════════
   unitcheatsheet.com — design tokens, layout primitives, and components.
   Sibling stylesheet to regexguide.com but with teal (#0d9488) accent
   so the two sites read as a related family while staying distinct.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand palette ─ teal as the accent, signals engineering/scientific precision.
     Sibling sites regexguide.com and crontabsheet.com use indigo; teal keeps
     this site in the same family while making the visual identity distinct. */
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-deep: #134e4a;

  /* Light theme neutrals */
  --bg: #fafaf8;
  --surface-1: #ffffff;
  --surface-2: #f5f5f4;
  --line: #e4e4e0;
  --ink: #1c1917;
  --ink-muted: #78716c;
  --ink-soft: #57534e;

  /* Type scale */
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Spacing & radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.10);

  --max-width: 1180px;
  --content-width: 760px;
}

[data-theme="dark"] {
  --bg: #18181b;
  --surface-1: #27272a;
  --surface-2: #1f1f23;
  --line: #3f3f46;
  --ink: #fafaf9;
  --ink-muted: #a1a1aa;
  --ink-soft: #d4d4d8;
  --accent: #5eead4;
  --accent-hover: #99f6e4;
  --accent-soft: rgba(94, 234, 212, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { min-height: 100vh; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--accent-hover); }

code, pre, .mono {
  font-family: var(--mono);
  font-size: 0.93em;
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ─────────── LAYOUT ─────────── */

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 64px 0;
}

@media (max-width: 768px) {
  .section { padding: 40px 0; }
  .wrap { padding: 0 18px; }
}

/* ─────────── NAVIGATION ─────────── */

.nav-bar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  color: var(--ink);
}
.nav-brand:hover { color: var(--ink); }

.nav-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  border-radius: 7px;
  letter-spacing: -0.02em;
}

.nav-brand-tld {
  color: var(--accent);
  font-weight: 400;
}

.nav-links {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 4px;
  align-items: center;
}

.nav-links a:not(.btn) {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:not(.btn):hover {
  background: var(--surface-2);
  color: var(--ink);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}

.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  padding: 24px;
  flex-direction: column;
  gap: 8px;
}
.mobile-nav.open { display: flex; }
.mobile-nav ul {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mobile-nav a {
  display: block;
  padding: 14px 16px;
  font-size: 18px;
  border-radius: 8px;
  color: var(--ink);
}
.mobile-nav a:hover { background: var(--surface-2); }

@media (max-width: 980px) {
  .nav-links { display: none; }
  .mobile-nav-toggle { display: inline-block; }
}

/* ─────────── BUTTONS ─────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
}

.btn-secondary {
  background: var(--surface-1);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}
.btn-ghost:hover { color: var(--ink); }

/* ─────────── ADSTERRA BANNER ─────────── */

.ad-banner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  min-height: 100px;
}
.ad-banner-inner.desktop { display: block; width: 728px; height: 90px; max-width: 100%; }
.ad-banner-inner.mobile { display: none; width: 320px; height: 50px; }
@media (max-width: 768px) {
  .ad-banner { min-height: 70px; padding: 10px; }
  .ad-banner-inner.desktop { display: none; }
  .ad-banner-inner.mobile { display: block; }
}

/* ─────────── HERO ─────────── */

.hero {
  padding: 56px 0 32px;
}

.hero-eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

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

.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 22px 0;
  color: var(--ink);
}
.hero h1 em {
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}

.hero-h2 {
  font-family: var(--sans);
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 400;
  line-height: 1.4;
  color: var(--ink-soft);
  margin: 0 0 18px 0;
  max-width: 64ch;
}
.hero-h2 em {
  color: var(--accent);
  font-style: italic;
  font-weight: 500;
}

.hero p {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 64ch;
  margin: 0 0 28px 0;
}

.hero-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.hero-features span {
  display: inline-block;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
[data-theme="dark"] .hero-features span { color: var(--accent); }

/* PDF download CTA */
.cta-download {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.cta-download:hover {
  border-color: var(--accent);
  background: var(--surface-1);
  color: var(--ink);
  transform: translateY(-1px);
}
.cta-download-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.cta-download-text { display: flex; flex-direction: column; line-height: 1.2; }
.cta-download-text strong { font-size: 13px; font-weight: 600; }
.cta-download-text small {
  font-size: 10px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
  font-family: var(--mono);
}
@media (max-width: 640px) {
  .hero-eyebrow-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .cta-download { width: 100%; }
}

/* ─────────── EXPLAINER TOOL ─────────── */

.explainer-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin: 32px 0;
}

.explainer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.explainer-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  color: var(--ink);
}
.explainer-actions { display: flex; flex-wrap: wrap; gap: 8px; row-gap: 6px; }

.regex-input {
  width: 100%;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
  min-height: 50px;
}
.regex-input:focus {
  border-color: var(--accent);
  background: var(--surface-1);
}

.input-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 18px 0 8px 0;
}

.intent-banner {
  margin-top: 20px;
  padding: 18px 22px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-deep);
  font-size: 17px;
  line-height: 1.5;
}
[data-theme="dark"] .intent-banner { color: var(--ink); }
.intent-banner strong {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  color: var(--accent);
  font-weight: 600;
}

.error-banner {
  margin-top: 20px;
  padding: 16px 18px;
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  border-radius: 8px;
  color: #991b1b;
  font-family: var(--mono);
  font-size: 14px;
}
[data-theme="dark"] .error-banner { background: #3b1f1f; color: #fca5a5; }

.warnings-list {
  margin-top: 14px;
  padding: 12px 16px;
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  font-size: 14px;
  color: #78350f;
}
.warnings-list ul { margin: 4px 0 0; padding-left: 18px; }
[data-theme="dark"] .warnings-list { background: #2d2410; color: #fcd34d; }

/* Tree explanation view */
.explain-tree {
  margin-top: 24px;
  padding: 0;
  list-style: none;
}
.explain-node {
  margin: 0;
  padding: 10px 12px 10px 14px;
  border-left: 2px solid var(--line);
  margin-left: 8px;
  position: relative;
}
.explain-node:hover { border-left-color: var(--accent); }
.explain-node-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.explain-token {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 4px;
}
.explain-role {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-weight: 600;
}
.explain-description {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.55;
}
.explain-children {
  margin-top: 8px;
  padding-left: 8px;
  list-style: none;
}

/* Test panel */
.test-panel { margin-top: 28px; }
.test-input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  min-height: 100px;
  resize: vertical;
}
.test-input:focus { border-color: var(--accent); }

.match-output {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
  min-height: 60px;
}
.match-highlight {
  /* Subtle neutral highlight — visible but not visually competing with the
     "X matches found" status line, which is the primary success/fail signal. */
  background: var(--surface-1);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--ink);
}
[data-theme="dark"] .match-highlight {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}
.match-summary {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-muted);
  font-family: var(--mono);
}
/* When matches are found, show the count in green. When no matches are
   found, show the message in a clear red. Bold weight so the status reads
   at a glance. Colors chosen to keep enough contrast on both light
   (default) and dark backgrounds; the greens match the existing
   .test-case.pass and .bench-verdict.good shades used elsewhere. */
.match-summary.success { color: #16a34a; font-weight: 600; }
.match-summary.fail    { color: #dc2626; font-weight: 600; }
[data-theme="dark"] .match-summary.success { color: #4ade80; }
[data-theme="dark"] .match-summary.fail    { color: #f87171; }

/* ─────────── SECTIONS ─────────── */

.section-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 36px 0;
  color: var(--ink);
}
.section-title em {
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}

/* Feature cards grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.feature-card {
  padding: 24px 22px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s;
}
.feature-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.feature-icon {
  font-size: 22px;
  margin-bottom: 12px;
}
.feature-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.feature-card p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ─────────── PROSE (for content pages) ─────────── */

.prose {
  max-width: var(--content-width);
  margin: 0 auto;
}
.prose h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  margin: 48px 0 18px 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.prose h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 20px;
  margin: 36px 0 12px 0;
  color: var(--ink);
}
.prose p { margin: 0 0 16px 0; color: var(--ink-soft); font-size: 17px; line-height: 1.65; }
.prose ul, .prose ol { margin: 0 0 20px 0; padding-left: 24px; color: var(--ink-soft); font-size: 17px; line-height: 1.7; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose code { font-size: 0.92em; }
.prose a { text-decoration: underline; text-decoration-color: rgba(13, 148, 136, 0.4); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }

/* ─────────── PATTERN LIBRARY ─────────── */

.pattern-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0 32px;
}
.pattern-table th,
.pattern-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.pattern-table th {
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
}
.pattern-table tr:last-child td { border-bottom: 0; }
.pattern-table tr:hover td { background: var(--surface-2); }
.pattern-table code {
  display: inline-block;
  background: var(--surface-2);
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  word-break: break-all;
  max-width: 360px;
}
.pattern-table .try-btn {
  display: inline-block;
  padding: 4px 12px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.pattern-table .try-btn:hover { background: var(--accent-hover); color: white; }

/* ─────────── BREADCRUMB ─────────── */

.breadcrumb {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 12px;
}
.breadcrumb a { 
  color: var(--ink); 
  font-weight: 600; 
  transition: color 0.15s; 
  display: inline-block;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 10px; color: var(--ink-muted); }

/* Larger tap targets on mobile (Google accessibility recommendation: ≥32px) */
@media (max-width: 767px) {
  .breadcrumb {
    font-size: 13px;
    line-height: 1.6;
  }
  .breadcrumb a {
    padding: 8px 4px;
    margin: -8px 0;        /* visually keep the breadcrumb height the same */
    min-height: 32px;
    line-height: 16px;
  }
  .breadcrumb span {
    margin: 0 6px;
  }
}

/* ─────────── FOOTER ─────────── */

.footer {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  padding: 56px 0 28px;
  margin-top: 64px;
}

.footer-grid {
  display: grid;
  gap: 32px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--line);
}

.footer-col h4 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 14px 0;
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-col li { margin-bottom: 8px; }
.footer-col a {
  color: var(--ink-soft);
  font-size: 14px;
}
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-muted);
  font-family: var(--mono);
}

/* Footer-grid uses an inline `style="grid-template-columns: 1.5fr 1fr 1fr 1fr"`
   on hundreds of pages, so we use !important to win against the inline rule
   at narrow widths. Without this, the 4-column layout forces ~80px of
   horizontal overflow at 320px viewports. */
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr !important; }
}

/* ─────────── UTILITY ─────────── */

.text-mono { font-family: var(--mono); }
.text-muted { color: var(--ink-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

/* ═══════════════════════════════════════════════════════════════════
 * TOOL TABS + NEW PANELS (added v3)
 * ═══════════════════════════════════════════════════════════════════ */

/* Regex + flags input row */
.regex-input-row { display: flex; gap: 12px; align-items: flex-start; }
.regex-input-wrap { flex: 1 1 auto; min-width: 0; }
.flags-input-wrap { flex: 0 0 80px; }
.flags-input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 16px;
  background: var(--surface-1);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm, 8px);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.flags-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 600px) {
  .regex-input-row { flex-direction: column; }
  .flags-input-wrap { flex: 0 0 auto; width: 100%; }
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 4px;
  margin: 20px 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

/* Replace tab */
.replace-result {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.replace-result .replace-changed {
  background: var(--accent-soft);
  color: var(--accent-deep);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 500;
}
.replace-summary {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-muted);
  font-family: var(--mono);
}

/* Test suite */
.test-case {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin: 6px 0;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--line);
}
.test-case-status {
  flex: 0 0 80px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.test-case.pass .test-case-status { color: #16a34a; }
.test-case.fail .test-case-status { color: #dc2626; }
.test-case-expected {
  flex: 0 0 110px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.test-case-text {
  flex: 1 1 auto;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
}
.test-case-remove {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
}
.test-case-remove:hover { color: #dc2626; }
.test-suite-summary {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.test-suite-summary.all-pass { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.test-suite-summary.some-fail { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Code generator */
.code-flavor-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.code-flavor-tab {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.15s;
}
.code-flavor-tab:hover { color: var(--ink); }
.code-flavor-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.code-output-wrap { position: relative; }
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  font-size: 12px;
  padding: 4px 10px;
}
.code-output {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  overflow-x: auto;
  margin: 0;
  white-space: pre;
}

/* Debug panel */
.debug-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}
.debug-view {
  margin-top: 14px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.debug-input {
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1.8;
  letter-spacing: 1px;
  white-space: pre-wrap;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--surface-1);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.debug-char { padding: 2px 1px; }
.debug-char.debug-cursor {
  background: var(--accent);
  color: white;
  border-radius: 3px;
  position: relative;
  font-weight: 600;
}
.debug-char.debug-cursor::after {
  content: '▾';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent);
  font-size: 12px;
}
.debug-char.debug-matched { background: var(--accent-soft); color: var(--accent-deep); }
.debug-char.debug-eof { color: var(--ink-muted); opacity: 0.5; }
.debug-message {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
}
.debug-message.debug-try { background: var(--surface-1); color: var(--ink-muted); border: 1px solid var(--line); }
.debug-message.debug-match-start { background: var(--accent-soft); color: var(--accent-deep); }
.debug-message.debug-match-success { background: #dcfce7; color: #166534; font-weight: 500; }

/* Diagram */
.diagram-output {
  margin-top: 14px;
  padding: 24px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  text-align: center;
}
.diagram-output svg.railroad { max-width: 100%; height: auto; display: inline-block; }

/* Benchmark */
.bench-output {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.bench-verdict { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.bench-verdict.good { color: #166534; }
.bench-verdict.warn { color: #b45309; }
.bench-verdict.bad { color: #991b1b; }
.bench-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.bench-stat {
  padding: 10px 12px;
  background: var(--surface-1);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.bench-stat-label { font-size: 11px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bench-stat-value { font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--ink); margin-top: 4px; }

.bench-growth-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-family: var(--mono); font-size: 13px; }
.bench-growth-table th, .bench-growth-table td { padding: 8px 12px; border: 1px solid var(--line); text-align: left; }
.bench-growth-table th { background: var(--surface-1); font-weight: 600; font-size: 11px; text-transform: uppercase; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--ink);
  color: var(--surface-1);
  border-radius: 8px;
  font-size: 14px;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══════════════════════════════════════════════════════════════════
 * EXTRAS — match list, history, formatter, export (added v4)
 * ═══════════════════════════════════════════════════════════════════ */

/* Match list */
.match-list-section { margin-top: 20px; }
.match-list-details { background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); padding: 0; }
.match-list-details summary { padding: 12px 16px; cursor: pointer; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); }
.match-list-details summary:hover { color: var(--ink); }
.match-list-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface-1); }
.match-list-table th, .match-list-table td { padding: 8px 12px; border-top: 1px solid var(--line); text-align: left; }
.match-list-table th { background: var(--surface-2); font-weight: 600; font-size: 11px; text-transform: uppercase; color: var(--ink-muted); letter-spacing: 0.06em; }
.match-list-table td code { background: var(--accent-soft); color: var(--accent-deep); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.match-list-table td .muted { color: var(--ink-muted); opacity: 0.5; }

/* History panel */
.history-panel { margin-top: 12px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.history-empty { font-size: 13px; color: var(--ink-muted); padding: 12px 0; }
.history-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.history-list { list-style: none; padding: 0; margin: 0; }
.history-item { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.history-restore { flex: 1; text-align: left; background: transparent; border: none; padding: 6px 8px; cursor: pointer; border-radius: 5px; color: inherit; }
.history-restore:hover { background: var(--surface-1); }
.history-pattern { display: block; font-size: 13px; word-break: break-all; }
.history-meta { display: block; font-size: 11px; color: var(--ink-muted); margin-top: 2px; font-family: var(--mono); }
.history-remove { background: transparent; border: none; color: var(--ink-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 8px; }
.history-remove:hover { color: #dc2626; }
.btn-sm { font-size: 12px; padding: 4px 10px; }

/* Format output */
.format-output { margin-top: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.format-output-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.format-output-header strong { flex: 1; font-size: 13px; }
.format-pre { background: var(--surface-1); border: 1px solid var(--line); border-radius: 6px; padding: 14px; overflow-x: auto; margin: 0; }
.format-pre code { font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--ink); }
.format-note { font-size: 12px; color: var(--ink-muted); margin-top: 10px; line-height: 1.5; }
.format-note code { background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }

/* Cheat-sheet download CTA — compact, top-right, below ad-banner */
.cheatsheet-top-cta-wrap {
  margin: 10px auto 0;
  padding: 0;
}
.cheatsheet-top-cta-wrap .wrap {
  display: flex;
  justify-content: flex-end;
  padding-top: 0;
  padding-bottom: 0;
}
.cheatsheet-top-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  text-decoration: none;
  color: #ffffff;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  font-size: 14px;
  max-width: 100%;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.18);
}
.cheatsheet-top-cta:hover {
  filter: brightness(1.08);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.28);
}
.cheatsheet-top-cta-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}
.cheatsheet-top-cta-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}
.cheatsheet-top-cta-text strong {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}
.cheatsheet-top-cta-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--mono);
  margin-top: 1px;
}
@media (max-width: 700px) {
  .cheatsheet-top-cta-wrap .wrap {
    justify-content: center;
    padding-left: 14px;
    padding-right: 14px;
  }
  .cheatsheet-top-cta {
    width: 100%;
    justify-content: center;
  }
  .cheatsheet-top-cta-sub {
    display: none;
  }
}

/* Mobile fixes for explainer toolbar */
@media (max-width: 640px) {
  .explainer-header { flex-wrap: wrap; gap: 8px; }
  .explainer-actions .btn { font-size: 12px; padding: 6px 10px; }
}

/* ═══════════════════════════════════════════════════════════════════
 * NARROW-VIEWPORT POLISH (added v5)
 * Fixes horizontal-overflow issues at ≤375px viewports (iPhone SE, older
 * Androids). Targets long inline code in prose, the cheat-sheet grid that
 * wouldn't collapse below 360px, and a few small touch-target tweaks.
 * ═══════════════════════════════════════════════════════════════════ */

/* Belt-and-suspenders: never let the page itself scroll horizontally.
   Using `overflow-x: clip` on body instead of `overflow-x: hidden` because
   `hidden` establishes a scroll context that breaks `position: sticky` on
   descendant elements (the nav bar). `clip` is supported in all modern
   browsers (Chrome 90+, Safari 16+, Firefox 81+) and doesn't have that
   side-effect. We keep `html` untouched so sticky works. */
body { overflow-x: clip; }
/* Fallback for older browsers that don't support `clip` (they get `hidden`,
   which is fine — the nav just won't be sticky on those browsers). */
@supports not (overflow-x: clip) {
  body { overflow-x: hidden; }
}

/* Long regex patterns inside <code> elements in prose used to overflow on
   pattern-detail pages, e.g. "regexp.MustCompile(pattern).MatchString(value)". */
.prose code,
.pattern-card-code,
.match-output,
.replace-result {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Tablet/mobile breakpoint */
@media (max-width: 768px) {
  /* Cheat-sheet grid: minmax(360px, 1fr) was too wide for 320px viewports
     and forced horizontal scroll on the cheat-sheet cards. Stack to one
     column on mobile — the cards are already self-contained. */
  .cheat-grid { grid-template-columns: 1fr !important; }
  /* Grid items default to min-width: auto, which uses the content's
     intrinsic min-width and can overflow narrow containers. Force them
     to shrink. */
  .cheat-grid > .cheat-card { min-width: 0; }
  .cheat-card table { table-layout: fixed; }
  .cheat-card td:first-child { width: 32% !important; word-break: break-word; }
  .cheat-card td:nth-child(2) { word-break: break-word; }
  .cheat-card .ex { word-break: break-word; }

  /* Pattern-table tries to lay out as a wide table; on phones, let cells
     stack vertically and allow long code samples to wrap. */
  .pattern-table th,
  .pattern-table td { padding: 10px 12px; }
  .pattern-table code { max-width: 100%; }

  /* Hero/explainer paddings get a bit tighter so the tool card uses more
     of the available width. */
  .explainer-card { padding: 20px 16px; }
  .hero { padding: 36px 0 20px; }

  /* Prose code blocks should never push the page wide. */
  .prose pre { font-size: 12px; }
}

/* Very narrow phones — 360px and below (e.g. Galaxy S8, iPhone SE 1st gen). */
@media (max-width: 380px) {
  /* Brand becomes too cramped at 320px; drop the .com tld and rely on the
     brand mark + name. */
  .nav-brand { font-size: 17px; }
  .nav-brand-tld { display: none; }

  /* Reduce wrap padding so the explainer card has room to breathe. */
  .wrap { padding: 0 14px; }

  /* The flag/quantifier "Try sample / History" toolbar buttons get tiny labels. */
  .tab-btn { padding: 8px 10px; font-size: 13px; }

  /* Section paddings */
  .section { padding: 28px 0; }

  /* Slightly smaller hero headline at 320px so it doesn't dominate the screen. */
  .hero h1 { font-size: clamp(32px, 9vw, 40px); }
}

/* Tap targets: ensure all interactive elements meet ~44px minimum on touch
   devices. Applies to mobile nav links specifically. */
.mobile-nav a,
.mobile-nav button { min-height: 44px; }

/* ═══════════════════════════════════════════════════════════════════
 * UNIVERSAL CONVERTER WIDGET
 * Two-column converter (value+unit on each side) with a category-chip
 * row above and a "related units" grid below.
 * ═══════════════════════════════════════════════════════════════════ */

.converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}
.converter-side { display: flex; flex-direction: column; }
.converter-arrow {
  font-size: 24px;
  color: var(--accent);
  padding-bottom: 12px;
  user-select: none;
}

.conv-input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.conv-input:focus { border-color: var(--accent); background: var(--surface-1); }
.conv-result {
  background: var(--surface-1);
  color: var(--accent-deep);
  font-weight: 500;
}
[data-theme="dark"] .conv-result { color: var(--accent); }

.conv-select {
  margin-top: 8px;
  width: 100%;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 14px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--ink);
  outline: none;
  cursor: pointer;
}
.conv-select:focus { border-color: var(--accent); }

@media (max-width: 640px) {
  .converter-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .converter-arrow {
    transform: rotate(90deg);
    text-align: center;
    padding: 0;
    margin: -4px 0;
  }
}

/* Category chips row */
.category-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.category-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.category-chip {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.category-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.category-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
[data-theme="dark"] .category-chip.active { color: var(--bg); }

/* Conversion summary line — same green/red language as regexguide */
.conversion-summary {
  margin: 12px 0;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-muted);
  min-height: 20px;
}
.conversion-summary.success { color: #16a34a; font-weight: 600; }
.conversion-summary.fail    { color: #dc2626; font-weight: 600; }
[data-theme="dark"] .conversion-summary.success { color: #4ade80; }
[data-theme="dark"] .conversion-summary.fail    { color: #f87171; }

/* Related-units grid — the input value rendered in every unit in the category */
.related-row { margin-top: 18px; }
.related-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 10px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.related-cell {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.related-cell:hover {
  border-color: var(--accent);
  background: var(--surface-1);
}
.related-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.related-unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: lowercase;
}

/* ═══════════════════════════════════════════════════════════════════
 * CHEAT SHEET PAGE TEMPLATE
 * Shared styles for every page under /cheatsheets/*. Designed for
 * dense reference tables that look excellent on screen, print, and
 * mobile (with horizontal scroll where needed).
 * ═══════════════════════════════════════════════════════════════════ */

.cheatsheet-article { max-width: 960px; }
.cheatsheet-header { margin-bottom: 24px; }
.cheatsheet-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}
.cheatsheet-article h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 14px 0;
  color: var(--ink);
}
.cheatsheet-article h1 em {
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}
.cheatsheet-tagline {
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0 0 18px 0;
  max-width: 70ch;
  line-height: 1.5;
}
.cheatsheet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* Interactive lookup widget — sits between the header and the chart */
.cheatsheet-lookup {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 24px 0;
}
.cheatsheet-lookup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.cheatsheet-lookup label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cheatsheet-lookup label > span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
.cheatsheet-lookup select,
.cheatsheet-lookup input {
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 14px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
}
.cheatsheet-lookup select:focus,
.cheatsheet-lookup input:focus {
  border-color: var(--accent);
  background: var(--surface-1);
}
.cheatsheet-lookup-arrow {
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
}
.cheatsheet-lookup-output {
  flex: 1 1 200px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 7px;
  border: 1px dashed var(--line);
  min-height: 36px;
  display: flex;
  align-items: center;
}
.cheatsheet-lookup-output.success {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.3);
  color: #166534;
  border-style: solid;
}
.cheatsheet-lookup-output.fail {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.3);
  color: #991b1b;
  border-style: solid;
}
[data-theme="dark"] .cheatsheet-lookup-output.success { color: #4ade80; }
[data-theme="dark"] .cheatsheet-lookup-output.fail    { color: #f87171; }

/* The cheat sheet table itself — designed for dense data */
.table-scroll-hint {
  display: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  text-align: right;
  margin-bottom: 4px;
}
@media (max-width: 768px) {
  .table-scroll-hint { display: block; }
}

.cheatsheet-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-1);
  margin: 12px 0 18px 0;
}
.cheatsheet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  min-width: 640px; /* forces horizontal scroll on narrow screens rather than crushing columns */
}
.cheatsheet-table thead th {
  background: var(--surface-2);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.cheatsheet-table thead th small {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-muted);
  margin-top: 2px;
}
.cheatsheet-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
.cheatsheet-table tbody tr:last-child td { border-bottom: 0; }
.cheatsheet-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.cheatsheet-table tbody tr:hover td { background: var(--accent-soft); }
[data-theme="dark"] .cheatsheet-table tbody tr:hover td { background: rgba(94, 234, 212, 0.06); }
.cheatsheet-table td.awg-size {
  font-weight: 600;
  color: var(--accent);
}

/* Footnotes and disclaimers */
.cheatsheet-footnote {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-left: 3px solid var(--ink-muted);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 14px 0;
}
.cheatsheet-disclaimer {
  font-size: 13px;
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 28px;
}

/* ─── PRINT MODE ──────────────────────────────────────────────────
   When users hit Print, hide the chrome and show only the table.
   This is what makes the "designed to print" promise real. */
@media print {
  body { background: white !important; color: black !important; }
  .nav-bar, .mobile-nav, .footer,
  .cheatsheet-actions, .cheatsheet-lookup,
  .breadcrumb,
  .table-scroll-hint { display: none !important; }
  .wrap { padding: 0; max-width: 100%; }
  .cheatsheet-article { max-width: 100%; }
  .cheatsheet-table-wrap { overflow: visible; border: 1px solid #999; }
  .cheatsheet-table { min-width: 0; font-size: 11px; }
  .cheatsheet-table thead th { background: #f0f0f0 !important; color: #333 !important; position: static; }
  .cheatsheet-table tbody tr:nth-child(even) td { background: #fafafa !important; }
  .cheatsheet-table tbody tr:hover td { background: transparent !important; }
  .cheatsheet-footnote { background: #fafafa !important; color: #444 !important; }
  h1, h2 { color: black !important; page-break-after: avoid; }
  h1 em, .cheatsheet-eyebrow { color: #0d9488 !important; }
  /* Hide "See also" and other follow-up sections on print */
  .feature-grid { display: none !important; }
  /* Also hide the "See also" h2 that precedes the feature-grid */
  h2:has(+ .feature-grid) { display: none !important; }
  /* And the HTML comment marker version */
  h2:has(+ div.feature-grid) { display: none !important; }
  @page { size: letter landscape; margin: 0.5in; }
}

/* ═══════════════════════════════════════════════════════════════════
 * CALCULATOR PAGE TEMPLATE
 * Shared styles for /calculators/*. Multi-input form on top, verdict
 * + detail-grid + "show work" details panel below.
 * ═══════════════════════════════════════════════════════════════════ */

.calc-article { max-width: 960px; }

.calc-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin: 24px 0;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.calc-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.calc-input input,
.calc-input select {
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 15px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}
.calc-input input:focus,
.calc-input select:focus {
  border-color: var(--accent);
  background: var(--surface-1);
}
.calc-hint {
  font-size: 12px;
  color: var(--ink-muted);
  font-style: italic;
}

.calc-result {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}
.calc-result-empty {
  text-align: center;
  color: var(--ink-muted);
  font-style: italic;
  padding: 24px;
}

.calc-verdict {
  padding: 18px 22px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.calc-verdict.success {
  background: rgba(22, 163, 74, 0.08);
  border-left: 4px solid #16a34a;
}
.calc-verdict.fail {
  background: rgba(220, 38, 38, 0.08);
  border-left: 4px solid #dc2626;
  color: #991b1b;
}
[data-theme="dark"] .calc-verdict.fail { color: #f87171; }

.calc-verdict-headline {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.calc-verdict-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.calc-verdict-value {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 500;
  color: #16a34a;
  letter-spacing: -0.02em;
}
[data-theme="dark"] .calc-verdict-value { color: #4ade80; }
.calc-verdict-material {
  font-size: 14px;
  color: var(--ink-soft);
  font-style: italic;
}
.calc-verdict-detail {
  font-size: 14px;
  color: var(--ink-soft);
}

.calc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.calc-detail {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.calc-detail-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
.calc-detail-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.calc-detail-note {
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--mono);
}

.calc-show-work {
  margin-top: 20px;
  font-size: 13px;
}
.calc-show-work summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 8px 0;
  user-select: none;
}
.calc-show-work summary:hover { color: var(--accent); }


/* ═══════════════════════════════════════════════════════════════════
 * CONVERSION-PAIR PAGE (/convert/*)
 * Quick one-line converter at the top, then formula, reference values,
 * and edge-case notes. Optimized for SEO long-tail traffic.
 * ═══════════════════════════════════════════════════════════════════ */

.convert-article { max-width: 760px; }
.convert-quick {
  background: var(--surface-1);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  padding: 18px 22px;
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}
.convert-quick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.convert-quick input {
  flex: 1 1 120px;
  min-width: 120px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  box-sizing: border-box;
}
.convert-quick input:focus { border-color: var(--accent); background: var(--surface-1); }
.convert-quick input[readonly] {
  background: var(--surface-1);
  color: var(--accent-deep);
  font-weight: 500;
}
[data-theme="dark"] .convert-quick input[readonly] { color: var(--accent); }
.convert-quick-unit {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 32px;
}
.convert-quick-arrow {
  font-size: 20px;
  color: var(--accent);
  font-weight: 500;
}

/* Copy button on the conversion-pair quick converter. Compact icon button. */
.qv-copy {
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.qv-copy:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--surface-1);
}
[data-theme="dark"] .qv-copy:hover { color: var(--accent); }
.qv-copy:active { transform: translateY(1px); }
.qv-copy.copied {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
[data-theme="dark"] .qv-copy.copied { color: var(--accent); }

/* ─── COMING SOON PLACEHOLDER CARDS ──────────────────────────────────
   For feature-grid cards that point at pages not yet built.
   Rendered as <div> not <a> so they're not clickable, and styled with
   a "Coming soon" badge so users see the visual signal. */
.feature-card.coming-soon {
  position: relative;
  opacity: 0.55;
  cursor: default;
  pointer-events: auto; /* still hoverable but not clickable */
}
.feature-card.coming-soon:hover {
  transform: none !important;
  border-color: var(--line) !important;
  background: var(--surface-1);
}
.coming-soon-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 3px 7px;
  border-radius: 999px;
}

/* ─── CHEAT SHEET FILTER ROW ──────────────────────────────────────
   For long tables (drill bit chart, screw sizes), allow filter by
   system or text search. */
.cheatsheet-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cheatsheet-filter-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
#filter-text {
  flex: 1 1 200px;
  padding: 7px 12px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}
#filter-text:focus { border-color: var(--accent); background: var(--surface-1); }
.cheatsheet-filter-chip {
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
}
.cheatsheet-filter-chip:hover { border-color: var(--accent); color: var(--ink); }
.cheatsheet-filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
[data-theme="dark"] .cheatsheet-filter-chip.active { color: var(--bg); }

/* Drill bit system tags + closest-match column */
.drill-system {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}
.drill-system-number      { background: rgba(13,148,136,0.12); color: #0d9488; }
.drill-system-letter      { background: rgba(217,119,6,0.12);  color: #b45309; }
.drill-system-fractional  { background: rgba(71,85,105,0.12);  color: #475569; }
.drill-system-metric      { background: rgba(124,58,237,0.12); color: #6d28d9; }
[data-theme="dark"] .drill-system-number     { background: rgba(94,234,212,0.15);  color: #5eead4; }
[data-theme="dark"] .drill-system-letter     { background: rgba(251,191,36,0.15); color: #fbbf24; }
[data-theme="dark"] .drill-system-fractional { background: rgba(148,163,184,0.15); color: #cbd5e1; }
[data-theme="dark"] .drill-system-metric     { background: rgba(196,181,253,0.15); color: #c4b5fd; }
.drill-label { font-weight: 600; color: var(--accent); }
.drill-closest { font-weight: 500; }
.drill-closest-diff { color: var(--ink-muted); font-size: 11px; }

/* ─── COLOR SWATCH for resistor color code page ─────────────────── */
.color-swatch {
  display: inline-block;
  width: 22px;
  height: 14px;
  vertical-align: middle;
  border-radius: 3px;
  margin-right: 8px;
}

/* ─── BAND DIAGRAM for showing read order ───────────────────────── */
.band-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 8px 0;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
}
.band-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--surface-1);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  min-width: 70px;
}
.band-num {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.band-name {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ─── HOMEPAGE: POPULAR CONVERSIONS GRID ────────────────────────────
   Multi-column list of conversion-pair links, grouped by category. */
.conversion-pairs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}
.conversion-pair-group h4 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.conversion-pair-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conversion-pair-group ul li a {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  padding: 4px 0;
  display: block;
  border-bottom: 1px solid transparent;
  transition: color 0.15s;
}
.conversion-pair-group ul li a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── GUIDE ARTICLE STYLES ──────────────────────────────────────────
   Long-form content with a focus on readability. */
.guide-article {
  max-width: 760px;
}
.guide-article p {
  font-size: 17px;
  line-height: 1.7;
  margin: 14px 0;
}
.guide-article h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 40px 0 12px 0;
  color: var(--ink);
}
.guide-article h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 19px;
  margin: 24px 0 8px 0;
  color: var(--ink);
}
.guide-article ul li {
  font-size: 17px;
  line-height: 1.7;
  margin: 4px 0;
}
.guide-tldr {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 24px 0;
}
.guide-tldr h3 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 6px 0;
}
[data-theme="dark"] .guide-tldr h3 { color: var(--accent); }
.guide-tldr p {
  font-size: 15px !important;
  line-height: 1.55 !important;
  margin: 0 !important;
  color: var(--ink);
}



/* ─── Mini converter widget ────────────────────────────────────── */
.mini-converter {
  margin: 28px 0;
  padding: 16px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
}

.mini-conv-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.mini-conv-label strong {
  color: var(--accent);
  font-weight: 600;
}

.mini-conv-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(120px, 1.4fr) auto minmax(80px, 1fr) minmax(120px, 1.4fr);
  gap: 8px;
  align-items: center;
}

.mini-conv-input,
.mini-conv-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  min-width: 0;
}

.mini-conv-input:focus {
  outline: none;
  border-color: var(--accent);
}

.mini-conv-result {
  background: rgba(13, 148, 136, 0.06);
  color: var(--accent);
  font-weight: 600;
}

.mini-conv-from,
.mini-conv-to {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  min-width: 0;
}

.mini-conv-arrow {
  font-family: var(--mono);
  color: var(--ink-muted);
  text-align: center;
  font-size: 18px;
}

.mini-conv-footer {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-muted);
}

.mini-conv-footer a {
  color: var(--accent);
}

/* Mobile: stack vertically */
@media (max-width: 640px) {
  .mini-conv-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .mini-conv-arrow {
    grid-column: 1 / -1;
    transform: rotate(90deg);
    text-align: center;
    padding: 4px 0;
  }
}

/* Hide on print */
@media print {
  .mini-converter { display: none !important; }
}

/* ============================================================
   Ad banner — Adsterra 728x90 desktop / 320x50 mobile
   ============================================================ */
.ad-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto 0;
  padding: 0;
  width: 100%;
  max-width: var(--max-width, 1180px);
  min-height: 90px;
}
.ad-banner-inner {
  display: none;
  line-height: 0;
}
.ad-banner-inner.desktop {
  width: 728px;
  height: 90px;
}
.ad-banner-inner.mobile {
  width: 320px;
  height: 50px;
}
/* Desktop ad on screens >= 768px */
@media (min-width: 768px) {
  .ad-banner-inner.desktop { display: block; }
}
/* Mobile ad on screens < 768px */
@media (max-width: 767px) {
  .ad-banner-inner.mobile { display: block; }
  .ad-banner { min-height: 50px; }
}
/* Hide ads in print */
@media print {
  .ad-banner { display: none !important; }
}
