:root {
  --bg: #ffffff; --fg: #111827; --muted: #6b7280; --border: #e5e7eb;
  --surface: #f9fafb;
  --accent: #2563eb; /* primary blue */
  --accent-weak: #eff6ff;
  --callout-info-bg: #eef2ff; --callout-info-border: #c7d2fe;
  --callout-warn-bg: #fff7ed; --callout-warn-border: #fed7aa;
  --callout-tip-bg:  #ecfdf5; --callout-tip-border:  #a7f3d0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f1a; --fg: #e5e7eb; --muted: #9ca3af; --border: #1f2937;
    --surface: #111827;
    --accent: #60a5fa; --accent-weak: #0b1220;
    --callout-info-bg:#111827; --callout-info-border:#374151;
    --callout-warn-bg:#1f2937; --callout-warn-border:#4b5563;
    --callout-tip-bg: #0f1f16; --callout-tip-border: #1f4732;
  }
}

html[data-theme='light'] {
  --bg: #ffffff; --fg: #111827; --muted: #6b7280; --border: #e5e7eb;
  --surface: #f9fafb;
  --accent: #2563eb; --accent-weak: #eff6ff;
  --callout-info-bg: #eef2ff; --callout-info-border: #c7d2fe;
  --callout-warn-bg: #fff7ed; --callout-warn-border: #fed7aa;
  --callout-tip-bg:  #ecfdf5; --callout-tip-border:  #a7f3d0;
}

html[data-theme='dark'] {
  --bg: #0b0f1a; --fg: #e5e7eb; --muted: #9ca3af; --border: #1f2937;
  --surface: #111827;
  --accent: #60a5fa; --accent-weak: #0b1220;
  --callout-info-bg:#111827; --callout-info-border:#374151;
  --callout-warn-bg:#1f2937; --callout-warn-border:#4b5563;
  --callout-tip-bg: #0f1f16; --callout-tip-border: #1f4732;
}

html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }
body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem;
  z-index: 100;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.nav-toggle {
  background: none;
  border: 0;
  font-size: 1.25rem;
  cursor: pointer;
  display: none;
}

.search { position: relative; flex:1; margin:0 1rem; }
.search input { width:100%; padding:0.25rem 0.5rem; }
.search-results { position:absolute; top:100%; left:0; right:0; background:var(--bg); border:1px solid var(--border); max-height:300px; overflow:auto; z-index:1000; }
.search-results a { display:block; padding:0.25rem 0.5rem; border-bottom:1px solid var(--border); text-decoration:none; }
.search-results a:hover { background:var(--accent-weak); }
.search-results a:last-child { border-bottom:0; }
.sr-title { font-weight:600; }
.sr-path { font-size:0.75rem; color:var(--muted); }

.page {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  padding: 32px 24px;
}

  .sidebar {
    border-right: 1px solid var(--border);
    padding-right: 16px;
  }

  .nav-tree, .nav-subtree {
    list-style: none;
    margin: 0;
    padding-left: 1rem;
  }
  .nav-number {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

@media (max-width: 992px) {
  .page { grid-template-columns: 1fr; }
  .sidebar { display: none; border-right: none; padding-right: 0; }
  body.sidebar-open .sidebar { display: block; }
  .nav-toggle { display: block; }
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.25;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}
h1, h2 { font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }

p, ul, ol, table, pre, blockquote {
  margin-top: 1em;
  margin-bottom: 1em;
}

ul, ol {
  padding-left: 1.5em;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover, a:focus {
  color: #1e40af;
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
.sidebar a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

nav.breadcrumbs {
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
}
nav.breadcrumbs a {
  color: inherit;
}


.doc-meta {
  margin: 24px 0 32px;
  padding: 20px 24px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
}

.doc-meta__dl {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.doc-meta__item {
  display: grid;
  grid-template-columns: minmax(0, 128px) 1fr;
  column-gap: 12px;
  row-gap: 4px;
  padding: 12px 0;
}

.doc-meta__item + .doc-meta__item {
  border-top: 1px solid var(--border);
}

.doc-meta__label {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  align-self: start;
  color: var(--muted);
}

.doc-meta__value {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}

@media (max-width: 900px) {
  .doc-meta {
    padding: 18px 20px;
  }
}

@media (max-width: 639px) {
  .doc-meta__item {
    grid-template-columns: minmax(0, 1fr);
  }
}

.chip {
  --chip-bg: rgba(148, 163, 184, 0.16);
  --chip-border: rgba(148, 163, 184, 0.35);
  --chip-color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--chip-color);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

html[data-theme='dark'] .chip {
  --chip-bg: rgba(148, 163, 184, 0.22);
  --chip-border: rgba(148, 163, 184, 0.45);
  --chip-color: var(--fg);
}

.chip--status {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chip--status-stub {
  --chip-bg: #ede9fe;
  --chip-border: rgba(139, 92, 246, 0.4);
  --chip-color: #4c1d95;
}

html[data-theme='dark'] .chip--status-stub {
  --chip-bg: #312e81;
  --chip-border: rgba(165, 180, 252, 0.5);
  --chip-color: #ede9fe;
}

.chip--status-draft {
  --chip-bg: #fef3c7;
  --chip-border: rgba(217, 119, 6, 0.45);
  --chip-color: #92400e;
}

html[data-theme='dark'] .chip--status-draft {
  --chip-bg: #7c2d12;
  --chip-border: rgba(251, 191, 36, 0.55);
  --chip-color: #fef3c7;
}

.chip--status-final {
  --chip-bg: #dcfce7;
  --chip-border: rgba(22, 163, 74, 0.45);
  --chip-color: #047857;
}

html[data-theme='dark'] .chip--status-final {
  --chip-bg: #064e3b;
  --chip-border: rgba(134, 239, 172, 0.55);
  --chip-color: #dcfce7;
}
.sr-only { position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }

table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.5em;
}
th {
  background: var(--accent-weak);
  text-align: left;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
pre {
  overflow-x: auto;
  padding: 1em;
  background: var(--accent-weak);
}

blockquote {
  border-left: 4px solid var(--border);
  margin: 0;
  padding-left: 1em;
  color: var(--muted);
}

.callout { border-left: 4px solid; padding: 1em; }
.callout.info { background: var(--callout-info-bg); border-color: var(--callout-info-border); }
.callout.warn { background: var(--callout-warn-bg); border-color: var(--callout-warn-border); }
.callout.tip  { background: var(--callout-tip-bg);  border-color: var(--callout-tip-border); }
#comment-list { list-style: none; margin: 0; padding: 0; }
#comment-list ul { list-style: none; margin-left: 2rem; padding: 0; }
#comment-list, #comment-list ul { list-style: none; margin: 0; padding: 0; }
.comment-item { padding:0.5rem 0; border-bottom:1px solid var(--border); display:flex; gap:0.5rem; }
.comment-item:last-child { border-bottom:0; }
.comment-avatar { width:40px; height:40px; border-radius:50%; background:var(--accent); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:bold; flex-shrink:0; overflow:hidden; }
.comment-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; display:block; }
.comment-content { flex:1; display:flex; flex-direction:column; }
.comment-message { margin:0; }
.comment-time { display:block; font-size:0.8rem; color:var(--fg); opacity:0.6; margin-top:0.25rem; }
.comment-actions { margin-top:0.5rem; display:flex; gap:0.5rem; }
.comment-form { margin-top:1rem; display:flex; flex-direction:column; gap:0.5rem; }
.comment-text { padding:0.5rem; border:1px solid var(--border); background:var(--bg); color:var(--fg); resize:vertical; }
.comment-submit { align-self:flex-end; background:var(--accent); color:#fff; border:none; padding:0.5rem 1rem; cursor:pointer; }
.comment-submit:hover,.comment-submit:focus { background:#1e40af; }
.user-info { position:relative; margin-left:1rem; }
.user-info img { width:40px; height:40px; border-radius:50%; object-fit:cover; cursor:pointer; display:block; }
.user-dropdown { position:absolute; right:0; top:100%; background:var(--bg); border:1px solid var(--border); padding:0.5rem; display:flex; flex-direction:column; gap:0.25rem; z-index:1000; box-shadow:0 8px 24px rgba(0,0,0,.08); }
.user-dropdown[hidden] { display:none !important; }
.user-dropdown a,.user-dropdown button { background:none; border:0; text-align:left; color:var(--fg); text-decoration:none; font-size:0.75rem; cursor:pointer; padding:0.25rem 0; }
.user-dropdown a:hover,.user-dropdown button:hover { background:var(--accent-weak); }
.login {
  min-height:100vh;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:1rem;
}
.login-form {
  display:flex;
  flex-direction:column;
  gap:0.75rem;
  width:100%;
  max-width:300px;
}
.login-logo {
  width:120px;
}
.login-form input,
.login-form button {
  padding:0.5rem;
}
