:root {
  --ink: #0b0e14;
  --muted: #626b7a;
  --line: #dfe4ea;
  --line-strong: #cdd5df;
  --panel: #ffffff;
  --surface: #f5f7fa;
  --surface-blue: #f5f8ff;
  --blue: #2f63d8;
  --blue-dark: #184cbf;
  --green: #2d9b66;
  --green-bg: #eff9f3;
  --danger: #b82f3d;
  --shadow: 0 14px 42px rgba(17, 31, 53, .08), 0 2px 8px rgba(17, 31, 53, .05);
  --radius: 18px;
  --shell: 1240px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 12%, rgba(47,99,216,.055), transparent 30%),
    linear-gradient(#fff, #fbfcfe 45%, #f6f8fb 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
button, input, select { font: inherit; }
a { color: inherit; }
.shell { width: min(calc(100% - 40px), var(--shell)); margin-inline: auto; }
.skip-link { position: fixed; left: 12px; top: 12px; z-index: 100; transform: translateY(-150%); background: #fff; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid rgba(223,228,234,.92);
  backdrop-filter: blur(16px);
}
.header-inner { min-height: 76px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 830; letter-spacing: -.03em; font-size: 1.2rem; }
.brand svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.nav-links { display: flex; gap: 28px; margin-left: auto; }
.nav-links a { position: relative; color: #4f5866; text-decoration: none; font-size: .94rem; font-weight: 650; padding-block: 27px; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }
.nav-links a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 17px; height: 2px; background: var(--blue); border-radius: 2px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.github-button, .mode-button { height: 42px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; background: #fff; border: 1px solid var(--line-strong); color: var(--ink); text-decoration: none; font-weight: 720; cursor: pointer; transition: .18s ease; }
.github-button:hover, .mode-button:hover { border-color: #9eabb9; transform: translateY(-1px); }
.github-button svg { width: 18px; height: 18px; fill: currentColor; }
.mode-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.hero { position: relative; display: grid; grid-template-columns: minmax(0, .94fr) minmax(500px, 1.06fr); gap: 54px; align-items: center; padding-top: 70px; padding-bottom: 40px; }
.intro-column, .result-card { position: relative; z-index: 2; }
.eyebrow { color: var(--blue-dark); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .75rem; }
h1 { margin: 11px 0 10px; font-size: clamp(2.55rem, 4vw, 4.25rem); line-height: .98; letter-spacing: -.055em; }
.hero-copy { color: var(--muted); max-width: 620px; margin: 0 0 28px; font-size: 1.03rem; }

.wheel-art { position: absolute; z-index: 0; border: 1px solid rgba(47,99,216,.10); border-radius: 50%; pointer-events: none; }
.wheel-art::before, .wheel-art::after { content: ""; position: absolute; inset: 11%; border: 1px dashed rgba(47,99,216,.10); border-radius: inherit; }
.wheel-art::after { inset: 48%; background: rgba(47,99,216,.05); border-style: solid; }
.wheel-art-left { width: 410px; height: 410px; left: -250px; top: 116px; background: repeating-conic-gradient(from 4deg, transparent 0 14deg, rgba(47,99,216,.075) 14.2deg 14.8deg); }
.wheel-art-right { width: 310px; height: 310px; right: -190px; top: 148px; background: repeating-conic-gradient(from 0deg, transparent 0 28deg, rgba(47,99,216,.07) 28.3deg 29deg); }

.calculator-card, .result-card, .database-section, .formula-section { background: rgba(255,255,255,.93); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.calculator-card { padding: 24px; }
.card-heading, .result-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.card-heading h2, .result-heading h2 { margin: 2px 0 0; font-size: 1.23rem; letter-spacing: -.02em; }
.card-kicker { color: #798391; font-size: .72rem; text-transform: uppercase; letter-spacing: .11em; font-weight: 800; }
.mini-wheel, .result-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 1.1rem; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 7px; font-size: .83rem; font-weight: 760; color: #323947; }
.field span { display: flex; justify-content: space-between; gap: 10px; }
.field small { color: #8a94a2; font-weight: 650; }
.field select, .field input { width: 100%; min-width: 0; height: 46px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,99,216,.11); }
.preset-note { display: flex; align-items: center; gap: 8px; color: #697382; margin: 10px 2px 2px; font-size: .78rem; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(45,155,102,.12); flex: 0 0 auto; }
.status-dot.neutral { background: #7c8795; box-shadow: 0 0 0 4px rgba(124,135,149,.12); }
.manual-fields { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.form-error { min-height: 22px; color: var(--danger); font-size: .82rem; font-weight: 670; padding-top: 7px; }
.calculator-actions, .result-actions { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.calculator-actions > a, .result-actions > a { margin-left: auto; color: var(--blue-dark); text-decoration: none; font-size: .84rem; font-weight: 700; }
.calculator-actions > a:hover, .result-actions > a:hover { text-decoration: underline; }
.primary-button { border: 0; min-height: 46px; border-radius: 10px; background: var(--ink); color: white; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 790; cursor: pointer; box-shadow: 0 7px 18px rgba(11,14,20,.12); transition: .18s ease; }
.primary-button:hover { background: #1b2230; transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }
.primary-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.result-card { padding: 24px; }
.result-heading { justify-content: flex-start; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.side-result { background: linear-gradient(180deg, var(--surface-blue), #fff); border: 1px solid #cfdbf6; border-radius: 14px; padding: 18px; text-align: center; }
.side-label { color: var(--blue-dark); text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 850; margin-bottom: 15px; }
.metric-label { display: block; color: #788291; font-size: .76rem; font-weight: 700; }
.side-result > strong { display: block; font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.1; letter-spacing: -.04em; margin: 3px 0 14px; }
.buy-row { border-top: 1px solid #d6e0f6; padding-top: 12px; display: flex; align-items: baseline; justify-content: space-between; color: #616b79; font-size: .84rem; }
.buy-row b { color: var(--blue-dark); font-size: 1.55rem; letter-spacing: -.03em; }
.rounding-note { margin: 12px 2px 0; color: #687383; font-size: .76rem; }
.measurements-panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.panel-title { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: .83rem; font-weight: 780; }
.panel-title small { color: #8a94a2; }
.measurement-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.measurement-grid div { padding: 12px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.measurement-grid div:nth-child(3n) { border-right: 0; }
.measurement-grid div:nth-child(n+4) { border-bottom: 0; }
.measurement-grid span { display: block; color: #828c9a; font-size: .69rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 760; }
.measurement-grid b { display: block; margin-top: 2px; font-size: .9rem; }
.source-panel { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--green-bg); border: 1px solid #dcefe4; }
.source-line { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: .83rem; }
.source-panel p { margin: 4px 0 0 18px; color: #69766e; font-size: .74rem; }
.source-links { margin: 7px 0 0 18px; display: flex; gap: 14px; }
.source-links a { color: #246a49; font-size: .74rem; font-weight: 800; }
.copy-status { color: var(--green); font-size: .8rem; font-weight: 780; }

.feature-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 6px; }
.feature-card { display: flex; gap: 16px; padding: 21px; background: rgba(255,255,255,.76); border: 1px solid var(--line); border-radius: 15px; }
.feature-number { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; background: #edf3ff; color: var(--blue-dark); font-size: .72rem; font-weight: 850; }
.feature-card h2 { font-size: .96rem; margin: 1px 0 5px; }
.feature-card p { color: var(--muted); font-size: .79rem; margin: 0; }

.database-section { margin-top: 46px; padding: 28px; }
.section-heading { display: flex; align-items: end; gap: 40px; justify-content: space-between; margin-bottom: 20px; }
.section-heading h2, .formula-copy h2 { margin: 5px 0 0; font-size: clamp(1.55rem, 2.5vw, 2.15rem); letter-spacing: -.035em; }
.section-heading p { max-width: 520px; color: var(--muted); margin: 0; font-size: .9rem; }
.component-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.component-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; text-decoration: none; padding: 15px; border: 1px solid var(--line); border-radius: 13px; transition: .18s ease; }
.component-card:hover { border-color: #aeb9c7; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(17,31,53,.07); }
.component-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface); font-size: 1.4rem; }
.component-copy { min-width: 0; }
.component-copy strong { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.component-copy small { color: var(--muted); font-size: .72rem; }
.component-type { color: #6f7987; background: var(--surface); border-radius: 999px; padding: 4px 8px; font-size: .66rem; font-weight: 800; }

.formula-section { margin-top: 22px; margin-bottom: 70px; padding: 28px; display: grid; grid-template-columns: .9fr 1.1fr; gap: 34px; align-items: center; }
.formula-copy p { color: var(--muted); margin: 10px 0 0; font-size: .9rem; max-width: 540px; }
.formula-card { border: 1px solid var(--line); background: linear-gradient(135deg, #f7f9fd, #fff); border-radius: 14px; padding: 24px; text-align: center; }
.formula-card span { color: #7a8492; font-size: .9rem; }
.formula-card strong { display: block; margin: 6px 0 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: clamp(1rem, 2vw, 1.35rem); }
.formula-card small { color: #7a8492; }
.site-footer { border-top: 1px solid var(--line); background: #fff; color: #717b89; font-size: .8rem; }
.site-footer .shell { min-height: 72px; display: flex; align-items: center; justify-content: center; }

@media (max-width: 1020px) {
  .nav-links { display: none; }
  .header-actions { margin-left: auto; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 48px; }
  .hero-copy { max-width: 720px; }
  .result-card { max-width: none; }
  .feature-strip, .component-list { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .formula-section { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { width: min(calc(100% - 24px), var(--shell)); }
  .site-header { position: relative; }
  .header-inner { min-height: 66px; gap: 12px; }
  .brand span { font-size: 1rem; }
  .brand svg { width: 28px; height: 28px; }
  .github-button { width: 42px; padding: 0; font-size: 0; }
  .github-button svg { width: 19px; height: 19px; }
  .mode-button { padding: 0 10px; font-size: .78rem; }
  .hero { padding-top: 34px; }
  h1 { font-size: clamp(2.4rem, 13vw, 3.5rem); }
  .hero-copy { font-size: .94rem; }
  .calculator-card, .result-card, .database-section, .formula-section { padding: 18px; border-radius: 15px; }
  .field-grid.two, .field-grid.three, .result-grid { grid-template-columns: 1fr; }
  .calculator-actions, .result-actions { align-items: stretch; flex-direction: column; gap: 10px; }
  .primary-button { width: 100%; }
  .calculator-actions > a, .result-actions > a { margin-left: 0; align-self: center; }
  .measurement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .measurement-grid div { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line) !important; }
  .measurement-grid div:nth-child(2n) { border-right: 0 !important; }
  .measurement-grid div:nth-last-child(-n+2) { border-bottom: 0 !important; }
  .feature-strip { gap: 10px; }
  .feature-card { padding: 17px; }
  .database-section { margin-top: 30px; }
  .formula-section { margin-bottom: 46px; }
  .wheel-art { opacity: .45; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
