:root {
  --ink: #142033;
  --muted: #55627a;
  --line: #d8deea;
  --bg: #f4f6fb;
  --card: #ffffff;
  --brand: #2446a8;
  --brand-dark: #18317a;
  --accent: #0f7b6c;
  --accent-soft: #e2f4f0;
  --warn: #9a3412;
  --warn-soft: #fff1e8;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.wordmark svg { width: 28px; height: 28px; }
.site-nav { display: flex; gap: 4px 16px; flex-wrap: wrap; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.site-nav a[aria-current="page"], .site-nav a:hover { color: var(--brand); }

.wrap { max-width: 1040px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
main { padding-bottom: 48px; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin: 18px 0 0; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); line-height: 1.2; margin: 14px 0 10px; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; line-height: 1.3; margin: 36px 0 10px; }
h3 { font-size: 1.1rem; margin: 22px 0 8px; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 760px; margin: 0 0 20px; }
.prose { max-width: 760px; }
.prose p, .prose li { font-size: 1.02rem; }
.prose table { margin: 12px 0; }

.tool { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(20, 32, 51, 0.04); }
.tool-head { display: flex; gap: 12px 20px; align-items: end; flex-wrap: wrap; }
.tool-title { margin: 6px 0 10px; font-size: 1.05rem; }
.tool-title + .course-head { margin-top: 0; }
.field { display: grid; gap: 4px; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="number"], select {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid #b9c3d6; border-radius: 8px; background: #fff;
}
select { padding-right: 28px; }
input:focus, select:focus { border-color: var(--brand); }
.field select, .field input { min-width: 200px; font-weight: 400; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid #b9c3d6; border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 9px 14px; cursor: pointer; min-height: 42px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.seg button:disabled { color: #9aa5b8; cursor: not-allowed; }
.notice { font-size: 0.88rem; background: #fff7d6; border: 1px solid #f1d98a; border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.notice[hidden] { display: none; }
.scale-note { font-size: 0.86rem; color: var(--muted); margin: 10px 0 12px; }
.weights { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.weights legend { font-weight: 700; font-size: 0.92rem; padding: 0 4px; }
.weights label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.weights input { width: 76px; }
.weights .hint { flex-basis: 100%; margin: 4px 0 0; }

.course-head, .course { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1.4fr) 40px; gap: 8px; align-items: center; }
.tool[data-mode="college"] .course-head, .tool[data-mode="college"] .course { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1.6fr) 40px; }
.tool[data-mode="middle"] .course-head, .tool[data-mode="middle"] .course { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1.6fr) 40px; }
.course-head.terms, .course.terms { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) 40px; }
.cell { min-width: 0; }
.cell-label { display: none; }
.course-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; margin: 4px 0 6px; }
.courses { display: grid; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 1.3rem; line-height: 1; color: var(--muted); }
.icon-btn:hover { color: var(--warn); border-color: var(--warn); }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: #eef2fc; color: var(--brand-dark); }
.btn[hidden] { display: none; }

.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 8px; }
.result > p { grid-column: 1 / -1; margin: 0; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; display: grid; }
.stat span { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 1.9rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 0.82rem; }
.stat.main { background: var(--accent-soft); border-color: #a9dccf; }
.stat.main.alt { background: #e8eefc; border-color: #b7c7f0; }
.empty { color: var(--muted); }
.verdict { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.verdict.ok { background: var(--accent-soft); }
.verdict.no { background: var(--warn-soft); color: var(--warn); }
.work-line { font-size: 0.92rem; color: var(--muted); }
.work { margin: 6px 0; border-top: 1px solid var(--line); padding-top: 8px; }
.work summary { cursor: pointer; font-weight: 700; color: var(--brand); padding: 4px 0; }
.work p { margin: 8px 0; }
.steps { margin: 8px 0; padding-left: 22px; }
.hint { font-size: 0.86rem; color: var(--muted); }
.target-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.target-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.target-grid .field input { min-width: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
th { background: #f0f3f9; font-weight: 700; }
tr.hl td { background: #fff7d6; font-weight: 700; }

.callout { border-left: 4px solid var(--accent); background: var(--card); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 18px 0; max-width: 760px; }
.next-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.next-steps a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-decoration: none; color: var(--ink); }
.next-steps a:hover { border-color: var(--brand); }
.next-steps strong { display: block; color: var(--brand); margin-bottom: 2px; }
.next-steps span { font-size: 0.9rem; color: var(--muted); }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; max-width: 760px; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { margin: 8px 0 2px; }
.updated { font-size: 0.85rem; color: var(--muted); }
.sources-list li { margin-bottom: 6px; }
.byline { font-size: 0.88rem; color: var(--muted); margin: 0 0 10px; }
.shot { margin: 22px 0; }
.shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.shot figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 8px; }
main code, .formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: #eef2fc; border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
.formula { display: block; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.guide-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 8px 0 20px; }
.guide-list a { display: grid; gap: 6px; align-content: start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-decoration: none; color: var(--ink); }
.guide-list a:hover { border-color: var(--brand); }
.guide-list img { width: 100%; height: 150px; object-fit: cover; object-position: top left; border-radius: 8px; border: 1px solid var(--line); }
.guide-list strong { color: var(--brand); line-height: 1.35; }
.guide-list span { font-size: 0.92rem; color: var(--muted); }

footer { border-top: 1px solid var(--line); background: var(--card); padding: 22px 0 30px; font-size: 0.9rem; color: var(--muted); }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
footer a { color: var(--muted); }

@media (max-width: 720px) {
  .course-head { display: none; }
  .course, .tool[data-mode] .course, .course.terms {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 40px;
    padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe;
  }
  .cell-label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
  .course .c-name { grid-column: 1 / 3; }
  .course .icon-btn { grid-column: 3; grid-row: 1; align-self: end; }
  .course .c-level { grid-column: 1 / -1; }
  .tool[data-mode="middle"] .course .c-level { grid-column: 2 / -1; }
  .course.terms .cell:nth-child(3) { grid-column: 2 / 4; }
  .site-nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .site-nav a { white-space: nowrap; }
  .target-grid, .target-grid.two { grid-template-columns: 1fr; }
  .field select, .field input { min-width: 0; }
  .tool-head { display: grid; grid-template-columns: 1fr; }
  .tool { padding: 14px; }
  .stat strong { font-size: 1.6rem; }
}

@media print {
  .site-header, footer, .tool-actions, .seg, .skip, .next-steps, .faq, .icon-btn, nav { display: none !important; }
  body, .tool { background: #fff; box-shadow: none; }
  .tool { border: 0; padding: 0; }
  .work { border: 0; }
  input, select { border: 0; padding: 0; min-height: 0; appearance: none; -webkit-appearance: none; background: none; }
  a { color: inherit; text-decoration: none; }
}
.custom-scale { border: 1px dashed #b9c3d6; border-radius: 10px; padding: 10px; margin: 0 0 14px; }
.custom-scale table { max-width: 420px; }
.custom-scale td { padding: 4px 6px; }
.custom-scale input { min-height: 36px; }
