/* ── Sidebar — always dark regardless of page theme ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: blur(48px) saturate(200%) brightness(95%);
  -webkit-backdrop-filter: blur(48px) saturate(200%) brightness(95%);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Subtle inner-edge specular on sidebar */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.12) 20%,
    rgba(255, 255, 255, 0.06) 60%,
    transparent 100%
  );
  pointer-events: none;
}

/* ── Logo area ── */
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 22px 24px;
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--c-cream);
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  position: relative;
}

/* Subtle gradient shimmer behind logo area */
.sidebar__logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--c-blue) 12%, transparent) 0%,
    color-mix(in srgb, var(--c-purple) 6%, transparent) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.sidebar__logo .sc-mark {
  flex-shrink: 0;
  color: var(--c-cream);
  --mark-bg: transparent;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c-blue) 35%, transparent));
  position: relative;
  z-index: 1;
}

.sidebar__logo span {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, var(--c-cream) 0%, color-mix(in srgb, var(--c-purple) 55%, white) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Nav ── */
.sidebar__nav {
  display: flex;
  flex-direction: column;
  padding: 14px 0 8px;
  gap: 1px;
  flex: 1;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 22px;
  font-family: var(--f-body);
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
  letter-spacing: 0.01em;
  position: relative;
}

.sidebar__num {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 180ms ease;
}

.sidebar__link:hover {
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.055);
}

.sidebar__link:hover .sidebar__num {
  opacity: 0.7;
}

.sidebar__link.active {
  color: var(--c-cream);
  border-left-color: var(--c-blue);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c-blue) 14%, transparent) 0%, transparent 100%);
}

.sidebar__link.active .sidebar__num {
  opacity: 0.8;
}

/* Glowing indicator for active item */
.sidebar__link.active::after {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 60%;
  background: var(--c-blue);
  border-radius: 2px;
  box-shadow:
    0 0 10px 2px color-mix(in srgb, var(--c-blue) 65%, transparent),
    0 0 4px color-mix(in srgb, var(--c-blue) 80%, transparent);
}

/* ── Bottom area: copy button + theme toggle + version ── */
.sidebar__bottom {
  padding: 16px 22px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.copy-md-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.50);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  margin-bottom: 10px;
}

.copy-md-btn:hover {
  background: color-mix(in srgb, var(--c-purple) 10%, transparent);
  border-color: color-mix(in srgb, var(--c-purple) 35%, transparent);
  color: var(--c-cream);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c-purple) 12%, transparent);
}

.copy-md-btn i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.copy-md-btn--copied {
  background: color-mix(in srgb, var(--c-green) 10%, transparent);
  border-color: color-mix(in srgb, var(--c-green) 40%, transparent);
  color: var(--c-green);
}

.copy-md-btn--error {
  background: color-mix(in srgb, var(--c-red) 10%, transparent);
  border-color: color-mix(in srgb, var(--c-red) 40%, transparent);
  color: var(--c-red);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.50);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  margin-bottom: 12px;
}

.theme-toggle:hover {
  background: color-mix(in srgb, var(--c-blue) 12%, transparent);
  border-color: color-mix(in srgb, var(--c-blue) 35%, transparent);
  color: var(--c-cream);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c-blue) 14%, transparent);
}

.theme-toggle i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sidebar__version {
  font-family: var(--f-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.22);
  letter-spacing: 0.08em;
  text-align: center;
}

/* ── Light mode overrides ── */
html[data-theme="light"] .sidebar__logo {
  color: var(--c-black);
  border-bottom-color: rgba(0, 0, 0, 0.07);
}
html[data-theme="light"] .sidebar__logo::before {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--c-blue) 6%, transparent) 0%,
    color-mix(in srgb, var(--c-purple) 4%, transparent) 50%,
    transparent 100%
  );
}
html[data-theme="light"] .sidebar__logo .sc-mark {
  color: var(--c-black);
}
html[data-theme="light"] .sidebar__logo span {
  background: linear-gradient(145deg, var(--c-black) 0%, color-mix(in srgb, var(--c-purple) 55%, var(--c-black)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
html[data-theme="light"] .sidebar__link {
  color: rgba(0, 0, 0, 0.45);
}
html[data-theme="light"] .sidebar__link:hover {
  color: rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.04);
}
html[data-theme="light"] .sidebar__link.active {
  color: var(--c-black);
}
html[data-theme="light"] .sidebar__bottom {
  border-top-color: rgba(0, 0, 0, 0.07);
}
html[data-theme="light"] .copy-md-btn,
html[data-theme="light"] .theme-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.50);
}
html[data-theme="light"] .copy-md-btn:hover {
  background: color-mix(in srgb, var(--c-purple) 8%, transparent);
  border-color: color-mix(in srgb, var(--c-purple) 30%, transparent);
  color: var(--c-black);
}
html[data-theme="light"] .theme-toggle:hover {
  background: color-mix(in srgb, var(--c-blue) 8%, transparent);
  border-color: color-mix(in srgb, var(--c-blue) 28%, transparent);
  color: var(--c-black);
}
html[data-theme="light"] .sidebar__version {
  color: rgba(0, 0, 0, 0.28);
}
html[data-theme="light"] .sidebar__toggle {
  color: var(--c-black);
}

/* ── Mobile toggle button ── */
.sidebar__toggle {
  display: none;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }
  .sidebar::after { display: none; }
  .sidebar__logo {
    padding: 14px 18px;
    border-bottom: none;
    flex: 1;
  }
  .sidebar__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    background: none;
    border: none;
    color: var(--c-cream);
    cursor: pointer;
  }
  .sidebar__nav {
    width: 100%;
    padding: 8px 0;
    display: none;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: color-mix(in srgb, var(--c-black) 92%, black);
    flex: none;
  }
  .sidebar__nav.open { display: flex; }
  .sidebar__link { padding: 11px 18px; }
  .sidebar__bottom { display: none; }
}
