:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e1ef;
  --text: #162033;
  --muted: #596781;
  --accent: #3459e6;
  --accent-soft: #edf2ff;
  --shadow: 0 16px 36px rgba(18, 31, 61, 0.08);
  --radius: 18px;
  --maxw: 1400px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.shell {
  width: min(var(--maxw), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}

.brand { max-width: 760px; }

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
  margin-bottom: 12px;
}

h2 {
  font-size: clamp(1.3rem, 1.6vw, 1.55rem);
  line-height: 1.16;
  margin-bottom: 8px;
}

.hero-text,
.section-head p,
.footer,
.results-head p,
.card-meta,
.metric,
.mini-note,
.key-point p,
.overview-card p,
.flow-card p,
.work-card p,
.timeline-panel p {
  color: var(--muted);
  line-height: 1.65;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.header-actions .button {
  min-height: 34px;
  padding: 0 11px;
  white-space: nowrap;
  font-size: 0.86rem;
  box-shadow: 0 8px 18px rgba(18, 31, 61, 0.07);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.button.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.button.ghost {
  box-shadow: none;
  background: transparent;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0;
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(8px);
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: grid; gap: 22px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}

.intro-panel {
  display: flex;
  flex-direction: column;
}

.figure-stack { display: grid; gap: 18px; }

.figure-stack img {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.figure-stack .repo-map-figure {
  width: min(900px, 100%);
  justify-self: center;
}

.key-points,
.overview-grid,
.flow-grid,
.card-grid,
.stats-grid,
.results {
  display: grid;
  gap: 16px;
}

.key-points {
  margin-top: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.key-point,
.overview-card,
.flow-card,
.axis-card,
.monthly-card,
.work-card,
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

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

.stat-card .value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.overview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.flow-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-head { margin-bottom: 18px; }

.axis-card h3,
.monthly-card h3,
.work-card h3,
.overview-card h3,
.flow-card h3,
.key-point h3 {
  margin-bottom: 8px;
}

.metric {
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.mini-note { font-size: 0.95rem; }

.monthly-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.timeline-panel {
  position: sticky;
  top: 72px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 74px 1fr 40px;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}

.timeline-row.is-active { font-weight: 700; }

.bar-wrap {
  height: 14px;
  border-radius: 999px;
  background: #edf1f7;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3459e6, #6d87ff);
}

.controls {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.controls input,
.controls select {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.92rem;
  margin-bottom: 10px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 0.85rem;
}

.footer {
  padding-top: 24px;
  font-size: 0.95rem;
}

.tab-panel,
.panel,
.markdown-body {
  min-width: 0;
}

.markdown-body {
  max-width: 100%;
}

.markdown-body > :not(.table-scroll) {
  max-width: 860px;
}

.markdown-body.reader-empty {
  color: var(--muted);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.4em 0 0.6em;
  line-height: 1.2;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body li,
.markdown-body blockquote {
  line-height: 1.7;
}

.markdown-body pre,
.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Consolas, monospace;
}

.markdown-body code {
  padding: 0.12rem 0.38rem;
  border-radius: 6px;
  background: #f1f4fa;
  font-size: 0.92em;
}

.markdown-body pre {
  padding: 14px 16px;
  border-radius: 12px;
  overflow-x: auto;
  background: #0f172a;
  color: #e8edf8;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 4px solid #cbd7f2;
  color: var(--muted);
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.4em;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.96rem;
}

.table-scroll {
  width: 100%;
  margin: 1.1em 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  scrollbar-color: #aab8d3 #edf1f7;
  scrollbar-width: thin;
}

.table-scroll:focus-visible {
  outline: 3px solid rgba(52, 89, 230, 0.28);
  outline-offset: 3px;
}

.table-scroll.is-wide table {
  width: max-content;
  min-width: 100%;
  font-size: 0.86rem;
}

.table-scroll.is-wide th,
.table-scroll.is-wide td {
  padding: 8px 9px;
  text-align: center;
  white-space: nowrap;
}

.table-scroll.is-wide th:first-child,
.table-scroll.is-wide td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 180px;
  max-width: 240px;
  white-space: normal;
  text-align: left;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.table-scroll.is-wide th:first-child {
  z-index: 2;
  background: #f6f8fc;
}

.markdown-body th,
.markdown-body td {
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
}

.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body th:last-child,
.markdown-body td:last-child { border-right: 0; }

.markdown-body th {
  background: #f6f8fc;
  text-align: left;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.5em 0;
}

@media (max-width: 1080px) {
  .hero-grid,
  .monthly-layout,
  .overview-grid,
  .flow-grid,
  .card-grid,
  .stats-grid,
  .controls,
  .key-points {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .timeline-panel {
    position: static;
  }

}
