:root {
  color-scheme: light;
  --ink: #1c2830;
  --muted: #5a6b76;
  --faint: #93a0a9;
  --soft: #eef1f3;
  --line: #dce2e6;
  --paper: #ffffff;
  --canvas: #f4f6f7;
  --accent: #c7431f;
  --link: #2b5a8a;
  --note: #fbf5e6;
  --note-ink: #6e5716;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

body.static-page,
body.tool-page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
a:focus-visible, .button:focus-visible { outline: 3px solid rgba(43, 90, 138, .28); outline-offset: 3px; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.header-inner,
.page-shell,
.footer-inner {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand::after { content: "."; color: var(--accent); }

.site-nav { display: flex; align-items: stretch; gap: 20px; align-self: stretch; font-size: 14px; }
.site-nav a { display: flex; align-items: center; color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }
.site-nav a.active { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px var(--accent); }

.page-shell {
  padding: 22px 0 64px;
}

.static-page .page-shell {
  flex: 1 0 auto;
}

.tool-page > x-dc,
.tool-page > #dc-root {
  display: block;
  height: auto !important;
  flex: 1 0 auto;
}

.tool-page > #dc-root > .sc-host {
  height: auto !important;
}

/* Also kept in the shared CSS so previously cached tool HTML can recover on refresh. */
.tool-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
  box-sizing: border-box;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 18px;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.6;
}

.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span[aria-current="page"] { color: var(--ink); font-weight: 650; }

/* ---- hero band: white panel, matches the tool's container ---- */
.plain-band {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px 32px 34px;
}
.plain-band > h1 { max-width: 760px; }
.plain-band > .lead { max-width: 760px; }
.plain-band .action-row { margin-top: 24px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
}

h1, h2, h3 { letter-spacing: 0; text-wrap: balance; }
h1 { margin: 0; font-size: 32px; line-height: 1.3; }
h2 { margin: 36px 0 12px; font-size: 20px; line-height: 1.4; }
h3 { margin: 24px 0 8px; font-size: 16.5px; line-height: 1.5; }

.lead {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.8;
  text-wrap: pretty;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 42px;
  align-items: start;
}

.article {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px 32px 36px;
}

.article h2 {
  margin: 34px 0 12px;
  padding-top: 26px;
  border-top: 2px dashed var(--line);
}

/* ---- formula: white token card, red operators — same language as the tool ---- */
.formula-box {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 24px 0 8px;
  padding: 20px 100px 20px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.formula-box b { font-weight: 750; color: var(--ink); }
.formula-box b:first-of-type { color: var(--accent); }
.formula-box i {
  font-style: normal;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
}

.kind-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid #c9d2d8;
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--paper);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.article p,
.article li { font-size: 15px; line-height: 1.8; }
.article p { margin: 10px 0; }
.article ul,
.article ol { margin: 10px 0; padding-left: 1.45em; }
.article li + li { margin-top: 7px; }

.note {
  margin-top: 28px;
  padding: 14px 16px;
  border-left: 3px solid #c9a24b;
  border-radius: 0 5px 5px 0;
  color: var(--note-ink);
  background: var(--note);
  font-size: 13px;
  line-height: 1.7;
}

/* ---- buttons: primary = brand red, secondary = quiet outline ---- */
.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 16px;
  color: var(--paper);
  background: var(--accent);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
}
.button:hover { color: var(--paper); background: #a93a1b; border-color: #a93a1b; }
.button.secondary { color: var(--link); background: var(--paper); border-color: var(--line); }
.button.secondary:hover { color: var(--accent); border-color: var(--accent); background: var(--paper); }

.side-nav { position: sticky; top: 20px; }
.side-section + .side-section { margin-top: 28px; }
.side-title {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}
.link-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.link-list li { border-bottom: 1px solid var(--line); }
.link-list a { display: block; padding: 10px 2px; font-size: 14px; line-height: 1.5; text-decoration: none; }
.link-list a:hover { color: var(--accent); }
.link-list small { display: block; margin-top: 2px; color: var(--faint); font-size: 12px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 34px 0 14px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; color: var(--faint); font-size: 13px; }

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.item-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(28, 40, 48, .05);
  transition: border-color .15s ease;
}
.item-card:hover { border-color: var(--link); color: var(--ink); }
.item-card strong { display: block; font-size: 16.5px; line-height: 1.4; }
.item-card span { display: block; margin-top: 0; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.item-card .meta { color: var(--accent); font-size: 12px; font-weight: 700; }

.site-footer { border-top: 1px solid var(--line); background: var(--paper); margin-top: 24px; }
.static-page .site-footer,
.tool-page .site-footer { margin-top: auto; }
.footer-inner { padding: 24px 0 30px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.footer-inner p { margin: 0; }

.empty-state { color: var(--muted); font-size: 14px; }

@media (max-width: 820px) {
  .content-grid { grid-template-columns: 1fr; gap: 28px; }
  .side-nav { position: static; }
  .article { padding: 24px; }
  .plain-band { padding: 24px; }
  .formula-box { padding-right: 22px; padding-top: 52px; font-size: 18px; }
  .formula-box i { font-size: 20px; }
}

@media (max-width: 620px) {
  .header-inner, .page-shell, .footer-inner, .tool-shell { width: min(100% - 28px, 1080px); }
  .header-inner { min-height: 58px; gap: 12px; }
  .site-nav { gap: 12px; font-size: 13px; }
  .site-nav .optional { display: none; }
  .page-shell { padding-top: 16px; }
  .article { padding: 20px 18px; }
  h1 { font-size: 27px; }
  .lead { font-size: 15.5px; }
  .item-grid { grid-template-columns: 1fr; }
  .action-row .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
