:root {
  --bg: #0b0f14;
  --panel: #0f141b;
  --panel-2: #0d1117;
  --text: #e6edf3;
  --muted: #9fb3c8;
  --accent: #3aa1ff;
  --accent-2: #7ee787;
  --border: #202938;
  --note: #1e3a8a;
  --tip: #065f46;
  --code-bg-inline: rgba(255,255,255,.06);
  --code-bg-block: #0a0f14;
  --code-text: var(--text);
  --code-border: var(--border);
  --topbar-h: 46px;
}

/* Light theme overrides */
.theme-light {
  --bg: #ffffff;
  --panel: #f6f8fa;
  --panel-2: #ffffff;
  --text: #0b1220;
  --muted: #4b5563;
  --accent: #2563eb;
  --accent-2: #16a34a;
  --border: #e5e7eb;
  --note: #93c5fd;
  --tip: #86efac;
  --code-bg-inline: #f1f5f9;
  --code-bg-block: #f8fafc;
  --code-text: #0b1220;
  --code-border: #e5e7eb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Inter,Helvetica,Arial,sans-serif;
}

#app { display: grid; grid-template-columns: 280px 1fr 280px; min-height: 100vh; }
.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); background: var(--panel); border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; margin-bottom: 12px; }
.brand-logo { width: 22px; height: 22px; border-radius: 4px; border: none; background: transparent; object-fit: contain; }
.sidebar-hero { margin-top: 14px; }
.sidebar-hero-img { width: 100%; max-width: 240px; height: auto; display: block; margin: 0 auto; border-radius: 10px; border: none; background: transparent; }
.nav { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding-right: 4px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 6px; border: 1px solid transparent; }
.nav a.active { background: var(--panel-2); border-color: var(--border); }
.nav a:hover { background: rgba(255,255,255,.04); }
.controls { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Switch buttons */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 70px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; transition: background .15s ease, border-color .15s ease; overflow: hidden; }
.switch .label { font-size: .85rem; color: var(--muted); }
.switch .knob { position: absolute; left: 8px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); border-radius: 999px; background: #7c8796; transition: transform .2s ease, background .2s ease; border: 1px solid var(--border); }
.switch::after { content: ""; position: absolute; left: 8px; top: 50%; width: 44px; height: 14px; transform: translateY(-50%); border-radius: 999px; background: rgba(255,255,255,.08); border: 1px solid var(--border); }
.switch[aria-pressed="true"] .knob { background: var(--accent); transform: translateY(-50%) translateX(24px); }
.switch.theme .icon { position: absolute; left: 56px; top: 50%; transform: translateY(-50%); font-size: 12px; }
.switch:hover { filter: brightness(1.05); }

.content { padding: 28px 32px; }
body { padding-top: var(--topbar-h); }
article { max-width: 920px; margin: 0 auto; }
article h1, article h2, article h3, article h4, article h5 { line-height: 1.25; }
article h1 { font-size: 2rem; margin: 0 0 16px; }
article h2 { font-size: 1.5rem; margin: 28px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
article h3 { font-size: 1.2rem; margin: 20px 0 8px; }
article p { color: var(--text); }
article code { background: var(--code-bg-inline); color: var(--code-text); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--code-border); }
pre { background: var(--code-bg-block); color: var(--code-text); border: 1px solid var(--code-border); padding: 14px; overflow: auto; border-radius: 8px; }
pre code { background: transparent; padding: 0; color: inherit; }
.code-title { color: var(--muted); font-size: .85rem; margin: 0 0 6px; }

ul, ol { padding-left: 22px; }
li { margin: 6px 0; }
a { color: var(--accent); }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.admonition { border: 1px solid var(--border); border-left-width: 4px; padding: 10px 12px; border-radius: 6px; margin: 16px 0; background: var(--panel-2); }
.admonition.note { border-left-color: var(--note); }
.admonition.tip { border-left-color: var(--tip); }
.admonition .admonition-title { font-weight: 600; text-transform: uppercase; letter-spacing: .4px; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }

.toc { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); background: var(--panel); border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.toc.hidden { display: none; }
.toc h4 { margin: 6px 0 10px; color: var(--muted); }
.toc a { display: block; color: var(--muted); text-decoration: none; padding: 4px 0; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--text); font-weight: 600; }

.img-wrap { display: flex; justify-content: center; }
.img-wrap img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 28px auto; max-width: 920px; border-top: 1px solid var(--border); padding-top: 16px; }
.pager-btn { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; cursor: pointer; }
.pager-btn[disabled] { opacity: .5; cursor: not-allowed; }
.pager-btn:hover:not([disabled]) { background: var(--panel-2); }

@media (max-width: 1100px) {
  #app { grid-template-columns: 240px 1fr; }
  .toc { display: none; }
}

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { z-index: 2; }
}

/* Top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); background: var(--panel); border-bottom: 1px solid var(--border); z-index: 5; }
.topbar-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-logo { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; border: 1px solid var(--border); background: var(--panel-2); }
.topbar-title { font-weight: 600; }
.topbar-right { color: var(--muted); }
.topbar-right .topbar-link { color: var(--accent); text-decoration: none; }

/* Signature/Watermark */
.signature {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.7;
  transition: opacity 0.3s ease;
  z-index: 100;
  background-color: var(--container-bg);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.signature:hover {
  opacity: 1;
}

.developer-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.developer-link:hover {
  color: var(--hover-color);
}

.unifr-logo {
  height: 20px;
  width: auto;
  filter: var(--logo-filter, none);
  transition: filter 0.3s ease;
}

/* Dark mode adjustments for the logo */
@media (prefers-color-scheme: dark) {
  .unifr-logo {
      filter: brightness(0) invert(1); /* Makes the logo white in dark mode */
  }
}

@media (max-width: 768px) {
  .signature {
      font-size: 0.8rem;
      padding: 0.4rem 0.8rem;
      bottom: 0.5rem;
      right: 0.5rem;
  }
  
  .unifr-logo {
      height: 16px; /* Slightly smaller on mobile */
  }
}
