:root {
  --bg: #f7f9fd;
  --surface: #ffffff;
  --surface-soft: #f3f7ff;
  --text: #0f1e3b;
  --muted: #586781;
  --line: #dbe4f2;
  --line-strong: #c9d7ea;
  --primary: #2563eb;
  --primary-dark: #1749bb;
  --primary-soft: #eaf1ff;
  --success: #0f9f6e;
  --success-soft: #e9fbf4;
  --warning: #c66a08;
  --warning-soft: #fff7e8;
  --danger: #c73838;
  --danger-soft: #fff0f0;
  --purple: #7657d6;
  --shadow: 0 18px 45px rgba(35, 63, 116, 0.09);
  --shadow-sm: 0 8px 24px rgba(35, 63, 116, 0.08);
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 1.2em; height: 1.2em; fill: currentColor; }

.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; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 10px 14px; background: var(--text); color: #fff; border-radius: 8px; transform: translateY(-150%); transition: transform .2s ease; }
.skip-link:focus { transform: translateY(0); }
.container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.narrow-container { width: min(850px, calc(100% - 40px)); margin-inline: auto; }

.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(219, 228, 242, .9); }
.header-inner { width: min(1180px, calc(100% - 40px)); min-height: 74px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 44px; aspect-ratio: 1; border-radius: 12px; background: linear-gradient(145deg, #2f73f6, #1749bb); color: #fff; font-family: Georgia, serif; font-weight: 700; font-size: 1.35rem; box-shadow: 0 9px 22px rgba(37,99,235,.24); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.18; }
.brand-copy strong { font-size: 1rem; }
.brand-copy small { color: var(--muted); font-size: .76rem; margin-top: 4px; }
.github-button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; text-decoration: none; font-weight: 750; color: #17233c; box-shadow: 0 3px 10px rgba(40, 61, 98, .05); transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease; }
.github-button:hover { border-color: #9cb2d3; transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.hero { position: relative; overflow: hidden; background: radial-gradient(circle at 80% 15%, rgba(76, 126, 245, .12), transparent 29%), linear-gradient(180deg, #fff, #f6f9ff); border-bottom: 1px solid var(--line); }
.hero::after { content: "χ²"; position: absolute; right: max(4vw, 20px); bottom: -80px; color: rgba(37,99,235,.035); font-family: Georgia, serif; font-size: clamp(180px, 22vw, 330px); font-weight: 700; line-height: 1; pointer-events: none; }
.hero-inner { position: relative; z-index: 1; padding-block: 48px 44px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: #70809a; font-size: .86rem; margin-bottom: 26px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.eyebrow, .section-kicker { margin: 0 0 10px; color: var(--primary); font-size: .78rem; font-weight: 850; text-transform: uppercase; letter-spacing: .11em; }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow span { width: 28px; height: 2px; background: var(--primary); }
h1 { max-width: 900px; margin: 0; font-size: clamp(2.25rem, 5vw, 4.4rem); line-height: 1.04; letter-spacing: -.045em; }
.hero-copy { max-width: 820px; margin: 20px 0 0; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.25rem); line-height: 1.75; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 25px; }
.hero-badges span { padding: 7px 12px; border: 1px solid #cddcf4; border-radius: 999px; background: rgba(255,255,255,.74); color: #405372; font-size: .82rem; font-weight: 700; }

.calculator-section { padding: 42px 0 26px; }
.calculator-grid { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr); gap: 24px; align-items: stretch; }
.calculator-grid > *, .details-grid > *, .content-grid > * { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 26px; }
.results-panel { background: linear-gradient(150deg, #f7faff 0%, #eff5ff 100%); border-color: #cddcf2; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; align-items: center; gap: 11px; }
.panel-heading h2 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.38rem); letter-spacing: -.02em; }
.step-number { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.privacy-note, .status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 999px; font-size: .75rem; font-weight: 750; white-space: nowrap; }
.privacy-note { background: var(--success-soft); color: #117b59; }
.status-pill { background: #fff; color: var(--muted); border: 1px solid var(--line); }
.status-pill.success { background: var(--success-soft); border-color: #b8ead8; color: #08724f; }
.status-pill.warning { background: var(--warning-soft); border-color: #f1d7a2; color: #9c5407; }

.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; padding: 20px 0 2px; }
.contingency-table { min-width: 510px; display: grid; grid-template-columns: minmax(150px, 1.15fr) repeat(2, minmax(135px, 1fr)); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: #fff; }
.table-corner, .column-label, .row-label, .count-cell { min-height: 62px; display: flex; align-items: center; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.column-label:nth-child(3), .count-cell:nth-child(6), .count-cell:nth-child(9), .count-cell:nth-child(12) { border-right: 0; }
.row-label:nth-child(10), .count-cell:nth-child(11), .count-cell:nth-child(12) { border-bottom: 0; }
.table-corner { background: #f8faff; }
.column-label { background: #f8faff; }
.label-input, .count-cell input { width: 100%; min-height: 42px; border: 1px solid transparent; border-radius: 9px; color: var(--text); background: transparent; outline: none; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.label-input { padding: 8px 10px; font-weight: 750; }
.count-cell input { padding: 8px 12px; border-color: var(--line); background: #fbfcff; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.label-input:hover { background: #fff; border-color: var(--line); }
.label-input:focus, .count-cell input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input-help { color: var(--muted); font-size: .82rem; margin: 13px 0 0; }
.inline-message { margin-top: 13px; padding: 11px 13px; border-radius: 10px; font-size: .86rem; font-weight: 650; }
.error-message { background: var(--danger-soft); border: 1px solid #f0c1c1; color: #9f2929; }
.form-tools { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; margin-top: 19px; }
.alpha-control { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 0 9px 0 13px; border: 1px solid var(--line-strong); border-radius: 11px; color: #34445f; font-size: .82rem; font-weight: 700; background: #fff; }
.alpha-control select { min-width: 82px; padding: 6px 24px 6px 8px; border: 0; border-left: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 800; outline: none; }
.secondary-button, .primary-button, .copy-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; font-weight: 800; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease; }
.secondary-button { min-height: 44px; padding: 0 13px; border: 1px solid var(--line-strong); background: #fff; color: #263650; }
.secondary-button:hover { border-color: #91a9ce; background: #f9fbff; }
.primary-button { width: 100%; min-height: 51px; margin-top: 13px; border: 0; padding: 0 18px; background: linear-gradient(135deg, #2d71ef, #1d55cf); color: #fff; box-shadow: 0 12px 24px rgba(37,99,235,.2); font-size: 1rem; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 15px 28px rgba(37,99,235,.27); }
.primary-button:disabled { opacity: .65; cursor: progress; transform: none; }
.primary-button.compact { width: auto; min-width: 150px; margin: 0; }
.text-button { display: block; margin: 12px auto 0; padding: 4px 9px; border: 0; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; }
.text-button:hover { color: var(--primary); }

.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; padding-top: 20px; }
.metric-card { grid-column: span 2; min-height: 105px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; padding: 13px; border: 1px solid #d9e4f3; border-radius: 13px; background: rgba(255,255,255,.9); text-align: center; box-shadow: 0 7px 20px rgba(53,79,122,.05); }
.metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 3; }
.metric-card span, .conclusion-card span { color: var(--muted); font-size: .82rem; font-weight: 650; }
.metric-card strong { font-size: clamp(1.25rem, 3vw, 1.75rem); font-variant-numeric: tabular-nums; }
.metric-card.highlight { border-color: #b9cef3; background: #fff; }
.metric-card.highlight strong { color: var(--primary); }
.conclusion-card { min-height: 110px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 9px; margin-top: 10px; padding: 18px; border: 1px solid #d9e4f3; border-radius: 13px; background: rgba(255,255,255,.92); text-align: center; }
.conclusion-card strong { max-width: 540px; font-size: 1rem; line-height: 1.55; }
.results-placeholder { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 14px; border: 1px solid #bdd2f7; border-radius: 12px; background: rgba(231,240,255,.85); color: #244d91; font-size: .86rem; }
.results-placeholder svg { flex: 0 0 auto; margin-top: 3px; }

.details-section { padding: 12px 0 18px; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.detail-card { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow-sm); }
.detail-card h2 { margin: 0 0 8px; font-size: 1.06rem; }
.detail-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.detail-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.15rem; font-weight: 900; }
.shield-icon { color: var(--success); background: var(--success-soft); }
.exact-icon { color: var(--purple); background: #f0edff; }
.detail-card.warning { border-color: #edcf96; background: #fffdf8; }
.detail-card.warning .shield-icon { color: var(--warning); background: var(--warning-soft); }
.mini-stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin: 16px 0 0; }
.mini-stats div { padding: 10px; border-radius: 10px; background: var(--surface-soft); }
.mini-stats dt { color: var(--muted); font-size: .7rem; }
.mini-stats dd { margin: 3px 0 0; font-weight: 850; }
.results-table-card, .report-card { margin-top: 20px; padding: 26px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); }
.section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 18px; }
.section-heading h2, .report-card h2, .content-section h2, .faq-section h2, .formula-card h2 { margin: 0; letter-spacing: -.025em; }
.section-heading > p { max-width: 520px; margin: 0; color: var(--muted); font-size: .87rem; }
.responsive-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.results-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.results-table th, .results-table td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; font-size: .86rem; }
.results-table th { background: #f5f8fd; color: #41506b; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
.results-table tbody tr:last-child td { border-bottom: 0; }
.results-table tbody tr:nth-child(even) { background: #fbfcff; }
.residual-strong { color: var(--danger); font-weight: 850; }
.report-card { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: linear-gradient(135deg, #11244c, #17396f); color: #fff; border-color: transparent; }
.report-card .section-kicker { color: #9fc0ff; }
.report-card p { max-width: 820px; margin: 8px 0 0; color: #e1eaff; }
.copy-button { flex: 0 0 auto; min-height: 46px; padding: 0 17px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; }
.copy-button:hover { background: rgba(255,255,255,.2); }

.feature-strip { padding: 30px 0 60px; }
.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; }
.feature-grid article { display: flex; gap: 12px; align-items: flex-start; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.feature-grid h2 { margin: 0 0 4px; font-size: .92rem; }
.feature-grid p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.feature-icon { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; font-weight: 900; }
.feature-icon.blue { background: var(--primary-soft); color: var(--primary); }
.feature-icon.green { background: var(--success-soft); color: var(--success); }
.feature-icon.purple { background: #f0edff; color: var(--purple); }
.feature-icon.orange { background: #fff1df; color: #df7503; }

.content-section { padding: 68px 0; background: #fff; border-block: 1px solid var(--line); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 55px; align-items: center; }
.steps-list { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 19px; }
.steps-list li { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.steps-list > li > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.steps-list strong { display: block; margin-top: 3px; }
.steps-list p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.formula-card { padding: 30px; border: 1px solid #c8d9f4; border-radius: var(--radius-lg); background: linear-gradient(145deg, #f8fbff, #eef5ff); box-shadow: var(--shadow); }
.formula { margin: 25px 0; padding: 24px; border: 1px solid #c8d9f4; border-radius: 14px; background: #fff; color: var(--primary-dark); font-family: Georgia, serif; font-size: clamp(1.7rem, 4vw, 2.5rem); text-align: center; white-space: nowrap; }
.formula-card dl { margin: 0; display: grid; gap: 9px; }
.formula-card dl div { display: grid; grid-template-columns: 42px 1fr; padding-top: 9px; border-top: 1px solid #d6e2f4; }
.formula-card dt { font-weight: 900; color: var(--primary); }
.formula-card dd { margin: 0; color: var(--muted); }

.faq-section { padding: 70px 0 80px; }
.faq-section h2 { margin-bottom: 24px; font-size: clamp(1.7rem, 4vw, 2.5rem); }
details { border-top: 1px solid var(--line); }
details:last-child { border-bottom: 1px solid var(--line); }
summary { position: relative; padding: 18px 42px 18px 0; cursor: pointer; list-style: none; font-weight: 800; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--primary); font-size: 1.5rem; font-weight: 500; }
details[open] summary::after { content: "−"; }
details p { margin: -4px 0 18px; color: var(--muted); }
.site-footer { padding: 24px 0; background: #0e1d3a; color: #cbd6e8; text-align: center; font-size: .83rem; }

.paste-dialog { width: min(560px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 30px 80px rgba(5,18,45,.28); }
.paste-dialog::backdrop { background: rgba(7,18,39,.58); backdrop-filter: blur(3px); }
.paste-dialog form { padding: 25px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 0; }
.dialog-close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font-size: 1.35rem; line-height: 1; }
.paste-dialog > form > p { color: var(--muted); font-size: .88rem; }
.paste-dialog textarea { width: 100%; resize: vertical; min-height: 145px; padding: 13px; border: 1px solid var(--line-strong); border-radius: 11px; outline: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.paste-dialog textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 17px; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(37,99,235,.36); outline-offset: 3px; }
[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .form-tools { grid-template-columns: 1fr 1fr; }
  .alpha-control { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .container, .header-inner { width: min(100% - 28px, 680px); }
  .narrow-container { width: min(100% - 28px, 680px); }
  .site-header { position: relative; }
  .hero-inner { padding-block: 34px 36px; }
  .breadcrumb { margin-bottom: 19px; }
  .calculator-grid, .details-grid, .content-grid { grid-template-columns: 1fr; }
  .results-panel { min-height: auto; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .section-heading, .report-card { align-items: flex-start; flex-direction: column; }
  .copy-button { width: 100%; }
}

@media (max-width: 560px) {
  .contingency-table { min-width: 480px; }
  .header-inner { min-height: 66px; }
  .brand-copy small { display: none; }
  .brand-mark { width: 39px; border-radius: 10px; }
  .github-button { width: 42px; padding: 0; justify-content: center; }
  .github-button span { display: none; }
  .hero::after { display: none; }
  h1 { font-size: 2.35rem; }
  .hero-copy { font-size: 1rem; line-height: 1.65; }
  .hero-badges span { font-size: .75rem; }
  .calculator-section { padding-top: 20px; }
  .panel { padding: 18px; border-radius: 17px; }
  .panel-heading { align-items: flex-start; }
  .privacy-note { display: none; }
  .form-tools { grid-template-columns: 1fr; }
  .alpha-control { grid-column: auto; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card, .metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 1; min-height: 90px; }
  .metric-card:nth-child(5) { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: 1fr; }
  .detail-card { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: 1fr; }
  .results-table-card, .report-card { padding: 18px; border-radius: 16px; }
  .content-section { padding: 48px 0; }
  .formula-card { padding: 20px; }
  .formula { padding: 18px 10px; font-size: 1.6rem; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
