:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.35);
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --link: #2563eb;
}

:root.dark {
  --bg: #020617;
  --fg: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.28);
  --surface: #0f172a;
  --surface-soft: #111827;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --link: #93c5fd;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--accent-strong);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2000;
  padding: 10px 12px;
  border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

button,
input,
select,
textarea {
  font: inherit;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

main,
header,
footer {
  display: block;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding-inline: 16px;
}

footer {
  margin-top: 24px;
  padding: 16px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.small {
  font-size: 0.9rem;
  color: var(--muted);
}

.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

:root.dark .card {
  background: rgba(15, 23, 42, 0.82);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.lang-switch {
  margin-top: 8px;
}

.lang-switch summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.lang-switch summary::-webkit-details-marker {
  display: none;
}

.lang-switch summary::after {
  content: "▾";
  font-size: 0.8em;
}

.lang-switch[open] summary::after {
  content: "▴";
}

.lang-switch[open] summary {
  margin-bottom: 8px;
}

.lang-switch a {
  color: var(--link);
  text-decoration: none;
}

.lang-switch a:hover {
  text-decoration: underline;
}

.lang-switch a.is-current {
  font-weight: 600;
  color: var(--fg);
  cursor: default;
  text-decoration: none;
}

.lang-switch a.is-disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
  text-decoration: none;
}

.breadcrumb,
.latex-page header > nav {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.breadcrumb a,
.latex-page header > nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.breadcrumb span:not(.sep) {
  color: var(--fg);
  font-weight: 600;
}

.breadcrumb span.sep {
  margin: 0 4px;
  color: var(--muted);
}

.latex-page header > nav > span {
  color: var(--muted);
  font-weight: 400;
}

.latex-page header > nav > span:last-child {
  color: var(--fg);
  font-weight: 600;
}

.global-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 12px;
  padding: 0;
  min-height: 44px;
  font-size: 0.95rem;
  color: var(--fg);
}

.global-nav a,
.global-nav summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.global-nav a:hover,
.global-nav summary:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.global-nav a[data-global-search] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.global-nav a[data-global-search]:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.global-nav a.is-current:not([data-global-search]) {
  background: var(--surface-soft);
  border-color: var(--accent);
}

.global-nav a.global-brand {
  border-color: transparent;
  background: transparent;
  padding-left: 0;
  padding-right: 6px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.global-nav a.global-brand:hover {
  border-color: transparent;
  background: transparent;
  transform: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.global-nav a.global-brand .brand-tld {
  font-weight: 700;
  opacity: 0.75;
}

.global-nav-menu {
  position: relative;
}

.global-nav-menu summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.global-nav-menu summary::-webkit-details-marker {
  display: none;
}

.global-nav-menu summary::after {
  content: "▾";
  font-size: 0.8em;
  opacity: 0.7;
  margin-left: 4px;
}

.global-nav-menu[open] summary::after {
  content: "▴";
}

.global-nav-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.global-nav-panel a {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 4px 0;
  color: var(--link);
  transform: none;
}

.global-nav-panel a:hover {
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
  transform: none;
}

.global-nav-drawer summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.global-nav-drawer summary::-webkit-details-marker {
  display: none;
}

.global-nav-drawer summary::before {
  content: "☰";
  margin-right: 8px;
  font-size: 1.05em;
}

.global-nav-drawer[open] summary::before {
  content: "✕";
}

.global-nav-drawer-panel {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

ul.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

ul.link-list > li {
  display: grid;
  gap: 0.25rem;
}

ul.link-list > li > a {
  color: var(--link);
  font-weight: 600;
  text-decoration: none;
}

ul.link-list > li > a:hover {
  text-decoration: underline;
}

ul.link-list > li > .small {
  margin-top: 0.15rem;
}

.ad-slot {
  display: block;
  width: 100%;
  min-height: var(--ad-slot-min-height, 280px);
}

.ad-slot:empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.ad-slot[data-ad]:not(:empty) {
  border: 0 !important;
  background: transparent !important;
}

#comments button {
  margin-bottom: 8px;
}

.consent-banner {
  position: fixed;
  inset-inline: 1rem;
  bottom: 1rem;
  z-index: 70;
}

.consent-banner__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
}

.consent-banner__copy {
  flex: 1 1 28rem;
}

.consent-banner__copy p {
  margin: 0;
}

.consent-banner__copy > p:first-child {
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.consent-banner__copy p + p {
  margin-top: 0.45rem;
}

.consent-banner__links {
  font-size: 0.9rem;
}

.consent-banner__links a {
  color: #bfdbfe;
}

.consent-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.consent-banner__actions button,
.consent-banner__manage,
.consent-reopen {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.85rem;
  background: #e2e8f0;
  color: #0f172a;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
}

.consent-banner__actions button[data-consent-accept] {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.consent-banner__actions button[data-consent-reject] {
  background: transparent;
  color: #f8fafc;
}

.consent-banner__manage {
  display: none !important;
}

.consent-banner:not(.is-active) {
  display: none;
}

.consent-reopen {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 69;
}

.consent-reopen.is-hidden {
  display: none;
}

:root.dark .consent-banner__actions button,
:root.dark .consent-banner__manage,
:root.dark .consent-reopen {
  background: #1e293b;
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
}

:root.dark .consent-banner__actions button[data-consent-accept] {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

@media (max-width: 720px) {
  .consent-banner__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .consent-banner__actions {
    justify-content: stretch;
  }

  .consent-banner__actions button,
  .consent-banner__manage,
  .consent-reopen {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .global-nav {
    position: relative;
  }

  .global-nav-drawer {
    margin-left: auto;
  }

  .global-nav-drawer-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 80;
  }

  .global-nav-drawer-panel a,
  .global-nav-drawer-panel summary,
  .global-nav-drawer-panel .theme-toggle {
    width: 100%;
  }

  .global-nav-panel {
    position: static;
    min-width: 0;
    grid-template-columns: 1fr;
    padding: 6px 0 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }
}
