/* Crowd Memory docs: a documentation layout with greys and one accent. */
:root {
  --bg: #ffffff;
  --text: #0f1115;
  --text-2: #43454a;
  --muted: #61666b;
  --border: #e1e5ee;
  --side-bg: #f9fafb;
  --accent: #3964fe;
  --accent-bg: #e4edfd;
  --code-bg: rgba(30, 41, 59, 0.07);
  --pre-bg: #1e1e1e;
  --pre-bar: #2a2a2b;
  --pre-text: #d4d4d4;
  --pre-dim: #8f8f8f;
  --top-h: 60px;
  --tabs-h: 44px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", Roboto, "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1d; --text: #e6e6e6; --text-2: #c2c2c4; --muted: #8e9196; --border: #2e3036; --side-bg: #202124;
    --accent: #7c9cff; --accent-bg: rgba(124, 156, 255, 0.13); --code-bg: rgba(255, 255, 255, 0.08);
    --pre-bg: #141416; --pre-bar: #232326; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1b1d; --text: #e6e6e6; --text-2: #c2c2c4; --muted: #8e9196; --border: #2e3036; --side-bg: #202124;
  --accent: #7c9cff; --accent-bg: rgba(124, 156, 255, 0.13); --code-bg: rgba(255, 255, 255, 0.08);
  --pre-bg: #141416; --pre-bar: #232326; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + var(--tabs-h) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.75; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); }
.top-row { height: var(--top-h); display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border);
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { fill: currentColor; flex: none; }
.ver { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 100px; padding: 0 8px; line-height: 20px; }
.theme { margin-left: auto; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 18px; }
.theme:hover { background: var(--side-bg); color: var(--text); }
.menu { display: none; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; color: var(--text-2); }
.tabs { height: var(--tabs-h); display: flex; gap: 8px; align-items: stretch; border-bottom: 1px solid var(--border); overflow-x: auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.tabs a { display: flex; align-items: center; padding: 0 12px; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.side { position: sticky; top: calc(var(--top-h) + var(--tabs-h) + env(safe-area-inset-top, 0px)); align-self: start;
  height: calc(100vh - var(--top-h) - var(--tabs-h)); overflow-y: auto; background: var(--side-bg); border-right: 1px solid var(--border);
  padding: 16px 14px 32px max(14px, env(safe-area-inset-left, 0px)); }
.side-group { margin-bottom: 14px; }
.side-title { font-size: 13px; font-weight: 600; color: var(--text); padding: 6px 12px; }
.side a { display: block; padding: 7px 12px; border-radius: 6px; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.side a:hover { background: var(--border); text-decoration: none; }
.side a.on { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.main { display: grid; grid-template-columns: minmax(0, 780px) 200px; gap: 56px; justify-content: start;
  padding: 32px max(40px, env(safe-area-inset-right, 0px)) 64px 48px; min-width: 0; }

/* Article */
.doc { min-width: 0; }
.doc h1 { font-size: 28px; line-height: 1.4; font-weight: 600; margin: 0 0 20px; }
.doc h2 { font-size: 22px; line-height: 1.4; font-weight: 600; margin: 40px 0 14px; }
.doc h3 { font-size: 18px; font-weight: 600; margin: 28px 0 10px; }
.doc p { margin: 0 0 16px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 24px; }
.doc li { margin: 4px 0; }
.doc strong { font-weight: 600; }
.hash { margin-left: 8px; color: var(--muted); opacity: 0; font-weight: 400; }
h2:hover .hash, .hash:focus { opacity: 1; text-decoration: none; }
.small { font-size: 14px; color: var(--muted); }
code { font-family: var(--mono); font-size: 0.86em; background: var(--code-bg); border-radius: 6px; padding: 1px 5px; overflow-wrap: break-word; }
.table { overflow-x: auto; margin: 0 0 16px; }
table { border-collapse: collapse; font-size: 15px; line-height: 1.6; min-width: 100%; }
th, td { border: 1px solid var(--border); padding: 9px 16px; text-align: left; vertical-align: top; }
th { background: var(--side-bg); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
td code { white-space: normal; }
.code { margin: 0 0 18px; border-radius: 8px; overflow: hidden; background: var(--pre-bg); }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px; background: var(--pre-bar); color: var(--pre-dim); font-size: 12px; font-family: var(--mono); }
.code-bar .copy { color: var(--pre-dim); font-family: var(--sans); font-size: 12px; }
.code-bar .copy:hover { color: var(--pre-text); }
pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--pre-text); font: 13.5px/1.7 var(--mono); }
pre code { background: none; padding: 0; font-size: inherit; border-radius: 0; overflow-wrap: normal; white-space: pre; }
.note { border: 1px solid var(--border); border-left: 3px solid var(--muted); background: var(--side-bg); border-radius: 6px; padding: 12px 16px; margin: 0 0 18px; }
.note strong { display: block; font-size: 14px; margin-bottom: 2px; }
.note p { margin: 0; font-size: 15px; color: var(--text-2); }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.pg { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; color: var(--accent); font-weight: 500; line-height: 1.5; }
.pg:hover { border-color: var(--accent); text-decoration: none; }
.pg span { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.pg.next { grid-column: 2; text-align: right; }

/* On this page */
.toc { position: sticky; top: calc(var(--top-h) + var(--tabs-h) + 32px); align-self: start; font-size: 13px; line-height: 1.5;
  max-height: calc(100vh - 160px); overflow-y: auto; }
.toc-title { font-weight: 600; color: var(--text); margin-bottom: 8px; }
.toc a { display: block; padding: 4px 0 4px 12px; color: var(--muted); border-left: 1px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }

.foot { border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--muted);
  padding: 20px max(24px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
.mail { user-select: all; }

@media (max-width: 1200px) {
  .main { grid-template-columns: minmax(0, 780px); }
  .toc { display: none; }
}
@media (max-width: 996px) {
  .menu { display: inline-flex; align-items: center; justify-content: center; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; width: auto; height: auto; align-self: stretch;
    top: calc(var(--top-h) + var(--tabs-h) + env(safe-area-inset-top, 0px)); border-right: 0; padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
  .nav-open .side { display: block; }
  .main { padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
  .top-row, .tabs { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
@media (max-width: 560px) {
  .doc h1 { font-size: 24px; }
  .doc h2 { font-size: 20px; }
  th, td { padding: 8px 10px; }
  table { font-size: 14px; }
  .pager { grid-template-columns: 1fr; }
  .pg.next { grid-column: 1; }
  .ver { display: none; }
}
