html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

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

.macro-guide {
  max-width: 980px;
  margin: 0 auto;
  padding: 34px clamp(16px, 4vw, 32px) 80px;
}

.macro-guide .article-header,
.macro-guide .toc,
.macro-guide .article-body > p,
.macro-guide .article-body > section:not(.wide-section),
.macro-guide .article-footer {
  max-width: 820px;
  margin-right: auto;
  margin-left: auto;
}

.macro-guide .eyebrow {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
}

.macro-guide h1 {
  max-width: 760px;
  margin: 0;
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: clamp(2.1rem, 6vw, 3.55rem);
  line-height: 1.14;
  letter-spacing: -.025em;
}

.macro-guide .subtitle {
  max-width: 700px;
  margin: 16px 0 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.85;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 0;
}

.hero-actions a,
.macro-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.hero-actions a.primary,
.macro-button.primary {
  background: var(--accent);
  color: var(--bg-card);
}

.hero-actions a:hover,
.macro-button:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
}

.hero-actions a.primary:hover,
.macro-button.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--text-primary));
}

.hero-actions a:focus-visible,
.macro-button:focus-visible,
.scenario-tab:focus-visible,
.choice-control input:focus-visible + span,
.toc a:focus-visible,
.details-panel summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 44%, transparent);
  outline-offset: 3px;
}

.reading-formula {
  margin: 30px 0 0;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: 16px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 62%), var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.reading-formula .label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}

.reading-formula p {
  margin: 7px 0 0;
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: clamp(1.08rem, 2.5vw, 1.35rem);
  font-weight: 700;
  line-height: 1.65;
}

.toc {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
  margin-bottom: 42px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
}

.toc a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.4;
  text-decoration: none;
}

.toc a:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.article-body {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.9;
}

.article-body section {
  scroll-margin-top: 24px;
}

.article-body h2 {
  margin: 54px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  line-height: 1.35;
}

.article-body h3 {
  margin: 28px 0 8px;
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: 1.06rem;
}

.article-body p {
  margin: 12px 0;
}

.article-body strong {
  color: var(--text-primary);
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}

.article-body ul,
.article-body ol {
  margin: 12px 0;
  padding-left: 1.35em;
}

.article-body li {
  margin: 7px 0;
  padding-left: 4px;
}

.section-kicker {
  display: block;
  margin-top: 52px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
}

.section-lead {
  max-width: 740px;
  color: var(--text-secondary);
  font-size: 1rem;
}

.reasoning-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
  counter-reset: macro-step;
}

.reasoning-flow li {
  position: relative;
  min-height: 154px;
  margin: 0;
  padding: 16px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  counter-increment: macro-step;
}

.reasoning-flow li::before {
  content: "0" counter(macro-step);
  display: block;
  margin-bottom: 18px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.reasoning-flow li:not(:last-child)::after {
  content: "→";
  position: absolute;
  z-index: 2;
  top: 64px;
  right: -17px;
  width: 24px;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
}

.reasoning-flow b {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: 1rem;
}

.reasoning-flow span {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.metric-block {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

.metric-block .num {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

.metric-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.metric-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.68;
}

.note {
  margin: 20px 0;
  padding: 15px 17px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-card));
  color: var(--text-secondary);
}

.note strong {
  display: block;
  margin-bottom: 3px;
}

.wide-section {
  margin-top: 56px;
}

.wide-section > .section-kicker,
.wide-section > h2,
.wide-section > .section-lead,
.wide-section > .scenario-cheatsheet {
  max-width: 820px;
  margin-right: auto;
  margin-left: auto;
}

.wide-section > h2 {
  margin-top: 5px;
}

.scenario-explorer {
  margin-top: 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
}

.scenario-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--border);
}

.scenario-tab {
  min-height: 74px;
  padding: 12px 10px;
  border: 0;
  border-radius: 0;
  background: var(--bg-card);
  color: var(--text-secondary);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.scenario-tab span,
.scenario-tab small {
  display: block;
}

.scenario-tab span {
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: .98rem;
  font-weight: 700;
}

.scenario-tab small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.scenario-tab[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
  box-shadow: inset 0 3px 0 var(--accent);
}

.scenario-tab[aria-selected="true"] span,
.scenario-tab[aria-selected="true"] small {
  color: var(--accent);
}

.scenario-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
  gap: 24px;
  padding: clamp(18px, 3vw, 28px);
}

.scenario-copy h3 {
  margin: 0 0 5px;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
}

.scenario-equation {
  margin: 0 0 20px;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
}

.scenario-logic {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.scenario-logic div {
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.scenario-logic dt {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
}

.scenario-logic dd {
  margin: 5px 0 0;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.62;
}

.scenario-confirmation {
  margin: 12px 0 0;
  padding: 13px 14px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-secondary));
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
}

.scenario-confirmation b {
  color: var(--text-primary);
}

.scenario-chart-wrap {
  align-self: start;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-secondary);
}

.scenario-chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis {
  stroke: color-mix(in srgb, var(--text-muted) 65%, transparent);
  stroke-width: 1;
}

.chart-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-event-line {
  stroke: color-mix(in srgb, var(--accent) 70%, transparent);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.chart-dot {
  fill: var(--bg-card);
  stroke: var(--accent);
  stroke-width: 4;
}

.chart-label {
  fill: var(--text-secondary);
  font-size: 19px;
  font-weight: 700;
}

.chart-label.muted {
  fill: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}

.chart-caption {
  margin: 8px 2px 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.scenario-cheatsheet {
  margin-top: 22px;
}

.scenario-cheatsheet h3 {
  margin-bottom: 12px;
}

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

.cheatsheet-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

.cheatsheet-card b,
.cheatsheet-card span {
  display: block;
}

.cheatsheet-card b {
  color: var(--text-primary);
  font-family: var(--serif);
}

.cheatsheet-card span {
  margin-top: 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.cheatsheet-card p {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.practice-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .82fr);
  gap: 20px;
  margin-top: 24px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-card);
}

.practice-form fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.practice-form legend {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
}

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

.choice-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-control {
  position: relative;
  cursor: pointer;
}

.choice-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.choice-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.choice-control input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  color: var(--accent);
}

.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 4px;
}

.practice-result {
  min-height: 100%;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 14px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%), var(--bg-secondary);
}

.practice-result .result-label {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
}

.practice-result h3 {
  margin: 8px 0 12px;
  font-size: 1.25rem;
}

.practice-result p {
  margin: 9px 0;
  font-size: 13.5px;
  line-height: 1.68;
}

.practice-result .result-next {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  color: var(--text-primary);
}

.table-wrap {
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
}

.macro-guide table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.65;
}

.macro-guide th,
.macro-guide td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.macro-guide th {
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 700;
  background: var(--bg-tertiary);
}

.macro-guide tr:last-child td {
  border-bottom: 0;
}

.transmission-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
  padding: 0;
  list-style: none;
}

.transmission-flow li {
  position: relative;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.transmission-flow li:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -17px;
  z-index: 2;
  width: 24px;
  color: var(--accent);
  transform: translateY(-50%);
}

.routine-list {
  margin: 22px 0 0 !important;
  padding: 0 !important;
  list-style: none;
  counter-reset: routine;
}

.routine-list li {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 13px;
  margin: 0;
  padding: 15px 0;
  border-bottom: 1px dashed var(--border);
  counter-increment: routine;
}

.routine-list li::before {
  content: counter(routine);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-weight: 700;
}

.routine-list b,
.routine-list span {
  display: block;
}

.routine-list b {
  color: var(--text-primary);
}

.routine-list span {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.65;
}

.checklist {
  padding: 0 !important;
  list-style: none;
}

.checklist li {
  position: relative;
  padding: 11px 12px 11px 38px;
  border-bottom: 1px dashed var(--border);
}

.checklist li::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 10px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 4px;
}

.details-panel {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
}

.details-panel summary {
  min-height: 48px;
  padding: 14px 16px;
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
}

.details-content {
  padding: 0 18px 18px;
}

.details-content h3:first-child {
  margin-top: 8px;
}

.sources {
  margin-top: 48px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
}

.sources h2 {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  font-size: 1.1rem;
}

.sources li {
  font-size: 13px;
  line-height: 1.65;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.article-footer a {
  color: var(--accent);
}

@media (max-width: 840px) {
  .reasoning-flow {
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    overflow-x: auto;
    padding: 0 2px 10px;
    scroll-snap-type: x proximity;
  }

  .reasoning-flow li {
    scroll-snap-align: start;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scenario-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scenario-stage,
  .practice-panel {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .macro-guide {
    padding-top: 24px;
  }

  .toc,
  .metric-grid,
  .cheatsheet-grid {
    grid-template-columns: 1fr;
  }

  .toc {
    gap: 2px;
  }

  .reasoning-flow {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .reasoning-flow li {
    min-height: 0;
    padding: 15px 16px 15px 62px;
  }

  .reasoning-flow li::before {
    position: absolute;
    top: 17px;
    left: 16px;
    margin: 0;
  }

  .reasoning-flow li:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: auto;
    bottom: -18px;
    left: 25px;
  }

  .scenario-tabs,
  .scenario-logic,
  .choice-row.three {
    grid-template-columns: 1fr;
  }

  .scenario-tab {
    min-height: 60px;
  }

  .scenario-tab[aria-selected="true"] {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .scenario-stage {
    gap: 16px;
  }

  .scenario-logic div {
    min-height: 0;
  }

  .transmission-flow {
    grid-template-columns: 1fr;
  }

  .transmission-flow li:not(:last-child)::after {
    content: "↓";
    top: auto;
    right: auto;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
  }

  .article-body {
    font-size: 14.5px;
  }

  .article-body h2 {
    margin-top: 42px;
  }

  .article-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
