/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ── Dark theme (default) ──────────────────────────────────── */
:root {
  --bg-primary: #0e0e12;
  --bg-surface: #16161d;
  --bg-surface-alt: #1e1e28;
  --bg-hover: #252530;
  --text-primary: #e4e4ec;
  --text-secondary: #a8a8b8;
  --text-muted: #6a6a7a;
  --accent: #7b9ef0;
  --accent-hover: #9db8f5;
  --accent-dim: rgba(123, 158, 240, 0.12);
  --border: #2a2a38;
  --glow-color: rgba(123, 158, 240, 0.15);
  --glow-strong: rgba(123, 158, 240, 0.30);
  --gradient-surface: linear-gradient(135deg, #16161d 0%, #1a1a26 100%);
  --gradient-header: linear-gradient(90deg, #12121a 0%, #16161d 50%, #12121a 100%);
  --gradient-bg: radial-gradient(ellipse at 20% 0%, rgba(123, 158, 240, 0.06) 0%, transparent 50%),
                 radial-gradient(ellipse at 80% 100%, rgba(160, 120, 240, 0.04) 0%, transparent 50%);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 20px var(--glow-color);
  --shadow-card-hover: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 30px var(--glow-strong);
  --header-height: 56px;
  --content-max: 960px;
  --nav-width: 220px;
  --radius: 8px;

  color-scheme: dark;
}

/* ── Light theme ───────────────────────────────────────────── */
:root.light {
  --bg-primary: #f4f4f8;
  --bg-surface: #ffffff;
  --bg-surface-alt: #eeeef3;
  --bg-hover: #e4e4ed;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a60;
  --text-muted: #8888a0;
  --accent: #4a6fd6;
  --accent-hover: #3858b8;
  --accent-dim: rgba(74, 111, 214, 0.10);
  --border: #d0d0de;
  --glow-color: rgba(74, 111, 214, 0.10);
  --glow-strong: rgba(74, 111, 214, 0.18);
  --gradient-surface: linear-gradient(135deg, #ffffff 0%, #f8f8fc 100%);
  --gradient-header: linear-gradient(90deg, #eeeef4 0%, #ffffff 50%, #eeeef4 100%);
  --gradient-bg: radial-gradient(ellipse at 20% 0%, rgba(74, 111, 214, 0.06) 0%, transparent 50%),
                 radial-gradient(ellipse at 80% 100%, rgba(140, 100, 220, 0.04) 0%, transparent 50%);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 16px var(--glow-color);
  --shadow-card-hover: 0 4px 20px rgba(0, 0, 0, 0.08), 0 0 24px var(--glow-strong);

  color-scheme: light;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: var(--gradient-bg);
  background-attachment: fixed;
  transition: background-color 0.3s, color 0.3s;
}

/* ── Layout ────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 24px;
  padding: 24px 16px;
  max-width: calc(var(--content-max) + var(--nav-width) + 48px);
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 1159px) {
  .layout {
    flex-direction: column-reverse;
    max-width: var(--content-max);
    gap: 16px;
  }
}


/* ── Site header ───────────────────────────────────────────── */
site-header {
  display: block;
  background: var(--gradient-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 12px var(--glow-color);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
}

.site-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-header__home-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px 12px;
  font-size: 0.85rem;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.site-header__home-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow-color);
}

.site-header__home-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

html:not(.light) .site-header__home-btn svg{
  filter: invert(100%);
}


.site-header__name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.site-header__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-header__right a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.15s, filter 0.15s;
}

.site-header__right a:hover {
  color: var(--text-primary);
  filter: drop-shadow(0 0 4px var(--glow-color));
}

.site-header__right svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.site-header__divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

.site-header__theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.site-header__theme-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--glow-color);
}

.site-header__theme-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ── Nav pane ──────────────────────────────────────────────── */
nav-pane {
  display: block;
  width: 220px;
  flex-shrink: 0;
}

@media (max-width: 1159px) {
  nav-pane {
    width: 100%;
  }
}

.nav-pane__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}


.nav-pane__item {
  margin-bottom: 8px;
}

@media (max-width: 1159px) {
  .nav-pane__list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-pane__item {
    flex: 0 0 auto;
    margin-bottom: 0px;
  }
}



.nav-pane__item button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--gradient-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.nav-pane__item button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow-color);
}

.nav-pane__item button.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glow-strong),
              inset 0 0 12px var(--glow-color);
}

.nav-pane__item {
  position: relative;
}

.nav-pane__item .final {
  background: rgb(255, 255, 224);
}
.nav-pane__item .final:hover {
  background: rgb(255, 255, 203);
}

html:not(.light) .final {
  background: #474725;
}
html:not(.light) .final:hover {
  background: #63632f;
}

html:not(.light) .nav-pane__item button {
  border: 1px solid #6b6b86;
  color: #bfbfd9;
}
html:not(.light) .nav-pane__item button.active {
  color: var(--accent);
  border-color: var(--accent);
}

.nav-pane__item span {
  display: block;
  position: absolute;
  bottom: -5px;
  right: -2px;
  font-size: 8pt;
  padding: 0px 4px;
  border: none;
  border-radius: 4px;
  background: rgba(123, 158, 240, 0.30);
  color: var(--text-muted);
}

html:not(.light) .nav-pane__item span {
  color: #cdcdcd;
  background: #526393cc;
}

/* ── Content pane ──────────────────────────────────────────── */
content-pane {
  display: block;
  flex: 1;
  max-width: 960px;
  min-width: 0;
}

.content-pane__area {
  background: var(--gradient-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  min-height: 400px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s, background 0.3s, border-color 0.3s;
}

.content-pane__area:hover {
  box-shadow: var(--shadow-card-hover);
}

@media (max-width: 600px) {
  .content-pane__area {
    padding: 20px 16px;
  }
}

/* ── Shared prose styles ───────────────────────────────────── */
.prose h1 {
  font-size: 1.75rem;
  margin-bottom: 0.6em;
  color: var(--text-primary);
}

.prose h2 {
  font-size: 1.35rem;
  margin-top: 1.4em;
  margin-bottom: 0.5em;
  color: var(--text-primary);
}

.prose h3 {
  font-size: 1.1rem;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  color: var(--text-primary);
}

.prose p {
  margin-bottom: 1em;
  color: var(--text-secondary);
}

.prose ul, .prose ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
  color: var(--text-secondary);
}

.prose li {
  margin-bottom: 0.35em;
}

.prose a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

.prose a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.prose code {
  background: var(--bg-surface-alt);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.prose pre {
  background: var(--bg-surface-alt);
  padding: 1em;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1em;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  margin-bottom: 1em;
  color: var(--text-muted);
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

body.background {
  background-image: url(i/ai_rats_hor.png);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

body.background .nav-pane__item button.active {
  background: var(--gradient-surface);
}

body.background .content-pane__area {
  background: rgba(255, 255, 255, 0.7);
}

html:not(.light) body.background .content-pane__area {
  background: rgba(30, 30, 40, 0.7);
}

html:not(.light) .th {
  background: #3d3d3d;
}

html:not(.light) .section-header2 {
  color: #afc4eb;
}

.footer {
    width: 100%; 
    font-size: 10pt;
    margin-top: 20px;
    color: var(--text-muted);
    text-align: center;
}

#goTopBtn {
    display: none; 
    position: fixed; 
    bottom: 26px; 
    left: 45%;
    z-index: 99; 
    border: none;
    outline: none;
    background-color: rgba(106, 164, 230, 0.8);
    color: rgb(255, 255, 255);
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12pt;
}

#goTopBtn:hover {
    background-color: #555; /* Add a hover effect */
}

@media (max-width: 700px) {
  /* CSS rules to be applied when the screen width is 700px or less */

  .layout { 
    padding: 8px 2px;
    gap: 8px;
  }

  .nav-pane__item button {
    font-size: 9.5pt;
    border-radius: 4px;
    padding: 6px 8px;
  }
}