/* ============================================================================
   无限摄影社 · 布局层 Layout
   一套 DOM 同时服务 PC（侧栏）与移动端（底栏 Tab）
   ========================================================================== */

.app {
  position: relative;
  /* ★ 这里刻意不设 z-index（保持 auto），这不是遗漏。
     ──────────────────────────────────────────────────────────────
     设了任何非 auto 的 z-index，.app 就会**自己形成一个层叠上下文**，
     它内部的 z-index 就只在 .app 这个"盒子"里有效，爬不出去。

     而移动端抽屉的 DOM 结构是这样的：

         <div class="app">          ← 若此处 z-index:10，形成层叠上下文
           <aside class="sidebar">  ← 抽屉，z-index:400（被困在 .app 里）
           <div class="main">…
         </div>
         <div class="drawer-scrim"> ← 遮罩，z-index:399（.app 的兄弟节点）
         <nav class="tabbar">       ← z-index:100

     两者在根层叠上下文里比较：399 > 10，于是**遮罩盖在 .app 之上**，
     连同里面的抽屉一起被盖住。表现就是：点底部「更多」，
     抽屉其实滑出来了，却被压在一层模糊遮罩下面 —— 整屏发糊、看不到菜单。

     去掉 z-index 后，.sidebar 的 400 参与根层叠上下文，就能正常盖住 399 的遮罩；
     而 .app 与 .bg-field(0) 同属"定位元素 z-index:auto/0"这一层，按 DOM 顺序绘制，
     .app 在 .bg-field 之后，依然稳稳在背景之上。
     ────────────────────────────────────────────────────────────── */
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ══════════════════════════════════════════════════════════════════
   侧栏（PC / 平板横向）
   ═══════════════════════════════════════════════════════════════════ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3);
  background: linear-gradient(180deg,
    rgba(14,14,21,.72) 0%,
    rgba(10,10,16,.62) 60%,
    rgba(8,8,13,.76) 100%);
  backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  border-right: 1px solid var(--stroke-1);
  box-shadow: 1px 0 0 rgba(255,255,255,.03), 12px 0 40px -20px rgba(0,0,0,.7);
}

/* ── 品牌区 ── */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--stroke-1);
  margin-bottom: var(--sp-3);
  position: relative;
}
.brand::after {
  content: "";
  position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px; height: 1px;
  background: var(--metal-line);
  opacity: .5;
}
.brand__mark {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--stroke-2);
  box-shadow: var(--shadow-md), var(--shadow-inset-top);
  background: var(--ink-900);
}
.brand__text { min-width: 0; }
.brand__name {
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.25;
  color: var(--text-1);
  white-space: nowrap;
}
.brand__sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  color: var(--text-4);
  text-transform: uppercase;
  white-space: nowrap;
}
.brand__badge {
  position: absolute; top: var(--sp-2); right: var(--sp-2);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red-500);
  animation: pulseRed 3.4s var(--ease-out) infinite;
}

/* ── 导航 ── */
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  padding-right: 2px;
  margin-right: -2px;
}
.nav__group {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--text-4);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}
.nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-md);
  font-weight: 600;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.nav__item:hover {
  background: var(--glass-2);
  color: var(--text-1);
}
.nav__item:active { transform: scale(.985); }
.nav__item.is-active {
  background: linear-gradient(100deg, rgba(200,16,46,.20), rgba(200,16,46,.05) 62%, transparent);
  color: var(--text-1);
  box-shadow: var(--shadow-inset-top);
}
.nav__item.is-active::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: var(--r-full);
  background: var(--red-500);
  box-shadow: 0 0 12px rgba(200,16,46,.9);
}
.nav__icon {
  width: 20px; height: 20px; flex: 0 0 20px;
  stroke-width: 1.7;
  opacity: .9;
}
.nav__item.is-active .nav__icon { color: var(--red-400); opacity: 1; }
.nav__label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__tag {
  font-size: 10px; font-weight: 800;
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--red-600); color: #fff;
  letter-spacing: .02em;
}
.nav__count {
  font-size: var(--fs-2xs); font-weight: 700;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--glass-2);
  border: 1px solid var(--stroke-1);
}

/* ── 侧栏底部状态卡 ── */
.sidebar__foot {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--stroke-1);
}
.storage-card {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--glass-1);
  border: 1px solid var(--stroke-1);
  box-shadow: var(--shadow-inset-top);
}
.storage-card__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-2xs); color: var(--text-3);
  font-weight: 700; letter-spacing: .04em;
  margin-bottom: var(--sp-2);
}
.storage-card__bar {
  height: 4px; border-radius: var(--r-full);
  background: rgba(255,255,255,.07);
  overflow: hidden;
}
.storage-card__fill {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--red-600), var(--red-400));
  transition: width var(--dur-slow) var(--ease-out);
}

/* ══════════════════════════════════════════════════════════════════
   主区
   ═══════════════════════════════════════════════════════════════════ */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0;
  z-index: var(--z-sticky);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: linear-gradient(180deg, rgba(10,10,16,.82), rgba(10,10,16,.58));
  backdrop-filter: blur(var(--blur-md)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(150%);
  border-bottom: 1px solid var(--stroke-1);
}
.topbar__title { min-width: 0; }
.topbar__crumb {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  color: var(--text-4);
  text-transform: uppercase;
}
.topbar__h1 {
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

/* 搜索框 */
.search {
  position: relative;
  display: flex; align-items: center;
  width: 260px;
  transition: width var(--dur-base) var(--ease-out);
}
.search:focus-within { width: 320px; }
.search__icon {
  position: absolute; left: 12px;
  width: 16px; height: 16px;
  color: var(--text-4);
  pointer-events: none;
}
.search__input {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 36px;
  border-radius: var(--r-full);
  background: var(--glass-1);
  border: 1px solid var(--stroke-1);
  color: var(--text-1);
  font-size: var(--fs-sm);
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.search__input::placeholder { color: var(--text-4); }
.search__input:focus {
  outline: none;
  background: var(--glass-2);
  border-color: var(--stroke-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,.10);
}
.search__clear {
  position: absolute; right: 10px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-3);
  font-size: 15px; line-height: 1;
}
.search__clear:hover { background: var(--glass-3); color: var(--text-1); }

/* ── 内容容器 ── */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-16);
  animation: viewIn var(--dur-slow) var(--ease-out) both;
}
.content--wide { max-width: 1600px; }
.content--flush { padding-left: 0; padding-right: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.page-head__title {
  font-size: var(--fs-2xl);
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.page-head__desc {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-top: 6px;
  max-width: 62ch;
}

/* ── 栅格 ── */
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); }
.grid--auto-sm { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0,1fr) 340px; align-items: start; }

.section { margin-bottom: var(--sp-10); }
.section__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.section__title {
  font-size: var(--fs-xl);
  font-weight: 800;
  display: flex; align-items: center; gap: var(--sp-3);
  letter-spacing: -.02em;
}
.section__title::before {
  content: "";
  width: 4px; height: 20px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--red-500), var(--red-800));
  box-shadow: 0 0 14px rgba(200,16,46,.6);
}

/* ══════════════════════════════════════════════════════════════════
   移动端底栏 Tab
   ═══════════════════════════════════════════════════════════════════ */
.tabbar { display: none; }

.drawer-scrim { display: none; }

/* ══════════════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════════════ */

/* ── 大平板 / 小笔电：侧栏收成图标轨 ── */
@media (max-width: 1180px) {
  .app { grid-template-columns: var(--sidebar-w-rail) minmax(0,1fr); }
  .sidebar { padding: var(--sp-4) var(--sp-2); align-items: center; }
  .brand { padding: var(--sp-2) 0 var(--sp-4); justify-content: center; }
  .brand__text, .brand__badge { display: none; }
  .brand::after { left: 8px; right: 8px; }
  .nav { width: 100%; align-items: stretch; }
  .nav__group { display: none; }
  .nav__item { justify-content: center; padding: 12px 0; }
  .nav__label, .nav__count, .nav__tag { display: none; }
  .nav__item.is-active::before { left: -2px; }
  .sidebar__foot { width: 100%; }
  .storage-card { display: none; }
  .grid--sidebar { grid-template-columns: minmax(0,1fr); }
  .grid--4 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* ── 平板竖屏 ── */
@media (max-width: 900px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .search { width: 190px; }
  .search:focus-within { width: 230px; }
}

/* ── 手机：侧栏 → 抽屉，底栏 Tab 接管主导航 ── */
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, 316px);
    height: 100dvh;
    padding: var(--sp-5) var(--sp-3) calc(var(--sp-6) + env(safe-area-inset-bottom));
    align-items: stretch;
    transform: translateX(-102%);
    transition: transform var(--dur-slow) var(--ease-out);
    z-index: var(--z-drawer);
    border-right: 1px solid var(--stroke-2);
    background: linear-gradient(180deg, rgba(16,16,24,.94), rgba(8,8,13,.96));
    backdrop-filter: blur(var(--blur-xl)) saturate(170%);
    -webkit-backdrop-filter: blur(var(--blur-xl)) saturate(170%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.is-open { transform: none; }
  .brand { justify-content: flex-start; padding: var(--sp-2) var(--sp-3) var(--sp-5); }
  .brand__text, .brand__badge { display: block; }
  .brand__badge { display: block; }
  .nav__group { display: block; }
  .nav__item { justify-content: flex-start; padding: 12px var(--sp-3); }
  .nav__label, .nav__count, .nav__tag { display: block; }
  .nav__label { flex: 1; }
  .storage-card { display: block; }

  .drawer-scrim {
    display: block;
    position: fixed; inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: rgba(4,4,7,.66);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0; visibility: hidden;
    transition: opacity var(--dur-base), visibility var(--dur-base);
  }
  .drawer-scrim.is-open { opacity: 1; visibility: visible; }

  .topbar {
    height: 58px;
    padding: 0 var(--sp-4);
    gap: var(--sp-3);
    padding-top: env(safe-area-inset-top);
  }
  .topbar__h1 { font-size: var(--fs-md); }
  .topbar__crumb { display: none; }
  .search { display: none; }

  .content {
    padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--sp-8) + env(safe-area-inset-bottom));
  }
  .page-head { margin-bottom: var(--sp-5); }
  .page-head__title { font-size: var(--fs-xl); }

  .grid { gap: var(--sp-4); }
  .grid--2, .grid--3 { grid-template-columns: minmax(0,1fr); }
  /* 统计卡 / 活动要点这类短内容，手机上保留两列更紧凑 */
  .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--sp-3); }
  .grid--auto { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .grid--auto-sm { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .section { margin-bottom: var(--sp-8); }
  .section__title { font-size: var(--fs-lg); }

  /* ── 底栏 Tab ── */
  .tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-sticky);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(180deg, rgba(12,12,19,.86), rgba(6,6,10,.95));
    backdrop-filter: blur(var(--blur-lg)) saturate(170%);
    -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(170%);
    border-top: 1px solid var(--stroke-1);
    box-shadow: 0 -10px 34px -12px rgba(0,0,0,.8);
  }
  .tabbar__item {
    position: relative;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .01em;
    transition: color var(--dur-fast);
  }
  .tabbar__item svg { width: 21px; height: 21px; stroke-width: 1.75; }
  .tabbar__item.is-active { color: var(--text-1); }
  .tabbar__item.is-active svg { color: var(--red-400); filter: drop-shadow(0 0 8px rgba(200,16,46,.55)); }
  .tabbar__item.is-active::after {
    content: "";
    position: absolute; top: 0;
    width: 26px; height: 2.5px;
    border-radius: var(--r-full);
    background: var(--red-500);
    box-shadow: 0 0 12px rgba(200,16,46,.9);
  }
  .tabbar__item:active { transform: scale(.94); }
}

@media (max-width: 400px) {
  .grid--auto { grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--sp-3); }
  .content { padding-left: var(--sp-3); padding-right: var(--sp-3); }
}

/* ── 打印 ── */
@media print {
  .bg-field, .sidebar, .tabbar, .topbar { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
}
