/* Guide pages. Tokens match src/index.css so the guide and dashboards feel like one site. */
:root {
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-cond: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  --page: #e8ecf0;
  --panel: #fbfcfd;
  --panel2: #f1f3f6;
  --ink: #161b24;
  --ink2: #4c5768;
  --muted: #7b8594;
  --hair: #dde2e8;
  --accent: #2446cc;
  --accent-wash: rgba(36, 70, 204, 0.09);
  --warn: #fab219;
  --mark: rgba(250, 178, 25, 0.35);
  --shadow: 0 1px 0 rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lift: 0 12px 40px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  color-scheme: light;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root[data-theme='dark'] {
  --page: #0e1117;
  --panel: #161a22;
  --panel2: #1d222c;
  --ink: #e8ebf0;
  --ink2: #b2bac7;
  --muted: #7e8796;
  --hair: #252b36;
  --accent: #7891ff;
  --accent-wash: rgba(120, 145, 255, 0.12);
  --mark: rgba(250, 178, 25, 0.28);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lift: 0 16px 48px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a {
  color: var(--accent);
  text-underline-offset: 2px;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 100;
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 6px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hair);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: 21px;
  font-style: italic;
  text-decoration: none;
  white-space: nowrap;
}
.brand span {
  color: var(--ink);
}
.topnav {
  display: flex;
  gap: 4px;
}
.topnav a {
  padding: 5px 10px;
  border-radius: 7px;
  color: var(--ink2);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.topnav a:hover {
  background: var(--panel2);
  color: var(--ink);
}
.topnav a.active {
  color: var(--accent);
  background: var(--accent-wash);
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--panel2);
  color: var(--ink);
}
[data-theme='dark'] .i-moon,
[data-theme='light'] .i-sun {
  display: none;
}

/* ---------- search ---------- */
.search {
  position: relative;
  margin-left: auto;
  width: min(340px, 100%);
}
.search input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 34px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--panel2);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.search input::-webkit-search-cancel-button {
  display: none;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font: 600 11px var(--font);
  color: var(--muted);
  border: 1px solid var(--hair);
  border-radius: 4px;
  padding: 0 5px;
  pointer-events: none;
}
.search input:focus ~ kbd {
  display: none;
}
.search-big {
  margin: 0;
  width: 100%;
}
.search-big input {
  height: 52px;
  padding-left: 46px;
  font-size: 17px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.search-big .search-icon {
  left: 15px;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: max(100%, 440px);
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 560px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 6px;
  z-index: 60;
}
.search-big .search-results {
  left: 0;
  right: auto;
  width: 100%;
}
.search-results a {
  display: block;
  padding: 9px 11px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.4;
}
.search-results a[aria-selected='true'] {
  background: var(--accent-wash);
}
.search-results .r-title {
  font-weight: 600;
  font-size: 15px;
}
.search-results .r-where {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}
.search-results .r-snip {
  font-size: 13px;
  color: var(--ink2);
  margin-top: 3px;
}
.search-results mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
}
.search-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- home ---------- */
.home {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 56px 24px 64px;
  flex: 1;
}
.hero {
  max-width: 680px;
  margin: 0 auto 48px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: clamp(36px, 6vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}
.hero .lead {
  margin: 0 auto 28px;
}
.hero .search {
  text-align: left;
}
.popular {
  margin: 16px 0 0;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
}
.popular span {
  color: var(--muted);
}
.popular a {
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--hair);
  text-decoration: none;
  color: var(--ink2);
}
.popular a:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card h2 {
  font-family: var(--font-cond);
  font-size: 23px;
  font-weight: 700;
  margin: 0 0 4px;
}
.card h2 a {
  color: var(--ink);
  text-decoration: none;
}
.card h2 a:hover {
  color: var(--accent);
}
.card p {
  margin: 0 0 12px;
  color: var(--ink2);
  font-size: 15px;
}
.card ul {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
}
.card li {
  padding: 3px 0;
}
.card li a {
  text-decoration: none;
}
.card li a:hover {
  text-decoration: underline;
}

/* ---------- article layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 760px);
  gap: 48px;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.layout.has-toc {
  grid-template-columns: 260px minmax(0, 720px) 200px;
}
.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  font-size: 14.5px;
  padding-right: 4px;
}
.sidebar-toggle {
  display: none;
}
.sidebar details {
  margin-bottom: 2px;
}
.sidebar summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 7px;
  font-weight: 600;
}
.sidebar summary::-webkit-details-marker {
  display: none;
}
.sidebar summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
}
.sidebar details[open] > summary::before {
  transform: rotate(45deg);
}
.sidebar summary:hover {
  background: var(--panel2);
}
.sidebar summary a {
  color: var(--ink);
  text-decoration: none;
}
.sidebar ul {
  list-style: none;
  margin: 2px 0 8px;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--hair);
  margin-left: 11px;
}
.sidebar li a {
  display: block;
  padding: 3px 10px;
  color: var(--ink2);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.35;
}
.sidebar li a:hover {
  color: var(--ink);
  background: var(--panel2);
}
.sidebar a[aria-current='page'] {
  color: var(--accent);
  font-weight: 600;
}
.sidebar li a[aria-current='page'] {
  background: var(--accent-wash);
}

.crumbs {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 8px;
}
.crumbs a {
  color: var(--muted);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--accent);
}
.article h1 {
  font-family: var(--font-cond);
  font-weight: 800;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  margin: 0 0 20px;
}
.lead {
  font-size: 19px;
  color: var(--ink2);
  margin: 0 0 28px;
}
.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.article-list a {
  display: block;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink2);
}
.article-list a:hover {
  border-color: var(--accent);
}
.article-list strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  margin-bottom: 2px;
}

/* ---------- prose ---------- */
.prose {
  font-size: 17px;
  line-height: 1.7;
}
.prose > :first-child {
  margin-top: 0;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1em;
}
.prose li {
  margin-bottom: 0.35em;
}
.prose li > ul,
.prose li > ol {
  margin: 0.35em 0 0;
}
.prose h2 {
  font-family: var(--font-cond);
  font-size: 29px;
  font-weight: 700;
  line-height: 1.2;
  margin: 1.8em 0 0.5em;
  scroll-margin-top: 80px;
}
.prose h3 {
  font-size: 19px;
  font-weight: 700;
  margin: 1.5em 0 0.4em;
  scroll-margin-top: 80px;
}
.prose h4 {
  font-size: 17px;
  margin: 1.3em 0 0.3em;
}
.prose .anchor {
  float: left;
  margin-left: -0.9em;
  width: 0.9em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
}
.prose :is(h2, h3, h4):hover .anchor,
.prose .anchor:focus {
  opacity: 1;
}
.prose strong {
  font-weight: 650;
}
.prose code {
  font-size: 0.9em;
  background: var(--panel2);
  border-radius: 4px;
  padding: 1px 5px;
}
.prose blockquote {
  margin: 1.4em 0;
  padding: 14px 18px;
  background: var(--accent-wash);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.prose blockquote > :last-child {
  margin-bottom: 0;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--hair);
  margin: 2em 0;
}
.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.4em;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--panel);
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  line-height: 1.45;
}
.prose th,
.prose td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}
.prose th {
  background: var(--panel2);
  font-weight: 600;
}
.prose tr:last-child td {
  border-bottom: 0;
}
.prose dl dt {
  font-weight: 700;
}
.prose dl dd {
  margin: 0 0 1em;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--hair);
}
.pager a {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  font-weight: 600;
  color: var(--ink);
}
.pager a:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.pager span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.pager .next {
  text-align: right;
}

.toc {
  position: sticky;
  top: 76px;
  align-self: start;
  font-size: 14px;
}
.toc p {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--hair);
}
.toc a {
  display: block;
  padding: 3px 0 3px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink2);
  text-decoration: none;
  line-height: 1.35;
}
.toc a:hover {
  color: var(--ink);
}
.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.footer {
  border-top: 1px solid var(--hair);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.footer p {
  max-width: 720px;
  margin: 0 auto 6px;
}

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .layout.has-toc {
    grid-template-columns: 240px minmax(0, 760px);
  }
  .toc {
    display: none;
  }
}
@media (max-width: 860px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 16px;
  }
  .topbar .search {
    order: 5;
    width: 100%;
    margin: 0;
  }
  .topbar .search kbd {
    display: none;
  }
  .theme-toggle {
    margin-left: auto;
  }
  .layout,
  .layout.has-toc {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px 16px 48px;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
  .sidebar-wide {
    display: none;
  }
  .sidebar-toggle {
    display: block;
    background: var(--panel);
    border: 1px solid var(--hair);
    border-radius: var(--radius);
    padding: 4px;
  }
  .sidebar-toggle > summary {
    padding: 8px 10px;
  }
  .sidebar-toggle .sidebar-inner {
    padding: 4px 4px 8px;
  }
  .home {
    padding-top: 32px;
  }
  .prose {
    font-size: 16.5px;
  }
  .pager {
    grid-template-columns: 1fr;
  }
}

/* ---------- favourites ---------- */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.title-row h1 {
  margin: 0;
}
.fav-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink2);
  font: 600 14px var(--font);
  cursor: pointer;
}
.fav-btn svg {
  fill-opacity: 0;
  transition: fill-opacity 0.15s;
}
.fav-btn:hover {
  border-color: var(--warn);
  color: var(--ink);
}
.fav-btn[aria-pressed='true'] {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  color: var(--ink);
}
.fav-btn[aria-pressed='true'] svg {
  color: var(--warn);
  fill-opacity: 1;
}

.favs {
  margin: 0 0 32px;
}
.favs h2 {
  font-family: var(--font-cond);
  font-size: 23px;
  font-weight: 700;
  margin: 0 0 12px;
}
.favs ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.favs li {
  position: relative;
}
.favs li a {
  display: block;
  height: 100%;
  padding: 12px 40px 12px 16px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}
.favs li a:hover {
  border-color: var(--accent);
}
.favs li strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  margin-bottom: 1px;
}
.fav-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.fav-remove:hover {
  background: var(--panel2);
  color: var(--ink);
}

.sidebar-favs {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hair);
}
.sidebar-favs p {
  margin: 0 0 4px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-favs ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-favs li a {
  padding-left: 8px;
}
.sidebar-favs li a::before {
  content: '★';
  color: var(--warn);
  margin-right: 6px;
  font-size: 12px;
}

@media (max-width: 860px) {
  .fav-btn span {
    display: none;
  }
  .fav-btn {
    padding: 0 9px;
  }
}
