/* =====================================================================
   布局：应用外壳、顶栏、侧栏、底栏、主区
   ===================================================================== */

.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-4);
  padding: 0 var(--sp-5);
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(12px);
  -webkit-backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--primary);
  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.12; 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: 9.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: var(--sp-1); }
.topbar-nav { display: flex; align-items: center; gap: var(--sp-1); }

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

.topbar-icon svg { width: 19px; height: 19px; }
.topbar-icon:hover { color: var(--text); background: var(--surface-1); }
.topbar-icon.active { color: var(--primary); }

/* ---------- 布局主体 ---------- */
.layout {
  flex: 1;
  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--sp-5);
  gap: var(--sp-7);
}

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

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

/* 类别标签：小字距的全大写，不做折叠 */
.nav-group-label {
  padding: 0 var(--sp-2);
  margin: var(--sp-5) 0 var(--sp-2);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-3);
  opacity: .85;
}

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

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

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

.nav-item.active { color: var(--primary-ink); font-weight: 600; }

/* 选中：左侧一枚朱砂短线，而不是整块粉底 */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 50%;
  width: 2px; height: 15px;
  margin-top: -7.5px;
  background: var(--primary);
}

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

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

.nav-badge {
  margin-left: auto;
  min-width: 17px;
  padding: 0 5px;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  font-family: var(--font-en);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- 今日面板 ---------- */
.today-panel {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}

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

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

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

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

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

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

/* 少数需要横向空间的页面（词库、统计）自己声明 */
.main-content > .view.wide { max-width: none; width: calc(100% + 0px); }
.main-content:has(> .view.wide) { max-width: 1040px; }

/* 入场编排在 animations.css 里（.view > * 分层升起） */

/* ---------- 页面标题：辞书体的「词头栏」 ----------
   一条刻线横亘栏宽，标题挂在线的下方 —— 天城体就是这样挂在 शिरोरेखा 上的。 */
.section-head {
  position: relative;
  padding-top: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.section-head::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--rule-ink);
  transform: scaleX(0);
  transform-origin: left center;
  animation: ruleIn 620ms var(--ease-out) 60ms forwards;
}

.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: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(14px);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  border-top: 1px solid var(--line);
  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: 20px; height: 2px;
  margin-left: -10px;
  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: 4px;
  left: 50%;
  margin-left: 4px;
  min-width: 14px;
  padding: 0 3px;
  border-radius: 2px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-en);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

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

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .sidebar { width: 64px; }
  .sidebar .nav-label,
  .sidebar .nav-group-label,
  .sidebar .today-panel { display: none; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-item.active::before { left: -6px; }
  .nav-badge {
    position: absolute;
    top: 1px; right: 4px;
    margin: 0;
    min-width: 14px;
    padding: 0 3px;
    font-size: 9px;
  }
  .layout { gap: var(--sp-5); }
}

@media (max-width: 767px) {
  :root { --topbar-h: 54px; }
  .sidebar { display: none; }
  .layout { padding: 0 var(--sp-4); gap: 0; }
  .main-content { padding: var(--sp-4) 0 var(--sp-6); max-width: none; }
  .bottom-nav { display: block; }
  .section-title { font-size: 21px; }
  .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); }
}
