@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  color-scheme: light;

  /* Brand palette */
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --secondary: #00a7ff;

  /* Surfaces */
  --bg: #ffffff;
  --surface: #f7faff;
  --panel: #eef4fc;
  --panel-strong: #e3edf9;
  --sidebar-bg: #f6f9fe;

  /* Text */
  --text: #111827;
  --muted: #6b7280;
  --line: #dde8f4;
  --line-strong: #c6d8ee;

  /* Accent (uses brand) */
  --accent: var(--primary);
  --accent-soft: #dcecff;

  /* Links */
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --link-soft: #dcecff;

  /* Callouts */
  --info: #eef4ff;
  --info-line: #bdd3ff;
  --info-icon: #2563eb;
  --success: #ecf8f0;
  --success-line: #b6e2c4;
  --success-icon: #16a34a;
  --warning: #fff8eb;
  --warning-line: #f4dca0;
  --warning-icon: #d97706;
  --danger: #fef2f2;
  --danger-line: #f3c4c4;
  --danger-icon: #dc2626;

  /* Code block */
  --code-bg: #1b1b1f;
  --code-text: #f4f4f5;

  /* Shadows (soft only) */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 2px 6px rgba(17, 24, 39, 0.05), 0 8px 24px rgba(17, 24, 39, 0.07);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.1), 0 4px 12px rgba(17, 24, 39, 0.06);

  /* Radii */
  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Google Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 140ms ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 66px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  box-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(37, 99, 235, 0.07), 0 2px 6px rgba(17, 24, 39, 0.05);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-right: 16px;
}

.brand-logo img {
  display: block;
  width: auto;
  max-width: min(180px, 40vw);
  height: 40px;
  object-fit: contain;
  object-position: left center;
}

.brand-doc {
  display: inline-flex;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

@media (max-width: 760px) {
  .brand-doc {
    display: none;
  }
}

/* ---------- Search ---------- */
.search-wrap {
  position: relative;
  width: min(540px, 100%);
  margin-left: auto;
}

.search {
  display: flex;
  align-items: center;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px 11px 38px;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px center;
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:hover {
  border-color: var(--line-strong);
  background-color: var(--bg);
}

.search input:focus {
  border-color: var(--primary);
  background-color: var(--bg);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Auth (login button / user state) ---------- */
.topbar-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.topbar-login:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar-login svg {
  display: block;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.topbar-user-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

/* Edit Mode toggle switch */
.topbar-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.topbar-edit-toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar-edit-toggle .toggle-track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background-color 0.18s;
  flex: 0 0 auto;
}

.topbar-edit-toggle .toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform 0.18s;
}

.topbar-edit-toggle .toggle-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-edit-toggle[aria-pressed="true"] {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.topbar-edit-toggle[aria-pressed="true"] .toggle-track {
  background: var(--primary);
}

.topbar-edit-toggle[aria-pressed="true"] .toggle-knob {
  transform: translateX(18px);
}

.topbar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.topbar-logout:hover {
  border-color: var(--danger-icon, #dc2626);
  color: var(--danger-icon, #dc2626);
  background-color: var(--bg);
  text-decoration: none;
}

.topbar-logout svg {
  display: block;
}

/* ---------- Sign-in page ---------- */
/* Override the default 2-column shell grid: one centered flex column that
   fills the viewport minus the topbar, so the card sits dead center. */
.shell.shell-auth {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: calc(100vh - 66px);
  padding: 24px;
}

.shell.shell-auth .content {
  flex: 0 1 auto;
  padding: 0;
}

.auth-landing {
  max-width: 460px;
  margin: 0;
  padding: 0;
  text-align: center;
}

.auth-landing h1 {
  font-size: 40px;
}

.auth-landing .lead {
  margin-left: auto;
  margin-right: auto;
}

.auth-card {
  display: grid;
  gap: 18px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  background: var(--bg);
  box-shadow: var(--shadow-md);
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field span {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.auth-field input:hover {
  background-color: var(--bg);
}

.auth-field input:focus {
  border-color: var(--primary);
  background-color: var(--bg);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-submit {
  margin-top: 4px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background-color: var(--primary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.auth-submit:hover {
  background-color: var(--primary-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-error {
  margin: 0;
  border: 1px solid var(--danger-line, #fca5a5);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--danger-icon, #b91c1c);
  background: var(--danger, #fef2f2);
  font-size: 14px;
}

.search-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: min(640px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 92px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
}

.search-panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-results {
  display: grid;
  gap: 2px;
  padding: 8px;
}

.search-result {
  display: grid;
  gap: 3px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
}

.search-result:hover,
.search-result.active {
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.search-result-source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-result strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.search-result span:last-child,
.search-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.search-result mark {
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--primary-strong);
  font-weight: 600;
  padding: 0 3px;
}

.search-empty {
  margin: 0;
  padding: 14px 16px 16px;
}

/* ---------- Shell layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 240px;
  gap: 56px;
  max-width: 1680px;
  margin: 0 auto;
  padding: 48px 40px 96px;
}

/* Archive page has no sidebar/TOC — single centered column. */
.shell.shell-archive {
  display: block;
  max-width: 960px;
}

.sidebar,
.toc {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 114px);
  overflow: auto;
}

.sidebar {
  padding-right: 6px;
}

.sidebar-section + .sidebar-section {
  margin-top: 10px;
}

.toc h2 {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Sidebar nav ---------- */
.sidebar details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sidebar-bg);
  box-shadow: var(--shadow-sm);
}

.sidebar summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 16px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 140ms ease;
  /* Keep the category heading pinned to the top of the sidebar's scroll
     area when its (open) link list is long enough to scroll. */
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sidebar-bg);
  border-radius: var(--radius) var(--radius) 0 0;
}

/* When collapsed, the summary is the whole card — restore full rounding. */
.sidebar details:not([open]) summary {
  border-radius: var(--radius);
}

.sidebar summary::-webkit-details-marker {
  display: none;
}

.sidebar summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 180ms ease;
}

.sidebar details[open] summary::before {
  transform: rotate(45deg);
}

.sidebar summary span {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
}

.sidebar summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-strong);
}

.sidebar summary:hover {
  background: var(--panel);
}

.sidebar nav {
  border-top: 1px solid var(--line);
  padding: 8px;
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

.sidebar details:not([open]) nav {
  display: none;
}

.sidebar nav,
.toc {
  display: grid;
  gap: 2px;
}

.sidebar a,
.toc a {
  display: block;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13.5px;
  line-height: 1.4;
}

.sidebar a {
  position: relative;
  color: #374151;
  transition: background 130ms ease, color 130ms ease;
}

.sidebar a:hover,
.toc a:hover {
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.sidebar a.active {
  background: var(--accent-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.sidebar a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 999px;
  background: var(--primary);
}

.toc a {
  color: var(--muted);
}

.toc a:hover {
  color: var(--text);
}

.toc-level-3 {
  padding-left: 22px !important;
}

/* ---------- Content ---------- */
.content {
  min-width: 0;
  padding-top: 8px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 28px;
}

.breadcrumbs a {
  color: var(--primary);
}

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

.article {
  max-width: 820px;
}

.article h1 {
  margin: 0 0 16px;
  font-size: 44px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

/* lead paragraph right after h1 — Stripe-style intro */
.article h1 + p {
  font-size: 19px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 36px;
}

.article h2 {
  margin: 48px 0 14px;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.article h3 {
  margin: 32px 0 12px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.article p,
.article li {
  color: #2b3442;
}

.article p {
  margin: 16px 0;
}

.article li {
  margin: 6px 0;
}

.article > *:first-child {
  margin-top: 0;
}

.article img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.article figure {
  margin: 28px 0;
}

.article figcaption {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- Tables ---------- */
.article table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: separate;
  border-spacing: 0;
  margin: 28px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.article th,
.article td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
}

.article tr td:last-child,
.article tr th:last-child {
  border-right: none;
}

.article tbody tr:last-child td {
  border-bottom: none;
}

.article th {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.article tbody tr:nth-child(even) {
  background: rgba(250, 250, 248, 0.6);
}

.article tbody tr:hover {
  background: var(--panel);
}

/* ---------- Inline code ---------- */
.article code {
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--primary-strong);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 1px 6px;
}

.article mark {
  background: transparent;
  color: inherit !important;
  font-weight: 700;
  padding: 0;
}

/* ---------- Code blocks ---------- */
.article pre {
  position: relative;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  padding: 18px 18px;
  margin: 24px 0;
  font-size: 13.5px;
  line-height: 1.6;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.article pre code {
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: inherit;
  padding: 0;
}

/* Copy button (JS may inject .copy-btn into pre) */
.article pre .copy-btn,
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease, border-color 140ms ease;
}

.article pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

.copy-btn.copied {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
  opacity: 1;
}

/* ---------- Video ---------- */
.video-embed {
  max-width: 900px;
  margin: 28px 0;
}

.video-embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--text);
  box-shadow: var(--shadow-sm);
}

.video-embed figcaption {
  overflow-wrap: anywhere;
}

.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.video-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--link-soft);
  color: var(--link);
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease;
}

.video-open-link:hover {
  color: var(--link-hover);
  border-color: var(--primary);
  text-decoration: none;
}

/* ---------- Data cards ---------- */
.data-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.data-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.data-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.data-card-title {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
}

.data-card p {
  margin: 0;
}

.data-card dl {
  margin: 0;
}

.data-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.data-card dd {
  margin: 2px 0 0;
}

.data-card-links {
  display: grid;
  gap: 6px;
  overflow-wrap: anywhere;
}

/* ---------- Callouts (Info / Tip / Warning / Success / Danger) ---------- */
.hint {
  position: relative;
  margin: 24px 0;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px 16px 48px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.hint::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.hint p:first-child {
  margin-top: 0;
}

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

/* default (tip / accent) */
.hint::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6'/%3E%3Cpath d='M10 22h4'/%3E%3Cpath d='M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0 0 18 8 6 6 0 0 0 6 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 0 1 8.91 14'/%3E%3C/svg%3E");
}

.hint-info {
  background: var(--info);
  border-color: var(--info-line);
  border-left-color: var(--info-icon);
}

.hint-info::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
}

.hint-success {
  background: var(--success);
  border-color: var(--success-line);
  border-left-color: var(--success-icon);
}

.hint-success::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.801 10A10 10 0 1 1 17 3.335'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E");
}

.hint-warning {
  background: var(--warning);
  border-color: var(--warning-line);
  border-left-color: var(--warning-icon);
}

.hint-warning::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23d97706' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

.hint-danger {
  background: var(--danger);
  border-color: var(--danger-line);
  border-left-color: var(--danger-icon);
}

.hint-danger::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6'/%3E%3Cpath d='m9 9 6 6'/%3E%3C/svg%3E");
}

/* ---------- Content reference cards ---------- */
.content-ref-block {
  margin: 22px 0;
}

.content-ref {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 900px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  background: var(--bg);
  color: var(--link);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, transform 160ms ease;
}

.content-ref:hover {
  border-color: var(--primary);
  background: var(--link-soft);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.content-ref-title {
  min-width: 0;
  color: inherit;
}

.content-ref-arrow {
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  transition: color 160ms ease, transform 160ms ease;
}

.content-ref:hover .content-ref-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

/* ---------- Article footer / pager ---------- */
.article-footer {
  max-width: 900px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.pager a {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.pager a:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.pager a:last-child {
  text-align: right;
}

.pager strong {
  color: var(--text);
}

/* ---------- Landing / hero ---------- */
.landing {
  position: relative;
  max-width: 900px;
  padding: 28px 0 56px;
}

.overview-banner {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 28px;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}

/* subtle gradient hero background — full-bleed, sits behind sidebar + content, flush under the navbar */
.shell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 440px;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(1100px 380px at 10% -12%, rgba(0, 167, 255, 0.14), transparent 62%),
    radial-gradient(820px 340px at 90% -18%, rgba(37, 99, 235, 0.1), transparent 60%),
    linear-gradient(180deg, var(--surface), transparent 80%);
}

.shell {
  position: relative;
  overflow-x: clip;
}

/* Decorative grid overlay on top of the hero gradient */
.shell-grid {
  position: absolute;
  top: -64px;
  left: 50%;
  transform: translateX(-50%);
  width: 918px;
  max-width: none;
  height: auto;
  pointer-events: none;
  z-index: 0;
}

.content {
  position: relative;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary-strong);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 12.5px;
}

.landing h1 {
  margin: 0 0 18px;
  font-size: 52px;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.025em;
}

.lead {
  max-width: 680px;
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.source-card {
  display: grid;
  gap: 8px;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: var(--link);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.source-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.source-card > span:not(.source-card-cover):not(.source-card-icon) {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.source-card strong {
  color: var(--muted);
  font-weight: 600;
}

/* Cover image + material icon on a category card. */
.source-card-cover {
  position: relative;
  display: block;
  margin: -22px -22px 4px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  background: var(--bg-soft, #f5f5f5);
}
.source-card-cover img {
  display: block;
  width: 100%;
  height: 200px;
  object-fit: cover;
}
.source-card-icon {
  font-size: 32px;
  line-height: 1;
  color: var(--primary);
}

/* Placeholder chrome inside an empty cover (shown only in edit mode). */
.source-card-cover-label { display: none; }

/* Outside edit mode, empty cover/icon collapse entirely. */
.source-card-cover.is-empty { display: none; }
.source-card-icon.is-empty { display: none; }

/* In edit mode, empty slots become clickable placeholders matching the design. */
body.edit-mode .source-card-cover.is-empty {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-direction: column;
  height: 200px; margin: -22px -22px 4px;
  border: 1.5px dashed var(--line, #d4d4d8);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  color: var(--muted); cursor: pointer;
}
body.edit-mode .source-card-cover.is-empty:hover { border-color: var(--primary); color: var(--primary); }
body.edit-mode .source-card-cover.is-empty .source-card-cover-label { display: block; font-size: 13px; }
/* A real cover image is also clickable in edit mode (to replace it). */
body.edit-mode .source-card-cover:not(.is-empty) { cursor: pointer; }

/* Pencil affordance on a populated cover, top-right (edit mode only). */
.source-card-cover-edit { display: none; }
body.edit-mode .source-card-cover:not(.is-empty) .source-card-cover-edit {
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,0.92); color: #374151;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
body.edit-mode .source-card-cover:not(.is-empty) .source-card-cover-edit .material-symbols-rounded { font-size: 18px; }
body.edit-mode .source-card-cover:not(.is-empty):hover .source-card-cover-edit { background: var(--primary); color: #fff; }

body.edit-mode .source-card-icon {
  display: inline-flex; cursor: pointer; border-radius: 8px; padding: 2px;
}
body.edit-mode .source-card-icon:hover { background: rgba(37,99,235,0.08); }
body.edit-mode .source-card-icon.is-empty { display: inline-flex; color: var(--muted); opacity: 0.6; }

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

/* ---------- Responsive ---------- */
@media (max-width: 1320px) {
  .shell {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 980px) {
  .shell {
    display: block;
    padding: 22px 18px 56px;
  }

  .sidebar {
    position: static;
    max-height: 320px;
    margin-bottom: 28px;
  }

  .shell::before {
    height: 620px;
    background:
      radial-gradient(700px 520px at 8% -8%, rgba(0, 167, 255, 0.16), transparent 64%),
      radial-gradient(640px 520px at 95% -6%, rgba(37, 99, 235, 0.12), transparent 62%),
      linear-gradient(180deg, var(--surface) 0%, var(--surface) 18%, transparent 100%);
  }
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    flex-wrap: wrap;
    padding: 14px 16px;
  }

  /* full-width panel below the sticky header, lifted above shell content */
  .search-panel {
    left: 0;
    right: 0;
    z-index: 60;
    width: 100%;
    max-height: calc(100vh - 160px);
  }

  .search {
    margin-left: 0;
  }

  .search-wrap {
    order: 2;
    margin-left: 0;
  }

  .brand-logo {
    order: 1;
    margin-right: auto;
  }

  .brand-logo img {
    width: min(180px, 52vw);
    height: 38px;
  }

  .shell {
    display: block;
    padding: 18px 16px 48px;
  }

  .sidebar {
    position: static;
    max-height: 320px;
    margin-bottom: 28px;
  }

  .article h1,
  .landing h1 {
    font-size: 32px;
  }

  .source-grid,
  .data-card-grid,
  .pager {
    grid-template-columns: 1fr;
  }

  .pager a:last-child {
    text-align: left;
  }
}

/* Print / Save as PDF — keep only the article body */
@media print {
  /* @page margin applies to every page, so page breaks keep equal margins
     (padding on .article only pads the first/last page, not the middle ones).
     Note: browsers may still print the native header inside this margin —
     uncheck "Headers and footers" in the print dialog to hide it. */
  @page { margin: 18mm 20mm; }
  .topbar, .sidebar, .toc, .shell-grid, .breadcrumbs,
  .article-edit-bar, .article-footer, .footer { display: none !important; }
  .shell, .content { display: block !important; margin: 0 !important; padding: 0 !important; }
  .article { max-width: none !important; padding: 0 !important; }
  body { background: #fff !important; }
}
