:root {
  --paper:      #FBF9F4;   /* 页面底色：暖白宣纸 */
  --paper-2:    #F2EDE1;   /* 外层衬底 */
  --surface:    #FFFFFF;   /* 卡片本体 */
  --ink:        #2B2924;   /* 正文主色，偏暖黑 */
  --ink-dim:    #8B8577;   /* 次要文字 */
  --ink-faint:  #BDB6A4;   /* 占位符/最弱文字 */
  --hairline:   #E8E1D0;   /* 细分隔线 */

  --seal:       #B3402E;   /* 主题朱红，弱化饱和度，只做点缀 */
  --seal-soft:  #F5E4DD;
  --jade:       #2E6B5A;   /* 主题墨绿，只做点缀 */
  --jade-soft:  #E3EEE8;
  --gold:       #B8922A;   /* 金，仅用于极细的强调线 */
  --gold-soft:  #F4EAC9;

  --shadow-sm: 0 1px 2px rgba(43,38,28,.05), 0 1px 1px rgba(43,38,28,.04);
  --shadow-md: 0 10px 30px rgba(43,38,28,.08), 0 2px 8px rgba(43,38,28,.04);

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #DDD6C4;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 400;
  overscroll-behavior-y: none;
  line-height: 1.5;
}
.app {
  width: 100%; max-width: 480px; margin: 0 auto;
  height: 100vh; height: 100dvh;
  background: var(--paper); position: relative;
  overflow: hidden;
}
/* 四角"氧化"暗角：极淡的暖褐色四角光晕，只在边缘留一点岁月感 */
.app::before {
  content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background:
    radial-gradient(circle at 0% 0%,   rgba(99, 54, 11, 0.10), transparent 30%),
    radial-gradient(circle at 100% 0%, rgba(99, 54, 11, 0.10), transparent 30%),
    radial-gradient(circle at 0% 100%, rgba(99, 54, 11, 0.10), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(107, 64, 24, 0.12), transparent 32%);
}
/* 颗粒噪点：叠在纸面上做细微颗粒感，overlay 混合模式 + 低透明度，不会盖住文字 */
.app::after {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  mix-blend-mode: overlay; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page { display: none; height: 100%; }
.page.active { display: flex; flex-direction: column; height: 100%; }

/* ===== 列表页头部：圆形印章徽标 + 磨砂搜索框，取代整块纯色矩形 ===== */
.header {
  padding: calc(8px + var(--safe-top)) 22px 18px; flex-shrink: 0; position: relative; z-index: 6;
  background: rgba(251,249,244,.68);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(232,225,208,.7);
}
.header-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.seal-badge {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--seal); color: #FBF3EC;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 16px; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.seal-badge.small { width: 26px; height: 26px; font-size: 13px; }
.header-title { font-size: 17px; font-weight: 700; letter-spacing: 1px; color: var(--ink); }
.header-count {
  margin-left: auto; font-size: 11px; color: var(--ink-dim);
  display: flex; align-items: center; gap: 8px;
}
.ghost-btn {
  border: 1px solid var(--hairline); background: var(--surface);
  color: var(--ink-dim); font-size: 12px; border-radius: 8px;
  padding: 4px 8px; font-family: var(--font-serif); cursor: pointer;
}
.search-pill {
  width: 100%; height: 38px; border-radius: 19px; background: rgba(255,255,255,.55);
  backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid rgba(255,255,255,.6); padding: 0 16px; font-size: 12.5px;
  color: var(--ink); outline: none; font-family: var(--font-serif); box-shadow: var(--shadow-sm);
}
.search-pill::placeholder { color: var(--ink-dim); }
.actions-row { display: flex; gap: 10px; margin-top: 14px; }
.action-btn {
  flex: 1; height: 38px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: var(--font-serif);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  letter-spacing: .5px;
}
.action-btn.primary { background: var(--seal); color: #FBF3EC; box-shadow: var(--shadow-sm); }
.action-btn.primary:active { opacity: .85; }
.action-btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--hairline); }
.action-btn.secondary:active { background: #f7f4ec; }

/* ---- 列表区 ---- */
.list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 13px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.card {
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); border: 1px solid var(--hairline);
  padding: 13px 14px; display: flex; align-items: center; gap: 12px;
  cursor: pointer; flex-shrink: 0;
}
.card:active { background: #fbfaf6; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-dot.seal { background: var(--seal); }
.tag-dot.jade { background: var(--jade); }
.tag-dot.gold { background: var(--gold); }
.card-body { flex: 1; min-width: 0; }
.c-name {
  font-family: var(--font-serif); font-size: 14.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.c-artist {
  font-size: 11px; color: var(--ink-dim); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-arrow { color: var(--ink-faint); font-size: 13px; flex-shrink: 0; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--ink-faint); text-align: center; padding: 40px;
}
.empty-state .glyph {
  width: 52px; height: 52px; border-radius: 50%; background: var(--seal-soft);
  color: var(--seal); font-family: var(--font-serif); font-size: 24px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.empty-state .line1 { font-size: 13px; color: var(--ink-dim); margin-bottom: 6px; }
.empty-state .line2 { font-size: 11.5px; }

/* ===== 录入页 ===== */
.form-header {
  padding: calc(10px + var(--safe-top)) 22px 16px; flex-shrink: 0; position: relative; z-index: 6;
  background: rgba(251,249,244,.68);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(232,225,208,.7);
}
.nav-link {
  background: none; border: none; color: var(--ink-dim); font-size: 12.5px;
  cursor: pointer; font-family: var(--font-serif); padding: 2px 4px;
}
.form-title-row { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.form-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 18px 22px calc(20px + var(--safe-bottom)); }
.field { margin-bottom: 24px; }
.field .flabel { font-size: 11px; color: var(--ink-dim); margin-bottom: 8px; letter-spacing: 1px; }
.fline {
  width: 100%; border: none; border-bottom: 1.5px solid var(--hairline); background: none;
  outline: none; padding: 8px 2px; font-size: 13.5px; color: var(--ink); font-family: var(--font-serif);
}
.fline::placeholder { color: var(--ink-faint); }
.fline:focus { border-bottom-color: var(--seal); }
.flyric {
  width: 100%; border: 1px solid var(--hairline); border-radius: var(--radius-sm); padding: 12px;
  font-family: var(--font-serif); font-size: 13px; line-height: 2; color: var(--ink); min-height: 220px;
  background: var(--surface); outline: none; resize: none;
}
.flyric::placeholder { color: var(--ink-faint); }
.flyric:focus { border-color: var(--seal); }
.field .hint { font-size: 10px; color: var(--ink-faint); margin-top: 6px; }
.dup-warn {
  background: var(--seal-soft); border: 1px solid var(--seal); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 16px; font-size: 12px; color: var(--seal); line-height: 1.7;
}
.form-btns { margin-top: 4px; }
.save-btn {
  width: 100%; height: 46px; border-radius: 14px; border: none; background: var(--seal); cursor: pointer;
  color: #FBF3EC; font-size: 14px; font-weight: 700; letter-spacing: 2px; box-shadow: var(--shadow-sm);
  margin-bottom: 10px; font-family: var(--font-serif);
}
.save-btn:active { opacity: .85; }
.cancel-btn {
  width: 100%; height: 44px; border-radius: 14px; background: none; cursor: pointer;
  color: var(--ink-dim); border: 1px solid var(--hairline); font-size: 13px; letter-spacing: 1.5px;
  margin-bottom: 10px; font-family: var(--font-serif);
}
.btn-del { background: none; color: var(--seal); border: none; font-size: 12px; letter-spacing: 1px; height: auto; cursor: pointer; font-family: var(--font-serif); }

/* ===== 详情页 ===== */
.detail-nav {
  padding: calc(10px + var(--safe-top)) 18px 12px; display: flex; align-items: center; flex-shrink: 0;
}
.detail-center { flex: 1; text-align: center; padding: 0 8px; min-width: 0; }
.d-title { font-family: var(--font-serif); font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-artist { font-size: 11px; color: var(--ink-dim); margin-top: 3px; }
.hairline { height: 1px; background: var(--hairline); margin: 0 20px; flex-shrink: 0; }
.lyrics-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.scroll-hint { text-align: center; color: var(--ink-faint); font-size: 11px; padding: 5px 0; flex-shrink: 0; user-select: none; }
.scroll-hint.hidden { visibility: hidden; }
.lyrics-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 30px; }
.lyric-line { text-align: center; font-family: var(--font-serif); font-size: 13px; line-height: 2.3; letter-spacing: 1.5px; color: var(--ink); }
.lyrics-empty { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 40px 0; font-style: italic; }
.control-area {
  display: flex; align-items: center; justify-content: center; gap: 32px;
  padding: 22px 20px calc(22px + var(--safe-bottom)); flex-shrink: 0;
}
.ctrl-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--hairline);
  background: var(--surface); box-shadow: var(--shadow-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--ink); padding: 0;
}
.ctrl-btn.filled { background: var(--seal); color: #FBF3EC; border: none; }
.ctrl-btn:active { opacity: .82; }
.ctrl-btn:disabled { opacity: .3; cursor: default; }
.ctrl-index { font-size: 10px; color: var(--ink-faint); min-width: 40px; text-align: center; letter-spacing: 1px; }

/* ===== 备份面板 ===== */
.bk-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(43,41,36,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.bk-overlay.show { opacity: 1; pointer-events: auto; }
.bk-sheet {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: 0; width: 100%; max-width: 480px; z-index: 95;
  background: var(--paper); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--hairline); box-shadow: var(--shadow-md);
  padding: 8px 22px calc(22px + var(--safe-bottom)); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.bk-sheet.show { transform: translateX(-50%) translateY(0); }
.bk-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--hairline); margin: 8px auto 16px; }
.bk-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; letter-spacing: 1px; color: var(--ink); }
.bk-desc { font-size: 11px; color: var(--ink-dim); line-height: 1.8; margin-bottom: 16px; }
.bk-btns { display: flex; gap: 10px; margin-bottom: 10px; }
.bk-btns button {
  flex: 1; height: 40px; border-radius: 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: var(--font-serif); letter-spacing: 1px;
}
.bk-export { background: var(--surface); color: var(--jade); border: 1px solid var(--hairline); }
.bk-import { background: var(--surface); color: var(--ink); border: 1px solid var(--hairline); }
.bk-viewer {
  width: 100%; height: 40px; margin-bottom: 10px; background: var(--seal); border: none; border-radius: 12px;
  color: #FBF3EC; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font-serif);
  letter-spacing: 1px; box-shadow: var(--shadow-sm);
}

.toast {
  position: fixed; left: 50%; bottom: calc(60px + var(--safe-bottom));
  transform: translateX(-50%) translateY(16px); z-index: 100;
  background: var(--ink); color: var(--paper); padding: 9px 18px; border-radius: 20px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: all .22s; letter-spacing: 1px;
}
.toast.show { opacity: .94; transform: translateX(-50%) translateY(0); }
