/* =====================================================================
   布局：外壳、顶栏、侧栏、抽屉、底栏、主区
   ===================================================================== */

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏（玻璃） ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-6);
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--primary);
  filter: drop-shadow(0 1px 1px rgba(167, 53, 44, .18));
  transition: transform var(--dur-slow) var(--ease-spring);
}

.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }

.brand-hi {
  font-family: var(--font-deva);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--text);
}

.brand-sub {
  font-size: 8.5px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--text-3);
  font-family: var(--font-en);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar-nav { display: flex; align-items: center; gap: 4px; }

.topbar-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.topbar-icon svg { width: 19px; height: 19px; }
.topbar-icon:hover { background: rgba(120, 100, 70, .09); color: var(--text); }
.topbar-icon.active { color: var(--primary); background: var(--primary-soft); }

/* 汉堡：只在手机上出现 */
.hamburger {
  display: none;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  color: var(--text);
  place-items: center;
  margin-left: -6px;
}

.hamburger svg { width: 20px; height: 20px; }
.hamburger:active { background: rgba(120, 100, 70, .1); }

/* ---------- 布局主体 ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  gap: var(--sp-7);
}

/* ---------- 侧栏 ---------- */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--sp-4) + env(safe-area-inset-top, 0px));
  max-height: calc(100dvh - var(--topbar-h) - var(--sp-6));
  overflow-y: auto;
  padding: var(--sp-6) 0 var(--sp-6);
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}

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

.nav-group-label {
  padding: 0 10px;
  margin: var(--sp-5) 0 var(--sp-2);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-3);
}

.nav-group-label:first-child { margin-top: 0; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.nav-item:hover { color: var(--text); background: rgba(120, 100, 70, .08); }

.nav-item.active {
  color: var(--primary-ink);
  font-weight: 600;
  background: linear-gradient(180deg, #FBEEE9, #F7E6DF);
  box-shadow: var(--inner-light), 0 1px 2px rgba(167, 53, 44, .10);
}

:root[data-theme='dark'] .nav-item.active {
  background: linear-gradient(180deg, #3B2521, #33201C);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  width: 3px; height: 16px;
  margin-top: -8px;
  border-radius: var(--r-pill);
  background: var(--primary);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .78;
}

.nav-item.active .nav-icon { opacity: 1; }
.nav-icon svg { width: 100%; height: 100%; }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-en);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.65;
  text-align: center;
}

.nav-item.active .nav-badge { background: #fff; color: var(--primary); }

/* ---------- 今日面板 ---------- */
.today-panel {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--grad-surface);
  border: 1px solid var(--line-soft);
  box-shadow: var(--inner-light), var(--shadow-sm);
}

.today-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
  padding: 0 2px;
}

.today-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 2px;
  border-radius: var(--r-xs);
  font-size: 13px;
  color: var(--text-2);
  transition: color var(--dur-fast);
}

.today-row:hover { color: var(--text); }

.t-num {
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.t-num.zero { color: var(--text-3); font-weight: 400; }

/* ---------- 主区 ---------- */
.main-content {
  min-width: 0;
  padding: var(--sp-6) 0 var(--sp-8);
}

/* ---------- 页面标题 ---------- */
.section-head { position: relative; margin-bottom: var(--sp-5); }

.section-title {
  font-family: var(--font-ui);
  font-size: var(--t-h1);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.section-title .sub {
  font-family: var(--font-en);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---------- 底栏（移动端 · 玻璃） ---------- */
.bottom-nav {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bn-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  max-width: 560px;
  margin: 0 auto;
}

.bn-item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px var(--sp-1) 7px;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--text-3);
  transition: color var(--dur-fast) var(--ease-out);
}

.bn-item.active { color: var(--primary); }

.bn-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  width: 22px; height: 3px;
  margin-left: -11px;
  border-radius: 0 0 3px 3px;
  background: var(--primary);
}

.bn-icon { width: 21px; height: 21px; display: grid; place-items: center; }
.bn-icon svg { width: 100%; height: 100%; }

.bn-badge {
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: 5px;
  min-width: 15px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--primary);
  color: #fff;
  font-family: var(--font-en);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

:root[data-theme='dark'] .bn-badge { color: #17140F; }

/* ---------- 抽屉（移动端导航） ---------- */
.drawer-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(38, 30, 20, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

.drawer {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: min(318px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: saturate(1.4) blur(26px);
  -webkit-backdrop-filter: saturate(1.4) blur(26px);
  border-right: 1px solid var(--glass-border);
  box-shadow: 24px 0 60px -30px rgba(60, 48, 30, .55);
  transform: translateX(-102%);
  transition: transform var(--dur-slow) var(--ease-out);
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px
           calc(env(safe-area-inset-bottom, 0px) + 16px);
  will-change: transform;
}

.drawer-root.open { pointer-events: auto; }
.drawer-root.open .drawer-scrim { opacity: 1; }
.drawer-root.open .drawer { transform: none; }

.drawer:focus { outline: none; }

.drawer-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 12px;
}

.drawer-head .brand-mark { width: 28px; height: 28px; }
.drawer-close {
  margin-left: auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-3);
}
.drawer-close:hover { background: rgba(120, 100, 70, .1); color: var(--text); }
.drawer-close svg { width: 18px; height: 18px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 2px 12px;
  scrollbar-width: none;
}
.drawer-body::-webkit-scrollbar { display: none; }

.drawer-body .nav-item { padding: 11px 10px; font-size: 14.5px; }
.drawer-body .nav-group-label { margin-top: var(--sp-4); }

.drawer-foot {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.drawer-foot .btn { flex: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  :root { --sidebar-w: 200px; }
  .layout { gap: var(--sp-5); padding: 0 var(--sp-5); }
}

@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { display: none; }
  .hamburger { display: grid; }
  .main-content { padding: var(--sp-5) 0 var(--sp-7); }
}

@media (max-width: 767px) {
  :root { --topbar-h: 58px; }
  .topbar { padding: 0 var(--sp-4); }
  .layout { padding: 0 var(--sp-4); }
  .main-content { padding: var(--sp-4) 0 var(--sp-6); }
  .bottom-nav { display: block; }
  .section-title { font-size: 22px; }
  .brand-sub { display: none; }
  .brand-hi { font-size: 15px; }
}

@media (max-width: 420px) {
  .layout { padding: 0 var(--sp-3); }
  .topbar { padding: 0 var(--sp-3); }
}
