/* Layout (sidebar, TOC, pager). Colours come from theme.css tokens. */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 230px;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.1rem 1rem 2rem;
  font-family: var(--font-sans);
  font-size: .9rem;
}
.brand { display: block; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-bottom: .9rem; }
.brand span { color: var(--accent); font-weight: 500; }

#search {
  width: 100%;
  padding: .5rem .7rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  margin-bottom: .8rem;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.search-results { list-style: none; margin: 0 0 1rem; padding: 0; }
.search-results li { margin-bottom: .5rem; }
.search-results a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--text); text-decoration: none; background: var(--surface); }
.search-results a:hover { background: var(--surface-2); }
.search-results small { display: block; color: var(--text-faint); line-height: 1.4; margin-top: .15rem; }
.search-results .empty { color: var(--text-faint); padding: .3rem .6rem; }

.nav-chapter { margin-bottom: .4rem; }
.nav-chapter > summary { cursor: pointer; padding: .4rem .3rem; color: var(--text-muted); font-weight: 600; }
.nav-chapter ul { list-style: none; margin: 0 0 .4rem; padding: 0 0 0 .6rem; border-left: 1px solid var(--border); }
.nav-chapter li a {
  display: block;
  padding: .3rem .6rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
}
.nav-chapter li a:hover { background: var(--surface); color: var(--text); }
.nav-chapter li a.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* ---------- content ---------- */
.content { padding: 2.5rem 3rem 5rem; min-width: 0; }
.note-header { max-width: var(--measure); margin-bottom: 2rem; }
.note-header h1 { font-family: var(--font-sans); font-size: 2.2rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }
.crumb { font-family: var(--font-sans); font-size: .85rem; color: var(--text-faint); margin: 0 0 .4rem; }
.note-date { display: block; font-family: var(--font-sans); font-size: .85rem; color: var(--text-faint); margin-bottom: .7rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

.pager { display: flex; justify-content: space-between; gap: 1rem; max-width: var(--measure); margin-top: 3rem; font-family: var(--font-sans); }
.pager a {
  display: block;
  flex: 1;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--text-faint); font-size: .75rem; }
.pager .next { text-align: right; }

/* ---------- TOC ---------- */
.toc {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: 2.5rem 1.2rem 2rem 0;
  font-family: var(--font-sans);
  font-size: .82rem;
}
.toc h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 0 0 .6rem; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: .2rem .8rem; color: var(--text-muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--accent-text); }
.toc .l3 a { padding-left: 1.6rem; color: var(--text-faint); }

/* ---------- index cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; max-width: 1000px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; font-family: var(--font-sans); }
.card h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.card ul { margin: 0; padding-left: 1.1rem; }

/* ---------- responsive ---------- */
@media (max-width: 1150px) {
  .layout { grid-template-columns: 270px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .content { padding: 1.5rem 1.1rem 4rem; }
}
