* {
  box-sizing: border-box;
}

:root {
  --primary: #5340c8;
  --primary-hover: #3f30a3;
  --secondary: #13d2ea;
  --color-fg-default: #1f2328;
  --color-fg-muted: #636c76;
  --color-canvas-default: #ffffff;
  --color-canvas-subtle: #f6f8fa;
  --color-border-default: #d0d7de;
  --color-accent-fg: #0969da;
  --color-btn-bg: #f6f8fa;
  --sidebar-width: 260px;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Plus Jakarta Sans";
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-fg-default);
  background-color: var(--color-canvas-default);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

body.home-mode {
  overflow-x: hidden;
  overflow-y: auto;
}

/* Ensure font is applied to form elements */
button,
input,
select,
textarea {
  font-family: inherit;
}

/* Monospace fonts for code */
code,
pre code {
  font-family:
    ui-monospace,
    SFMono-Regular,
    SF Mono,
    Menlo,
    Consolas,
    Liberation Mono,
    monospace !important;
}

/* Navbar */
.header {
  background-color: #24292f;
  color: rgba(255, 255, 255, 0.7);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
}

.header-brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.header-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.header-link {
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}

.header-link:hover {
  color: rgba(255, 255, 255, 0.7);
}

/* Layout */
.container-main {
  display: flex;
  width: 100%;
  margin: 0;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  padding: 32px 16px;
  border-right: 1px solid var(--color-border-default);
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
  background-color: var(--color-canvas-default);
  overflow-y: auto;
  display: none;
}

.docs-mode #sidebar {
  display: block;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-title {
  font-size: 11px;
  font-weight: 700;
  color: #8c959f;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 0 8px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-title i {
  font-size: 14px;
  color: var(--color-fg-muted);
}

.nav-item {
  display: block;
  padding: 6px 12px;
  color: #484f58;
  text-decoration: none;
  font-size: 14px;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: all 0.1s ease;
}

.nav-item:hover {
  background-color: rgba(208, 215, 222, 0.32);
  color: var(--color-fg-default);
}

.nav-item.active {
  font-weight: 600;
  background-color: #f0effc;
  color: var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: 2px 6px 6px 2px;
}

/* Submenu Styles */
.nav-item-group {
  margin-bottom: 2px;
}

.nav-submenu {
  padding-left: 16px;
  display: none;
  margin-top: 2px;
  margin-bottom: 8px;
}

.nav-item.active + .nav-submenu,
.nav-item-group:has(.nav-item.active) .nav-submenu {
  display: block;
}

.nav-subitem {
  display: block;
  padding: 4px 12px;
  color: var(--color-fg-muted);
  text-decoration: none;
  font-size: 13px;
  border-radius: 0;
  transition: all 0.1s ease;
  border-left: 1px solid var(--color-border-default);
  margin-left: 8px;
}

.nav-subitem:hover {
  color: var(--primary);
  background-color: rgba(83, 64, 200, 0.05);
  border-left-color: var(--primary);
}

.nav-subitem.active {
  color: var(--primary);
  font-weight: 600;
  border-left: 4px solid var(--primary);
  background-color: rgba(83, 64, 200, 0.05);
  border-radius: 0 6px 6px 0;
}

/* Documentation Content Icons */
.doc-header-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 12px;
  display: block;
}

.markdown-body h1 i,
.markdown-body h2 i,
.markdown-body h3 i {
  margin-right: 8px;
  color: var(--primary);
  vertical-align: middle;
}

.markdown-body ul li i {
  margin-right: 6px;
  color: var(--primary);
  font-size: 1.1em;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
}

.lang-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
}

.lang-btn.active {
  opacity: 1;
  border-color: var(--secondary);
  color: var(--secondary);
}

/* Content */
#content-wrapper {
  flex: 1;
  min-width: 0;
  padding: 40px 64px;
}

.docs-mode #content-wrapper {
  width: calc(100% - var(--sidebar-width));
}

.home-mode #content-wrapper {
  width: 100%;
  padding: 0;
}

.page-loader {
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-fg-muted);
  font-weight: 600;
  animation: loader-fade-in 0.18s ease-out both;
}

.page-loader-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(83, 64, 200, 0.16);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: loader-spin 0.75s linear infinite;
}

.page-loader-text {
  line-height: 1;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loader-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-loader,
  .page-loader-spinner {
    animation: none;
  }
}

/* Markdown Body (GitHub Style) */
.markdown-body {
  font-size: 16px;
  word-wrap: break-word;
}

.markdown-body h1 {
  font-size: 2em;
  border-bottom: 1px solid var(--color-border-default);
  padding-bottom: 0.3em;
  margin-top: 0;
  margin-bottom: 24px;
}
.markdown-body h2 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--color-border-default);
  padding-bottom: 0.3em;
  margin-top: 48px;
  margin-bottom: 16px;
}
.markdown-body h3 {
  font-size: 1.25em;
  margin-top: 32px;
  margin-bottom: 12px;
}
.markdown-body p {
  margin-top: 0;
  margin-bottom: 20px;
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 20px;
}

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 8px;
}

/* Tables (GitHub Style) */
.markdown-body table {
  display: block;
  width: 100%;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  border-spacing: 0;
  border-collapse: collapse;
  margin-top: 0;
  margin-bottom: 16px;
}

.markdown-body table th {
  font-weight: 600;
  background-color: var(--color-canvas-subtle);
}
.markdown-body table th,
.markdown-body table td {
  padding: 6px 13px;
  border: 1px solid var(--color-border-default);
}

.markdown-body table tr {
  background-color: var(--color-canvas-default);
  border-top: 1px solid var(--color-border-default);
}
.markdown-body table tr:nth-child(2n) {
  background-color: var(--color-canvas-subtle);
}

/* Code Blocks */
.markdown-body pre {
  background-color: var(--color-canvas-subtle);
  border-radius: 6px;
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  margin-bottom: 16px;
}

.markdown-body code {
  font-family:
    ui-monospace,
    SFMono-Regular,
    SF Mono,
    Menlo,
    Consolas,
    Liberation Mono,
    monospace;
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(175, 184, 193, 0.2);
  border-radius: 6px;
}

.markdown-body pre code {
  padding: 0;
  background-color: transparent;
  font-size: 100%;
}

/* Buttons */
.btn-github {
  display: inline-block;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  background-color: var(--color-btn-bg);
  color: var(--color-fg-default);
  text-decoration: none;
}

.btn-github:hover {
  background-color: #f3f4f6;
  border-color: #1b1f2326;
}

.btn-primary-github {
  background-color: var(--primary);
  color: #fff;
  border-color: rgba(27, 31, 35, 0.15);
}

.btn-primary-github:hover {
  background-color: var(--primary-hover);
  color: #fff;
}

/* Home Layout (Center Middle & Cover) */
.home-mode .container-main {
  position: relative;
  z-index: 10;
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  background: transparent;
}

.home-mode .header {
  z-index: 100;
}

.home-hero,
.site-footer {
  background: transparent !important; /* Ensure all components are transparent */
}

.home-mode #content-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  padding: 0;
}

.home-mode #home-hero-wrapper {
  flex: 0 0 auto;
  width: 100%;
}

/* Spacer to push content to middle while keeping footer at bottom */
.home-mode #home-hero-wrapper {
  margin-top: auto;
}

.home-mode #site-footer-wrapper {
  margin-top: auto;
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Hero Section for Home (Restored Text Size) */
.home-hero {
  padding: 0 16px 32px;
  text-align: center;
  background-color: transparent;
  width: 100%;
}

.home-hero img {
  width: 100px;
  height: 100px;
  margin-bottom: 24px;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(149, 157, 165, 0.2);
}

.home-hero h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 16px;
  border: none;
  letter-spacing: -0.04em;
}

.home-hero p {
  font-size: 20px;
  color: var(--color-fg-muted);
  max-width: 800px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.home-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 24px;
}

.home-badges a {
  display: inline-flex;
  line-height: 0;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.home-badges a:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.home-badges img {
  display: block;
  height: 20px;
  width: auto;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.home-hero-btns {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Quick Install Bar */
.home-quick-install {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--color-canvas-subtle);
  border: 1px solid var(--color-border-default);
  padding: 9px 10px 10px 14px;
  border-radius: 8px;
  max-width: min(100%, 420px);
  margin: 0 auto 32px;
  font-family:
    ui-monospace,
    SFMono-Regular,
    SF Mono,
    Menlo,
    monospace;
  white-space: nowrap;
}

.home-quick-install code {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--color-fg-default);
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-action {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--color-fg-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s ease;
}

.install-action:hover {
  background-color: rgba(175, 184, 193, 0.2);
  color: var(--primary);
}

.npm-link {
  font-size: 18px;
}

.copy-btn.copied {
  color: #2da44e;
}

/* Footer Sticky at Bottom */
.site-footer {
  width: 100%;
  max-width: 1012px;
  margin: 40px auto 0;
  padding: 24px 16px 20px;
  border-top: 1px solid var(--color-border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-fg-muted);
  font-size: 12px;
  background-color: transparent;
}

.home-mode .site-footer {
  border-top: none;
  margin-top: auto; /* Push to bottom of flex container if needed */
  padding-bottom: 20px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-link {
  color: var(--color-accent-fg);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-link-credit {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.footer-link-credit:hover {
  text-decoration: underline;
}

/* Antigravity Interactive Background */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0; /* Above background but below content */
  pointer-events: none;
  display: none;
}

.home-mode #bg-canvas {
  display: block;
}

.floating-icon {
  position: absolute;
  opacity: 0.4;
  color: #78909c;
  pointer-events: none;
  filter: none;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  body.home-mode {
    overflow-y: auto; /* Allow scroll on small home screens */
  }

  body {
    padding-top: 96px;
  }

  .header {
    min-height: 96px;
    padding: 10px 16px 12px;
    justify-content: flex-start;
    align-content: flex-start;
    flex-wrap: wrap;
    gap: 8px 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .header-brand {
    min-width: 0;
    height: 32px;
  }

  .header-brand img {
    width: 30px;
    height: 30px;
  }

  .header-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .header-nav {
    display: flex;
    position: static;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .header-link {
    flex: 0 0 auto;
    font-size: 13px;
    line-height: 28px;
    padding: 0 2px;
  }

  .lang-switcher {
    flex: 0 0 auto;
    margin-right: 2px;
    justify-content: flex-start;
    gap: 6px;
  }

  .lang-btn {
    height: 24px;
    min-width: 34px;
    padding: 0 8px;
    line-height: 22px;
  }

  .container-main {
    flex-direction: column;
    width: 100%;
    min-width: 0;
    height: auto !important;
  }

  #sidebar {
    display: block;
    width: min(86vw, 340px);
    height: auto;
    max-height: none;
    border-right: 1px solid var(--color-border-default);
    border-bottom: none;
    position: fixed;
    top: 96px;
    bottom: 0;
    left: 0;
    z-index: 999;
    background: var(--color-canvas-default);
    padding: 20px 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 18px 0 40px rgba(31, 35, 40, 0.16);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  #sidebar.active,
  .docs-mode #sidebar.active,
  .home-mode #sidebar.active {
    transform: translateX(0);
  }

  #content-wrapper,
  .docs-mode #content-wrapper {
    flex: none;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    padding: 24px 16px;
  }

  .markdown-body {
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .markdown-body h1 {
    font-size: 1.75em;
    line-height: 1.25;
  }

  .markdown-body h2 {
    font-size: 1.35em;
    line-height: 1.3;
  }

  .markdown-body table,
  .markdown-body pre {
    max-width: 100%;
  }

  .markdown-body table {
    width: 100%;
  }

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

  .home-mode .container-main {
    min-height: calc(100vh - 96px);
  }

  .home-mode #content-wrapper {
    padding: 20px 0;
  }

  .home-hero h1 {
    font-size: 32px;
  }

  .home-hero p {
    font-size: 16px;
  }

  .home-badges {
    gap: 6px;
    padding: 0 12px;
  }

  .home-quick-install {
    width: calc(100% - 32px);
    max-width: 100%;
  }

  .home-hero-btns {
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    gap: 8px;
  }

  .home-hero-btns .btn-github {
    width: 100%;
    text-align: center;
    padding: 12px;
  }

  .site-footer {
    flex-direction: column;
    gap: 16px;
    text-align: center;
    padding: 24px 16px;
    position: static;
    transform: none;
  }

  .home-mode .site-footer {
    position: static;
    transform: none;
    margin-top: 40px;
  }

  .footer-links {
    justify-content: center;
  }
}
