/* SBIR 115 指南頁。
 * 版面主軸是一條垂直管線，對應 SBIR 的階段與閘門；互動工具停靠在它被需要的節點旁。
 * 色票沿用 /sbir/ 的品牌 token，不另開一套。
 */
:root {
  --wine: #8b2520;
  --wine-soft: #a8453f;
  --accent: #7a4a2a;
  --paper: #f8f4ee;
  --base: #fbf9f7;
  --ink: #2b2420;
  --muted: #6b5d52;
  --white: #fff;
  --rule: rgba(43, 36, 32, 0.14);
  --rule-soft: rgba(43, 36, 32, 0.08);
  --serif: "Noto Serif TC", serif;
  --sans: "Noto Sans TC", system-ui, sans-serif;
  --measure: 40rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--ink);
  background: var(--base);
  -webkit-text-size-adjust: 100%;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--wine); color: #fff; padding: .6rem 1rem; z-index: 99;
}
.skip:focus { left: 1rem; top: 1rem; }

a { color: var(--wine); text-underline-offset: .18em; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--wine); outline-offset: 2px;
}

/* ---------- 頁首 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(251, 249, 247, .93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule-soft);
}
.brand { font-family: var(--serif); font-weight: 700; text-decoration: none; color: var(--ink); }
.brand span { color: var(--muted); font-weight: 600; font-size: .85em; }
.topnav a { font-size: .9rem; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 1px; }

/* ---------- Hero ---------- */
.hero {
  padding: clamp(2.5rem, 7vw, 5rem) clamp(1rem, 4vw, 2.5rem) 2rem;
  max-width: 54rem; margin-inline: auto;
}
.kicker {
  margin: 0 0 .6rem; font-size: .8rem; letter-spacing: .18em;
  color: var(--wine); font-weight: 700;
}
.hero h1 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(2rem, 5.5vw, 3.1rem); line-height: 1.25;
  margin: 0 0 1rem; letter-spacing: -.01em;
}
.hero h1 .yr {
  display: inline-block; font-size: .5em; vertical-align: .35em;
  color: var(--white); background: var(--wine);
  padding: .1em .6em; border-radius: 2px; letter-spacing: .04em;
}
.lede { font-size: clamp(1.02rem, 2.2vw, 1.2rem); color: var(--muted); margin: 0 0 1.8rem; }
.meta { display: grid; gap: .7rem; margin: 0; padding: 1rem 0 0; border-top: 1px solid var(--rule); }
.meta > div { display: grid; grid-template-columns: 6rem 1fr; gap: .8rem; }
.meta dt { font-size: .8rem; color: var(--muted); font-weight: 500; }
.meta dd { margin: 0; font-size: .85rem; }

/* ---------- 讀者分流 ---------- */
.triage {
  max-width: 54rem; margin: 0 auto clamp(2rem, 5vw, 3.5rem);
  padding: clamp(1.2rem, 3vw, 2rem) clamp(1rem, 4vw, 2.5rem);
}
.triage h2 {
  font-family: var(--serif); font-size: 1.05rem; margin: 0 0 1rem;
  color: var(--muted); font-weight: 600;
}
.triage ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.triage li { background: var(--paper); }
.triage a {
  display: grid; gap: .1rem; padding: .85rem 1.1rem;
  text-decoration: none; color: var(--ink);
  border-left: 3px solid transparent; transition: background .15s, border-color .15s;
}
.triage a:hover, .triage a:focus-visible { background: var(--white); border-left-color: var(--wine); }
.triage b { font-weight: 700; font-size: .98rem; }
.triage span { font-size: .82rem; color: var(--muted); }
@media (min-width: 40rem) { .triage ul { grid-template-columns: 1fr 1fr; } }

/* ---------- 管線版面 ---------- */
.layout {
  display: grid; gap: 0;
  max-width: 68rem; margin-inline: auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 4rem;
}
@media (min-width: 60rem) {
  .layout { grid-template-columns: 11rem minmax(0, 1fr); gap: clamp(2rem, 4vw, 3.5rem); }
}

/* 寬螢幕時 Hero 與分流區讓出左側管線的寬度，與內文共用同一條左基線 */
@media (min-width: 60rem) {
  .hero, .triage {
    max-width: 68rem;
    padding-left: calc(clamp(1rem, 4vw, 2.5rem) + 11rem + clamp(2rem, 4vw, 3.5rem));
    padding-right: clamp(1rem, 4vw, 2.5rem);
  }
}

/* 左側管線：節點串成一條線，捲動時高亮 */
.spine { display: none; }
@media (min-width: 60rem) {
  .spine { display: block; position: sticky; top: 5rem; align-self: start; max-height: calc(100vh - 7rem); overflow: auto; }
  .spine ol { list-style: none; margin: 0; padding: .5rem 0 .5rem 1.1rem; position: relative; }
  .spine ol::before {
    content: ""; position: absolute; left: .32rem; top: 1.1rem; bottom: 1.1rem;
    width: 1px; background: var(--rule);
  }
  .spine li { position: relative; }
  .spine li::before {
    content: ""; position: absolute; left: -.92rem; top: .82rem;
    width: .42rem; height: .42rem; border-radius: 50%;
    background: var(--base); border: 1px solid var(--rule); transition: background .2s, border-color .2s;
  }
  .spine a {
    display: block; padding: .3rem 0; font-size: .85rem;
    text-decoration: none; color: var(--muted); transition: color .2s;
  }
  .spine a:hover { color: var(--ink); }
  .spine li.on::before { background: var(--wine); border-color: var(--wine); transform: scale(1.25); }
  .spine li.on a { color: var(--wine); font-weight: 700; }
}

/* ---------- 內文 ---------- */
.body { min-width: 0; }

.node {
  padding: clamp(2rem, 5vw, 3.2rem) 0;
  border-top: 1px solid var(--rule);
}
.node:first-child { border-top: 0; padding-top: 0; }

.node h2 {
  font-family: var(--serif); font-weight: 700;
  font-size: clamp(1.5rem, 3.6vw, 2.05rem); line-height: 1.35;
  margin: 0 0 1.1rem; letter-spacing: -.005em;
}
.node h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.12rem, 2.4vw, 1.3rem);
  margin: 2.2rem 0 .8rem; padding-left: .75rem;
  border-left: 3px solid var(--wine);
}
.node h4 {
  font-size: 1rem; font-weight: 700; margin: 1.6rem 0 .6rem; color: var(--accent);
}
.node p, .node li { max-width: var(--measure); }
.node p { margin: 0 0 1rem; }
.node ul, .node ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
.node li { margin-bottom: .45rem; }
.node li > ul, .node li > ol { margin-top: .4rem; margin-bottom: .2rem; }

.intro { font-size: 1.05rem; color: var(--muted); }

cite {
  font-style: normal; font-size: .72rem; font-family: var(--sans);
  color: var(--wine); background: rgba(139, 37, 32, .07);
  padding: .1em .45em; border-radius: 2px; margin-left: .35em;
  white-space: nowrap; vertical-align: .08em;
}
.src { font-size: .82rem; color: var(--muted); }
.srcnote {
  font-size: .85rem; color: var(--muted);
  background: var(--paper); border-left: 3px solid var(--rule);
  padding: .7rem .95rem; max-width: var(--measure);
}
.note { font-size: .9rem; color: var(--muted); }

/* 三件事：編號段落 */
.pt { margin: 0 0 2.2rem; }
.pt h3 {
  border-left: 0; padding-left: 0; display: flex; gap: .7rem; align-items: baseline;
  font-size: clamp(1.18rem, 2.6vw, 1.42rem); margin-top: 0;
}
.pt .n {
  flex: none; font-family: var(--serif); font-size: .82em;
  color: var(--white); background: var(--wine);
  width: 1.7em; height: 1.7em; border-radius: 50%;
  display: grid; place-items: center; line-height: 1;
}

.formula {
  font-family: var(--serif); font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  font-weight: 600; text-align: center; letter-spacing: .04em;
  background: var(--paper); border: 1px solid var(--rule);
  padding: 1rem .8rem; margin: 1.2rem 0; max-width: var(--measure);
}
.eg {
  background: var(--paper); border-left: 3px solid var(--accent);
  padding: .8rem 1rem; font-size: .95rem; max-width: var(--measure);
}
.warn {
  background: rgba(139, 37, 32, .06); border-left: 3px solid var(--wine);
  padding: .85rem 1rem; max-width: var(--measure);
}
.highlight {
  background: var(--white); border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: .9rem 1.1rem; max-width: var(--measure);
}
blockquote {
  margin: 1.2rem 0; padding: 1rem 1.2rem; max-width: var(--measure);
  background: var(--paper); border-left: 3px solid var(--wine);
  font-family: var(--serif); font-size: 1.08rem;
}

.stage { margin-bottom: 1.8rem; padding-bottom: 1.4rem; border-bottom: 1px dashed var(--rule); }
.stage:last-of-type { border-bottom: 0; }
.stage h3 { margin-top: 0; }
.fmt { font-size: .88rem; color: var(--muted); }

.flow { counter-reset: f; list-style: none; padding-left: 0; }
.flow li {
  counter-increment: f; position: relative; padding-left: 2.2rem; margin-bottom: .7rem;
}
.flow li::before {
  content: counter(f); position: absolute; left: 0; top: .28em;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--rule);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--wine);
}

.accounts { counter-reset: a; }
.defects li { margin-bottom: .8rem; }
.inds { display: block; margin-top: .35rem; font-size: .88rem; color: var(--muted); }

.pay { margin-bottom: 1.4rem; }
.pay h4 { margin-top: 0; }

.contact { margin: 0 0 1rem; max-width: var(--measure); }
.contact > div { display: grid; grid-template-columns: 7rem 1fr; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--rule-soft); }
.contact dt { font-size: .85rem; color: var(--muted); }
.contact dd { margin: 0; font-size: .92rem; }

/* ---------- 表格 ---------- */
.scroll { overflow-x: auto; margin: 0 0 1.4rem; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; min-width: 32rem; font-size: .88rem; background: var(--white); }
caption {
  text-align: left; font-size: .82rem; color: var(--muted);
  padding: 0 0 .5rem; font-weight: 500;
}
th, td { border: 1px solid var(--rule); padding: .6rem .75rem; text-align: left; vertical-align: top; line-height: 1.6; }
thead th { background: var(--paper); font-weight: 700; font-size: .84rem; }
tbody th { background: var(--paper); font-weight: 600; }
tbody th span { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
td.na, td.nd { color: var(--muted); font-style: normal; background: repeating-linear-gradient(135deg, transparent, transparent 5px, var(--rule-soft) 5px, var(--rule-soft) 6px); }
table ul { margin: 0; padding-left: 1.05rem; }
table li { margin-bottom: .3rem; max-width: none; }
table li:last-child { margin-bottom: 0; }
.reject tbody th { width: 13rem; }
.local tbody th { white-space: nowrap; }

/* ---------- 互動工具 ---------- */
.tool {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--wine);
  padding: 1.1rem clamp(.9rem, 2.5vw, 1.4rem); margin: 1.4rem 0 1.6rem;
}
.tool > :last-child { margin-bottom: 0; }
.toolnote { font-size: .82rem; color: var(--muted); margin: 0; }
.tool .toolhead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin: -.2rem 0 .9rem; padding-bottom: .6rem; border-bottom: 1px solid var(--rule);
}
.tool .toolhead b { font-family: var(--serif); font-size: 1.02rem; }
.tool .reset {
  font: inherit; font-size: .8rem; color: var(--muted); background: none;
  border: 1px solid var(--rule); border-radius: 2px; padding: .2rem .6rem; cursor: pointer;
}
.tool .reset:hover { color: var(--wine); border-color: var(--wine); }

.checks { list-style: none; padding-left: 0; margin-bottom: 1rem; counter-reset: c; }
.checks > li { counter-increment: c; margin-bottom: .5rem; max-width: none; }
.checks > li::before { content: counter(c) ". "; color: var(--muted); font-size: .85rem; }
.tool.live .checks > li::before { content: none; }
.tool.live .checks > li { margin-bottom: 0; }
.tool.live .checks label {
  display: grid; grid-template-columns: 1.4rem 1fr; gap: .6rem; align-items: start;
  padding: .55rem .6rem; cursor: pointer; border-radius: 2px;
}
.tool.live .checks label:hover { background: var(--white); }
.tool.live .checks input { margin-top: .45rem; width: 1rem; height: 1rem; accent-color: var(--wine); }
.tool.live .checks li.hit label { background: rgba(139, 37, 32, .08); }

.verdict {
  margin-top: 1rem; padding: .85rem 1rem; border: 1px solid var(--rule);
  background: var(--white); font-size: .92rem;
}
.verdict.bad { border-color: var(--wine); background: rgba(139, 37, 32, .06); }
.verdict.good { border-color: var(--accent); }
.verdict b { display: block; font-family: var(--serif); font-size: 1.05rem; margin-bottom: .3rem; }
.verdict ul { margin: .5rem 0 0; padding-left: 1.2rem; font-size: .88rem; }

.fields { display: grid; gap: .9rem; margin-bottom: 1rem; }
@media (min-width: 34rem) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.field { display: grid; gap: .25rem; }
.field label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.field input, .field select {
  font: inherit; font-size: .95rem; padding: .5rem .6rem;
  border: 1px solid var(--rule); background: var(--white); color: var(--ink); border-radius: 2px;
  width: 100%;
}
.field .hint { font-size: .75rem; color: var(--muted); }

.result { border-top: 1px solid var(--rule); padding-top: .9rem; }
.result .big {
  font-family: var(--serif); font-size: clamp(1.6rem, 5vw, 2.3rem);
  font-weight: 700; color: var(--wine); line-height: 1.2; margin: 0 0 .2rem;
}
.result .sub { font-size: .85rem; color: var(--muted); margin: 0 0 .9rem; }
.chain { list-style: none; padding: 0; margin: 0 0 .9rem; display: grid; gap: .35rem; }
.chain li {
  display: grid; grid-template-columns: 1fr auto; gap: .8rem; align-items: baseline;
  font-size: .87rem; padding: .35rem .55rem; background: var(--white); border: 1px solid var(--rule-soft);
  max-width: none;
}
.chain li.binds { border-color: var(--wine); background: rgba(139, 37, 32, .06); font-weight: 700; }
.chain .tag { font-size: .72rem; color: var(--wine); }
.basis { font-size: .8rem; color: var(--muted); margin: 0; }

.timeline { list-style: none; padding: 0; margin: .4rem 0 .8rem; }
.timeline li {
  position: relative; padding: .5rem 0 .5rem 1.6rem; font-size: .88rem;
  border-left: 2px solid var(--rule); max-width: none;
}
.timeline li::before {
  content: ""; position: absolute; left: -.31rem; top: .95rem;
  width: .5rem; height: .5rem; border-radius: 50%; background: var(--wine);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline b { display: block; }
.timeline span { color: var(--muted); }

/* ---------- CTA 與頁尾 ---------- */
.cta {
  margin-top: 3rem; padding: clamp(1.5rem, 4vw, 2.4rem);
  background: var(--ink); color: var(--paper);
}
.cta h2 { font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 0 0 .9rem; color: #fff; }
.cta p { margin: 0 0 .9rem; max-width: var(--measure); color: rgba(248, 244, 238, .82); }
.btn {
  display: inline-block; margin-top: .5rem; padding: .7rem 1.5rem;
  background: var(--wine); color: #fff; text-decoration: none; font-weight: 700;
  border-radius: 2px;
}
.btn:hover { background: var(--wine-soft); }

.foot {
  border-top: 1px solid var(--rule); padding: 2rem clamp(1rem, 4vw, 2.5rem) 3rem;
  font-size: .85rem; color: var(--muted); text-align: center;
}
.foot p { margin: 0 0 .5rem; }

@media print {
  .top, .spine, .triage, .cta, .skip { display: none; }
  body { background: #fff; }
  .scroll { overflow: visible; }
  table { min-width: 0; }
}
