:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #181a1f;
  --muted: #666f7a;
  --line: #d9ddd7;
  --accent: #1e6f5c;
  --accent-strong: #164d41;
  --code-bg: #eef1ed;
  --shadow: 0 10px 30px rgba(24, 26, 31, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 244, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 80px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 32px;
  align-items: end;
  min-height: 260px;
  padding: 42px 0 34px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.note-folder {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}

.hero h1,
.note > h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 19px;
}

.stats {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stats span {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}

.stats small {
  color: var(--muted);
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  padding: 28px 0;
}

.search-box {
  position: relative;
}

input[type="search"] {
  width: 100%;
  min-height: 52px;
  padding: 0 96px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 111, 92, 0.16);
}

.search-shortcuts {
  position: absolute;
  top: 50%;
  right: 12px;
  display: flex;
  gap: 6px;
  transform: translateY(-50%);
  pointer-events: none;
}

kbd {
  min-width: 28px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font: 600 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  box-shadow: inset 0 -1px 0 rgba(24, 26, 31, 0.08);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-links a {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  font-size: 14px;
  text-decoration: none;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.note-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(24, 26, 31, 0.03);
}

.note-card[hidden] {
  display: none;
}

.note-card:hover {
  border-color: rgba(30, 111, 92, 0.45);
  box-shadow: var(--shadow);
}

.note-card strong {
  align-self: end;
  font-size: 17px;
  line-height: 1.25;
}

.note {
  width: min(860px, 100%);
  margin: 0 auto;
  padding-top: 20px;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.back-link {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.back-link:hover {
  border-color: rgba(30, 111, 92, 0.45);
}

.index-link {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.note > h1 {
  margin-bottom: 32px;
  font-size: clamp(34px, 5vw, 60px);
}

.note > h1 + .note-body {
  margin-top: 32px;
}

.note-properties {
  display: grid;
  gap: 0;
  margin: 0 0 28px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.property-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-height: 36px;
  padding: 6px 0;
}

.property-key {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.property-value {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.property-chip,
.property-text,
.property-empty {
  font-size: 14px;
  line-height: 1.8;
}

.property-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-strong);
  text-decoration: none;
}

.property-tag {
  background: rgba(30, 111, 92, 0.08);
  border-color: rgba(30, 111, 92, 0.18);
}

a.property-tag:hover {
  border-color: rgba(30, 111, 92, 0.42);
  background: rgba(30, 111, 92, 0.12);
}

.property-empty {
  color: var(--muted);
}

.note-properties + .note-body {
  padding-top: 0;
  border-top: 0;
}

.note-body {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 18px;
}

.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4 {
  margin-top: 36px;
  line-height: 1.2;
}

.note-body p,
.note-body ul,
.note-body ol {
  margin: 18px 0;
}

.note-body li + li {
  margin-top: 6px;
}

.note-embed {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  text-decoration: none;
}

.note-body hr {
  margin: 28px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

blockquote {
  margin: 22px 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.callout {
  --callout-rgb: 30, 111, 92;
  margin: 22px 0;
  padding: 14px 16px 12px;
  border: 1px solid rgba(var(--callout-rgb), 0.22);
  border-left: 4px solid rgb(var(--callout-rgb));
  border-radius: 8px;
  background: rgba(var(--callout-rgb), 0.08);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgb(var(--callout-rgb));
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

summary.callout-title {
  cursor: pointer;
}

.callout-icon {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.72);
}

.callout-content {
  margin-top: 10px;
}

.callout-content > :first-child {
  margin-top: 0;
}

.callout-content > :last-child {
  margin-bottom: 0;
}

.callout-abstract,
.callout-summary,
.callout-tldr {
  --callout-rgb: 84, 105, 130;
}

.callout-info,
.callout-todo {
  --callout-rgb: 37, 99, 235;
}

.callout-tip,
.callout-success {
  --callout-rgb: 22, 122, 83;
}

.callout-question,
.callout-example {
  --callout-rgb: 116, 75, 162;
}

.callout-warning {
  --callout-rgb: 180, 83, 9;
}

.callout-failure,
.callout-danger,
.callout-bug {
  --callout-rgb: 190, 51, 51;
}

.callout-quote {
  --callout-rgb: 92, 99, 112;
}

code,
pre {
  background: var(--code-bg);
  border-radius: 6px;
}

code {
  padding: 2px 5px;
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  padding: 16px;
  border: 1px solid var(--line);
}

pre code {
  padding: 0;
  background: transparent;
}

mjx-container[display="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
}

.missing-link {
  color: var(--muted);
  border-bottom: 1px dashed var(--line);
}

@media (max-width: 720px) {
  .topbar {
    padding: 14px 20px;
  }

  main {
    width: min(100% - 28px, 1120px);
    padding-top: 20px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .stats {
    width: 128px;
  }

  input[type="search"] {
    padding-right: 76px;
  }

  kbd {
    min-width: 24px;
    padding-inline: 5px;
    font-size: 11px;
  }

  .property-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
