/* Agent Memory — standalone documentation site.
   Deliberately styled after the open-standard docs idiom (agentskills.io):
   fixed topbar, left sidebar nav, measured content column, right page TOC.
   Self-contained: does not share the main site's design system. */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --text: #1e293b;
  --text-strong: #0f172a;
  --text-dim: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0f172a;
  --code-bg: #fafafa;
  --sidebar-active-bg: #f1f5f9;
  --card-hover: #f8fafc;
}

:root[data-theme="dark"] {
  --bg: #0b0d10;
  --bg-subtle: #101318;
  --text: #cbd5e1;
  --text-strong: #f1f5f9;
  --text-dim: #7c8899;
  --border: #1e2530;
  --border-strong: #334155;
  --accent: #f1f5f9;
  --code-bg: #101318;
  --sidebar-active-bg: #161b23;
  --card-hover: #11151b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d10;
    --bg-subtle: #101318;
    --text: #cbd5e1;
    --text-strong: #f1f5f9;
    --text-dim: #7c8899;
    --border: #1e2530;
    --border-strong: #334155;
    --accent: #f1f5f9;
    --code-bg: #101318;
    --sidebar-active-bg: #161b23;
    --card-hover: #11151b;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }

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

a { color: inherit; }

code, pre {
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Topbar ── */

.am-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.am-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}

.am-brand-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}

.am-topbar-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.am-theme,
.am-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}

.am-theme svg, .am-github svg { width: 17px; height: 17px; }

.am-theme:hover, .am-github:hover { color: var(--text-strong); background: var(--card-hover); }

/* Show the icon for the scheme you'd switch to */
.am-theme-sun { display: none; }
:root[data-theme="dark"] .am-theme-sun { display: block; }
:root[data-theme="dark"] .am-theme-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .am-theme-sun, :root[data-theme="dark"] .am-theme-sun { display: block; }
  :root:not([data-theme]) .am-theme-moon, :root[data-theme="dark"] .am-theme-moon { display: none; }
}

/* ── Layout ── */

.am-shell {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding-top: 64px;
}

.am-sidebar {
  position: sticky;
  top: 64px;
  align-self: flex-start;
  width: 264px;
  flex-shrink: 0;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 28px 16px 48px 24px;
}

.am-nav-group { margin-bottom: 22px; }

.am-nav-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  padding: 6px 12px;
  margin: 0;
}

.am-nav a {
  display: block;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
}

.am-nav a:hover { color: var(--text-strong); background: var(--card-hover); }

.am-nav a.is-active {
  color: var(--text-strong);
  font-weight: 500;
  background: var(--sidebar-active-bg);
}

.am-main {
  flex: 1;
  min-width: 0;
  padding: 44px 48px 96px;
}

.am-article { max-width: 720px; margin: 0 auto; }
.am-article--wide { max-width: 840px; }
.am-article--wide table { font-size: 13px; }

.am-toc {
  position: sticky;
  top: 64px;
  align-self: flex-start;
  width: 240px;
  flex-shrink: 0;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 40px 24px 48px 8px;
  font-size: 13.5px;
}

.am-toc-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 10px;
}

.am-toc a {
  display: block;
  color: var(--text-dim);
  text-decoration: none;
  padding: 4px 0;
  line-height: 1.5;
}

.am-toc a:hover { color: var(--text-strong); }
.am-toc a.is-active { color: var(--text-strong); font-weight: 500; }

@media (max-width: 1279px) { .am-toc { display: none; } }

@media (max-width: 959px) {
  .am-sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 20px 24px 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
  }
  .am-shell { flex-direction: column; }
  .am-main { padding: 32px 24px 72px; }
}

/* ── Article head (title + copy page) ── */

.am-article-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.am-article-head-text { min-width: 0; }

.am-copy-page {
  flex-shrink: 0;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 13px;
  cursor: pointer;
}

.am-copy-page:hover { color: var(--text-strong); border-color: var(--border-strong); background: var(--card-hover); }
.am-copy-page.is-copied { color: var(--text-strong); }

@media (max-width: 700px) {
  .am-article-head { flex-direction: column; }
  .am-copy-page { margin-top: 0; }
}

/* ── Article typography ── */

.am-article h1 {
  font-size: 34px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin: 0 0 10px;
}

.am-subtitle {
  font-size: 18px;
  color: var(--text-dim);
  margin: 0 0 36px;
}

.am-article h2 {
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-strong);
  margin: 44px 0 14px;
}

.am-article h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 32px 0 10px;
}

.am-article p { margin: 0 0 16px; }

.am-article ul, .am-article ol { margin: 0 0 16px; padding-left: 26px; }
.am-article li { margin-bottom: 6px; }

.am-article strong { color: var(--text-strong); font-weight: 600; }

.am-article a { color: var(--text-strong); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.am-article a:hover { text-decoration-color: var(--text-strong); }

.am-article code {
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--text-strong);
}

.am-article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 20px;
  position: relative;
}

.am-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

.am-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

.am-article pre:hover .am-copy { opacity: 1; }
.am-copy:hover { color: var(--text-strong); border-color: var(--border-strong); }

/* Tables */

.am-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  margin: 0 0 22px;
}

.am-article th {
  text-align: left;
  font-weight: 600;
  color: var(--text-strong);
  border-bottom: 1px solid var(--border-strong);
  padding: 9px 14px 9px 0;
}

.am-article td {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 10px 0;
  vertical-align: top;
}

/* Callout note */

.am-note {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14.5px;
  margin: 0 0 20px;
}

.am-note-icon { flex-shrink: 0; line-height: 1.7; }

.am-note p { margin: 0; }
.am-note p + p { margin-top: 8px; }

/* Cards */

.am-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 22px 0 8px;
}

@media (max-width: 700px) { .am-cards { grid-template-columns: 1fr; } }

.am-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  text-decoration: none !important;
  transition: border-color 120ms ease, background 120ms ease;
}

.am-card:hover { border-color: var(--border-strong); background: var(--card-hover); }

.am-card-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0 0 6px;
}

.am-card-desc {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.6;
}
