:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --fg-dim: #666;
  --fg-link: #2a6f97;
  --fg-link-hover: #1a4f6f;
  --hover: #f0f0f0;
  --line: #e0e0e0;
  --accent: #2a6f97;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --indicator-space: 22px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --fg: #e0e0e0;
    --fg-dim: #999;
    --fg-link: #6ab0d6;
    --fg-link-hover: #8cc8e8;
    --hover: #252525;
    --line: #333;
    --accent: #6ab0d6;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  margin: 0 auto;
  max-width: 720px;
  padding: 32px 24px 80px;
}

.site-header {
  margin-bottom: 32px;
}

.site-nav {
  font-size: 14px;
  margin-bottom: 16px;
}

.site-nav a {
  color: var(--fg-dim);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--fg-link-hover);
  text-decoration: underline;
}

.header-top {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.header-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 16px;
}

.view-switch {
  border: 1px solid var(--line);
  border-radius: 4px;
  display: none;
  overflow: hidden;
}

.js .view-switch {
  display: flex;
}

.view-switch button {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
  padding: 7px 10px;
}

.view-switch button + button {
  border-left: 1px solid var(--line);
}

.view-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: white;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
}

.meta {
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.meta a,
main a {
  color: var(--fg-link);
  text-decoration: none;
}

.meta a:hover,
main a:hover {
  color: var(--fg-link-hover);
  text-decoration: underline;
}

.toggle-container {
  align-items: center;
  display: none;
  flex-shrink: 0;
  gap: 8px;
  margin-top: 4px;
}

.js .toggle-container {
  display: flex;
}

.toggle-label {
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  white-space: nowrap;
}

.toggle-switch {
  flex-shrink: 0;
  height: 20px;
  position: relative;
  width: 36px;
}

.toggle-switch input {
  height: 0;
  opacity: 0;
  width: 0;
}

.toggle-slider {
  background: var(--line);
  border-radius: 20px;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: background 0.2s;
}

.toggle-slider::before {
  background: white;
  border-radius: 50%;
  bottom: 3px;
  content: "";
  height: 14px;
  left: 3px;
  position: absolute;
  transition: transform 0.2s;
  width: 14px;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.controls {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.js .controls {
  display: flex;
}

.controls button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--fg-dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
  padding: 6px 10px;
  transition: all 0.15s;
}

.controls button:hover {
  background: var(--hover);
  border-color: var(--fg-dim);
  color: var(--fg);
}

.links-hidden a {
  color: inherit;
  cursor: default;
  pointer-events: none;
  text-decoration: none;
}

.intro {
  margin-bottom: 32px;
}

.intro p {
  margin-bottom: 12px;
}

.view-panel[hidden] {
  display: none;
}

.normal-view > p:first-child,
.outline-view > p:first-child {
  margin-bottom: 32px;
}

.normal-view h2,
.note-group h2 {
  margin: 32px 0 12px;
}

.normal-view h3 {
  margin: 24px 0 10px;
}

.normal-view h4 {
  margin: 20px 0 8px;
}

.normal-view p {
  margin-bottom: 14px;
}

.normal-view ul,
.normal-view ol {
  margin: 0 0 18px 24px;
}

.normal-view li {
  margin-bottom: 8px;
}

.note-group {
  margin-bottom: 28px;
}

.home-note {
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 14px;
  margin-top: 32px;
  padding-top: 16px;
}

.home-note p:last-child {
  margin-bottom: 0;
}

.section {
  border-left: 2px solid var(--line);
  margin-bottom: 8px;
  padding-left: 16px;
}

.section-heading {
  align-items: baseline;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 6px 0;
  transition: color 0.15s;
  user-select: none;
}

.section-heading:hover {
  color: var(--accent);
}

.section-heading .indicator {
  color: var(--fg-dim);
  display: inline-block;
  flex-shrink: 0;
  font-size: 12px;
  transition: transform 0.2s;
  width: 14px;
}

.section-heading.collapsed .indicator {
  transform: rotate(0deg);
}

.section-heading.expanded .indicator {
  transform: rotate(90deg);
}

h2 {
  font-size: 22px;
  font-weight: 600;
}

h3 {
  font-size: 18px;
  font-weight: 500;
}

h4 {
  color: var(--fg-dim);
  font-size: 16px;
  font-weight: 500;
}

.section-content {
  overflow: hidden;
  padding-left: var(--indicator-space);
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.section-content p {
  margin-bottom: 14px;
}

.section .section {
  border-left-color: var(--line);
  margin-top: 4px;
}

.note-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: inherit;
  display: block;
  margin-bottom: 12px;
  padding: 16px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.note-card:hover {
  background: var(--hover);
  border-color: var(--accent);
  text-decoration: none;
}

.note-card .note-title {
  color: var(--fg);
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 4px;
}

.note-card .note-meta {
  color: var(--fg-dim);
  font-size: 13px;
}

.note-card .note-desc {
  color: var(--fg-dim);
  font-size: 15px;
  margin-top: 6px;
}

.ref-list {
  list-style: none;
  padding: 0;
}

.ref-list li {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 16px;
  padding-left: 0;
}

.ref-list li strong {
  font-weight: 500;
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
    padding: 20px 16px 60px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 20px;
  }

  h3 {
    font-size: 17px;
  }

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

  .header-actions {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}
