:root {
  --navy: #075985;
  --blue: #0284c7;
  --cyan: #0ea5e9;
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --slate-950: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --white: #fff;
  --red: #dc2626;
  --green: #15803d;
  --purple: #7c3aed;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--slate-950);
  background: #f7fbfe;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  color: white;
  background: rgba(7, 89, 133, .96);
  border-bottom: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
}
.header-inner { min-height: 72px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: max-content; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: white; color: var(--navy); font-size: 22px; font-weight: 900; }
.brand strong { display: block; font-size: 14px; letter-spacing: .05em; }
.brand small { display: block; opacity: .76; font-size: 11px; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-link { border: 0; background: transparent; color: rgba(255,255,255,.76); padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.nav-link:hover, .nav-link.active { color: white; background: rgba(255,255,255,.13); }
.download-button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 11px; background: white; color: var(--navy); text-decoration: none; font-size: 14px; font-weight: 800; box-shadow: 0 8px 22px rgba(2, 132, 199, .15); }
.download-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.hero {
  color: white;
  background:
    radial-gradient(circle at 80% 15%, rgba(14,165,233,.3), transparent 30%),
    linear-gradient(130deg, #063b5a, #075985 55%, #0369a1);
  padding: 62px 0 76px;
}
.hero-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 48px; align-items: center; }
.eyebrow { display: inline-block; color: var(--cyan); font-size: 12px; font-weight: 900; letter-spacing: .14em; }
.hero .eyebrow { color: #7dd3fc; }
.hero h1 { max-width: 760px; margin: 14px 0 16px; font-size: clamp(34px, 5vw, 58px); line-height: 1.08; letter-spacing: -.035em; }
.hero p { max-width: 700px; margin: 0; color: rgba(255,255,255,.8); font-size: 18px; }
.hero-actions { display: flex; gap: 12px; margin-top: 28px; }
.primary-button, .secondary-button, .ghost-button, .danger-button, .success-button, .purple-button {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.primary-button { background: white; color: var(--navy); }
.secondary-button { border: 1px solid rgba(255,255,255,.42); color: white; background: rgba(255,255,255,.06); }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .danger-button:hover, .success-button:hover, .purple-button:hover { transform: translateY(-1px); }
.hero-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 18px; border: 1px solid rgba(255,255,255,.14); border-radius: 24px; background: rgba(255,255,255,.08); box-shadow: 0 28px 55px rgba(2, 27, 45, .25); backdrop-filter: blur(10px); }
.metric { min-height: 118px; padding: 20px; border-radius: 17px; background: rgba(255,255,255,.1); }
.metric span { display: block; font-size: 28px; font-weight: 900; }
.metric small { color: rgba(255,255,255,.74); }

.workspace { margin-top: -34px; padding-bottom: 60px; position: relative; z-index: 2; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 28px 30px; margin-bottom: 18px; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading h2 { margin: 7px 0 4px; font-size: clamp(26px, 4vw, 38px); letter-spacing: -.025em; }
.section-heading p { margin: 0; color: var(--slate-500); }
.ghost-button { color: var(--navy); background: var(--sky-100); white-space: nowrap; }
.as-link { display: inline-flex; align-items: center; }
.card { background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.calculator-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
.input-card { padding: 26px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-title-row h3 { margin: 0; font-size: 20px; }
.card-title-row p { margin: 4px 0 0; color: var(--slate-500); }
.status-pill { padding: 6px 10px; border-radius: 999px; color: var(--navy); background: var(--sky-100); font-size: 12px; font-weight: 800; }
.injury-grid { display: grid; grid-template-columns: repeat(10, minmax(54px, 1fr)); gap: 7px; margin-top: 20px; }
.injury-input { width: 100%; min-width: 0; height: 52px; border: 1px solid var(--slate-300); border-radius: 10px; text-align: center; font-size: 18px; font-weight: 800; color: var(--slate-950); background: #fbfdff; outline: none; }
.injury-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(14,165,233,.13); background: white; }
.injury-input.invalid { border-color: #f59e0b; background: #fffbeb; }
.keyboard-note { margin-top: 12px; color: var(--slate-500); font-size: 13px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.danger-button { color: white; background: var(--red); }
.success-button { color: white; background: var(--green); }
.purple-button { color: white; background: var(--purple); }
.result-card { padding: 26px; color: white; background: linear-gradient(155deg, #075985, #0369a1 62%, #0284c7); border-color: transparent; }
.result-label { display: block; color: #bae6fd; font-size: 12px; font-weight: 900; letter-spacing: .16em; }
.result-value { display: flex; align-items: baseline; gap: 7px; margin: 20px 0 8px; }
.result-value strong { font-size: 55px; line-height: 1; letter-spacing: -.04em; }
.result-value span { font-size: 22px; font-weight: 800; }
.result-card > p { margin: 0; color: rgba(255,255,255,.75); }
.result-rule { display: grid; gap: 6px; margin-top: 28px; padding: 15px; border-radius: 13px; background: rgba(255,255,255,.1); }
.result-rule span { color: rgba(255,255,255,.72); font-size: 13px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mini-stats div { padding: 13px; border-radius: 12px; background: rgba(255,255,255,.1); }
.mini-stats span { display: block; font-size: 20px; font-weight: 900; }
.mini-stats small { color: rgba(255,255,255,.67); }
.detail-card { margin-top: 18px; padding: 24px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 10px; color: var(--slate-600); background: var(--slate-100); font-size: 25px; }
.detail-table-wrap { overflow-x: auto; margin-top: 18px; border: 1px solid var(--slate-200); border-radius: 13px; }
.detail-table { width: 100%; border-collapse: collapse; min-width: 740px; }
.detail-table th, .detail-table td { padding: 13px 14px; border-bottom: 1px solid var(--slate-200); text-align: left; font-size: 14px; }
.detail-table th { color: var(--slate-600); background: var(--slate-100); }
.detail-table tbody tr:last-child td { border-bottom: 0; }

.advanced-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.formula-card { display: flex; flex-direction: column; min-height: 320px; padding: 22px; background: white; border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.formula-card h3 { margin: 0 0 5px; color: var(--navy); font-size: 20px; }
.formula-card > p { margin: 0 0 18px; color: var(--slate-500); font-size: 14px; }
.field-pair, .field-grid-three, .field-grid-six { display: grid; gap: 10px; }
.field-pair { grid-template-columns: 1fr 1fr; }
.field-grid-three { grid-template-columns: repeat(3, 1fr); }
.field-grid-six { grid-template-columns: repeat(3, 1fr); }
.formula-card label { color: var(--slate-600); font-size: 13px; font-weight: 700; }
.formula-card input, .chapter-search input { width: 100%; margin-top: 5px; padding: 10px 11px; border: 1px solid var(--slate-300); border-radius: 10px; outline: none; background: #fbfdff; }
.formula-card input:focus, .chapter-search input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(14,165,233,.12); }
.formula-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.formula-actions button, .burn-toolbar button, .upload-button { padding: 9px 12px; border: 0; border-radius: 9px; color: white; background: var(--blue); font-weight: 800; }
.formula-actions .muted-action, .burn-toolbar button:not(:nth-child(2)) { color: var(--navy); background: var(--sky-100); }
.formula-card output { display: block; margin-top: auto; padding: 14px; min-height: 72px; border: 1px solid var(--slate-200); border-radius: 12px; color: var(--slate-700); background: #f8fafc; white-space: pre-line; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.wide-formula { grid-column: span 2; }
.burn-card { grid-column: span 2; }
.upload-zone { display: grid; place-items: center; gap: 9px; min-height: 190px; padding: 24px; border: 2px dashed var(--slate-300); border-radius: 14px; text-align: center; color: var(--slate-500); background: #fbfdff; }
.upload-button { background: var(--blue); }
.burn-viewer { overflow: hidden; border: 1px solid var(--slate-200); border-radius: 14px; }
.burn-toolbar { display: flex; align-items: center; gap: 7px; padding: 9px; border-bottom: 1px solid var(--slate-200); background: var(--slate-100); }
.burn-toolbar span { margin-left: auto; color: var(--slate-600); font-size: 13px; font-weight: 800; }
.burn-canvas { height: 330px; overflow: auto; background: #f8fafc; cursor: grab; }
.burn-canvas:active { cursor: grabbing; }
.burn-canvas img { display: block; max-width: none; transform-origin: top left; user-select: none; -webkit-user-drag: none; }

.pdf-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 760px; overflow: hidden; }
.chapter-sidebar { padding: 18px; border-right: 1px solid var(--slate-200); background: #f8fafc; }
.chapter-search { display: block; color: var(--slate-600); font-size: 13px; font-weight: 800; }
.chapter-list { display: grid; gap: 8px; margin-top: 15px; max-height: 675px; overflow-y: auto; padding-right: 4px; }
.chapter-button { width: 100%; padding: 12px; border: 1px solid var(--slate-200); border-radius: 11px; text-align: left; color: var(--slate-700); background: white; font-size: 13px; font-weight: 700; }
.chapter-button:hover, .chapter-button.active { color: white; border-color: var(--blue); background: var(--blue); }
.pdf-viewer-section { min-width: 0; }
.pdf-title-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; padding: 12px 16px; border-bottom: 1px solid var(--slate-200); }
.pdf-title-bar strong { color: var(--navy); }
.pdf-title-bar span { color: var(--slate-500); font-size: 12px; }
#pdfViewer { width: 100%; height: 700px; border: 0; background: var(--slate-100); }

.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.guide-card { padding: 26px; }
.guide-card > span { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--navy); background: var(--sky-100); font-weight: 900; }
.guide-card h3 { margin: 16px 0 7px; }
.guide-card p { margin: 0; color: var(--slate-500); }
.guide-card code { padding: 2px 5px; border-radius: 5px; color: var(--navy); background: var(--sky-100); }

footer { border-top: 1px solid var(--slate-200); color: var(--slate-500); background: white; }
.footer-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 13px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: 360px; padding: 12px 16px; border-radius: 11px; color: white; background: var(--slate-950); box-shadow: 0 16px 36px rgba(15,23,42,.24); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1060px) {
  .main-nav { display: none; }
  .download-button { margin-left: auto; }
  .hero-grid, .calculator-layout { grid-template-columns: 1fr; }
  .hero-card { max-width: 620px; }
  .result-card { min-height: auto; }
  .advanced-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .wide-formula, .burn-card { grid-column: span 2; }
}
@media (max-width: 780px) {
  .header-inner { min-height: 64px; gap: 10px; }
  .brand small { display: none; }
  .brand strong { font-size: 12px; }
  .brand-mark { width: 36px; height: 36px; }
  .download-button { padding: 9px 10px; font-size: 12px; }
  .hero { padding: 44px 0 62px; }
  .hero-grid { gap: 30px; }
  .hero p { font-size: 16px; }
  .workspace { margin-top: -24px; }
  .section-heading { align-items: flex-start; padding: 22px; flex-direction: column; }
  .input-card, .result-card { padding: 20px; }
  .injury-grid { grid-template-columns: repeat(5, minmax(48px,1fr)); }
  .advanced-grid, .guide-grid { grid-template-columns: 1fr; }
  .wide-formula, .burn-card { grid-column: auto; }
  .pdf-layout { grid-template-columns: 1fr; min-height: 0; }
  .chapter-sidebar { border-right: 0; border-bottom: 1px solid var(--slate-200); }
  .chapter-list { max-height: 230px; }
  .pdf-title-bar { align-items: flex-start; flex-direction: column; }
  #pdfViewer { height: 620px; }
  .footer-inner { flex-direction: column; align-items: flex-start; justify-content: center; padding-block: 18px; }
}
@media (max-width: 520px) {
  .container { width: min(100% - 20px, 1180px); }
  .brand strong { max-width: 130px; line-height: 1.1; }
  .download-button svg { display: none; }
  .hero-card { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 96px; padding: 15px; }
  .metric span { font-size: 22px; }
  .hero-actions { flex-direction: column; align-items: stretch; text-align: center; }
  .injury-grid { grid-template-columns: repeat(3, 1fr); }
  .field-pair, .field-grid-three, .field-grid-six { grid-template-columns: 1fr; }
  .result-value strong { font-size: 48px; }
}
