:root {
  color-scheme: light dark;
  font-size: 100%;
}

:root[data-font-scale="small"] {
  font-size: 94%;
}

:root[data-font-scale="normal"] {
  font-size: 100%;
}

:root[data-font-scale="large"] {
  font-size: 108%;
}

:root[data-font-scale="xlarge"] {
  font-size: 116%;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #f8fafc;
  color: #374151;
}

body.dark {
  background: #0f172a;
  color: #e2e8f0;
}

header.shrinkable-header {
  transition: padding 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

header.shrinkable-header .container.mx-auto {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  transition: padding 0.25s ease, gap 0.25s ease;
}

header.shrinkable-header .flex.flex-wrap {
  transition: gap 0.25s ease;
}

header.shrinkable-header img {
  transition: height 0.25s ease, transform 0.25s ease;
}

header.shrinkable-header nav {
  transition: padding 0.25s ease;
}

header.shrinkable-header.header-compact {
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

body.dark header.shrinkable-header.header-compact {
  background-color: rgba(15, 23, 42, 0.9);
  box-shadow: 0 6px 22px rgba(2, 6, 23, 0.4);
}

header.shrinkable-header.header-compact .container.mx-auto {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

header.shrinkable-header.header-compact .flex.flex-wrap {
  gap: 0.75rem;
}

header.shrinkable-header.header-compact img.h-10 {
  height: 2.25rem !important;
}

header.shrinkable-header.header-compact img.h-16 {
  height: 2.75rem !important;
}

header.shrinkable-header.header-compact .text-lg {
  font-size: 1rem;
}

header.shrinkable-header.header-compact .text-xs {
  display: none;
}

header.shrinkable-header.header-compact nav {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

main {
  scroll-margin-top: 7rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: rgba(15, 23, 42, 0.05);
  color: #1b5e20;
  transition: all 0.2s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: rgba(15, 23, 42, 0.12);
  color: #064e3b;
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
}

.theme-toggle span {
  font-weight: 600;
}

.theme-toggle[data-mode="dark"],
body.dark .theme-toggle {
  color: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.18);
}

.font-size-widget {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid rgba(27, 94, 32, 0.3);
  background: rgba(255, 255, 255, 0.85);
  color: #1b5e20;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  backdrop-filter: blur(6px);
  box-shadow: 0 10px 25px -20px rgba(15, 23, 42, 0.45);
}

body.dark .font-size-widget {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(15, 23, 42, 0.65);
  color: #a7f3d0;
}

.font-size-widget button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.2rem 0.6rem;
  border-radius: 0.55rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.font-size-widget button:hover,
.font-size-widget button:focus-visible {
  background-color: rgba(27, 94, 32, 0.14);
}

body.dark .font-size-widget button:hover,
body.dark .font-size-widget button:focus-visible {
  background-color: rgba(16, 185, 129, 0.25);
}

.font-size-widget button:focus-visible {
  outline: 2px solid #1b5e20;
  outline-offset: 2px;
}

body.dark .font-size-widget button:focus-visible {
  outline: 2px solid #34d399;
}

.font-size-widget button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: transparent;
}

.font-size-widget-divider {
  width: 1px;
  height: 1.1rem;
  background: rgba(27, 94, 32, 0.3);
}

body.dark .font-size-widget-divider {
  background: rgba(16, 185, 129, 0.35);
}

.font-size-widget-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(27, 94, 32, 0.7);
}

body.dark .font-size-widget-label {
  color: rgba(110, 231, 183, 0.8);
}

#reading-progress {
  transform-origin: left;
}

.code-container,
.code-block {
  position: relative;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}

pre[class*="language-"] {
  border-radius: 0.75rem;
  font-family: 'Source Code Pro', Consolas, "Fira Code", monospace;
  font-size: 0.95em;
  margin: 0;
  padding-right: 3rem;
}

.copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.35rem 0.9rem;
  background-color: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  border: none;
  border-radius: 9999px;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.copy-btn::before {
  content: '\2398';
  font-size: 0.9rem;
}

.code-block:hover .copy-btn,
.code-container:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.copy-btn.copied {
  background-color: rgba(16, 185, 129, 0.9);
}

.toc-link {
  display: block;
  padding: 0.35rem 0.25rem;
  font-size: 0.9rem;
  color: #475569;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

body.dark .toc-link {
  color: #cbd5f5;
}

.toc-link:hover,
.toc-link:focus-visible {
  background-color: rgba(16, 185, 129, 0.12);
  color: #059669;
  padding-left: 0.5rem;
}

.toc-link.active {
  background-color: rgba(16, 185, 129, 0.18);
  color: #047857;
  font-weight: 600;
  padding-left: 0.75rem;
}

body.dark .toc-link.active {
  background-color: rgba(34, 197, 94, 0.18);
  color: #34d399;
}

.pwa-install-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  z-index: 1000;
}

.pwa-install-overlay[hidden] {
  display: none !important;
}

body.dark .pwa-install-overlay {
  background: rgba(15, 23, 42, 0.65);
}

body.pwa-install-visible {
  overflow: hidden;
}

.pwa-install-dialog {
  position: relative;
  max-width: 420px;
  width: 100%;
  border-radius: 1.5rem;
  padding: 2.25rem 2rem;
  background: #ffffff;
  box-shadow: 0 40px 70px -30px rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

body.dark .pwa-install-dialog {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

.pwa-install-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: none;
  color: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 9999px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.dark .pwa-install-close {
  color: rgba(226, 232, 240, 0.75);
}

.pwa-install-close:hover,
.pwa-install-close:focus-visible {
  background-color: rgba(27, 94, 32, 0.12);
  color: rgba(27, 94, 32, 0.95);
}

body.dark .pwa-install-close:hover,
body.dark .pwa-install-close:focus-visible {
  background-color: rgba(16, 185, 129, 0.18);
  color: #bbf7d0;
}

.pwa-install-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pwa-install-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1rem;
  background: rgba(27, 94, 32, 0.12);
  color: #1b5e20;
}

body.dark .pwa-install-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.pwa-install-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1b5e20;
  margin: 0;
}

body.dark .pwa-install-title {
  color: #6ee7b7;
}

.pwa-install-description {
  margin: 0 0 1rem;
  color: rgba(15, 23, 42, 0.75);
  line-height: 1.6;
}

body.dark .pwa-install-description {
  color: rgba(226, 232, 240, 0.75);
}

.pwa-install-benefits {
  margin: 0 0 1.5rem;
  padding-left: 1.2rem;
  color: rgba(15, 23, 42, 0.78);
  font-size: 0.92rem;
  line-height: 1.6;
}

.pwa-install-benefits li + li {
  margin-top: 0.4rem;
}

body.dark .pwa-install-benefits {
  color: rgba(226, 232, 240, 0.75);
}

.pwa-install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pwa-install-btn,
.pwa-install-secondary {
  border: none;
  border-radius: 9999px;
  font-weight: 600;
  cursor: pointer;
  padding: 0.65rem 1.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.pwa-install-btn {
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  color: #ecfdf5;
  box-shadow: 0 20px 40px -18px rgba(27, 94, 32, 0.6);
}

.pwa-install-btn:hover,
.pwa-install-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 24px 40px -16px rgba(27, 94, 32, 0.7);
}

.pwa-install-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.pwa-install-secondary {
  background: rgba(15, 23, 42, 0.08);
  color: #1b5e20;
}

body.dark .pwa-install-secondary {
  background: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

.pwa-install-secondary:hover,
.pwa-install-secondary:focus-visible {
  background: rgba(27, 94, 32, 0.18);
}

body.dark .pwa-install-secondary:hover,
body.dark .pwa-install-secondary:focus-visible {
  background: rgba(16, 185, 129, 0.28);
}

.pwa-install-hint {
  font-size: 0.78rem;
  color: rgba(15, 23, 42, 0.6);
  margin: 0;
}

body.dark .pwa-install-hint {
  color: rgba(226, 232, 240, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
