
:root {
  --primary: #1976d2;
  --primary-dark: #0d47a1;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1e2430;
  --muted: #5f6b7a;
  --border: #e1e5ea;
  --link: #1565c0;
  --code-bg: #f4f6f8;
  --nav-active: #e3f0fc;
  --tag-bg: #e8f0fe;
  --tag-fg: #0d47a1;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --card: #1c222b;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --border: #2b3340;
    --link: #64b5f6;
    --code-bg: #232a35;
    --nav-active: #1e3350;
    --tag-bg: #1e3350;
    --tag-fg: #90caf9;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; height: 64px;
  background: linear-gradient(to right, var(--primary-dark), var(--primary));
  color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 500; font-size: 18px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }
.appbar-links { display: flex; gap: 6px; margin-left: auto; }
.appbar-links a { color: #fff; padding: 8px 12px; border-radius: 4px; font-weight: 500; font-size: 14px; }
.appbar-links a:hover { background: rgba(255,255,255,.15); text-decoration: none; }

/* Layout */
.shell {
  display: grid; grid-template-columns: 260px minmax(0, 1fr) 280px;
  gap: 24px; max-width: 1440px; margin: 0 auto; padding: 24px 16px;
}
.sidenav, .pageinfo { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 112px); overflow: auto; }
.card, .sidenav, .content article {
  background: var(--card); border-radius: 8px; box-shadow: var(--shadow);
}
.content article { padding: 28px 36px 40px; }
.card { padding: 16px 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* Side nav */
.sidenav { padding: 8px 0; font-size: 14px; }
.sidenav-toggle > summary { display: none; }
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree li a, .nav-tree summary { display: flex; align-items: center; gap: 8px; padding: 7px 16px; color: var(--text); }
.nav-tree li a:hover { background: var(--nav-active); text-decoration: none; }
.nav-tree li.active > a { background: var(--nav-active); color: var(--link); font-weight: 500; box-shadow: inset 3px 0 0 var(--primary); }
.nav-tree summary { cursor: pointer; font-weight: 500; list-style: none; }
.nav-tree summary::-webkit-details-marker { display: none; }
.nav-tree summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.nav-tree details[open] > summary::after { transform: rotate(90deg); }
.nav-tree .level-1 li a, .nav-tree .level-1 summary { padding-left: 32px; }
.nav-tree .level-2 li a { padding-left: 48px; }
.nav-icon { font-size: 13px; opacity: .8; }

/* Page header */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb .sep { margin: 0 6px; }
.page-title { margin: 0; font-size: 30px; font-weight: 500; line-height: 1.2; }
.page-description { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.page-header { padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }

/* Wiki.js / CKEditor content */
.page-body { display: flow-root; font-size: 15px; overflow-wrap: anywhere; }
.content { min-width: 0; }
.page-body h1, .page-body h2, .page-body h3 { font-weight: 500; line-height: 1.3; margin: 1.6em 0 .5em; }
.page-body h1 { font-size: 26px; }
.page-body h2 { font-size: 21px; }
.page-body h3 { font-size: 17px; }
.page-body h1:first-child, .page-body h2:first-child { margin-top: 0; }
.page-body .toc-header { position: relative; scroll-margin-top: 80px; }
.page-body .toc-anchor { position: absolute; left: -1.1em; color: var(--muted); opacity: 0; font-weight: 400; }
.page-body .toc-header:hover .toc-anchor { opacity: .7; }
.page-body p { margin: 0 0 .9em; }
.page-body ul { padding-left: 1.6em; margin: 0 0 1em; }
.page-body li { margin: .2em 0; }
.page-body blockquote {
  margin: 1em 0; padding: .6em 1em; border-left: 4px solid var(--primary);
  background: var(--code-bg); border-radius: 0 6px 6px 0;
}
.page-body blockquote p:last-child { margin-bottom: 0; }
.page-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }
.page-body .text-big { font-size: 1.25em; }
.page-body figure { margin: 1em 0; }
.page-body figure.image { display: flex; flex-direction: column; align-items: center; margin: 1em auto; text-align: center; }
.page-body figure.image img { display: block; max-width: 100%; border-radius: 4px; }
.page-body figure.image_resized img { width: 100%; }
.page-body figure.image-style-align-right { float: right; margin: .3em 0 1em 1.5em; max-width: 50%; }
.page-body figure.image-style-align-left { float: left; margin: .3em 1.5em 1em 0; max-width: 50%; }
.page-body figcaption { font-size: 13px; color: var(--muted); padding-top: 6px; text-align: center; }
.page-body figure.table { margin: 1em 0; overflow-x: auto; }
.page-body table { border-collapse: collapse; min-width: 50%; }
.page-body td, .page-body th { border: 1px solid var(--border); padding: 6px 12px; vertical-align: top; }
.page-body tr td:first-child { font-weight: 500; background: var(--code-bg); white-space: nowrap; }
.page-body .is-invalid-page { color: #c62828; border-bottom: 1px dotted #c62828; cursor: help; }
.page-body .is-external-link::after {
  content: ""; display: inline-block; width: .7em; height: .7em; margin-left: .2em; vertical-align: -.05em; opacity: .55;
  background: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3zM5 5h6v2H7v10h10v-4h2v6H5V5z"/></svg>') center/contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 3h7v7h-2V6.4l-9.3 9.3-1.4-1.4L17.6 5H14V3zM5 5h6v2H7v10h10v-4h2v6H5V5z"/></svg>') center/contain no-repeat;
}
.video-embed { position: relative; aspect-ratio: 16 / 9; max-width: 800px; margin: 1em auto; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 6px; }
.video-fallback { text-align: center; font-size: 13px; }

/* Right column */
.meta dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; background: var(--tag-bg); color: var(--tag-fg); font-size: 12px; }
.tag:hover { text-decoration: none; filter: brightness(1.07); }
.toc { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.toc li { margin: 4px 0; }
.toc .level-1 { padding-left: 14px; border-left: 1px solid var(--border); margin-left: 2px; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--link); }

/* Lists on index pages */
.page-list, .tag-list { list-style: none; padding: 0; margin: 0; }
.page-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.page-list li a { font-weight: 500; font-size: 16px; }
.page-list .desc { display: block; color: var(--muted); font-size: 14px; }
.page-list .path { display: block; color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list li { display: flex; align-items: center; gap: 4px; }
.tag-list .count { color: var(--muted); font-size: 12px; }


/* Responsive */
@media (max-width: 1200px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .pageinfo { grid-column: 2; position: static; max-height: none; }
}
@media (max-width: 800px) {
  .appbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .shell { grid-template-columns: minmax(0, 1fr); padding: 16px 12px; gap: 16px; }
  .sidenav, .pageinfo { position: static; max-height: none; grid-column: 1; }
  .content { order: 1; } .pageinfo { order: 2; } .sidenav { order: 3; }
  .sidenav-toggle > summary { display: block; padding: 10px 16px; font-weight: 500; cursor: pointer; }
  .sidenav-toggle:not([open]) { padding: 0; }
  .content article { padding: 20px 18px 28px; }
  .page-title { font-size: 24px; }
  .page-body figure.image-style-align-right, .page-body figure.image-style-align-left { float: none; margin: 1em auto; max-width: 100%; }
}
