/* ============================================================
   base.css — 公共样式：reset、变量、星空背景、toolbar、响应式
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- Dark theme (default) ---- */
:root {
  --bg: #0b0e17;
  --surface: #13172a;
  --border: #1e2440;
  --text: #e2e8f0;
  --text-muted: #8892b0;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --accent-glow: rgba(108, 99, 255, .25);
  --green: #22c55e;
  --cyan: #06b6d4;
  --radius: 10px;
  --star-opacity: 1;
  --header-gradient-1: #fff;
  --header-gradient-2: var(--cyan);
  --card-hover-shadow: 0 8px 24px rgba(0,0,0,.3);
  --toggle-bg: #1e2440;
  --toggle-knob: #6c63ff;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #dfe3ec;
  --text: #1a1d2e;
  --text-muted: #5a6178;
  --accent: #5b52e0;
  --accent-hover: #4a42c8;
  --accent-glow: rgba(91, 82, 224, .15);
  --green: #16a34a;
  --cyan: #0891b2;
  --star-opacity: 0;
  --header-gradient-1: #1a1d2e;
  --header-gradient-2: #5b52e0;
  --card-hover-shadow: 0 8px 24px rgba(0,0,0,.08);
  --toggle-bg: #dfe3ec;
  --toggle-knob: #5b52e0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* ---- Stars background ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: var(--star-opacity);
  transition: opacity .4s;
  background:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.3), transparent),
    radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,.3), transparent),
    radial-gradient(1.5px 1.5px at 10% 80%, rgba(108,99,255,.5), transparent),
    radial-gradient(1.5px 1.5px at 90% 10%, rgba(6,182,212,.4), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,.2), transparent),
    radial-gradient(1px 1px at 30% 90%, rgba(255,255,255,.35), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,.25), transparent);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ---- Toolbar (theme + lang) ---- */
.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 0 0;
}

.theme-toggle {
  background: var(--toggle-bg);
  border: none;
  border-radius: 20px;
  width: 52px;
  height: 28px;
  cursor: pointer;
  position: relative;
  transition: background .3s;
  flex-shrink: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform .3s, background .3s;
}
[data-theme="light"] .theme-toggle::after {
  transform: translateX(24px);
}
.theme-toggle .icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
}
.theme-toggle .icon-moon { left: 7px; }
.theme-toggle .icon-sun  { right: 7px; }

.lang-select {
  background: var(--toggle-bg);
  border: none;
  border-radius: 20px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 28px 6px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background .3s, color .3s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
	  background-position: right 10px center;
	}
	.lang-select option {
	  background: var(--surface);
	  color: var(--text);
	}

	.theme-toggle:focus-visible,
	.lang-select:focus-visible,
	.back-btn:focus-visible {
	  outline: 2px solid var(--accent);
	  outline-offset: 3px;
	}

/* ---- Back button (doc pages) ---- */
.back-btn {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .3s;
  font-family: inherit;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
}
