:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #24292f;
  --muted: #57606a;
  --border: #d0d7de;
  --subtle: #f6f8fa;
  --accent: #0969da;
  --code-bg: rgba(175, 184, 193, 0.2);
  --nav-bg: rgba(255, 255, 255, 0.86);
  /* Rouge token colors -- same palette family as the hand-colored .op/.str/
     .num/.com classes on me.whatever.what.html etc., adapted for a light
     ground. Rouge can't tell a .me operator string ("@", "->") from an
     ordinary one, so both render as --hl-string; there's no light-mode
     equivalent of the pink .op accent here on purpose. */
  --hl-string: #0a7d3f;
  --hl-number: #b45309;
  --hl-comment: #6b7280;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1114;
    --fg: #c9d1d9;
    --muted: #8b949e;
    --border: #30363d;
    --subtle: #161b22;
    --accent: #58a6ff;
    --code-bg: rgba(110, 118, 129, 0.4);
    --nav-bg: rgba(11, 17, 20, 0.86);
    --hl-string: #86efac;
    --hl-number: #fbbf24;
    --hl-comment: #8b949e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 32px;
  min-height: 48px;
  box-sizing: border-box;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  line-height: 1;
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  flex: 0 0 auto;
}

.topbar-search {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 280px;
}

/* gui-searchbar ships as a self-contained widget with inline styles. These
   overrides keep the remote-theme topbar visually aligned with the neurons.me
   index page instead of falling back to the widget's default white surface. */
[data-gui-searchbar] input {
  min-width: 0;
}

[data-gui-searchbar] > div > div {
  border-color: rgba(9, 105, 218, 0.24) !important;
}

[data-gui-searchbar] > div > div:focus-within {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a {
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1;
}

.nav-links a:hover {
  color: var(--fg);
  background: var(--subtle);
  text-decoration: none;
}

.markdown-body {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 24px 0 16px;
  font-weight: 600;
  line-height: 1.25;
}

h1,
h2 {
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 2em;
}

h2 {
  font-size: 1.5em;
}

h3 {
  font-size: 1.25em;
}

p,
blockquote,
ul,
ol,
dl,
table,
pre,
details {
  margin-top: 0;
  margin-bottom: 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

hr {
  height: 0.25em;
  padding: 0;
  margin: 24px 0;
  background-color: var(--border);
  border: 0;
}

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

code,
kbd,
pre,
samp {
  font-family: ui-monospace, SFMono-Regular, SFMono, Consolas,
    "Liberation Mono", Menlo, monospace;
  font-size: 85%;
}

code {
  padding: 0.2em 0.4em;
  background-color: var(--code-bg);
  border-radius: 6px;
}

pre {
  padding: 16px;
  overflow: auto;
  background-color: var(--subtle);
  border-radius: 6px;
}

pre code {
  display: inline;
  padding: 0;
  overflow: visible;
  font-size: 100%;
  line-height: inherit;
  background: transparent;
  border: 0;
}

/* Rouge (Jekyll's fenced-code highlighter) token colors. Only real Rouge
   token classes are targeted -- .nx (identifiers) and .p (punctuation) stay
   the default foreground, since Rouge can't tell "me" from any other
   identifier, or a .me operator string like "@" from an ordinary one. */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .dl {
  color: var(--hl-string);
}

.highlight .c,
.highlight .c1,
.highlight .cm {
  color: var(--hl-comment);
  font-style: italic;
}

.highlight .m,
.highlight .mi,
.highlight .mf {
  color: var(--hl-number);
}

table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  border-spacing: 0;
  border-collapse: collapse;
}

th,
td {
  padding: 6px 13px;
  border: 1px solid var(--border);
}

tr {
  background-color: var(--bg);
  border-top: 1px solid var(--border);
}

tr:nth-child(2n) {
  background-color: var(--subtle);
}

@media (prefers-color-scheme: dark) {
  [data-gui-searchbar] > div > div {
    background: #111a1f !important;
    border-color: rgba(232, 237, 237, 0.1) !important;
  }

  [data-gui-searchbar] > div > div:focus-within {
    border-color: #4fd1c5 !important;
    box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.12);
  }

  [data-gui-searchbar] input {
    color: #e8eded !important;
  }

  [data-gui-searchbar] input::placeholder {
    color: #98a7b3 !important;
    opacity: 1 !important;
  }

  [data-gui-searchbar] > div > div > span:last-of-type {
    background: rgba(232, 237, 237, 0.1) !important;
    color: #98a7b3 !important;
  }

  [data-gui-searchbar] a[role="option"] {
    color: #e8eded !important;
    border-bottom-color: rgba(232, 237, 237, 0.08) !important;
  }

  [data-gui-searchbar] a[role="option"] > span:nth-child(2) > span:last-child,
  [data-gui-searchbar] a[role="option"] > span:last-child {
    color: #98a7b3 !important;
  }
}

@media (max-width: 767px) {
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    min-height: 0;
  }

  .topbar-search {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .nav-links a {
    padding: 6px 8px;
  }

  .markdown-body {
    padding: 24px 16px;
  }
}
