/* ==========================================================================
   AspectCalc — style.css
   Mobile-first. No frameworks, no vendor CSS, no complex animation.
   ========================================================================== */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --brand-line: #bfdbfe;

  --ink: #0f172a;
  --body: #334155;
  /* 加深过：原 #64748b 在浅色底（--stage #f1f5f9）上只有 4.34:1，
     低于 WCAG AA 正文要求的 4.5 —— 计算器标签、未选中 tab 都栽在这一条上。
     改成 #5a697e 后是 5.10:1（在纯白上是 5.59:1）。 */
  --muted: #5a697e;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --bg: #f8fafc;
  --card: #ffffff;
  --stage: #f1f5f9;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --ok: #15803d;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);

  --wrap: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--body);
  background: var(--bg);
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.75rem; letter-spacing: -.02em; }
h2 { font-size: 1.375rem; letter-spacing: -.01em; }
h3 { font-size: 1.0625rem; }
h4 { font-size: 1rem; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.35em; }
li { margin-bottom: .35em; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 正文与导语里的行内链接必须带下划线：只靠颜色区分对色觉障碍读者不可用（WCAG 1.4.1），
   而且 --brand #2563eb 与导语灰 #5a697e 的对比不足以让链接「跳出来」。
   只作用于 .prose / .lede，导航、卡片、页脚、相关链接的观感完全不变。 */
.prose a:not(.btn), .lede a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }
.prose a:not(.btn):hover, .lede a:not(.btn):hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: .65rem 1rem;
  z-index: 999;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 16px;
}

.section { padding: 2.25rem 0; }
.section--tight { padding: 1.5rem 0; }
.section > .wrap > h2 { margin-bottom: .75rem; }
.lede { font-size: 1.0625rem; color: var(--muted); margin-bottom: 1.25rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--ink);
  letter-spacing: -.02em;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; flex: 0 0 auto; }
.brand em { font-style: normal; color: var(--brand); }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  padding: .45rem .7rem;
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--brand); color: var(--brand-dark); }

.site-nav {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 6px 16px 12px;
  flex-direction: column;
  gap: 2px;
}
.site-nav.is-open { display: flex; }
.site-nav a {
  color: var(--body);
  font-size: .9375rem;
  font-weight: 600;
  padding: .6rem 4px;
  border-radius: var(--radius-sm);
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--brand); text-decoration: none; }

/* ---------- Hero ---------- */
.hero {
  padding: 2rem 0 1.25rem;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}
.hero h1 { margin-bottom: .5rem; }
.hero p { font-size: 1rem; color: var(--muted); max-width: 62ch; margin-bottom: 0; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.125rem;
}

/* ---------- Calculator ---------- */
.calc { scroll-margin-top: 70px; }
.calc-head { margin-bottom: 1rem; }
.calc-head h2 { margin-bottom: .25rem; }
.calc-head p { margin: 0; color: var(--muted); font-size: .9375rem; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 1.125rem;
}
.tab {
  flex: 1 1 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  padding: .55rem .4rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  /* Comfortable tap target on narrow screens (Apple/Google guidance: 44px). */
  min-height: 44px;
}
/*
 * The active tab used to be a white pill on grey, which was easy to miss.
 * It is now a filled brand block with white text, and the inactive tabs are
 * pushed down in weight so the contrast is unmistakable at a glance.
 */
.tab[aria-selected="true"] {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .18), inset 0 0 0 1px var(--brand-dark);
}
.tab[aria-selected="true"]::after {
  /* Underline bar as a second, non-colour cue — colour alone is not enough
     for anyone with a colour-vision deficiency. */
  content: "";
  display: block;
  height: 2px;
  margin: .3rem auto 0;
  width: 62%;
  border-radius: 2px;
  background: rgba(255, 255, 255, .85);
}
.tab[aria-selected="false"] { font-weight: 600; }
.tab:hover:not([aria-selected="true"]) { color: var(--ink); background: #fff; }
.tab:focus-visible {
  outline: 3px solid var(--brand-dark);
  outline-offset: 2px;
}

.panel[hidden] { display: none; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .875rem;
  margin-bottom: 1rem;
}
.field-grid--pair { grid-template-columns: 1fr auto 1fr; align-items: end; }
.field-grid--pair .colon {
  padding-bottom: .72rem;
  font-weight: 700;
  color: var(--muted);
}

/* File drop zone (image aspect ratio checker) */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: 2rem 1.25rem;
  border: 2px dashed var(--brand);
  border-radius: .75rem;
  background: var(--brand-soft, #eef2ff);
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  margin-bottom: 1rem;
}
.drop:hover, .drop:focus-visible { border-color: var(--brand-dark); }
.drop__icon { font-size: 1.5rem; line-height: 1; }
.drop span { font-size: .875rem; color: var(--muted); }

.field { display: block; min-width: 0; }
.field-label {
  display: block;
  font-size: .8125rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .3rem;
  letter-spacing: .01em;
}
.field-hint { display: block; font-size: .75rem; font-weight: 500; color: var(--muted); margin-top: .25rem; }

input[type="number"], input[type="text"], input[type="email"], textarea {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .6rem .7rem;
}
input[type="number"]:focus, input[type="text"]:focus, input[type="email"]:focus, textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-bg);
}
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-bg); }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  gap: .55rem;
  align-items: flex-start;
  font-size: .875rem;
  border-radius: var(--radius-sm);
  padding: .7rem .8rem;
  margin: 0 0 1rem;
  border: 1px solid transparent;
}
.alert[hidden] { display: none; }
.alert--error {
  background: var(--danger-bg);
  border-color: var(--danger-line);
  color: #991b1b;
}
.alert--error strong { color: #7f1d1d; }
.alert__icon { flex: 0 0 auto; font-weight: 800; line-height: 1.5; }

/* ---------- Result ---------- */
.result {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--stage);
  padding: .9rem;
  margin-bottom: 1rem;
}
.result-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem .75rem;
  margin-bottom: .65rem;
}
.result-ratio {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.result-decimal {
  font-size: .9375rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.result-rows {
  display: grid;
  gap: .4rem;
  margin: 0;
  font-size: .875rem;
}
.result-row { display: flex; justify-content: space-between; gap: 1rem; }
.result-row dt { color: var(--muted); margin: 0; flex: 0 1 auto; }
.result-row dd { margin: 0; color: var(--ink); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.closest {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
  margin-top: .15rem;
}
.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-dark);
  white-space: nowrap;
}
.badge--plain {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--muted);
}

/* ---------- Preview ---------- */
.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}
.preview-head h3 { margin: 0; font-size: .9375rem; }
.preview-head span { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.preview-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 216px;
  padding: 16px;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.preview-shape {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 4px;
  min-height: 4px;
  width: 200px;
  height: 200px;
  background: linear-gradient(150deg, #dbeafe 0%, #eff6ff 100%);
  border: 2px solid var(--brand);
  border-radius: 4px;
  color: var(--brand-dark);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  transition: width .16s ease, height .16s ease;
  overflow: hidden;
}
.preview-shape span { padding: 2px 4px; white-space: nowrap; }
.preview-shape[data-empty="true"] {
  background: repeating-linear-gradient(45deg, #fff 0 8px, var(--stage) 8px 16px);
  border-color: var(--line-strong);
  border-style: dashed;
  color: var(--muted);
  width: 200px;
  height: 200px;
}
.preview-caption {
  margin: .5rem 0 0;
  font-size: .8125rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===== Homepage hero calculator — visual hierarchy boost (UI-only) =====
   Scope: .calc-hero (the homepage calculator wrapper only). Goal: make the
   primary calculation obvious — Width/Height are the entry point, the Aspect
   Ratio result is the focal answer, Visual Preview is secondary. No markup,
   content, URL, or calculation logic changed; CSS only. Other calculator
   instances (ratio pages, screen, embed) are untouched because the rules are
   scoped to .calc-hero. */
.calc-hero .field-label {
  color: var(--brand-dark);
  font-size: .875rem;
}
.calc-hero .field input[type="number"] {
  font-size: 1.0625rem;
  font-weight: 700;
  padding: .75rem .8rem;
  border-color: var(--brand-line);
  box-shadow: inset 0 0 0 1px var(--brand-soft);
}
.calc-hero .result {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  padding: 1.1rem 1.15rem;
}
.calc-hero .result-top { margin-bottom: .75rem; }
.calc-hero .result-ratio {
  font-size: clamp(2rem, 5.5vw, 2.6rem);
  line-height: 1.04;
}
.calc-hero .result-decimal { font-size: 1rem; }
.calc-hero .result-rows {
  margin-top: .85rem;
  padding-top: .8rem;
  border-top: 1px solid var(--brand-line);
  font-size: .8125rem;
  color: var(--muted);
}
.calc-hero .result-row dt { font-weight: 500; }
.calc-hero .result-row dd { font-weight: 700; }

/* Preview steps back so the ratio reads first */
.calc-hero .preview-stage { height: 184px; }
.calc-hero .preview-shape { background: var(--brand-soft); }

/* Secondary actions toned down but fully usable */
.calc-hero .copy-bar { margin-top: .85rem; }
.calc-hero .copy-bar .btn {
  font-size: .8125rem;
  padding: .45rem .7rem;
  min-height: 44px;
}

/* ---------- Copy buttons ---------- */
.copy-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}
.btn {
  appearance: none;
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  padding: .55rem .85rem;
  cursor: pointer;
  /* 44px minimum tap target, per the Apple/Google accessibility guideline the
     narrow-screen check calls out. */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 3px solid var(--brand-dark);
  outline-offset: 2px;
}
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn--copy { border-color: var(--brand-line); color: var(--brand-dark); background: #fff; }
.btn--copy.is-done { background: #ecfdf5; border-color: #86efac; color: var(--ok); }
/*
 * Confirmation on the copy buttons. The tick is a pseudo-element rather than a
 * character inside the button so the button's textContent stays exactly
 * "Copied" — the status is announced separately through the live region that
 * the calculator keeps next to the copy bar. Drawn with borders rather than an
 * SVG data URI, so this stylesheet contains no absolute URL of any kind and a
 * grep-based mixed-content scan stays clean.
 */
.btn--copy.is-done::before {
  content: "";
  flex: 0 0 auto;
  width: .45rem;
  height: .85rem;
  margin: -.15rem .1rem 0 0;
  border: solid currentColor;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  border-color: var(--line-strong);
  color: var(--muted);
  background: var(--stage);
}
.btn:disabled:hover { border-color: var(--line-strong); color: var(--muted); background: var(--stage); }
.btn--block { width: 100%; }

/* ---------- Chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.chip {
  appearance: none;
  font: inherit;
  font-size: .8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--body);
  border-radius: 999px;
  padding: .35rem .7rem;
  cursor: pointer;
  /* Ratio presets are a primary way in on mobile, so they get a full-size
     tap target rather than the 27px they used to measure. */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }

/* ---------- Recently used sizes ---------- */
.recent {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.recent[hidden] { display: none; }
.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.recent-title {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 0;
}
.recent-clear {
  appearance: none;
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  padding: .3rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  /* Small text link, but still a 44px tall target. */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.recent-clear:hover { color: var(--brand-dark); background: var(--brand-soft); }
.recent-clear:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.recent-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .6rem 0 0;
  padding: 0;
}
.recent-item {
  appearance: none;
  font: inherit;
  font-size: .8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-dark);
  background: #fff;
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  padding: .35rem .7rem;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.recent-item:hover { background: var(--brand-soft); border-color: var(--brand); }
.recent-item:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.recent-note {
  font-size: .75rem;
  color: var(--muted);
  margin: .5rem 0 0;
}

.subhead {
  font-size: .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 .5rem;
}

.note {
  font-size: .8125rem;
  color: var(--muted);
  margin: .75rem 0 0;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 480px;
}
caption {
  caption-side: top;
  text-align: left;
  padding: .7rem .8rem;
  font-size: .8125rem;
  color: var(--muted);
}
th, td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  background: var(--stage);
  color: var(--ink);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.ratio-cell { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Card grid (guides) ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.grid li {
  display: block;
  height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .85rem .95rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.grid li:hover { border-color: var(--brand); }
.grid li a { text-decoration: none; }
.grid li a:hover { text-decoration: none; }
.grid strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: .15rem; font-variant-numeric: tabular-nums; }
.grid span { display: block; font-size: .8125rem; color: var(--muted); }
/* Inline diagrams inside prose and figures scale to the container. */
.fig svg, .ratio-figure svg { width: 100%; height: auto; display: block; }

/* ---------- FAQ ---------- */
.faq { border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.faq + .faq { margin-top: .5rem; }
.faq summary {
  cursor: pointer;
  padding: .8rem .95rem;
  font-weight: 700;
  color: var(--ink);
  font-size: .9375rem;
  list-style: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 700; color: var(--brand); flex: 0 0 auto; font-size: 1.1rem; line-height: 1.4; }
.faq[open] summary::after { content: "\2013"; }
.faq summary:hover { background: var(--brand-soft); }
.faq-body { padding: 0 .95rem .9rem; font-size: .9375rem; }
.faq-body > :last-child { margin-bottom: 0; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  font-size: .8125rem;
  color: var(--muted);
  margin-bottom: .6rem;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb > span[aria-hidden] { color: var(--line-strong); }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- Prose blocks ---------- */
.prose { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 1.1rem; }
.prose > :last-child { margin-bottom: 0; }
.prose h3 { margin-top: 1.25rem; }
.prose h3:first-child { margin-top: 0; }
.prose--legal { padding: 1.25rem; }
.prose--legal h2 { margin-top: 1.75rem; font-size: 1.1875rem; }
.prose--legal h2:first-of-type { margin-top: 0; }
.prose--legal ul { padding-left: 1.25rem; }
.prose--legal .notice p { margin-bottom: .35rem; }
.prose--legal .notice p:last-child { margin-bottom: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.1rem;
  margin-bottom: .6rem;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: .1rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-dark);
  font-size: .8125rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .1rem .35rem;
}
pre {
  margin: 0 0 1rem;
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .75rem .85rem;
  overflow-x: auto;
  font-size: .8125rem;
  line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; }

/* ---------- Ratio page quick facts ---------- */
.fact-list { margin: 0; padding: 0; list-style: none; display: grid; gap: .45rem; font-size: .9375rem; }
.fact-list li { display: flex; gap: .5rem; margin: 0; }
.fact-list b { color: var(--ink); flex: 0 0 auto; min-width: 8.5rem; }

.related {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.related a {
  display: inline-block;
  font-size: .875rem;
  font-weight: 700;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: .4rem .8rem;
  font-variant-numeric: tabular-nums;
}
.related a:hover { border-color: var(--brand); text-decoration: none; background: var(--brand-soft); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 2rem;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 2rem 0 1.5rem;
  font-size: .875rem;
}
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
/* 页脚栏目名用 h3 而不是 h4：h2 → h4 跳级会触发无障碍「标题层级不连续」告警。
   这里同时锁住视觉样式，换标签不影响观感。 */
.footer-col h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .6rem; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: .35rem; }
.footer-col a { color: var(--body); }
.footer-col a:hover { color: var(--brand); }
.footer-about p { color: var(--muted); margin: 0; max-width: 40ch; }
.footer-bottom {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  justify-content: space-between;
  color: var(--muted);
  font-size: .8125rem;
}

/* ---------- Asides / notices ---------- */
.notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  font-size: .875rem;
  color: #1e3a8a;
}
.notice strong { color: #1e3a8a; }

/* ---------- Editorial pages ---------- */
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin: .6rem 0 0;
  font-size: .875rem;
  color: var(--muted);
}
.article-meta time { color: var(--body); }
.prose--article { padding: 1.25rem; }
.prose--article p { font-size: 1.0625rem; }
.prose--article > :last-child { margin-bottom: 0; }
.prose--article ol, .prose--article ul { padding-left: 1.25rem; }
.prose--article li { margin-bottom: .4rem; }
/* Article cards carry a full sentence, so two columns read better than four. */
.grid--articles li { padding: .95rem 1.05rem; }
.grid--articles strong { font-variant-numeric: normal; }

/* ---------- Reserved advertising slots ---------- */
/*
 * The container is in the DOM at the final position but collapses to zero
 * height until a unit is added, so nothing shows while the account is
 * unapproved. See ad_slot() in tools/build_site.py for the placement rules.
 */
.ad-slot {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 728px;
}
.ad-slot--below-calc {
  /*
   * Hard 150px buffer. The Copy / calculate buttons sit directly above this
   * slot, and AdSense treats clicks landing that close to an interactive
   * control as invalid traffic — repeated invalid traffic is what gets
   * accounts suspended, so this gap is deliberate. Do not shrink it.
   */
  margin-top: 150px;
}
.ad-slot--in-content { margin: 2.5rem auto; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Breakpoints
   ========================================================================== */
@media (min-width: 640px) {
  h1 { font-size: 2.125rem; }
  h2 { font-size: 1.5rem; }
  .section { padding: 2.75rem 0; }
  .card { padding: 1.5rem; }
  .field-grid { grid-template-columns: 1fr 1fr; }
  .field-grid--pair { grid-template-columns: 1fr auto 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: .875rem; }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-about { grid-column: 1 / -1; }
  .preview-stage { height: 248px; }
  .hero { padding: 2.75rem 0 1.75rem; }
}

@media (min-width: 900px) {
  h1 { font-size: 2.375rem; }
  .header-inner { min-height: 64px; }
  .nav-toggle { display: none; }
  .site-nav {
    display: flex;
    position: static;
    flex-direction: row;
    gap: 1.6rem;
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .site-nav a { padding: .35rem 0; }
  .hero { padding: 3.25rem 0 2rem; }
  .section { padding: 3.25rem 0; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  /* Article cards stay at two columns — four columns would wrap the teaser
     sentence into a column of single words. */
  .grid--articles { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .footer-about { grid-column: 1 / -1; }
  /* Calculator: inputs left, live preview right */
  .calc-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.75rem; align-items: start; }
  .calc-side { position: sticky; top: 84px; }
  .preview-stage { height: 218px; }
  .result-ratio { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .preview-shape { transition: none; }
}

/* ---------------------------------------------------------------------------
   Inline diagrams (the computed-comparison figures on the ratio deep-dive
   sections). SVG scales with the column, the caption sits under it.
   --------------------------------------------------------------------------- */
.fig {
  margin: 1.5rem 0;
  text-align: center;
}
.fig svg {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
}
.fig figcaption {
  margin-top: .6rem;
  font-size: .875rem;
  color: var(--muted, #6b7280);
  line-height: 1.5;
}
/* Raster/SVG images dropped into a figure scale like the inline diagrams and
   pick up a soft SaaS-style shadow. --wide lets a comparison span the column. */
.fig img {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 10px 28px rgba(15, 23, 42, .07);
  background: #fff;
}
.fig--wide { max-width: 100%; }
.fig--wide img { max-width: 100%; }
/* Portrait phone mockups stay narrow so a tall screenshot does not dominate
   the reading column. */
.fig--portrait img { max-width: 300px; }

@media print {
  .site-header, .site-footer, .copy-bar, .tabs, .calc-side { display: none; }
  body { background: #fff; }
}
