:root {
  --background: #f9f8f3;
  --surface: #ffffff;
  --surface-soft: #f2f7ed;
  --text: #131210;
  --muted: #565052;
  --border: rgba(19, 18, 16, 0.12);
  --border-strong: rgba(19, 18, 16, 0.22);
  --accent-green: #109e60;
  --accent-light-green: #d7fdce;
  --accent-yellow: #ffc300;
  --accent-magenta: #cc1757;
  --chart-blue: #2f7fb7;
  --chart-green: #2e7d32;
  --chart-orange: #f08a24;
  --chart-red: #c62828;
  --shadow: 0 18px 60px rgba(19, 18, 16, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.08rem 0.28rem;
  font-size: 0.9em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #11130f;
  color: #f4f4ed;
  padding: 18px;
  font-size: 14px;
}

pre code {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  background: rgba(249, 248, 243, 0.92);
  padding: 0 28px;
  backdrop-filter: blur(18px);
}

.brand,
.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 750;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--accent-light-green);
  color: #0d4c32;
  font-size: 13px;
}

.topnav a {
  border-radius: 8px;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 650;
}

.topnav a:hover,
.topnav a:focus-visible {
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.topnav .lang-link {
  border: 1px solid rgba(16, 158, 96, 0.26);
  background: rgba(215, 253, 206, 0.72);
  color: #0b5d38;
}

.shell {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 820px) minmax(180px, 240px);
  gap: 34px;
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 34px 28px 96px;
}

.left-nav,
.right-rail {
  position: sticky;
  top: 90px;
  align-self: start;
}

.left-nav,
.rail-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.left-nav a,
.right-rail a {
  border-radius: 8px;
  color: var(--muted);
  padding: 7px 9px;
  font-size: 14px;
}

.left-nav a:hover,
.right-rail a:hover,
.left-nav a:focus-visible,
.right-rail a:focus-visible {
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.right-rail {
  display: grid;
  gap: 18px;
}

.rail-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  padding: 14px;
}

.rail-box p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.content {
  min-width: 0;
}

.hero {
  padding: 34px 0 74px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(16, 158, 96, 0.22);
  border-radius: 8px;
  background: var(--accent-light-green);
  color: #0b5d38;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 790px;
  margin-top: 22px;
  font-size: clamp(36px, 6vw, 64px);
}

h2 {
  font-size: clamp(28px, 4vw, 40px);
}

h3 {
  font-size: 20px;
}

.lead {
  max-width: 780px;
  margin: 24px 0 0;
  color: #302d29;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.notice {
  margin-top: 28px;
  border-left: 4px solid var(--accent-magenta);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  color: #31292c;
  overflow-wrap: anywhere;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-strip > div,
.summary-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.metric-value,
.summary-cell strong {
  display: block;
  color: var(--text);
  font-size: 30px;
  font-weight: 780;
  line-height: 1.15;
}

.metric-label,
.summary-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.section {
  border-top: 1px solid var(--border);
  padding: 82px 0;
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 28px;
}

.section-head > * {
  min-width: 0;
}

.section-head h2 {
  margin-top: 14px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.article-prose {
  display: grid;
  gap: 18px;
  color: #302d29;
  font-size: 17px;
}

.article-prose p {
  margin: 0;
}

.article-prose h3 {
  margin-top: 18px;
  font-size: 22px;
}

.article-prose a {
  border-bottom: 1px solid rgba(16, 158, 96, 0.45);
  color: #0b5d38;
  font-weight: 680;
}

.essay-lead {
  border-left: 4px solid var(--accent-green);
  background: rgba(255, 255, 255, 0.58);
  padding: 16px 18px;
  font-size: 19px;
}

.article-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  color: var(--muted);
  font-size: 15px;
}

.explorer {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1.1fr;
  gap: 14px;
  align-items: end;
  padding-bottom: 18px;
}

fieldset {
  min-width: 0;
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

select,
button,
input {
  font: inherit;
}

select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--background);
  padding: 3px;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 720;
}

.segmented button.is-active {
  background: var(--text);
  color: var(--surface);
}

.slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: center;
  min-height: 40px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-green);
}

output {
  color: var(--text);
  font-weight: 760;
  text-align: right;
}

.chart-panel {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.chart-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.chart-title-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.swatch.pass {
  background: var(--chart-green);
}

.swatch.fail {
  background: var(--chart-red);
}

.chart-wrap {
  width: 100%;
  min-height: 330px;
}

#rate-chart {
  display: block;
  width: 100%;
  min-height: 330px;
}

.bar-label,
.axis-label,
.value-label {
  fill: var(--text);
  font-size: 12px;
}

.selected-row .bar-label {
  font-weight: 800;
}

.pass-value,
.fail-value {
  fill: #ffffff;
  font-size: 11px;
  font-weight: 760;
  pointer-events: none;
}

.selected-outline {
  stroke: rgba(19, 18, 16, 0.72);
  stroke-width: 2;
  pointer-events: none;
}

.bar-hitbox {
  cursor: pointer;
}

.axis-label {
  fill: var(--muted);
}

.grid-line {
  stroke: rgba(19, 18, 16, 0.12);
  shape-rendering: crispEdges;
}

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

.summary-cell strong {
  font-size: 23px;
}

.tooltip {
  position: absolute;
  z-index: 5;
  max-width: 240px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}

.figure {
  margin: 28px 0;
}

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

.explain-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.explain-item strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 16px;
}

.explain-item p {
  margin: 8px 0 0;
  color: #302d29;
  font-size: 14px;
  line-height: 1.55;
}

.explain-item pre {
  margin: 10px 0 0;
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
}

.body-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.story-note {
  border-left: 4px solid var(--accent-green);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  padding: 14px 16px;
  color: #302d29;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: var(--surface-soft);
  color: #302d29;
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.data-table td:first-child {
  font-weight: 740;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.figure figcaption {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.check-list,
.limit-list,
.lesson-list {
  margin: 22px 0 0;
  padding: 0;
}

.check-list {
  list-style: none;
}

.check-list li,
.limit-list p,
.lesson-list p {
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 12px 0;
  color: #302d29;
}

.lesson-list strong {
  color: var(--text);
}

.check-list li::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--accent-green);
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 900px);
  }

  .left-nav,
  .right-rail {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  .topbar {
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 10px 12px;
  }

  .brand {
    flex: 0 0 auto;
    min-width: 0;
  }

  .brand span:not(.brand-mark) {
    font-size: 14px;
  }

  .topnav {
    flex: 1 1 0;
    flex-wrap: wrap;
    gap: 2px;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  }

  .topnav a {
    padding: 4px 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .shell {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: clip;
    padding: 24px 16px 72px;
  }

  .content,
  .hero,
  .section,
  .lead,
  .notice,
  .metric-strip,
  .explorer,
  .chart-panel,
  .chart-wrap,
  .summary-grid,
  .controls,
  .explain-grid,
  .explain-item,
  .figure,
  .article-prose,
  .essay-lead,
  .data-table {
    min-width: 0;
    max-width: 100%;
  }

  .hero {
    padding-top: 18px;
  }

  .lead {
    font-size: 17px;
  }

  h1 {
    font-size: clamp(28px, 8.2vw, 34px);
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .lead,
  .notice,
  .article-prose p,
  .section-head p {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .segmented button {
    padding: 4px;
    font-size: 13px;
    line-height: 1.2;
    white-space: normal;
  }

  .metric-strip,
  .section-head,
  .controls,
  .summary-grid,
  .explain-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .section {
    padding: 62px 0;
  }

  .explorer {
    overflow: hidden;
    padding: 16px;
  }

  .chart-title-row {
    display: block;
  }

  .legend {
    justify-content: flex-start;
    margin-top: 10px;
  }
}

@media (max-width: 520px) {
  .brand span:not(.brand-mark) {
    display: none;
  }
}
