/* Shared design system — single source of truth for tokens, base type,
   header, footer and shared components across every route. */

    /* ===== DESIGN SYSTEM ===== */
    :root {
      --primary:       #2563EB;
      --primary-dark:  #1d4ed8;
      --primary-light: #dbeafe;
      --secondary:     #0ea5e9;
      --dark:          #0f172a;
      --dark-card:     #1e293b;
      --dark-border:   #334155;
      --bg:            #f1f5f9;
      --white:         #ffffff;
      --border:        #e2e8f0;
      --text:          #1e293b;
      --text-muted:    #64748b;
      --text-light:    #94a3b8;
      --success:       #10b981;
      --success-light: #d1fae5;
      --warning:       #f59e0b;
      --warning-light: #fef3c7;
      --teal:          #0d9488;
      --teal-light:    #ccfbf1;
      --purple:        #7c3aed;
      --purple-light:  #ede9fe;
      --radius:        12px;
      --radius-sm:     8px;
      --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
      --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
      --shadow-lg:     0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.05);
      --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      --max-w:         1100px;
    }
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { scroll-behavior: smooth; }
    body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; font-size: 16px; }
    img { max-width: 100%; display: block; }
    a { color: var(--primary); text-decoration: none; }
    a:hover { text-decoration: underline; }

    /* HEADER */
    .site-header { background: var(--dark); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--dark-border); }
    .header-inner { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; height: 62px; display: flex; align-items: center; justify-content: space-between; }
    .site-logo { font-size: 1.2rem; font-weight: 800; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .site-logo span.logo-icon { background: var(--primary); color: #fff; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
    .site-nav { display: flex; align-items: center; gap: 4px; }
    .site-nav a { color: #cbd5e1; font-size: 0.875rem; font-weight: 500; padding: 6px 12px; border-radius: 6px; text-decoration: none; transition: all .15s; white-space: nowrap; }
    .site-nav a:hover, .site-nav a.active { background: rgba(255,255,255,.1); color: #fff; }
    .nav-cta { background: var(--primary) !important; color: #fff !important; margin-left: 8px; }
    .nav-cta:hover { background: var(--primary-dark) !important; }
    .nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; flex-direction: column; gap: 5px; }
    .nav-toggle span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; }
    @media(max-width:768px){
      .site-nav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--dark); flex-direction: column; padding: 12px 20px 20px; gap: 4px; border-bottom: 1px solid var(--dark-border); }
      .site-nav.open { display: flex; }
      .site-nav a { padding: 10px 12px; width: 100%; }
      .nav-cta { margin-left: 0; margin-top: 8px; text-align: center; }
      .nav-toggle { display: flex; }
    }

    /* HERO */
    .hero { background: linear-gradient(135deg, var(--dark) 0%, #1e3a5f 55%, #1d4ed8 100%); padding: 52px 20px 0; position: relative; overflow: hidden; }
    .hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 70% 50%, rgba(37,99,235,.25) 0%, transparent 70%); pointer-events: none; }
    .hero-inner { max-width: var(--max-w); margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; position: relative; }
    .hero-text { color: #fff; }
    .hero-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(37,99,235,.3); border: 1px solid rgba(37,99,235,.5); border-radius: 20px; padding: 5px 14px; font-size: 0.78rem; font-weight: 700; color: #93c5fd; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 16px; }
    .hero h1 { font-size: clamp(1.75rem, 4vw, 2.6rem); font-weight: 800; line-height: 1.15; margin-bottom: 14px; }
    .hero h1 em { font-style: normal; color: #60a5fa; }
    .hero-sub { color: #94a3b8; font-size: 1rem; line-height: 1.7; margin-bottom: 24px; max-width: 480px; }
    .hero-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
    .hero-stat { text-align: center; }
    .hero-stat .hs-val { font-size: 1.35rem; font-weight: 800; color: #fff; }
    .hero-stat .hs-label { font-size: 0.72rem; color: #64748b; text-transform: uppercase; letter-spacing: .06em; }
    .hero-stat-divider { width: 1px; background: var(--dark-border); align-self: stretch; }
    .hero-btns { display: flex; gap: 10px; flex-wrap: wrap; }
    .btn-primary { display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff; padding: 11px 22px; border-radius: var(--radius-sm); font-weight: 700; font-size: 0.9rem; text-decoration: none; transition: background .15s; border: none; cursor: pointer; font-family: var(--font); }
    .btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
    .btn-ghost { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: #cbd5e1; padding: 11px 22px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; text-decoration: none; transition: all .15s; border: 1px solid var(--dark-border); cursor: pointer; font-family: var(--font); }
    .btn-ghost:hover { border-color: #94a3b8; color: #fff; text-decoration: none; }

    /* HERO CALCULATOR PANEL */
    .hero-calc { background: var(--white); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-lg); position: relative; top: 0; }
    .hero-calc-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
    .hero-calc-title::before { content: "\23F1"; }
    .hc-tabs { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 18px; }
    .hc-tab { flex: 1; padding: 9px 6px; font-size: 0.8rem; font-weight: 600; text-align: center; cursor: pointer; background: var(--white); color: var(--text-muted); border: none; transition: .15s; font-family: var(--font); }
    .hc-tab.active { background: var(--primary); color: #fff; }
    .hc-panel { display: none; }
    .hc-panel.active { display: block; }
    .hc-input { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: 1rem; color: var(--text); background: var(--bg); transition: border-color .15s; margin-bottom: 12px; }
    .hc-input:focus { outline: none; border-color: var(--primary); background: var(--white); }
    .hc-input::placeholder { color: var(--text-light); }
    .speed-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin-bottom: 12px; }
    .sp-btn { padding: 7px 4px; border: 1.5px solid var(--border); border-radius: 6px; background: var(--white); cursor: pointer; text-align: center; font-family: var(--font); transition: .15s; }
    .sp-btn.active { border-color: var(--primary); background: var(--primary-light); }
    .sp-btn:hover:not(.active) { border-color: var(--primary); }
    .sp-btn .sp-lab { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); display: block; text-transform: uppercase; }
    .sp-btn .sp-val { font-size: 0.82rem; font-weight: 700; color: var(--text); display: block; }
    .sp-btn.active .sp-lab, .sp-btn.active .sp-val { color: var(--primary-dark); }
    .hc-btn { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: background .15s; }
    .hc-btn:hover { background: var(--primary-dark); }
    .hc-result { display: none; margin-top: 14px; background: var(--dark); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
    .hc-result.show { display: block; }
    .hc-result-main { font-size: 1.8rem; font-weight: 800; color: #fff; }
    .hc-result-sub { font-size: 0.75rem; color: #64748b; margin-top: 4px; }
    .hc-result-breakdown { display: flex; justify-content: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
    .hcr-item .hcr-val { font-size: 0.85rem; font-weight: 700; color: #e2e8f0; }
    .hcr-item .hcr-lab { font-size: 0.65rem; color: #64748b; }

    .hero-wave { display: block; width: 100%; margin-top: 40px; }
    @media(max-width:768px){ .hero-inner { grid-template-columns: 1fr; gap: 24px; } .hero-wave { margin-top: 24px; } }

    /* LAYOUT */
    .page-body { max-width: var(--max-w); margin: 0 auto; padding: 36px 20px 60px; display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
    @media(max-width:900px){ .page-body { grid-template-columns: 1fr; } .sidebar { order: 3; } }

    /* CARDS */
    .card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
    .card + .card { margin-top: 20px; }
    .section-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 18px; display: flex; align-items: center; gap: 10px; }
    .section-title::after { content: ''; flex: 1; height: 2px; background: var(--border); border-radius: 2px; }

    /* TOOLS GRID */
    .tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; }
    .tool-card { background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 16px; text-decoration: none; transition: all .2s; display: block; position: relative; overflow: hidden; }
    .tool-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
    .tool-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
    .tool-card:hover::before { transform: scaleX(1); }
    .tool-card .tc-icon { font-size: 1.6rem; margin-bottom: 8px; }
    .tool-card .tc-name { font-size: 0.875rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
    .tool-card .tc-desc { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }
    .tool-card .tc-badge { position: absolute; top: 10px; right: 10px; font-size: 0.6rem; font-weight: 700; padding: 2px 7px; border-radius: 10px; text-transform: uppercase; background: var(--success-light); color: #065f46; }

    /* QUICK ANSWERS GRID */
    .answers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 10px; }
    .answer-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px; text-decoration: none; transition: all .15s; display: block; }
    .answer-card:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
    .answer-card .ac-wc { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
    .answer-card .ac-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
    .answer-card .ac-row:last-of-type { border-bottom: none; }
    .answer-card .ac-mode { color: var(--text-muted); font-size: 0.78rem; }
    .answer-card .ac-speak { color: var(--primary-dark); font-weight: 700; }
    .answer-card .ac-read { color: var(--teal); font-weight: 700; }

    /* REFERENCE TABLE */
    .table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
    .data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
    .data-table thead tr { background: var(--dark); }
    .data-table thead th { padding: 10px 12px; color: #e2e8f0; font-weight: 600; text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .05em; }
    .data-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
    .data-table tbody tr:hover { background: var(--bg); }
    .data-table tbody tr:last-child { border-bottom: none; }
    .data-table td { padding: 9px 12px; }
    .data-table td:first-child { font-weight: 600; }
    .data-table .col-speak { color: var(--primary-dark); font-weight: 600; }
    .data-table .col-read { color: var(--teal); font-weight: 600; }
    .data-table .col-link a { color: var(--primary); font-size: 0.8rem; text-decoration: none; }
    .data-table .col-link a:hover { text-decoration: underline; }
    .table-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }

    /* SPEECH WORD COUNT CARDS */
    .speech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 10px; }
    .speech-card { background: var(--dark); border-radius: var(--radius-sm); padding: 14px; text-decoration: none; display: block; text-align: center; transition: all .15s; }
    .speech-card:hover { background: var(--dark-card); transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
    .speech-card .sc-dur { font-size: 1.4rem; font-weight: 800; color: #60a5fa; }
    .speech-card .sc-label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
    .speech-card .sc-words { font-size: 0.85rem; font-weight: 700; color: #e2e8f0; margin-top: 4px; }
    .speech-card .sc-range { font-size: 0.72rem; color: #64748b; margin-top: 2px; }

    /* FAQ */
    .faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
    .faq-question { padding: 14px 18px; font-weight: 600; font-size: 0.95rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: var(--white); transition: background .15s; gap: 12px; }
    .faq-question:hover { background: var(--bg); }
    .faq-question.open { background: var(--primary-light); color: var(--primary-dark); border-bottom: 1px solid var(--border); }
    .faq-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-muted); transition: transform .2s; }
    .faq-question.open .faq-icon { transform: rotate(45deg); color: var(--primary); }
    .faq-answer { display: none; padding: 14px 18px; font-size: 0.9rem; line-height: 1.75; color: var(--text-muted); background: var(--white); }
    .faq-answer.open { display: block; }
    .faq-answer a { color: var(--primary); }

    /* SIDEBAR */
    .sidebar { display: flex; flex-direction: column; gap: 20px; }
    .sidebar-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
    .sidebar-card h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 14px; }
    .sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 7px; }
    .sidebar-links li a { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--text-muted); text-decoration: none; padding: 6px 8px; border-radius: 6px; transition: .15s; }
    .sidebar-links li a:hover { background: var(--bg); color: var(--primary); text-decoration: none; }
    .sl-icon { width: 22px; height: 22px; background: var(--primary-light); color: var(--primary-dark); border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex-shrink: 0; }
    .sl-icon.teal { background: var(--teal-light); color: var(--teal); }
    .sl-icon.green { background: var(--success-light); color: #065f46; }

    .sidebar-qref table { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
    .sidebar-qref tr { border-bottom: 1px solid var(--border); }
    .sidebar-qref tr:last-child { border-bottom: none; }
    .sidebar-qref td { padding: 7px 4px; }
    .sidebar-qref td:first-child { color: var(--text-muted); }
    .sidebar-qref .col-sp { color: var(--primary-dark); font-weight: 700; text-align: right; }
    .sidebar-qref .col-rd { color: var(--teal); font-weight: 700; text-align: right; }

    /* AD */
    .ad-unit { background: var(--white); border: 1px dashed var(--border); border-radius: var(--radius-sm); min-height: 90px; display: flex; align-items: center; justify-content: center; overflow: hidden; }

    /* INFO BOX */
    .info-box { background: var(--primary-light); border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 13px 16px; font-size: 0.9rem; color: var(--dark); margin: 16px 0; }
    .info-box strong { color: var(--primary-dark); }

    /* FOOTER */
    .site-footer { background: var(--dark); color: #94a3b8; margin-top: 60px; }
    .footer-top { max-width: var(--max-w); margin: 0 auto; padding: 44px 20px; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
    .footer-brand .site-logo { margin-bottom: 12px; }
    .footer-brand p { font-size: 0.85rem; line-height: 1.75; max-width: 300px; }
    .footer-col h4 { color: #e2e8f0; font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }
    .footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
    .footer-col ul li a { color: #94a3b8; font-size: 0.83rem; text-decoration: none; transition: color .15s; }
    .footer-col ul li a:hover { color: #fff; }
    .footer-bottom { border-top: 1px solid var(--dark-border); max-width: var(--max-w); margin: 0 auto; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; flex-wrap: wrap; gap: 8px; }
    .footer-bottom a { color: #94a3b8; }
    .footer-bottom a:hover { color: #fff; }
    @media(max-width:768px){ .footer-top { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1/-1; } }
    @media(max-width:480px){ .footer-top { grid-template-columns: 1fr; } .speed-row { grid-template-columns: repeat(2,1fr); } }
  
/* ── PASS 4: mobile safety, tap targets, ad stability ─────────────── */
/* Grid/flex children default to min-width:auto, which lets wide tables
   (table{min-width:480px}) stretch the whole page on phones. */
.page-body > *, .page-with-sidebar > *, .main-col, .sidebar, .sidebar-col, main {
  min-width: 0;
}
.tbl-wrap { max-width: 100%; }
@media (max-width: 520px) {
  table { min-width: 380px; }
}
html, body { overflow-x: hidden; max-width: 100%; }

/* Tap targets + no iOS zoom-on-focus (keyboard covering the input). */
@media (max-width: 768px) {
  .calc-number-input, .calc-textarea, .wcc-input, input[type="number"], input[type="text"], textarea {
    font-size: 16px;
    min-height: 48px;
  }
  .speed-pill, .calc-tab, button, .btn, .sidebar-btn { min-height: 44px; }
  .calc-textarea { min-height: 120px; }
}

/* Reserve ad space up-front so slots never shift the layout after load,
   and never render at width 0 (which breaks adsbygoogle). */
.ad-zone { min-height: 100px; width: 100%; contain: layout; }
.ad-zone .adsbygoogle { display: block; width: 100%; min-width: 250px; min-height: 90px; }
@media (max-width: 480px) { .ad-zone .adsbygoogle { min-width: 200px; } }
/* Any table (wrapped or not) scrolls inside its own box on small screens. */
@media (max-width: 768px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; max-width: 100%; }
}

/* ===== LEGACY TOKEN BRIDGE =====
   Older pages (practice mode, reading speed test, guide pages) were authored
   against the pre-rebuild palette in style.css (teal/forest/serif). Map those
   tokens onto the shared design system so every route renders identically. */
:root {
  --ink:       #1e293b;
  --ink2:      #475569;
  --ink3:      #64748b;
  --teal:      #1d4ed8;
  --teal-lt:   #2563eb;
  --teal-h:    #1e40af;
  --teal-bg:   #eff6ff;
  --teal-bd:   #bfdbfe;
  --forest:    #1e3a8a;
  --forest-lt: #2563eb;
  --forest-bg: #eff6ff;
  --forest-bd: #bfdbfe;
  --slate:     #0f172a;
  --slate-lt:  #1e293b;
  --sand:      #f1f5f9;
  --bdr:       #e2e8f0;
  --bdr2:      #cbd5e1;
}
body,
h1, h2, h3, h4, h5, h6,
.logo-text, .hero-title, .section-title,
button, input, select, textarea {
  font-family: var(--font);
}
body { background: var(--bg); color: var(--text); line-height: 1.6; }
/* Kill legacy serif/mono display faces so type is identical sitewide. */
body, h1, h2, h3, h4, h5, h6, p, li, td, th, label, span, div,
button, input, select, textarea, .logo-text, .section-title {
  font-family: var(--font) !important;
}
code, pre, kbd, samp { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; }
.sidebar-cta .sidebar-card-title { color: var(--primary); }
.sidebar-cta p { color: var(--text-muted); }

/* ===== MOBILE PARAGRAPH READABILITY =====
   Duration (/N-minute-speech-word-count/) and word-count (/N-words-to-minutes/)
   pages ship long, dense prose blocks that collapsed into unbroken walls of
   text on phones. Tighten measure, open up rhythm, and give lists/tables room
   so the copy below the calculator stays scannable. */
@media (max-width: 640px) {
  .main-col p,
  .data-card p,
  .faq-body p,
  .deep-dive p {
    font-size: 16px;
    line-height: 1.75;
    margin: 0 0 14px;
    max-width: 68ch;
    text-wrap: pretty;
    overflow-wrap: anywhere;
  }

  /* First sentence of a section reads as a lead-in, not part of the wall. */
  .main-col > h2 + p,
  .main-col > h3 + p {
    font-size: 16.5px;
    color: var(--text);
  }

  .main-col li {
    line-height: 1.7;
    margin-bottom: 10px;
  }

  .main-col h2,
  .main-col h3 {
    margin-top: 28px;
    margin-bottom: 10px;
    line-height: 1.3;
    text-wrap: balance;
  }

  .data-card,
  .answer-box,
  .deep-dive {
    padding: 16px;
  }

  /* Wide comparison tables scroll instead of forcing the page sideways. */
  .tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Comfortable tap targets on the FAQ/deep-dive disclosures. */
  .faq-btn,
  .deep-dive > summary {
    min-height: 48px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
}
