:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f7f4;
  color: #161616;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 32px;
}

main {
  width: min(100%, 1440px);
  margin: 0 auto;
}

.page-header {
  max-width: 900px;
  margin: 0 auto 28px;
  text-align: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: #2b668d;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus {
  text-decoration: underline;
}

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

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.page-header p {
  max-width: 720px;
  margin: 16px auto 0;
  color: #4f555b;
  font-size: 1.08rem;
  line-height: 1.65;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.25;
}

h3 {
  font-size: 0.92rem;
  line-height: 1.25;
}

p {
  color: #4f555b;
  font-size: 1rem;
  line-height: 1.65;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.diagram-section,
.rule-card,
.kinematics {
  border: 1px solid #d9ddd7;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgb(30 37 47 / 8%);
}

.diagram-section {
  padding: 22px;
}

.diagram-section h2 {
  margin-bottom: 16px;
}

.diagram-layout {
  display: grid;
  grid-template-columns: minmax(640px, 1.45fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.diagram-figure,
.dot-panel {
  min-width: 0;
  margin: 0;
  border: 1px solid #e0e4df;
  border-radius: 8px;
  background: #ffffff;
}

.diagram-figure {
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: hidden;
  padding: 8px;
}

.diagram-figure img {
  display: block;
  width: min(100%, 940px);
  height: auto;
}

.dot-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.dot-panel h3 {
  margin-bottom: 12px;
  color: #4f555b;
  text-transform: uppercase;
}

.dot-panel pre {
  flex: 1;
}

.dot-code {
  background: #10151d;
  color: #d8e1ea;
}

.dot-code .dot-keyword {
  color: #86d9ff;
  font-weight: 800;
}

.dot-code .dot-attr {
  color: #ffd166;
}

.dot-code .dot-string {
  color: #9ee493;
}

.dot-code .dot-value {
  color: #f7a8b8;
}

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

.rule-card {
  padding: 20px;
}

.rule-card h2 {
  margin-bottom: 12px;
}

.rule-card p + p {
  margin-top: 12px;
}

.nowrap {
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}

th,
td {
  border-bottom: 1px solid #e5e8e3;
  padding: 10px 0;
  text-align: left;
}

th {
  color: #5d6570;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.ratio-line {
  color: #161616;
  font-weight: 800;
}

.kinematics {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 2fr);
  gap: 20px;
  margin-top: 18px;
  padding: 22px;
}

.kinematics h2 {
  margin-bottom: 10px;
}

pre {
  overflow-x: auto;
  margin: 0;
  border: 1px solid #d9ddd7;
  border-radius: 8px;
  background: #f7f8f7;
  padding: 16px;
  color: #151515;
  font-size: 0.86rem;
  line-height: 1.55;
}

@media (max-width: 900px) {
  body {
    padding: 22px;
  }

  .diagram img {
    min-width: 720px;
  }

  .rules-grid,
  .diagram-layout,
  .kinematics {
    grid-template-columns: 1fr;
  }

  .diagram-figure img {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  body {
    padding: 18px;
  }

  .diagram-section,
  .rule-card,
  .kinematics {
    padding: 16px;
  }
}
