/* ═══════════════════════════════════════════════════════
   Starlight Panel — Global Theme
   暗夜星图 × 极简高奢 × 数据即艺术
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700;800&family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  /* Base palette */
  --bg:           #07070d;
  --bg-raised:    #0d0d1a;
  --bg-hover:     #121220;
  --surface:      rgba(255,255,255,0.04);
  --surface-2:    rgba(255,255,255,0.07);
  --surface-3:    rgba(255,255,255,0.10);
  --border:       rgba(255,255,255,0.08);
  --border-strong:rgba(255,255,255,0.15);

  /* Typography */
  --text-1:  #eeeef8;
  --text-2:  #9898b8;
  --text-3:  #52526a;
  --font-ui-cn: 'Noto Sans SC', 'Source Han Sans SC', 'Microsoft YaHei UI', system-ui, sans-serif;
  --font-ui-en: 'Sora', 'Segoe UI', system-ui, sans-serif;
  --font-ui:   var(--font-ui-cn);
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', 'Fira Code', monospace;

  /* Starfield identity colors — used ONLY for their domain */
  --qingqiu:       #2dd4bf;
  --qingqiu-dim:   rgba(45,212,191,0.10);
  --qingqiu-glow:  rgba(45,212,191,0.22);
  --yanguang:      #f59e0b;
  --yanguang-dim:  rgba(245,158,11,0.10);
  --yanguang-glow: rgba(245,158,11,0.22);
  --xuanpu:        #818cf8;
  --xuanpu-dim:    rgba(129,140,248,0.10);
  --xuanpu-glow:   rgba(129,140,248,0.22);

  /* Tier badge colors */
  --tier-1: #eeeef8;
  --tier-2: #94a3b8;
  --tier-3: #64748b;
  --tier-4: #475569;
  --tier-5: #334155;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --duration-fast: 120ms;
  --duration-base: 220ms;
  --duration-slow: 380ms;

  /* Layout */
  --nav-h: 56px;
  --content-w: 1240px;
  --page-side: clamp(16px, 3vw, 32px);
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ui-cn);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

img,
svg,
canvas {
  max-width: 100%;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
}

/* ── Navigation ────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 var(--page-side);
  gap: var(--sp-5);
  background: rgba(8,8,14,0.92);
  backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand-mark {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}

.nav-brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-brand-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-1);
  text-transform: uppercase;
  font-family: var(--font-ui-en);
}

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-2);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast), border-color var(--duration-fast);
}

.nav-toggle:hover {
  color: var(--text-1);
  background: var(--surface);
  border-color: var(--border-strong);
}

.nav-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-menu {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin-left: var(--sp-3);
  flex: 1;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--duration-fast), background var(--duration-fast);
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--text-2);
  background: var(--surface);
}

.nav-links a.active {
  color: var(--text-1);
  background: var(--surface-2);
}

.nav-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'liga' 0;
}

.nav-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #22c55e;
  opacity: 0.85;
  animation: pulse-dot 3s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 0.35; }
}

/* ── Page layout ───────────────────────────────────────── */
.page {
  padding-top: var(--nav-h);
  padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.container {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--page-side);
}

.page-header {
  padding: var(--sp-6) 0 var(--sp-5);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}

.page-title {
  font-size: clamp(22px, 3vw, 30px);
  font-family: var(--font-ui-cn);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--text-1);
}

.page-subtitle {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--font-ui-en);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

/* Section header row (label + optional right content) */
.section-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
  font-family: var(--font-ui-en);
}

.section-label::before {
  content: '';
  display: block;
  width: 2px;
  height: 11px;
  border-radius: 1px;
  background: var(--border-strong);
  flex-shrink: 0;
}

/* ── Starfield color utilities ─────────────────────────── */
.sf-qingqiu  { --sf-color: var(--qingqiu);  --sf-rgb: 45,212,191;  --sf-dim: var(--qingqiu-dim);  --sf-glow: var(--qingqiu-glow); }
.sf-yanguang { --sf-color: var(--yanguang); --sf-rgb: 245,158,11;  --sf-dim: var(--yanguang-dim); --sf-glow: var(--yanguang-glow); }
.sf-xuanpu   { --sf-color: var(--xuanpu);   --sf-rgb: 129,140,248; --sf-dim: var(--xuanpu-dim);   --sf-glow: var(--xuanpu-glow); }

.sf-accent { color: var(--sf-color); }
.sf-bg     { background: var(--sf-dim); }
.sf-border { border-color: rgba(var(--sf-rgb, 255,255,255), 0.25); }

/* ── Tier badge ────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}

.tier-badge[data-tier="1"] { background: rgba(238,238,248,0.07); border-color: rgba(238,238,248,0.15); color: var(--text-1); }
.tier-badge[data-tier="2"] { background: rgba(148,163,184,0.07); border-color: rgba(148,163,184,0.15); color: #94a3b8; }
.tier-badge[data-tier="3"] { background: rgba(100,116,139,0.07); border-color: rgba(100,116,139,0.15); color: #64748b; }
.tier-badge[data-tier="4"] { background: rgba(71,85,105,0.07);   border-color: rgba(71,85,105,0.15);   color: #475569; }
.tier-badge[data-tier="5"] { background: rgba(51,65,85,0.07);    border-color: rgba(51,65,85,0.15);    color: #3e4f63; }

/* ── Card / Surface ────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-base), background var(--duration-base);
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.card-pad { padding: var(--sp-5); }

/* ── KPI stat cell ─────────────────────────────────────── */
.kpi-item {
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color var(--duration-base);
}

.kpi-item:hover { border-color: var(--border-strong); }

.kpi-val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text-1);
}

.kpi-label {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Stat number (legacy hero usage) ───────────────────── */
.stat-num {
  font-family: var(--font-mono);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text-1);
}

.stat-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: var(--sp-2);
}

/* ── Divider ───────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  border: none;
}

/* ── Tab strip ─────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tab-btn:hover { color: var(--text-2); }

.tab-btn.active {
  color: var(--text-1);
  border-bottom-color: var(--text-2);
}

/* ── Monospace data tag ────────────────────────────────── */
.mono-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* ── Score bar ─────────────────────────────────────────── */
.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.score-bar-track {
  flex: 1;
  height: 2px;
  background: var(--surface-2);
  border-radius: 1px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 1px;
  background: var(--sf-color, var(--text-2));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.75s var(--ease-out);
}

.score-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  min-width: 52px;
  text-align: right;
}

/* ── Modal / Drawer ────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow);
}

.overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.97) translateY(8px);
  width: min(960px, calc(100vw - 24px));
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  z-index: 201;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow), transform var(--duration-slow) var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal.open {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1) translateY(0);
}

.drawer {
  position: fixed;
  top: var(--nav-h); right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--bg-raised);
  border-left: 1px solid var(--border-strong);
  z-index: 201;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.drawer.open { transform: translateX(0); }

.modal-close, .drawer-close {
  position: sticky;
  top: var(--sp-4);
  float: right;
  margin: var(--sp-4) var(--sp-4) 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
  z-index: 1;
  line-height: 1;
}

.modal-close:hover, .drawer-close:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-1);
}

/* ── Loading state ─────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30vh;
  gap: var(--sp-3);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.loading-spinner {
  width: 16px; height: 16px;
  border: 1.5px solid var(--border);
  border-top-color: var(--text-3);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Grid utilities ────────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .nav {
    gap: var(--sp-3);
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: var(--page-side);
    right: var(--page-side);
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 18px;
    border: 1px solid var(--border-strong);
    background: rgba(8, 8, 16, 0.96);
    backdrop-filter: blur(22px) saturate(160%);
    box-shadow: 0 18px 40px rgba(0,0,0,0.32);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px) scale(0.98);
    transform-origin: top center;
    transition: opacity var(--duration-base), transform var(--duration-base) var(--ease-out);
    max-height: calc(100svh - var(--nav-h) - 24px);
    overflow-y: auto;
  }

  .nav.nav-open .nav-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .nav-links {
    flex: none;
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    width: 100%;
    padding: 11px 13px;
    justify-content: flex-start;
    color: var(--text-2);
    background: rgba(255,255,255,0.02);
  }

  .nav-end {
    margin-left: 0;
    padding: 6px 4px 2px;
    justify-content: flex-start;
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }

  .page-header {
    padding: var(--sp-5) 0 var(--sp-4);
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: var(--sp-5);
  }

  .page-title {
    font-size: clamp(24px, 8vw, 30px);
  }

  .page-subtitle {
    line-height: 1.5;
  }

  .section-hdr {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .card-pad {
    padding: var(--sp-4);
  }

  .modal {
    width: calc(100vw - 16px);
    max-height: calc(100svh - 16px);
  }

  .drawer {
    top: 0;
    bottom: 0;
    width: 100vw;
    border-left: none;
  }

  .modal-close,
  .drawer-close {
    top: 12px;
    margin-top: 12px;
  }
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── GSAP initial states (hidden before animation) ──────── */
[data-gsap="fade-up"]  { opacity: 0; transform: translateY(20px); }
[data-gsap="fade-in"]  { opacity: 0; }
[data-gsap="scale-in"] { opacity: 0; transform: scale(0.96); }

/* ── Benchmark detail panel components ─────────────────── */
.detail-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: var(--sp-4) 0 var(--sp-2);
  display: flex;
  align-items: center;
  gap: 7px;
}
.detail-section-title::before {
  content: '';
  display: block;
  width: 2px; height: 10px;
  border-radius: 1px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.detail-metric {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.detail-metric-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.detail-metric-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

/* ── Planning page classes ──────────────────────────────── */
.sf-banner {
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--sf-color, var(--border));
  background: var(--sf-dim, var(--surface));
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}
.sf-banner-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--sf-color);
  line-height: 1.1;
}
.sf-banner-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
}
.sf-banner-count {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
  flex-shrink: 0;
}

/* ── Score grade colors ─────────────────────────────────── */
.grade-s { color: #f59e0b; }
.grade-a { color: #818cf8; }
.grade-b { color: #2dd4bf; }
.grade-c { color: #22c55e; }
.grade-d { color: var(--text-3); }
