.app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  padding: 20px 0 16px;
  color: var(--sidebar-ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(201, 162, 39, 0.16), transparent 46%),
    linear-gradient(180deg, var(--sidebar-1) 0%, var(--sidebar-2) 100%);
  border-right: 1px solid rgba(201, 162, 39, 0.22);
  overflow: hidden auto;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    repeating-linear-gradient(45deg, rgba(232, 220, 200, 0.14) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(-45deg, rgba(232, 220, 200, 0.1) 0 1px, transparent 1px 12px);
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.18);
}

.seal {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff4e4;
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(145deg, #a13a24, #7a2e1d 60%, #5e2013);
  border: 1px solid rgba(255, 235, 200, 0.45);
  border-radius: var(--r-xs);
  box-shadow: inset 0 0 0 2px rgba(255, 240, 210, 0.16);
}

.seal-lg {
  width: 44px;
  height: 44px;
  font-size: 15px;
  line-height: 1.05;
}

.seal-sm {
  width: 30px;
  height: 30px;
  font-size: 11px;
  line-height: 1.05;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #f4e7cf;
}

.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--sidebar-dim);
}

.nav {
  position: relative;
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group {
  padding: 14px 12px 6px;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(232, 220, 200, 0.42);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: rgba(232, 220, 200, 0.82);
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item:hover {
  background: rgba(255, 244, 226, 0.07);
  color: #fff4e2;
}

.nav-item.is-active {
  color: #fff7e7;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.2), rgba(201, 162, 39, 0.04));
  box-shadow: inset 2px 0 0 var(--gold);
}

.nav-name {
  flex: 0 0 auto;
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 1px;
}

.nav-sub {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  color: rgba(232, 220, 200, 0.46);
}

.nav-item.is-active .nav-sub {
  color: rgba(246, 235, 200, 0.7);
}

.nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff2e4;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.sidebar-foot {
  position: relative;
  padding: 14px 20px 0;
  border-top: 1px solid rgba(201, 162, 39, 0.16);
}

.sidebar-quote {
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: rgba(232, 220, 200, 0.42);
}

.side-link {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(232, 220, 200, 0.5);
  transition: color 0.16s ease;
}

.side-link:hover {
  color: #f0c9a8;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 28px;
  background: rgba(247, 242, 231, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.menu-btn {
  display: none;
}

.crumb {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  color: var(--ink-2);
}

.chip b {
  font-size: 14px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.chip-k {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--faint);
}

.chip-u {
  font-size: 11px;
  color: var(--faint);
}

.chip-gold {
  border-color: rgba(201, 162, 39, 0.42);
  background: linear-gradient(180deg, #fffdf5, var(--gold-soft));
}

.chip-gold b {
  color: var(--gold-deep);
}

.sync-chip {
  gap: 6px;
  padding: 0 10px;
  height: 28px;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: 0 0 auto;
}

.sync-idle .sync-dot {
  background: var(--gold);
}

.sync-ok .sync-dot {
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(63, 122, 86, 0.15);
}

.sync-busy .sync-dot {
  background: var(--gold);
  animation: sync-pulse 1s ease-in-out infinite;
}

.sync-err .sync-dot {
  background: var(--warn);
}

@keyframes sync-pulse {
  50% { opacity: 0.3; }
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 39, 0.5);
  background: linear-gradient(145deg, #fdf4e2, #ecd9b4);
  color: var(--brand);
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 36px;
}

.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 28px 22px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--faint);
}

.foot-mark {
  letter-spacing: 2px;
}

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: none;
  height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 253, 247, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(58, 35, 24, 0.06);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10.5px;
  color: var(--muted);
}

.tab-item svg {
  width: 20px;
  height: 20px;
}

.tab-item.is-active {
  color: var(--brand);
  font-weight: 600;
}

.tab-item.is-active svg {
  stroke-width: 2.1;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 65;
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    box-shadow: var(--sh-3);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 0 18px;
  }

  .view {
    padding: 20px 18px 32px;
  }

  .page-foot {
    padding: 0 18px 20px;
  }
}

@media (max-width: 720px) {
  .tabbar {
    display: flex;
  }

  .topbar {
    height: 54px;
    padding: 0 14px;
  }

  .crumb {
    font-size: 14px;
  }

  .chip:not(.chip-gold):not(.sync-chip) {
    display: none;
  }

  .sync-chip {
    height: 26px;
    padding: 0 8px;
    font-size: 11px;
  }

  .view {
    padding: 16px 14px 82px;
  }

  .page-foot {
    display: none;
  }

  .sidebar {
    width: 268px;
    flex-basis: 268px;
  }
}