/* ============================================================
   核纪元 · 布局层：顶栏 / 导航 / 主区域 / 首页
   ============================================================ */

/* ---------- 顶栏 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  background: linear-gradient(180deg, rgba(4, 10, 18, 0.94), rgba(4, 10, 18, 0.72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.header-inner {
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 26px;
}

/* 品牌 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  border: 1px solid rgba(56, 225, 255, 0.35);
  border-radius: 11px;
  background: radial-gradient(circle at 50% 40%, rgba(56, 225, 255, 0.18), transparent 70%);
  box-shadow: inset 0 0 18px rgba(56, 225, 255, 0.12);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  animation: spin 22s linear infinite;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.brand-text small {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.24em;
  color: var(--text-3);
  margin-top: 3px;
}

/* 导航 */
.mode-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 -4px;
  padding: 4px;
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(120, 190, 255, 0.07);
  text-decoration: none;
}

.nav-link svg {
  width: 15px;
  height: 15px;
  opacity: 0.8;
}

.nav-link.is-active {
  color: var(--cyan);
  background: rgba(56, 225, 255, 0.09);
  border-color: rgba(56, 225, 255, 0.24);
}

.nav-link.is-active svg {
  opacity: 1;
}

/* 右侧操作 */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(255, 200, 87, 0.08);
  border: 1px solid rgba(255, 200, 87, 0.22);
  font-variant-numeric: tabular-nums;
}

.score-pill-icon {
  font-size: 12px;
  filter: drop-shadow(0 0 6px rgba(255, 200, 87, 0.55));
}

.score-pill.bump {
  animation: popIn 0.35s var(--ease-spring);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(120, 190, 255, 0.05);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: rgba(120, 190, 255, 0.1);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.is-off {
  color: var(--text-3);
}

/* ---------- 主区域 ---------- */
#view {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 34px 24px 64px;
  min-height: calc(100dvh - var(--header-h) - 64px);
  outline: none;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}

.view-head .view-title {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.view-head h1,
.view-head h2 {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-head h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.view-head h2 .mode-emoji {
  font-size: 0.9em;
  filter: drop-shadow(0 0 14px rgba(56, 225, 255, 0.35));
}

.view-head p.lead {
  color: var(--text-2);
  font-size: 14.5px;
  max-width: 62ch;
}

.view-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- 页脚 ---------- */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 18px 24px 26px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.footer-sep {
  opacity: 0.4;
}

/* 首页模块网格 */
.section-block {
  margin-top: 34px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: clamp(19px, 2vw, 23px);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head .section-note {
  font-size: 12.5px;
  color: var(--text-3);
}


/* ---------- 外壳响应式 ---------- */
@media (max-width: 960px) {
  .header-inner {
    gap: 14px;
    padding: 0 16px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-h);
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .mode-nav {
    order: 3;
    width: 100%;
    padding-bottom: 6px;
  }

  .app-header {
    height: auto;
  }

  #view {
    padding: 24px 16px 52px;
  }
}

@media (max-width: 560px) {
  .header-actions .score-pill {
    padding: 6px 10px;
    font-size: 12px;
  }

  .brand-text small {
    display: none;
  }

  .app-footer {
    font-size: 10.5px;
    padding: 16px 16px 24px;
  }
}

/* ---------- 视图切换动画 ---------- */
#view.is-entering > * {
  animation: fadeUp 0.45s var(--ease-out) both;
}

/* ============================================================
   移动端：底部 Tab 导航（≤640px）
   ============================================================ */
@media (max-width: 640px) {
  .app-header {
    /* 移除 backdrop-filter，避免为 fixed 子元素创建包含块 */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(4, 10, 18, 0.97);
  }

  .mode-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 90;
    width: 100%;
    margin: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    gap: 2px;
    overflow: visible;
    background: rgba(4, 10, 18, 0.97);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.38);
  }

  .nav-link {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 1px;
    border-radius: 9px;
    font-size: clamp(8px, 2.35vw, 9.5px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
  }

  .nav-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-link svg {
    width: 18px;
    height: 18px;
  }

  .nav-link.is-active {
    background: rgba(56, 225, 255, 0.1);
    border-color: rgba(56, 225, 255, 0.26);
  }

  body {
    padding-bottom: calc(62px + env(safe-area-inset-bottom));
  }

  #view {
    padding-bottom: 34px;
  }

  .app-footer {
    padding-bottom: 22px;
  }

  .toast-root {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

/* 平板：顶部导航可横向滚动，右侧渐隐提示 */
@media (min-width: 641px) and (max-width: 960px) {
  .mode-nav {
    mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 32px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 32px), transparent 100%);
  }
}
