/* === Root Variables (新增) === */
:root {
  --color-bg: #0B0D17;
  --color-surface: #1A1F2E;
  --color-border: #2D354A;
  --color-text-primary: #F0F4F8;
  --color-text-secondary: #9AA3B5;
  --color-text-muted: #8C9CAB;
  --color-accent: #00E5FF;
  --color-accent-hover: #0A66C2;
  --color-accent-bright: #00E5FF;
  --font-heading: 'Exo 2', 'Orbitron', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --header-width: 250px;
  --transition-speed: 0.2s;
}

/* === Reset & Base === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#main-content {
  flex: 1;
  min-width: 0;
  padding: 1rem;
  margin-left: var(--header-width);
}

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

/* === Skip Link === */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-accent);
  color: var(--color-bg);
  padding: 0.5rem 1rem;
  font-weight: 700;
  text-decoration: none;
  z-index: 1000;
  transition: top var(--transition-speed);
  clip: rect(1px, 1px, 1px, 1px);
  overflow: hidden;
}

.skip-link:focus {
  top: 0;
  clip: auto;
  overflow: visible;
}

/* === Header / Side Navigation === */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--header-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 900;
  overflow-y: auto;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--color-accent);
  letter-spacing: 0.05em;
}

.brand-tagline {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

.nav-toggle {
  display: none; /* 桌面隐藏 */
  background: none;
  border: none;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  position: relative;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  display: block;
  background: var(--color-text-primary);
  height: 2px;
  width: 100%;
  position: absolute;
  left: 0;
  transition: transform 0.3s;
}

.nav-toggle-icon {
  top: 50%;
  transform: translateY(-50%);
}

.nav-toggle-icon::before {
  top: -7px;
}

.nav-toggle-icon::after {
  top: 7px;
}

[data-open] .nav-toggle-icon {
  background: transparent;
}

[data-open] .nav-toggle-icon::before {
  top: 0;
  transform: rotate(45deg);
}

[data-open] .nav-toggle-icon::after {
  top: 0;
  transform: rotate(-45deg);
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.version-hint {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.5rem;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 1rem;
}

.nav-link {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--color-text-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: background var(--transition-speed), color var(--transition-speed);
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--color-accent-hover);
  color: var(--color-text-primary);
}

.nav-link[aria-current="page"] {
  background: var(--color-accent-hover);
  color: var(--color-accent-bright);
  box-shadow: inset 3px 0 0 var(--color-accent-bright);
}

.nav-toggle:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--color-accent-bright);
  outline-offset: 2px;
}

/* === Main content offset === */
#main-content {
  margin-left: var(--header-width);
  padding-top: 0;
}

/* === Footer === */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 2rem 1rem;
  margin-left: var(--header-width);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.footer-brand .brand-name {
  font-size: 1.2rem;
}

.footer-brand .brand-tagline {
  font-size: 0.6rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color var(--transition-speed);
}

.footer-links a:hover {
  color: var(--color-accent);
}

.footer-contact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.footer-copyright {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* === Universal components === */
.trust-statement {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-accent);
  border-radius: 4px;
  margin: 1rem 0;
}

/* === Reading Progress Bar === */
#reading-progress {
  position: fixed;
  top: 0;
  left: var(--header-width); /* 侧边栏右侧 */
  width: calc(100% - var(--header-width));
  height: 4px;
  background: transparent;
  z-index: 950;
  pointer-events: none;
}

#reading-progress::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 0.1s ease;
}

/* === Back to Top === */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--color-accent-hover);
  border: none;
  border-radius: 50%;
  color: var(--color-text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.back-to-top.is-visible {
  display: flex;
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--color-accent);
  color: var(--color-bg);
  transform: scale(1.1);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  #main-content,
  .site-footer,
  #reading-progress {
    margin-left: 0;
  }

  #reading-progress {
    left: 0;
    width: 100%;
  }

  .site-header {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .site-header-inner {
    padding: 0.75rem 1rem;
  }

  .nav-toggle {
    display: block;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-accent-hover);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    max-height: 80vh;
    overflow-y: auto;
  }

  .nav[data-open] {
    display: flex;
  }

  .nav-list {
    padding: 0.5rem 1rem 1rem;
  }

  .site-footer-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .back-to-top {
    right: 1rem;
    bottom: 1rem;
  }
}
