/* ========================================
   小窝 · 古风治愈
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --paper: #f6f1e6;
  --paper-2: #fbf7ee;
  --paper-3: #fffdf7;

  --ink: #3b352b;
  --ink-2: #6b6355;
  --ink-3: #9a8f7c;

  --line: #e4dac7;
  --line-2: #efe7d7;

  --celadon: #7e9c8f;
  --celadon-soft: #e6eee9;
  --vermilion: #b4553c;
  --vermilion-soft: #f7e8e3;
  --gold: #c09a52;
  --gold-soft: #f6eede;

  --radius: 10px;
  --shadow-sm: 0 2px 10px rgba(120, 100, 70, 0.06);
  --shadow: 0 6px 24px rgba(120, 100, 70, 0.08);

  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC",
    "SimSun", "STZhongsong", serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "Noto Serif SC", "SimSun", serif;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.92;
  letter-spacing: 0.3px;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* 宣纸晕染与纸纹 */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(
      circle at 16% 12%,
      rgba(126, 156, 143, 0.12),
      transparent 46%
    ),
    radial-gradient(
      circle at 88% 6%,
      rgba(180, 85, 60, 0.07),
      transparent 44%
    ),
    radial-gradient(
      circle at 50% 112%,
      rgba(192, 154, 82, 0.1),
      transparent 56%
    ),
    repeating-linear-gradient(
      115deg,
      rgba(120, 100, 70, 0.022) 0 1px,
      transparent 1px 5px
    );
}

::selection {
  background: rgba(126, 156, 143, 0.26);
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f0e9db;
}

::-webkit-scrollbar-thumb {
  background: #d8ccb6;
  border: 2px solid #f0e9db;
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: #c7b89e;
}

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

/* ---------- 侧边栏 ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  flex: 0 0 auto;
  width: 248px;
  padding: 26px 14px 20px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    180deg,
    rgba(241, 234, 218, 0.96),
    rgba(236, 228, 210, 0.92)
  );
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: width 0.32s var(--ease), padding 0.32s var(--ease);
}

/* 侧栏右缘的细线，似卷轴装裱 */

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 3px;
  width: 1px;
  height: 100%;
  background: rgba(180, 85, 60, 0.16);
  pointer-events: none;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 10px;
  height: 40px;
  margin-bottom: 24px;
}

.brand {
  flex: 1;
  min-width: 0;
  font-family: var(--kai);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 7px;
  color: var(--ink);
  white-space: nowrap;
  transition: opacity 0.2s var(--ease);
}

.collapse-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.collapse-btn:hover {
  background: rgba(255, 253, 247, 0.9);
  border-color: var(--line);
  color: var(--ink-2);
}

.collapse-btn svg {
  transition: transform 0.32s var(--ease);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.22s, color 0.22s, gap 0.32s var(--ease),
    padding 0.32s var(--ease);
}

.nav-item:hover {
  background: rgba(255, 253, 247, 0.78);
  color: var(--ink);
}

.nav-item.active {
  background: var(--paper-3);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--vermilion);
}

.nav-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.nav-item.active .nav-icon {
  color: var(--celadon);
}

.nav-label {
  font-family: var(--kai);
  font-size: 16px;
  letter-spacing: 2.2px;
  overflow: hidden;
  transition: opacity 0.18s var(--ease), width 0.32s var(--ease);
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 12px 2px;
  font-family: var(--kai);
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--ink-3);
  letter-spacing: 2px;
  white-space: nowrap;
  transition: opacity 0.18s var(--ease);
}

.sidebar-foot::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--vermilion);
  opacity: 0.7;
  vertical-align: middle;
}

/* 收起状态 */

.sidebar.collapsed {
  width: 80px;
  padding-left: 12px;
  padding-right: 12px;
}

.sidebar.collapsed .brand,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-foot {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-head {
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar.collapsed .nav-item {
  gap: 0;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.sidebar.collapsed .nav-item.active::before {
  left: -1px;
  height: 16px;
}

/* ---------- 主内容 ---------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 48px 54px 80px;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  animation: rise 0.6s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  margin-bottom: 34px;
}

.eyebrow {
  display: inline-block;
  font-family: var(--serif);
  font-size: 11.5px;
  letter-spacing: 4px;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.page-title {
  font-family: var(--kai);
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 4px;
  line-height: 1.5;
  color: var(--ink);
}

/* 朱砂印章 */

.page-title::after {
  content: attr(data-seal);
  display: inline-block;
  vertical-align: 7px;
  margin-left: 14px;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-family: var(--kai);
  font-size: 17px;
  letter-spacing: 0;
  color: #fffaf2;
  background: var(--vermilion);
  border-radius: 4px;
  box-shadow: 0 2px 7px rgba(180, 85, 60, 0.3);
  transform: rotate(-4deg);
}

.page-sub {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-2);
  letter-spacing: 0.6px;
}

/* ---------- 通用面板 ---------- */

.card,
.recent,
.drawers,
.frame {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  position: relative;
  padding: 30px 32px;
}

/* 内框双线，似装裱 */

.card::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  pointer-events: none;
}

.card > * {
  position: relative;
}

/* ---------- 头像页 ---------- */

.profile {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 98px;
  height: 98px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(
    circle at 42% 36%,
    rgba(126, 156, 143, 0.22),
    rgba(192, 154, 82, 0.12) 62%,
    transparent 75%
  );
  border: 1px solid rgba(126, 156, 143, 0.5);
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(192, 154, 82, 0.28);
}

.avatar svg {
  width: 44px;
  height: 44px;
  stroke: var(--celadon);
  stroke-width: 1.4;
  stroke-linecap: round;
  fill: none;
}

.profile-info {
  flex: 1;
  min-width: 180px;
}

.profile-name {
  font-family: var(--kai);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--ink);
}

.profile-motto {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 14px;
  letter-spacing: 0.6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  font-family: var(--kai);
  font-size: 13px;
  letter-spacing: 1.4px;
  padding: 3px 13px;
  border-radius: 999px;
  color: #5d7a6d;
  background: var(--celadon-soft);
  border: 1px solid rgba(126, 156, 143, 0.22);
}

.chip.peach {
  color: #9c5a45;
  background: var(--vermilion-soft);
  border-color: rgba(180, 85, 60, 0.2);
}

.chip.lav {
  color: #8a6f34;
  background: var(--gold-soft);
  border-color: rgba(192, 154, 82, 0.24);
}

.quote {
  margin-top: 26px;
  padding: 18px 22px;
  border-left: 2px solid var(--celadon);
  background: linear-gradient(
    90deg,
    rgba(126, 156, 143, 0.08),
    rgba(126, 156, 143, 0)
  );
  color: var(--ink-2);
  font-family: var(--kai);
  font-size: 16px;
  line-height: 2;
  letter-spacing: 1.2px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 42px 0 16px;
  font-family: var(--kai);
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--ink-3);
}

.section-title::before {
  content: "「";
  color: var(--gold);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.recent {
  list-style: none;
  overflow: hidden;
  border-radius: var(--radius);
}

.recent li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 26px;
  font-size: 14.5px;
  color: var(--ink-2);
  transition: background 0.2s;
}

.recent li:hover {
  background: #fdfaf2;
}

.recent li + li {
  border-top: 1px solid var(--line-2);
}

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

.dot.peach {
  background: var(--vermilion);
}

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

.hint {
  font-family: var(--kai);
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 1px;
}

/* ---------- 空壳占位 ---------- */

.shell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.shell {
  position: relative;
  min-height: 172px;
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.7);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 5px var(--paper-3),
    inset 0 0 0 6px var(--line-2);
  display: flex;
  flex-direction: column;
  transition: background 0.25s, box-shadow 0.25s, transform 0.3s var(--ease),
    border-color 0.25s;
}

.shell:hover {
  background: var(--paper-3);
  border-color: rgba(126, 156, 143, 0.42);
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 5px var(--paper-3),
    inset 0 0 0 6px rgba(126, 156, 143, 0.18), var(--shadow);
}

.shell.no {
  font-family: var(--kai);
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--gold);
}

.shell h3 {
  margin: 10px 0 6px;
  font-family: var(--kai);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--ink);
}

.shell p {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.85;
}

.shell .mark {
  margin-top: auto;
  padding-top: 16px;
  font-family: var(--kai);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 1.6px;
}

/* ---------- 百宝箱：抽屉 ---------- */

.drawers {
  overflow: hidden;
}

.drawer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 26px;
  transition: background 0.22s;
  cursor: default;
}

.drawer + .drawer {
  border-top: 1px solid var(--line-2);
}

.drawer:hover {
  background: #fdfaf2;
}

.drawer-no {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(180, 85, 60, 0.28);
  background: var(--vermilion-soft);
  color: #9c5a45;
  font-family: var(--kai);
  font-size: 14px;
}

.drawer-body {
  flex: 1;
  min-width: 0;
}

.drawer-title {
  font-family: var(--kai);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: var(--ink);
}

.drawer-desc {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 1px;
}

.empty-tag {
  flex: 0 0 auto;
  font-family: var(--kai);
  font-size: 11.5px;
  letter-spacing: 2px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 11px;
}

/* ---------- 创金阁：画廊 ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.frame {
  position: relative;
  overflow: hidden;
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}

.frame:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(120, 100, 70, 0.12);
}

.frame-canvas {
  height: 152px;
  display: grid;
  place-items: center;
  font-family: var(--kai);
  font-size: 15px;
  letter-spacing: 5px;
  color: rgba(59, 53, 43, 0.62);
  position: relative;
}

.frame-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 253, 247, 0.28),
    rgba(255, 253, 247, 0)
  );
  pointer-events: none;
}

.frame-canvas.a {
  background: linear-gradient(140deg, #e3ece6, #cfe0d6 55%, #e8f0ea);
}

.frame-canvas.b {
  background: linear-gradient(140deg, #f6e5df, #ecd0c6 55%, #f8ebe6);
}

.frame-canvas.c {
  background: linear-gradient(140deg, #f3ead8, #e6d7b8 55%, #f6efdf);
}

.frame-meta {
  padding: 17px 21px 21px;
}

.frame-meta h3 {
  font-family: var(--kai);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--ink);
}

.frame-meta p {
  margin-top: 3px;
  font-size: 13px;
  color: var(--ink-2);
}

/* ---------- 移动端基础 ---------- */

body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.mobile-bar,
.backdrop {
  display: none;
}

body.drawer-open {
  overflow: hidden;
}

.menu-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.2s;
}

.menu-btn:active {
  background: rgba(126, 156, 143, 0.16);
}

.mobile-brand {
  font-family: var(--kai);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--ink);
}

/* ---------- 手机：顶栏 + 抽屉 ---------- */

@media (max-width: 820px) {
  .mobile-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 6px;
    height: calc(54px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 16px 0;
    background: rgba(246, 241, 230, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(59, 53, 43, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s var(--ease), visibility 0.28s var(--ease);
  }

  .backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    width: 272px;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    padding: 26px 14px 20px;
    background: #f1eada;
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform 0.3s var(--ease);
  }

  .sidebar.open {
    transform: none;
    box-shadow: 14px 0 44px rgba(90, 78, 60, 0.18);
  }

  .sidebar .collapse-btn {
    display: none;
  }

  .sidebar .sidebar-head {
    padding: 0 6px 0 10px;
    justify-content: flex-start;
  }

  .sidebar .brand,
  .sidebar .nav-label,
  .sidebar .sidebar-foot {
    opacity: 1;
    width: auto;
    pointer-events: auto;
  }

  .sidebar .nav-item {
    gap: 12px;
    padding: 13px 12px;
    justify-content: flex-start;
  }

  /* 手机端忽略桌面端的收起状态，抽屉始终完整 */

  .sidebar.collapsed {
    width: 272px;
    max-width: 82vw;
    padding: 26px 14px 20px;
  }

  .sidebar.collapsed .sidebar-head {
    padding: 0 6px 0 10px;
    justify-content: flex-start;
  }

  .sidebar.collapsed .brand,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .sidebar-foot {
    opacity: 1;
    width: auto;
    pointer-events: auto;
  }

  .sidebar.collapsed .nav-item {
    gap: 12px;
    padding: 13px 12px;
    justify-content: flex-start;
  }

  .main {
    padding: calc(54px + env(safe-area-inset-top) + 26px) 20px
      calc(44px + env(safe-area-inset-bottom));
  }

  .page-head {
    margin-bottom: 24px;
  }

  .eyebrow {
    font-size: 11px;
    letter-spacing: 3px;
  }

  .page-title {
    font-size: 25px;
    letter-spacing: 3px;
  }

  .page-title::after {
    width: 26px;
    height: 26px;
    line-height: 26px;
    font-size: 15px;
    vertical-align: 5px;
    margin-left: 11px;
  }

  .page-sub {
    font-size: 13.5px;
  }

  .card {
    padding: 22px 20px;
  }

  .card::before {
    inset: 5px;
  }

  .profile {
    gap: 18px;
  }

  .avatar {
    width: 76px;
    height: 76px;
  }

  .avatar svg {
    width: 34px;
    height: 34px;
  }

  .profile-name {
    font-size: 21px;
  }

  .quote {
    margin-top: 20px;
    padding: 16px 18px;
    font-size: 15px;
    line-height: 1.95;
  }

  .section-title {
    margin: 32px 0 12px;
  }

  .recent li {
    padding: 14px 18px;
    font-size: 14px;
  }

  .shell-grid {
    gap: 14px;
  }

  .shell {
    min-height: 152px;
    padding: 20px;
  }

  .drawer {
    padding: 15px 18px;
  }

  .drawer-no {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .gallery {
    gap: 16px;
  }

  .frame-canvas {
    height: 132px;
    font-size: 14px;
  }

  .frame-meta {
    padding: 15px 18px 18px;
  }
}

/* 触屏设备取消悬停位移，避免点击后停留在悬停态 */

@media (hover: none) {
  .shell:hover,
  .frame:hover {
    transform: none;
  }
}

@media (max-width: 420px) {
  .main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-title {
    font-size: 22px;
    letter-spacing: 2px;
  }

  .page-title::after {
    width: 23px;
    height: 23px;
    line-height: 23px;
    font-size: 13px;
    margin-left: 9px;
  }

  .card {
    padding: 20px 16px;
  }

  .drawer-desc {
    font-size: 12.5px;
  }

  .empty-tag {
    display: none;
  }

  .chips {
    gap: 6px;
  }

  .chip {
    font-size: 12px;
    padding: 3px 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page {
    animation: none;
  }

  .sidebar,
  .backdrop {
    transition: none;
  }
}
