/* ============================================================
 * 万年历 · 视觉设计系统
 * 设计语言：东方极简 / 现代历书
 * 宣纸底 · 墨色字 · 朱砂点睛 · 青绿节气 · 细线网格
 * ============================================================ */

:root {
  /* 表面与线条 */
  --paper: #f4f2ed;
  --paper-2: #eceae4;
  --surface: #fffefb;
  --surface-2: #f8f6f1;
  --surface-3: #f1eee7;
  --surface-4: #e9e5dc;
  --line: #e5e0d6;
  --line-strong: #d5cec1;
  --grid-line: #ded7c9;

  /* 文字 */
  --ink: #23282b;
  --ink-2: #5d666b;
  --ink-3: #949b9e;
  --ink-invert: #fffefb;

  /* 语义色 */
  --verm: #a83b30;
  --verm-deep: #82271f;
  --verm-soft: #f7ebe7;
  --verm-line: #e8c9c2;
  --jade: #2f7767;
  --jade-soft: #e6f0ec;
  --jade-line: #bcd9cf;
  --gold: #a67c33;
  --gold-soft: #f6efdf;
  --gold-line: #e5d3ae;
  --ochre: #b0792a;
  --ochre-soft: #faf0de;
  --weekend: #fbf4f1;
  --rest: #2f7767;
  --rest-soft: #e6f0ec;
  --work: #a96f22;
  --work-soft: #f8ecd8;

  /* 阴影：低对比、分层 */
  --sh-1: 0 1px 2px rgba(35, 30, 22, .04), 0 2px 8px rgba(35, 30, 22, .035);
  --sh-2: 0 2px 6px rgba(35, 30, 22, .045), 0 12px 32px rgba(35, 30, 22, .07);
  --sh-3: 0 18px 56px rgba(28, 24, 18, .18), 0 2px 8px rgba(28, 24, 18, .08);
  --sh-focus: 0 0 0 3px rgba(168, 59, 48, .18);

  /* 尺度 */
  --r-xs: 6px;
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  --cell-h: 82px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --font-num: "SF Pro Display", "Helvetica Neue", "PingFang SC", var(--font-sans);
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #14171a;
  --paper-2: #101316;
  --surface: #1c2024;
  --surface-2: #22272c;
  --surface-3: #282e34;
  --surface-4: #30373e;
  --line: #30363c;
  --line-strong: #414951;
  --grid-line: #363d44;
  --ink: #ece9e3;
  --ink-2: #a9b0b4;
  --ink-3: #757e84;
  --ink-invert: #14171a;
  --verm: #e07463;
  --verm-deep: #f0927f;
  --verm-soft: #342422;
  --verm-line: #5a3630;
  --jade: #63bd9f;
  --jade-soft: #1d332d;
  --jade-line: #2d5044;
  --gold: #d3ad69;
  --gold-soft: #332a1d;
  --gold-line: #4d3f27;
  --ochre: #d9a458;
  --ochre-soft: #352a1a;
  --weekend: #241f1e;
  --rest: #63bd9f;
  --rest-soft: #1d332d;
  --work: #d9a458;
  --work-soft: #352a1a;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .2), 0 2px 8px rgba(0, 0, 0, .16);
  --sh-2: 0 2px 8px rgba(0, 0, 0, .25), 0 16px 36px rgba(0, 0, 0, .28);
  --sh-3: 0 20px 60px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  --sh-focus: 0 0 0 3px rgba(224, 116, 99, .28);
  color-scheme: dark;
}

[data-density="compact"] { --cell-h: 64px; }

/* ---------- Reset / Base ---------- */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 88% -12%, rgba(168, 59, 48, .055), transparent 62%),
    radial-gradient(900px 520px at -12% 8%, rgba(47, 119, 103, .045), transparent 58%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--verm); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--verm); color: #fff; }

/* ---------- 图标 / 通用元件 ---------- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.icon {
  width: 1em; height: 1em; display: inline-block; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.14em;
}
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font-family: var(--font-num); font-size: 11px; font-weight: 600; line-height: 1;
  color: var(--ink-3); background: var(--surface-2);
  border: 1px solid var(--line); border-bottom-color: var(--line-strong);
  border-radius: 5px; white-space: nowrap;
}
.muted-text { color: var(--ink-3); font-size: 13px; }

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px max(24px, env(safe-area-inset-right)) 40px max(24px, env(safe-area-inset-left));
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: var(--s6);
  animation: rise .5s var(--ease) both;
  /* rise 动画（fill-mode: both）会让 topbar 形成层叠上下文，
     必须显式抬高整层，否则下拉菜单的 z-index 被困在内部，被下方 hero 卡片盖住 */
  position: relative; z-index: 70;
}
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-seal {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 25px; font-weight: 700;
  color: #fff8f2; background: var(--verm);
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px var(--verm), inset 0 0 0 3px rgba(255, 255, 255, .42), 0 4px 12px rgba(168, 59, 48, .24);
  letter-spacing: 0;
}
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 21px; font-weight: 700; letter-spacing: .16em;
  line-height: 1.25; white-space: nowrap;
}
.brand-text p { font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em; margin-top: 2px; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; align-items: center; position: relative; flex: none; }

.cmd-trigger {
  display: inline-flex; align-items: center; gap: 9px;
  height: 40px; min-width: 232px; padding: 0 10px 0 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-3);
  font-size: 13px; cursor: pointer; text-align: left;
  box-shadow: var(--sh-1);
  transition: border-color .2s, color .2s, box-shadow .2s, transform .2s;
}
.cmd-trigger .icon { font-size: 17px; }
.cmd-trigger-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-trigger:hover { border-color: var(--line-strong); color: var(--ink-2); transform: translateY(-1px); box-shadow: var(--sh-2); }
.cmd-trigger .kbd { font-size: 10px; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-sm); color: var(--ink-2);
  font-size: 19px; cursor: pointer; padding: 0;
  box-shadow: var(--sh-1);
  transition: color .2s, background .2s, border-color .2s, transform .2s, box-shadow .2s;
}
.icon-btn:hover { color: var(--verm); border-color: var(--verm-line); background: var(--verm-soft); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn-sm { width: 34px; height: 34px; font-size: 16px; border-radius: var(--r-xs); box-shadow: none; }

.menu-wrap { position: relative; }
/* 文件选择器：视觉隐藏但保持可点击，避免 display:none 在部分浏览器无法唤起选择器 */
.sr-file { position: fixed; left: 0; top: -100px; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.menu:not([hidden]) {
  position: absolute; top: calc(100% + 9px); right: 0;
  min-width: 224px; padding: 7px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--sh-3);
  display: flex; flex-direction: column; gap: 2px; z-index: 60;
  /* 功能型控件不做 opacity 渐显：动画时钟不推进时（后台页 / 省电 / 内嵌浏览器）
     fill-mode: both 会把菜单永久停在首帧而变成隐形的 */
  animation: popIn .18s var(--ease) both;
}
.menu-label { padding: 5px 10px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; color: var(--ink-2);
  text-align: left; padding: 9px 10px; border-radius: var(--r-xs);
  cursor: pointer; font-size: 13px; min-height: 40px;
}
.menu-item .icon { font-size: 16px; color: var(--ink-3); }
.menu-item:hover { background: var(--verm-soft); color: var(--verm); }
.menu-item:hover .icon { color: var(--verm); }

/* ---------- Hero · 今日速览 ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
  gap: var(--s7);
  padding: 26px 30px 24px;
  background:
    radial-gradient(760px 340px at 92% -30%, var(--verm-soft), transparent 66%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-2);
  margin-bottom: var(--s5);
  animation: rise .55s .05s var(--ease) both;
}
.hero::before {
  content: ""; position: absolute; inset: 5px; pointer-events: none;
  border: 1px solid rgba(168, 59, 48, .07); border-radius: calc(var(--r-xl) - 5px);
}
[data-theme="dark"] .hero::before { border-color: rgba(255, 255, 255, .045); }
.hero-grain {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: repeating-linear-gradient(0deg, transparent 0 3px, rgba(120, 100, 70, .018) 3px 4px);
}
.hero-main, .hero-side { position: relative; z-index: 1; min-width: 0; }
.hero-kicker {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px; font-weight: 600; letter-spacing: .14em; color: var(--ink-3);
  text-transform: uppercase;
}
.kicker-rule { width: 22px; height: 1px; background: var(--verm); flex: none; }
.hero-date-row { display: flex; align-items: center; gap: 18px; margin-top: 6px; }
.hero-daynum {
  font-family: var(--font-num); font-size: clamp(54px, 6.4vw, 78px);
  font-weight: 250; line-height: 1; letter-spacing: -.055em; color: var(--ink);
  font-variant-numeric: tabular-nums lining-nums;
}
.hero-date-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hero-ym { font-size: 17px; font-weight: 650; letter-spacing: .04em; color: var(--ink); }
.hero-week { font-size: 13px; color: var(--ink-2); }
.hero-today-badge {
  align-self: flex-start; margin-top: 3px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--verm); background: var(--verm-soft);
  border: 1px solid var(--verm-line); border-radius: 999px; padding: 2px 9px;
}
.hero-seal {
  margin-left: auto; flex: none;
  width: 52px; height: 52px; display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 27px; font-weight: 700; color: var(--verm);
  border: 2px solid var(--verm); border-radius: 7px;
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--verm);
  transform: rotate(-7deg); opacity: .82;
}
.hero-lunar {
  margin-top: 12px; font-family: var(--font-serif);
  font-size: 15.5px; font-weight: 600; letter-spacing: .04em;
  color: var(--verm); overflow-wrap: anywhere;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.hero-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; line-height: 1.4; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
button.hero-chip { cursor: pointer; transition: border-color .2s, background .2s; }
button.hero-chip:hover { border-color: var(--verm); background: var(--verm-soft); }
.hero-chip .icon { font-size: 13px; color: var(--ink-3); }
.hero-chip b { font-weight: 650; color: var(--ink); }
.hero-chip.is-jade .icon { color: var(--jade); }
.hero-chip.is-gold .icon { color: var(--gold); }
.hero-chip.is-verm .icon { color: var(--verm); }

.hero-yiji { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.h-yi, .h-ji {
  display: flex; align-items: flex-start; gap: 10px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px;
}
.h-yi { border-left: 2px solid var(--jade); }
.h-ji { border-left: 2px solid var(--verm); }
.hy-label, .hj-label {
  flex: none; width: 25px; height: 25px; display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 14px; font-weight: 700; color: #fff;
  border-radius: 5px;
}
.hy-label { background: var(--jade); }
.hj-label { background: var(--verm); }
.hy-items, .hj-items {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.75;
  overflow-wrap: anywhere; min-width: 0; padding-top: 2px;
}

.hero-side { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.countdown-card {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 13px; cursor: pointer;
  color: var(--ink); box-shadow: var(--sh-1);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.countdown-card:hover { border-color: var(--verm-line); transform: translateY(-2px); box-shadow: var(--sh-2); }
.cd-ring { position: relative; width: 44px; height: 44px; flex: none; }
.cd-ring > svg[viewBox] { position: absolute; inset: 0; width: 44px; height: 44px; }
.cd-ring circle { fill: none; stroke-width: 2.2; }
.cd-ring-bg { stroke: var(--line); }
.cd-ring-fg {
  stroke: var(--jade); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 22px 22px;
  stroke-dasharray: 113.1; stroke-dashoffset: 113.1;
  transition: stroke-dashoffset .8s var(--ease);
}
#cdFestRing { stroke: var(--verm); }
.cd-ring .cd-ring-icon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 19px; height: 19px; font-size: 19px; color: var(--jade); stroke-width: 1.6;
}
#cdFest .cd-ring-icon { color: var(--verm); }
.cd-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.cd-label { font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); }
.cd-name { font-size: 15px; font-weight: 680; color: var(--ink); overflow-wrap: anywhere; }
.cd-days { font-size: 12px; font-weight: 600; color: var(--verm); }
.cd-arrow { font-size: 15px; color: var(--ink-3); flex: none; }
.hero-timeline-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px dashed var(--line-strong); background: transparent;
  color: var(--ink-2); border-radius: var(--r); padding: 8px 12px;
  font-size: 12px; cursor: pointer; transition: all .2s;
}
.hero-timeline-btn .icon { font-size: 13px; }
.hero-timeline-btn:hover { border-color: var(--verm); color: var(--verm); background: var(--verm-soft); }

/* ---------- 未来节令时间线 ---------- */
.timeline-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
  padding: 18px 22px 16px; margin-bottom: var(--s5);
  animation: rise .3s var(--ease) both;
}
.tp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.tp-head h2 { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.tp-head p { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.tp-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; scrollbar-width: thin; }
.tp-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; border-bottom: 1px solid var(--line); background: transparent;
  padding: 9px 6px; text-align: left; cursor: pointer; color: var(--ink);
  transition: background .18s;
}
.tp-item:last-child { border-bottom: 0; }
.tp-item:hover { background: var(--surface-2); }
.tp-date { flex: none; width: 74px; font-family: var(--font-num); font-size: 12px; color: var(--ink-3); }
.tp-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--jade); }
.tp-item.t-festival .tp-dot { background: var(--verm); }
.tp-item.t-holiday .tp-dot { background: var(--gold); }
.tp-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.tp-kind { flex: none; font-size: 10.5px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.tp-left { flex: none; font-size: 11.5px; color: var(--verm); min-width: 58px; text-align: right; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px 16px;
  box-shadow: var(--sh-1); margin-bottom: var(--s5);
  animation: rise .6s .1s var(--ease) both;
}
.nav-group, .jump-group { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-sm); color: var(--ink-2); font-size: 19px; cursor: pointer;
  transition: all .2s;
}
.nav-btn .icon { font-size: 17px; }
.nav-btn:hover { background: var(--verm-soft); color: var(--verm); border-color: var(--verm-line); }
.current-label { display: flex; gap: 7px; }
.select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 8px 28px 8px 12px;
  font-size: 14px; font-weight: 650; cursor: pointer; min-width: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23949b9e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color .2s, background-color .2s;
}
.select:hover { border-color: var(--line-strong); }
.select:focus { outline: none; border-color: var(--verm); box-shadow: var(--sh-focus); }
.select-sm { padding: 7px 26px 7px 11px; font-size: 12.5px; font-weight: 600; }
.today-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--verm); background: var(--verm); color: #fff;
  border-radius: var(--r-sm); padding: 8px 14px; min-height: 38px;
  font-size: 13px; font-weight: 650; cursor: pointer;
  box-shadow: 0 3px 10px rgba(168, 59, 48, .22);
  transition: transform .2s, filter .2s;
}
.today-btn .icon { font-size: 15px; }
.today-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }

.view-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px;
}
.view-tab {
  min-width: 44px; min-height: 32px; padding: 0 12px;
  border: 0; background: transparent; color: var(--ink-3);
  border-radius: 7px; font-size: 13px; font-weight: 650; cursor: pointer;
  transition: all .2s;
}
.view-tab:hover { color: var(--ink); }
.view-tab.is-active { background: var(--surface); color: var(--verm); box-shadow: var(--sh-1); }

.jump-group { position: relative; flex: 1 1 250px; max-width: 330px; justify-content: flex-end; }
.jump-icon { position: absolute; left: 11px; font-size: 15px; color: var(--ink-3); pointer-events: none; }
.jump-input {
  min-width: 0; flex: 1 1 auto; width: 100%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 9px 12px 9px 33px; font-size: 13px;
  transition: border-color .2s, box-shadow .2s;
}
.jump-input::placeholder { color: var(--ink-3); }
.jump-input:focus { outline: none; border-color: var(--verm); box-shadow: var(--sh-focus); }
.jump-btn {
  flex: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-2); border-radius: var(--r-sm); padding: 9px 14px;
  font-size: 13px; font-weight: 650; cursor: pointer; transition: all .2s;
}
.jump-btn:hover { background: var(--verm-soft); color: var(--verm); border-color: var(--verm-line); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(320px, 1fr); gap: var(--s5); align-items: start; animation: rise .65s .14s var(--ease) both; }
.calendar-col { display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }

/* ---------- Calendar ---------- */
.calendar-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px 20px 16px;
  box-shadow: var(--sh-2); min-width: 0; overflow: hidden;
}
.cal-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cal-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.cal-num { font-family: var(--font-num); font-size: 42px; font-weight: 250; line-height: 1; letter-spacing: -.05em; color: var(--ink); }
.cal-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cal-meta b { font-size: 10.5px; font-weight: 700; letter-spacing: .2em; color: var(--verm); }
.cal-meta span { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.cal-range { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.weekdays {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--grid-line); border-bottom: 1px solid var(--line-strong);
}
.weekdays span {
  padding: 8px 4px; text-align: center;
  font-size: 11px; font-weight: 650; letter-spacing: .1em; color: var(--ink-3);
}
.weekdays .wk-sun, .weekdays .wk-sat { color: var(--verm); }

.grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-left: 1px solid var(--grid-line);
}
.grid.anim { animation: gridIn .32s var(--ease) both; }
.cell {
  position: relative; min-width: 0; min-height: var(--cell-h);
  border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line);
  background: transparent; padding: 7px 8px 6px;
  display: flex; flex-direction: column; gap: 1px;
  cursor: pointer; overflow: hidden;
  transition: background .18s var(--ease), box-shadow .18s var(--ease);
}
.cell:hover { background: var(--surface-2); }
.cell.muted { opacity: .38; background: var(--surface-2); }
.cell.muted:hover { opacity: .72; }
/* 深色下相邻月日期若沿用浅色透明度会几乎不可读 */
[data-theme="dark"] .cell.muted { opacity: .58; }
[data-theme="dark"] .cell.muted:hover { opacity: .85; }
.cell.weekend:not(.muted) { background: var(--weekend); }
.cell.weekend:not(.muted):hover { background: var(--verm-soft); }
.cell.rest-day:not(.muted) { background: var(--rest-soft); }
.cell.work-day:not(.muted) { background: var(--work-soft); }
.cell.today { background: var(--verm-soft); }
.cell.selected { box-shadow: inset 0 0 0 2px var(--verm); background: var(--verm-soft); z-index: 1; }
.cell.selected:hover { background: var(--verm-soft); }

.cell-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px; min-width: 0; }
.cell .solar {
  font-family: var(--font-num); font-size: 19px; font-weight: 550; line-height: 1.15;
  color: var(--ink); letter-spacing: -.02em;
}
.cell.weekend:not(.muted) .solar { color: var(--verm); }
.cell.work-day:not(.muted) .solar { color: var(--work); }
.cell.today .solar { color: var(--verm); font-weight: 750; }
.cell.today .solar::after {
  content: ""; display: block; width: 14px; height: 2px;
  background: var(--verm); border-radius: 2px; margin-top: 1px;
}
.cell-flags { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; min-width: 0; }
.cell-pip { width: 5px; height: 5px; border-radius: 50%; flex: none; margin-top: 6px; }
.cell-pip.p-festival { background: var(--verm); }
.cell-pip.p-term { background: var(--jade); }
.cell-pip.p-birth { background: var(--gold); }
.cell .lunar {
  font-size: 11.5px; color: var(--ink-3); line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cell .lunar.festival { color: var(--verm); font-weight: 650; }
.cell .lunar.term { color: var(--jade); font-weight: 650; }
.cell .lunar.lunar-month { color: var(--gold); font-weight: 600; }
.cell-note-preview {
  margin-top: 2px; padding-left: 5px; border-left: 2px solid var(--gold);
  font-size: 10px; line-height: 1.35; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cell.is-done-preview .cell-note-preview { border-left-color: var(--jade); color: var(--ink-3); text-decoration: line-through; }
.cell.muted .cell-note-preview { opacity: .55; }
.cell-foot { margin-top: auto; display: flex; align-items: center; gap: 4px; min-height: 15px; }
.cell .rest-badge, .cell .work-badge {
  font-size: 9px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 4px; white-space: nowrap;
}
.cell .rest-badge { background: var(--rest-soft); color: var(--rest); border: 1px solid var(--jade-line); }
.cell .work-badge { background: var(--work-soft); color: var(--work); border: 1px solid var(--gold-line); }
.cell .note-badge {
  margin-left: auto; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--gold); color: #fff;
  font-family: var(--font-num); font-size: 10px; font-weight: 700;
  line-height: 17px; text-align: center;
}
.cell .note-badge.all-done { background: var(--jade); }
.cell .birth-dot { font-size: 12px; line-height: 1; color: var(--gold); }
.cell .birth-dot .icon { font-size: 13px; }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 14px; font-size: 11px; color: var(--ink-3);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-today { background: var(--verm); }
.dot-festival { background: var(--verm); opacity: .55; }
.dot-term { background: var(--jade); }
.dot-note { background: var(--gold); }
.dot-birth { background: var(--gold); }
.badge-rest, .badge-work { display: inline-flex; align-items: center; font-size: 9px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 4px; }
.badge-rest { background: var(--rest-soft); color: var(--rest); border: 1px solid var(--jade-line); }
.badge-work { background: var(--work-soft); color: var(--work); border: 1px solid var(--gold-line); }

/* ---------- 择吉 ---------- */
.auspicious-card, .notes-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); min-width: 0;
}
.auspicious-card { padding: 16px 18px 18px; }
.card-heading { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.card-heading .icon { font-size: 16px; color: var(--verm); }
.auspicious-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; flex-wrap: wrap; }
.auspicious-title, .notes-title { font-size: 14.5px; font-weight: 700; letter-spacing: .03em; color: var(--ink); }
.auspicious-list { display: flex; flex-wrap: wrap; gap: 8px; min-height: 34px; }
.auspicious-empty { color: var(--ink-3); font-size: 12.5px; }
.auspicious-day {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-sm); padding: 6px 11px; cursor: pointer;
  font-size: 12.5px; font-weight: 650; color: var(--ink);
  transition: all .18s;
}
.auspicious-day:hover { border-color: var(--jade); background: var(--jade-soft); color: var(--jade); }
.auspicious-day .ad-lunar { color: var(--ink-3); font-size: 11px; font-weight: 400; margin-left: 3px; }

/* ---------- 高级备忘录 ---------- */
.notes-card { overflow: hidden; }
.notes-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.notes-heading { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; min-width: 0; }
.notes-scope { font-size: 11.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.notes-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.notes-count-pill {
  font-size: 11px; font-weight: 700; color: var(--verm);
  background: var(--verm-soft); border: 1px solid var(--verm-line);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.notes-icon-btn {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-3); border-radius: var(--r-xs); cursor: pointer;
  font-size: 15px; transition: all .18s;
}
.notes-icon-btn .icon { font-size: 15px; }
.notes-icon-btn:hover { border-color: var(--verm); color: var(--verm); }
.notes-body { padding: 16px 18px 14px; }
.notes-card.is-collapsed .notes-head { border-bottom: 0; }
.notes-card.is-collapsed [data-act="collapse"] .icon { transform: rotate(180deg); }

.notes-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(130px, 1.5fr);
  gap: 10px; align-items: stretch; margin-bottom: 14px;
}
.ns-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px 4px; min-width: 0;
}
.ns-item b { font-family: var(--font-num); font-size: 21px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.ns-item span { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.ns-progress-wrap { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 0 4px; }
.ns-progress-head { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-bottom: 7px; }
.ns-progress-head b { color: var(--jade); font-family: var(--font-num); font-size: 12px; }
.ns-progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.ns-progress i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .4s var(--ease); }

.notes-tabs { display: flex; gap: 4px; margin-bottom: 13px; border-bottom: 1px solid var(--line); }
.notes-tab {
  position: relative; flex: 0 1 auto; min-width: 62px; min-height: 36px;
  border: 0; background: transparent; color: var(--ink-3);
  font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0 14px 8px;
  transition: color .18s;
}
.notes-tab:hover { color: var(--ink); }
.notes-tab.is-active { color: var(--verm); }
.notes-tab.is-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--verm); border-radius: 2px 2px 0 0; }

.note-composer-row { display: flex; gap: 8px; align-items: stretch; }
.note-input {
  min-width: 0; flex: 1 1 auto; width: 100%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 9px 12px; font-size: 13.5px;
  transition: border-color .2s, box-shadow .2s;
}
.note-input:focus { outline: none; border-color: var(--verm); box-shadow: var(--sh-focus); }
.note-input::placeholder { color: var(--ink-3); }
.note-opt-btn {
  width: 40px; flex: 0 0 40px; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3);
  border-radius: var(--r-sm); cursor: pointer; font-size: 16px;
}
.note-opt-btn .icon { font-size: 16px; }
.note-opt-btn:hover, .note-opt-btn[aria-expanded="true"] { border-color: var(--verm); color: var(--verm); background: var(--verm-soft); }
.note-add-btn { flex: 0 0 auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.note-add-btn .icon { font-size: 15px; }
.note-composer-hint { display: inline-block; margin-top: 8px; padding: 4px 9px; border-radius: var(--r-xs); background: var(--jade-soft); color: var(--jade); font-size: 11px; }
.note-advanced {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  margin-top: 10px; padding: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r);
}
.note-advanced label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--ink-2); min-width: 0; }
.note-detail-label { grid-column: 1 / -1; }
.note-select, .note-textarea {
  min-width: 0; width: 100%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: var(--r-xs);
  padding: 8px 10px; font-size: 13px; transition: border-color .2s;
}
.note-select:focus, .note-textarea:focus { outline: none; border-color: var(--verm); }
.note-textarea { min-height: 60px; resize: vertical; line-height: 1.6; }

.notes-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 122px 122px; gap: 8px; margin: 12px 0; }
.notes-toolbar .note-search { width: 100%; }
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.notes-empty { text-align: center; padding: 24px 12px; color: var(--ink-3); font-size: 12.5px; border: 1px dashed var(--line-strong); border-radius: var(--r); }
.notes-empty .ne-icon { font-size: 24px; margin-bottom: 6px; color: var(--ink-3); display: block; }
.notes-empty .ne-icon .icon { font-size: 24px; }
.notes-group { display: flex; flex-direction: column; gap: 8px; }
.ng-head { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); cursor: pointer; padding: 4px 2px; }
.ng-head b { font-size: 12.5px; }
.ng-head span { font-size: 11px; color: var(--ink-3); }
.ng-head em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--ink-3); }
.ng-head:hover b { color: var(--verm); }
.ng-items { display: flex; flex-direction: column; gap: 8px; }

.note-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-left: 2px solid var(--line-strong);
  border-radius: var(--r); background: var(--surface-2); min-width: 0;
  transition: border-color .18s, background .18s;
}
.note-item:hover { border-color: var(--line-strong); }
.note-item.pri-high { border-left-color: var(--verm); }
.note-item.pri-low { opacity: .88; }
.note-item.is-pinned { background: var(--gold-soft); }
.note-item.is-done { opacity: .6; }
.note-item.is-done .ni-text { text-decoration: line-through; color: var(--ink-3); }
.ni-check {
  flex: 0 0 19px; width: 19px; height: 19px; margin-top: 2px;
  display: grid; place-items: center; padding: 0;
  border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface);
  color: #fff; cursor: pointer; font-size: 11px; line-height: 1;
  transition: all .18s;
}
.ni-check .icon { font-size: 12px; }
.ni-check:hover { border-color: var(--jade); }
.ni-check[aria-pressed="true"] { background: var(--jade); border-color: var(--jade); }
.ni-main { flex: 1 1 auto; min-width: 0; }
.ni-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.ni-time { font-family: var(--font-num); font-size: 11px; font-weight: 700; color: var(--verm); background: var(--verm-soft); border-radius: 4px; padding: 1px 5px; }
.ni-text { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.ni-detail { margin-top: 4px; font-size: 12px; color: var(--ink-2); line-height: 1.6; overflow-wrap: anywhere; }
.ni-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ni-tag, .ni-prio, .ni-pinned { font-size: 10px; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.ni-tag { background: var(--jade-soft); color: var(--jade); }
.ni-prio.pri-high { background: var(--verm-soft); color: var(--verm); font-weight: 700; }
.ni-prio.pri-low { background: var(--surface); color: var(--ink-3); }
.ni-pinned { background: var(--gold-soft); color: var(--gold); }
.ni-actions { display: flex; gap: 2px; flex: none; }
.ni-btn { width: 29px; height: 29px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); border-radius: 7px; cursor: pointer; font-size: 13px; padding: 0; }
.ni-btn .icon { font-size: 14px; }
.ni-btn:hover { background: var(--surface); color: var(--verm); }

.note-item.is-editing { display: block; border-left-color: var(--verm); }
.ne-form { display: flex; flex-direction: column; gap: 8px; }
.ne-form .note-input { width: 100%; }
.ne-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ne-actions { display: flex; gap: 8px; }

.notes-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 11px; color: var(--ink-3); }
.notes-foot > span { display: inline-flex; align-items: center; gap: 5px; }
.notes-foot .icon { font-size: 13px; }
.notes-link { border: 0; background: transparent; color: var(--verm); cursor: pointer; font-size: 12px; padding: 6px 4px; display: inline-flex; align-items: center; gap: 4px; text-decoration: underline; text-underline-offset: 3px; }
.notes-link .icon { font-size: 12px; }
.note-undo { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--verm-soft); color: var(--verm); font-size: 12px; }
.note-undo span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.note-undo .notes-link { flex: none; }

/* ---------- Detail ---------- */
.detail-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px;
  box-shadow: var(--sh-2);
  position: sticky; top: 18px;
  max-height: calc(100vh - 36px); overflow-y: auto;
  overscroll-behavior: contain; min-width: 0;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.detail-card::-webkit-scrollbar, .tp-list::-webkit-scrollbar { width: 7px; }
.detail-card::-webkit-scrollbar-thumb, .tp-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
.detail-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 16px; }
.detail-kicker { font-size: 10.5px; font-weight: 700; letter-spacing: .16em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 7px; }
.detail-date { font-size: 23px; font-weight: 700; letter-spacing: .01em; overflow-wrap: anywhere; line-height: 1.3; }
.detail-week { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.detail-lunar {
  margin-top: 11px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--verm-soft); color: var(--verm);
  border: 1px solid var(--verm-line);
  padding: 6px 12px; border-radius: var(--r-sm);
  font-family: var(--font-serif); font-weight: 600; font-size: 14px;
}
.detail-lunar .zodiac { color: var(--gold); font-family: var(--font-sans); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.info-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 11px; min-width: 0; }
.info-box .label { font-size: 10.5px; color: var(--ink-3); margin-bottom: 3px; letter-spacing: .04em; }
.info-box .value { font-size: 14px; font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.info-box .value .sub { font-size: 11.5px; color: var(--ink-2); font-weight: 400; }

.section { margin-top: 17px; }
.section-title {
  font-size: 11px; font-weight: 700; color: var(--ink-2);
  letter-spacing: .12em; margin-bottom: 9px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before { content: ""; width: 3px; height: 12px; background: var(--verm); border-radius: 2px; flex: none; }
.section-title .st-note { margin-left: auto; font-size: 10px; font-weight: 400; letter-spacing: 0; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.chip.festival { background: var(--verm-soft); color: var(--verm); border-color: var(--verm-line); font-weight: 650; }
.chip.term { background: var(--jade-soft); color: var(--jade); border-color: var(--jade-line); font-weight: 650; }
.chip.birth { background: var(--gold-soft); color: var(--gold); border-color: var(--gold-line); font-weight: 650; }
.chip.zodiac { background: var(--gold); color: #fff; border-color: transparent; font-weight: 650; }
.chip.bazi-good { background: var(--jade-soft); color: var(--jade); border-color: transparent; }
.bd-emoji { font-size: 15px; flex: none; color: var(--gold); }
.bd-emoji .icon { font-size: 15px; }
.hero-date, .hero-week, .footer, .bd-item .bd-meta { overflow-wrap: anywhere; }

/* 详情：节日 / 节气 / 生日 / 法定节假日 —— 横向自适应 */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 9px; margin-top: 16px; }
.quick-grid .section {
  margin-top: 0; min-width: 0; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 11px;
}
.quick-grid .section-title { font-size: 10.5px; letter-spacing: .06em; margin-bottom: 7px; }
.quick-grid .chips { gap: 5px; }
.quick-grid .chip { font-size: 11px; padding: 3px 8px; }

.yiji { display: flex; gap: 12px; }
.yiji .col { flex: 1; min-width: 0; }
.yiji .col .h { font-size: 12px; font-weight: 700; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.yiji .col.yi .h { color: var(--jade); }
.yiji .col.ji .h { color: var(--verm); }
.yiji .col .h::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.yiji .col .items { display: flex; flex-wrap: wrap; gap: 5px; }
.yiji .col .items span { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 3px 8px; border-radius: var(--r-xs); color: var(--ink-2); }

.pair-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; font-size: 12.5px; min-width: 0; }
.pair-list > div { min-width: 0; }
.pair-list .k { color: var(--ink-3); }
.pair-list .v { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }

/* 黄历神煞 · 十二时辰吉凶 */
.hl-pairs { margin-top: 12px; padding-top: 11px; border-top: 1px dashed var(--line); }
.hl-caption { display: flex; align-items: baseline; gap: 8px; margin-top: 13px; font-size: 11px; font-weight: 700; color: var(--ink-2); }
.hl-caption span { margin-left: auto; font-size: 10px; font-weight: 400; color: var(--ink-3); }
.hl-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.hl-item {
  min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 5px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); transition: transform .18s var(--ease);
}
.hl-item:hover { transform: translateY(-2px); }
.hl-zhi { font-family: var(--font-serif); font-size: 13px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.hl-luck { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.hl-item.is-ji { background: var(--jade-soft); border-color: var(--jade-line); }
.hl-item.is-ji .hl-luck { color: var(--jade); }
.hl-item.is-xiong { background: var(--verm-soft); border-color: var(--verm-line); }
.hl-item.is-xiong .hl-luck { color: var(--verm); }

#baziResult { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bazi-table { width: 100%; min-width: 320px; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.bazi-table th, .bazi-table td { border: 1px solid var(--line); padding: 7px 6px; text-align: center; }
.bazi-table th { background: var(--surface-2); color: var(--ink-3); font-weight: 600; }
.bazi-table .pillar-name { color: var(--ink-2); font-size: 11.5px; }
.bazi-table .g { font-weight: 700; font-size: 15px; color: var(--verm); }
.bazi-table .z { font-weight: 700; font-size: 15px; color: var(--jade); }
.bazi-table .elem { font-size: 11px; color: var(--ink-3); }
.bazi-table .god { font-size: 11px; color: var(--gold); font-weight: 600; }

.note-area { width: 100%; min-height: 70px; resize: vertical; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; }
.note-area:focus { outline: none; border-color: var(--verm); }
.note-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: var(--r-sm); padding: 8px 15px; min-height: 36px;
  font-size: 12.5px; font-weight: 650; cursor: pointer;
  transition: all .18s;
}
.btn .icon { font-size: 14px; }
.btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-3); }
.btn-primary { border-color: var(--verm); background: var(--verm); color: #fff; box-shadow: 0 3px 10px rgba(168, 59, 48, .2); }
.btn-primary:hover { background: var(--verm-deep); border-color: var(--verm-deep); color: #fff; transform: translateY(-1px); }
.btn-danger { color: var(--verm); }
.note-saved { font-size: 12px; color: var(--jade); margin-left: auto; align-self: center; }

/* ---------- 周视图 ---------- */
.week-view { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); padding: 18px 20px 14px; margin-top: 4px; animation: rise .35s var(--ease) both; }
.wv-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.wv-title { flex: 1; min-width: 140px; }
.wv-title h2 { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.wv-title p { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.wv-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--r); }
.wv-grid { min-width: 720px; display: grid; grid-template-columns: 58px repeat(7, minmax(0, 1fr)); }
.wv-corner { border-bottom: 1px solid var(--line-strong); background: var(--surface-2); }
.wv-dayhead { padding: 8px 4px; text-align: center; border: 0; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer; transition: background .18s; }
.wv-dayhead:hover { background: var(--verm-soft); }
.wv-dayhead.is-today { background: var(--verm-soft); }
.wv-dayhead b { display: block; font-family: var(--font-num); font-size: 17px; font-weight: 650; color: var(--ink); line-height: 1.2; }
.wv-dayhead.is-today b { color: var(--verm); }
.wv-dayhead span { display: block; font-size: 10.5px; color: var(--ink-3); }
.wv-dayhead em { display: block; font-style: normal; font-size: 10px; color: var(--jade); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wv-time-column { min-width: 0; }
.wv-time { border-top: 1px solid var(--line); font-family: var(--font-num); font-size: 10.5px; color: var(--ink-3); text-align: right; padding: 0 6px; height: 42px; transform: translateY(-6px); }
.wv-day { position: relative; border-left: 1px solid var(--line); min-width: 0; background: transparent; }
.wv-day.is-today { background: var(--verm-soft); }
.wv-hour { height: 42px; border-top: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.wv-hour:hover { background: var(--verm-soft); }
.wv-event {
  position: absolute; left: 3px; right: 3px; z-index: 2;
  border-radius: 5px; padding: 3px 6px; overflow: hidden;
  background: var(--jade-soft); color: var(--jade);
  border: 1px solid var(--jade-line); border-left: 3px solid var(--jade);
  font-size: 10.5px; line-height: 1.35; cursor: pointer;
  transition: filter .18s;
}
.wv-event:hover { filter: brightness(.96); }
.wv-event.is-done { opacity: .5; text-decoration: line-through; }
.wv-event.is-high { background: var(--verm-soft); border-color: var(--verm-line); border-left-color: var(--verm); color: var(--verm); }
.wv-event b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wv-event span { display: block; font-family: var(--font-num); opacity: .8; }
.wv-now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--verm); z-index: 3; pointer-events: none; }
.wv-now-line::before { content: ""; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--verm); }
.wv-hint { display: flex; align-items: center; gap: 6px; margin-top: 11px; font-size: 11px; color: var(--ink-3); }
.wv-hint .icon { font-size: 13px; }

/* ---------- 全年视图 ---------- */
.year-view { margin-top: 4px; animation: rise .4s var(--ease) both; }
.year-view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.year-view-title { display: flex; align-items: center; gap: 12px; }
.year-view-title h2 { font-size: 20px; letter-spacing: .06em; min-width: 140px; text-align: center; }
.year-view-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.year-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mini-month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 12px 10px; box-shadow: var(--sh-1); min-width: 0; }
.mini-title { text-align: center; font-weight: 700; font-size: 13px; margin-bottom: 9px; color: var(--ink); letter-spacing: .04em; }
.mini-weekdays, .mini-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.mini-weekdays span { text-align: center; font-size: 9.5px; color: var(--ink-3); padding-bottom: 4px; }
.mini-weekdays span:first-child, .mini-weekdays span:last-child { color: var(--verm); }
.mini-days .md { text-align: center; font-family: var(--font-num); font-size: 10.5px; padding: 4px 0; border-radius: 5px; cursor: pointer; color: var(--ink-2); position: relative; transition: background .15s; }
.mini-days .md:hover { background: var(--verm-soft); color: var(--verm); }
.mini-days .md.muted { color: var(--ink-3); opacity: .3; }
.mini-days .md.weekend { color: var(--verm); }
.mini-days .md.today { background: var(--verm); color: #fff; font-weight: 700; }
.mini-days .md.festival { color: var(--verm); font-weight: 700; }
.mini-days .md.rest { background: var(--rest-soft); color: var(--rest); }
.mini-days .md.work { background: var(--work-soft); color: var(--work); }
.mini-days .md .mb { position: absolute; top: 0; right: 2px; font-size: 8px; }
.mini-days .md .mb .icon { font-size: 9px; }
.year-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 11px; color: var(--ink-3); }
.year-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Footer ----------
   三段信息统一字号 / 行高 / 高度，视觉基线严格对齐；细短线划分信息带 */
.footer { margin-top: var(--s8); padding-top: 18px; border-top: 1px solid var(--line); }
.footer-main {
  display: flex; align-items: center; gap: 18px;
  font-size: 11.5px; line-height: 24px; color: var(--ink-3);
}
.footer-main > * { min-width: 0; height: 24px; margin-top: 0; margin-bottom: 0; line-height: 24px; }
.footer-brand { flex: none; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.footer-name { font-weight: 700; color: var(--ink-2); letter-spacing: .08em; }
.footer-seal {
  width: 20px; height: 20px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 12px; color: #fff;
  background: var(--verm); border-radius: 4px;
}
.footer-meta {
  flex: 0 1 auto; display: block; padding-left: 18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background-image: linear-gradient(var(--line-strong), var(--line-strong));
  background-size: 1px 12px;
  background-position: left center;
  background-repeat: no-repeat;
}
.footer-keys { flex: none; margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.fkey { display: inline-flex; align-items: center; gap: 5px; }
.footer-keys .kbd { height: 19px; min-width: 19px; font-size: 10.5px; }
.footer-note {
  display: flex; align-items: center; gap: 6px;
  margin: 6px 0 0; min-height: 20px;
  font-size: 11.5px; line-height: 20px;
  color: var(--ink-3); opacity: .92;
}
.footer-note .icon { font-size: 13px; flex: none; }

/* ---------- 命令面板 ---------- */
.cmd-overlay:not([hidden]) { position: fixed; inset: 0; z-index: 120; display: flex; align-items: flex-start; justify-content: center; padding: min(14vh, 120px) 16px 16px; }
.cmd-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 24, .46); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fadeIn .2s ease both; }
.cmd-panel {
  position: relative; width: min(640px, 100%);
  display: flex; flex-direction: column;
  max-height: min(70vh, 560px);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden;
  animation: cmdIn .24s var(--ease) both;
}
.cmd-input-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cmd-input-row > .icon { font-size: 19px; color: var(--ink-3); }
.cmd-input-row input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-size: 16px; outline: none; }
.cmd-input-row input::placeholder { color: var(--ink-3); }
.cmd-results { flex: 1; overflow-y: auto; padding: 8px; scrollbar-width: thin; }
.cmd-group { padding: 8px 10px 4px; font-size: 10px; font-weight: 700; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; }
.cmd-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  border: 0; background: transparent; color: var(--ink);
  padding: 9px 11px; border-radius: var(--r-sm); cursor: pointer; text-align: left;
  font-size: 13px; min-height: 42px;
}
.cmd-item .ci-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--surface-2); color: var(--ink-3); }
.cmd-item .ci-icon .icon { font-size: 15px; }
.cmd-item .ci-main { flex: 1; min-width: 0; }
.cmd-item .ci-main b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item .ci-main small { display: block; font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-item .ci-hint { flex: none; font-size: 11px; color: var(--ink-3); }
.cmd-item.is-active, .cmd-item:hover { background: var(--verm-soft); }
.cmd-item.is-active .ci-icon { background: var(--verm); color: #fff; }
.cmd-empty { padding: 34px 12px; text-align: center; color: var(--ink-3); font-size: 13px; }
.cmd-empty .icon { font-size: 26px; display: block; margin: 0 auto 8px; }
.cmd-foot { display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 10.5px; color: var(--ink-3); }
.cmd-foot span { display: inline-flex; align-items: center; gap: 3px; }
.cmd-foot .kbd { height: 17px; min-width: 17px; font-size: 10px; }
.cmd-foot-brand { margin-left: auto; }

/* ---------- Modal ---------- */
.modal:not([hidden]) { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 24, .5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fadeIn .2s ease both; }
.modal-card {
  position: relative; width: min(520px, 100%); max-height: min(88vh, 780px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-xl); padding: 22px; box-shadow: var(--sh-3);
  scrollbar-width: thin; animation: cmdIn .24s var(--ease) both;
}
.modal-card-wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.modal-head h3 .icon { font-size: 18px; color: var(--verm); }
.modal-close { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: var(--r-xs); cursor: pointer; font-size: 15px; padding: 0; }
.modal-close .icon { font-size: 15px; }
.modal-close:hover { color: var(--verm); border-color: var(--verm-line); }

.bd-form { display: flex; flex-direction: column; gap: 12px; }
.bd-row { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bd-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bd-row-3 { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 12px; }
.bd-row label { font-size: 11.5px; color: var(--ink-2); min-width: 0; }
.bd-input { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: var(--r-sm); padding: 9px 12px; font-size: 13.5px; width: 100%; transition: border-color .2s; }
.bd-input:focus { outline: none; border-color: var(--verm); box-shadow: var(--sh-focus); }
.bd-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.bd-msg { font-size: 12px; color: var(--jade); margin-right: auto; }
.bd-list-head { display: flex; align-items: center; gap: 8px; margin: 18px 0 9px; font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--ink-3); }
.bd-list-head span { font-family: var(--font-num); font-size: 10px; color: var(--verm); background: var(--verm-soft); border-radius: 999px; padding: 1px 7px; }
.bd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bd-item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; font-size: 12.5px; }
.bd-item .bd-info { flex: 1; min-width: 0; }
.bd-item .bd-name { font-weight: 650; color: var(--ink); }
.bd-item .bd-meta { font-size: 11px; color: var(--ink-3); }
.bd-item .bd-del { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--verm); cursor: pointer; font-size: 12px; padding: 5px 8px; border-radius: var(--r-xs); }
.bd-item .bd-del:hover { background: var(--verm-soft); }

/* 偏好设置 */
.settings-body { display: flex; flex-direction: column; gap: 20px; }
.set-group h4 { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 11px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; flex-wrap: wrap; }
.set-row > label { font-size: 13px; font-weight: 600; color: var(--ink-2); flex: none; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 9px; flex-wrap: wrap; }
.segmented button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--ink-3); border-radius: 6px; padding: 6px 11px; min-height: 30px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .18s; }
.segmented button .icon { font-size: 13px; }
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { background: var(--surface); color: var(--verm); box-shadow: var(--sh-1); }
.set-checks { justify-content: flex-start; gap: 10px 18px; }
.check-label { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.check-label input { width: 16px; height: 16px; accent-color: var(--verm); cursor: pointer; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.set-hint { display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px; color: var(--ink-3); line-height: 1.6; margin-top: 4px; }
.set-hint .icon { font-size: 14px; flex: none; margin-top: 1px; }
.shortcuts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.shortcuts-grid > div { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 7px 0; border-bottom: 1px solid var(--line); }
.shortcuts-grid span { margin-left: auto; font-size: 11.5px; color: var(--ink-2); text-align: right; }
.shortcuts-grid .kbd { flex: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(26px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px; max-width: min(92vw, 460px);
  background: var(--ink); color: var(--surface);
  padding: 10px 18px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; box-shadow: var(--sh-3); z-index: 200;
  animation: toastIn .3s var(--ease) both;
}
.toast .icon { font-size: 15px; color: var(--jade); }
[data-theme="dark"] .toast .icon { color: var(--jade); }
.toast span { overflow-wrap: anywhere; }

/* ---------- 生日提醒条 ---------- */
.bd-reminder { background: linear-gradient(100deg, var(--gold-soft), var(--verm-soft)); border: 1px solid var(--gold-line); color: var(--verm); border-radius: var(--r); padding: 10px 16px; margin-bottom: var(--s5); box-shadow: var(--sh-1); }
.bd-reminder-inner { display: flex; align-items: center; gap: 12px; }
.bd-reminder-icon { font-size: 18px; line-height: 1; flex: none; color: var(--verm); }
.bd-reminder-icon .icon { font-size: 19px; }
.bd-reminder-body { flex: 1; min-width: 0; }
.bd-reminder-title { font-weight: 700; font-size: 12px; margin-bottom: 6px; letter-spacing: .04em; }
.bd-reminder-list { display: flex; flex-wrap: wrap; gap: 8px; }
.bd-rem-item { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--verm-line); border-radius: 999px; padding: 3px 4px 3px 11px; font-size: 12px; }
.bd-rem-item b { font-weight: 700; }
.bd-rem-text { min-width: 0; overflow-wrap: anywhere; }
.bd-rem-go { border: 0; background: var(--verm); color: #fff; border-radius: 999px; padding: 3px 11px; font-size: 11.5px; font-weight: 650; cursor: pointer; }
.bd-rem-go:hover { filter: brightness(1.08); }
.bd-rem-dismiss { display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 12px; padding: 3px 7px; border-radius: 999px; }
.bd-rem-dismiss .icon { font-size: 12px; }
.bd-rem-dismiss:hover { background: var(--surface-3); color: var(--verm); }
.bd-reminder-close { border: 1px solid var(--verm-line); background: transparent; color: var(--verm); border-radius: 999px; padding: 5px 13px; font-size: 11.5px; cursor: pointer; flex: none; }
.bd-reminder-close:hover { background: var(--surface); }

/* ---------- 动效 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: translateY(-6px) scale(.98); } to { transform: none; } }
@keyframes cmdIn { from { opacity: 0; transform: translateY(-12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes gridIn { from { opacity: .35; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================================================
 * 响应式 · 断点体系
 * ============================================================ */
@media (max-width: 1240px) {
  .app { max-width: 100%; }
  .cmd-trigger { min-width: 190px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .detail-card { position: static; max-height: none; overflow: visible; overscroll-behavior: auto; }
  .quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1.4fr) minmax(260px, 1fr); gap: var(--s5); }
  .cal-num { font-size: 38px; }
  /* 中等宽度：品牌与快捷键同排，说明整行左对齐，仍是两条整齐的水平线 */
  .footer-main { flex-wrap: wrap; row-gap: 4px; }
  .footer-keys { margin-left: auto; }
  .footer-meta {
    flex: 1 1 100%; order: 3; padding-left: 0;
    background-image: none;
    height: auto; min-height: 20px; line-height: 20px;
    white-space: normal; overflow: visible; text-overflow: clip;
  }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 22px; }
  .hero-side { flex-direction: row; flex-wrap: wrap; }
  .hero-side .countdown-card { flex: 1 1 210px; }
  .hero-timeline-btn { flex: 1 1 100%; }
  .hero-seal { width: 46px; height: 46px; font-size: 24px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jump-group { flex-basis: 100%; max-width: none; }
  .toolbar { gap: 10px; }
  .cmd-trigger { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .cmd-trigger .cmd-trigger-label, .cmd-trigger .kbd { display: none; }
}

@media (max-width: 720px) {
  .app { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); padding-top: max(18px, env(safe-area-inset-top)); }
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 18px; }
  .brand-seal { width: 40px; height: 40px; font-size: 22px; }
  .topbar-actions { gap: 6px; }
  .icon-btn { width: 38px; height: 38px; }
  .cell { min-height: 74px; padding: 6px; }
  [data-density="compact"] .cell { min-height: 60px; }
  .cell-note-preview { display: none; }
  .cell .solar { font-size: 17px; }
  .cell .lunar { font-size: 10.5px; }
  .cal-num { font-size: 34px; }
  .calendar-card { padding: 16px 12px 14px; }
  .year-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 560px) {
  .app { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
  .topbar { flex-wrap: nowrap; gap: 8px; margin-bottom: 14px; }
  .topbar-actions { gap: 5px; }
  .brand-text { display: none; }
  .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .cmd-trigger { width: 38px; height: 38px; }

  /* 手机首屏优先：Hero 压到约 270px，让月历网格进入首屏可视区 */
  .hero { padding: 12px 12px 10px; border-radius: var(--r-lg); margin-bottom: 10px; row-gap: 6px; }
  .hero::before { inset: 4px; }
  .hero-kicker { font-size: 9.5px; gap: 6px; letter-spacing: .08em; }
  .kicker-rule { width: 14px; }
  .hero-date-row { gap: 9px; margin-top: 2px; }
  .hero-daynum { font-size: 40px; }
  .hero-ym { font-size: 13px; }
  .hero-week { font-size: 11px; }
  .hero-today-badge { font-size: 9px; padding: 1px 6px; margin-top: 1px; }
  .hero-seal { display: none; }
  .hero-lunar { font-size: 11.5px; margin-top: 5px; }
  /* 标签允许换行而不裁切，缩放间距控制高度 */
  .hero-chips {
    flex-wrap: wrap; overflow: visible; gap: 4px 5px; margin-top: 6px;
    padding-bottom: 0; scroll-snap-type: none; scrollbar-width: auto;
    -webkit-mask-image: none; mask-image: none;
  }
  .hero-chip { flex: none; scroll-snap-align: none; font-size: 9.5px; padding: 2px 7px; }
  .hero-chip .icon { font-size: 11px; }
  /* 宜忌只留一行摘要，全文见 title 与详情面板 */
  .hero-yiji { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 5px; margin-top: 8px; }
  .h-yi, .h-ji { gap: 6px; padding: 5px 7px; border-radius: 8px; align-items: center; }
  .hy-label, .hj-label { width: 18px; height: 18px; font-size: 11px; border-radius: 4px; }
  .hy-items, .hj-items {
    font-size: 10.5px; line-height: 1.4; padding-top: 0; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* 用 grid 彻底绕开 flex-direction 覆盖：两张倒计时并排，时间线按钮跨列 */
  .hero .hero-side {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px; justify-content: stretch; align-content: start;
  }
  .hero .hero-side .countdown-card {
    width: 100%; min-width: 0; flex: none; padding: 5px 7px; gap: 6px; border-radius: 8px;
  }
  .hero .hero-side .cd-ring { width: 24px; height: 24px; }
  .hero .hero-side .cd-ring > svg[viewBox] { width: 24px; height: 24px; }
  .hero .hero-side .cd-ring-icon { width: 12px; height: 12px; font-size: 12px; }
  .hero .hero-side .cd-label { font-size: 8.5px; letter-spacing: .04em; }
  .hero .hero-side .cd-name { font-size: 11.5px; }
  .hero .hero-side .cd-days { font-size: 10px; }
  .hero .hero-side .cd-arrow { display: none; }
  .hero .hero-side .hero-timeline-btn {
    grid-column: 1 / -1; flex: none; width: 100%; min-height: 30px;
    padding: 5px 8px; font-size: 10.5px;
  }
  .hl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .timeline-panel { padding: 14px; }
  .tp-date { width: 62px; font-size: 11px; }
  .tp-kind { display: none; }

  /* 导航压成一行：日期选择器自适应，今天按钮收为图标（保留 aria-label） */
  .toolbar { flex-direction: column; align-items: stretch; padding: 7px 9px; gap: 5px; margin-bottom: 10px; }
  .nav-group { flex-wrap: nowrap; gap: 6px; }
  .nav-group .nav-btn { width: 40px; height: 42px; flex: none; }
  .nav-group .current-label { flex: 1 1 auto; min-width: 0; gap: 5px; }
  .nav-group .current-label .select {
    flex: 1 1 0; min-width: 0; padding: 7px 22px 7px 8px;
    background-position: right 6px center;
  }
  .nav-group .current-label #monthSelect { flex: 0 1 78px; }
  .nav-group .today-btn { flex: none; padding: 0 9px; min-width: 40px; justify-content: center; }
  .nav-group .today-btn span { display: none; }
  .view-switch { justify-content: center; }
  .view-tab { flex: 1; min-height: 32px; }
  .jump-group { flex-basis: auto; }
  .jump-input { width: 100%; padding-top: 6px; padding-bottom: 6px; }

  .calendar-card { padding: 12px 8px 12px; }
  .cal-head { margin-bottom: 12px; padding: 0 4px; }
  .cal-range { display: none; }
  .grid { border-left: 0; }
  .cell { min-height: 62px; padding: 5px 3px; border-right: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  [data-density="compact"] .cell { min-height: 52px; }
  .cell:hover { background: var(--surface-2); }
  .cell .solar { font-size: 15px; }
  .cell .lunar { font-size: 9.5px; }
  .cell-flags { display: none; }
  .cell .rest-badge, .cell .work-badge { font-size: 8px; padding: 1px 3px; }
  .cell .note-badge { min-width: 14px; height: 14px; line-height: 14px; font-size: 9px; padding: 0 3px; }
  .cell .birth-dot .icon { font-size: 11px; }
  .cell.today .solar::after { width: 10px; }
  .legend { gap: 6px 10px; font-size: 10px; }
  .weekdays span { font-size: 10px; padding: 6px 2px; }

  .detail-card { padding: 16px; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pair-list { gap: 6px 10px; font-size: 12px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick-grid .section { padding: 8px 9px; }
  .quick-grid .chip { font-size: 10.5px; padding: 3px 7px; }

  .year-grid { grid-template-columns: 1fr; }
  .year-view-head { flex-direction: column; align-items: stretch; }
  .year-view-title { justify-content: center; }
  .year-view-actions { justify-content: center; }
  .week-view { padding: 14px 10px 12px; }

  .bd-row-3, .bd-row-2 { grid-template-columns: 1fr 1fr; }
  .modal-card { padding: 16px; border-radius: var(--r-lg); max-height: 90vh; overscroll-behavior: contain; }
  .shortcuts-grid { grid-template-columns: 1fr; }
  .cmd-overlay:not([hidden]) { padding-top: 8vh; }
  .cmd-foot-brand { display: none; }
  /* 手机：三段改为统一左对齐的整齐列表，行高与间距一致，避免视觉错位 */
  .footer { margin-top: 28px; padding-top: 14px; }
  .footer-main { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; gap: 5px; }
  .footer-brand, .footer-keys, .footer-meta { height: auto; min-height: 22px; line-height: 22px; }
  .footer-meta { flex: 0 0 auto; }
  .footer-keys { margin-left: 0; gap: 12px; }
  .footer-note { align-items: flex-start; margin-top: 7px; }
  .footer-note .icon { margin-top: 3px; }
  .bd-reminder { padding: 10px 12px; }
  .bd-reminder-inner { flex-wrap: wrap; gap: 8px; }
  .bd-reminder-list { width: 100%; }
  .bd-rem-item { max-width: 100%; }

  /* 高级备忘录 */
  .notes-head { padding: 12px 14px; }
  .notes-body { padding: 13px 14px 12px; }
  .notes-scope { width: 100%; }
  .notes-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ns-progress-wrap { grid-column: 1 / -1; padding: 0; }
  .notes-toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .notes-toolbar .note-search { grid-column: 1 / -1; }
  .note-advanced { grid-template-columns: 1fr 1fr; }
  .ne-row { grid-template-columns: 1fr; }
  .note-item { padding: 9px 10px; gap: 8px; }
  .ni-actions { gap: 0; }

  /* iOS：表单控件 <16px 时聚焦会自动放大页面 */
  .select, .select-sm, .jump-input, .bd-input, .note-area,
  .note-input, .note-select, .note-textarea, .cmd-input-row input { font-size: 16px; }
  /* 触摸目标 ≥44px */
  .icon-btn { min-width: 42px; min-height: 42px; }
  .nav-btn { width: 42px; height: 42px; }
  .today-btn, .jump-btn { min-height: 42px; }
  .menu-item { min-height: 44px; }
  .auspicious-day { min-height: 40px; }
  .bd-rem-go, .bd-rem-dismiss, .bd-reminder-close { min-height: 32px; min-width: 32px; }
  .bd-del { min-height: 36px; }
  .notes-icon-btn { width: 38px; height: 38px; flex-basis: 38px; }
  .note-opt-btn { width: 44px; flex-basis: 44px; }
  .notes-tab { min-height: 40px; }
  .ni-btn { width: 34px; height: 34px; }
  .ni-check { width: 24px; height: 24px; flex-basis: 24px; }
  .notes-link { min-height: 36px; }
  .note-add-btn { min-height: 42px; }
  .view-tab { min-height: 36px; }
  .cell { min-height: 58px; }
}

@media (max-width: 420px) {
  .topbar-actions { gap: 4px; }
  .icon-btn { width: 42px; height: 42px; min-width: 42px; min-height: 42px; }
  .cmd-trigger { width: 42px; height: 42px; min-width: 42px; }
  .yiji { flex-direction: column; }
  .bd-row-3, .bd-row-2 { grid-template-columns: 1fr; }
  .note-composer-row { flex-wrap: wrap; }
  .note-composer-row .note-input { flex: 1 1 100%; }
  .note-opt-btn, .note-add-btn { flex: 1 1 auto; }
  .note-advanced, .notes-toolbar { grid-template-columns: 1fr; }
  .notes-toolbar .note-search { grid-column: auto; }
  .notes-stats { gap: 6px; }
  .segmented button { padding: 6px 8px; font-size: 11px; }
  .set-row { align-items: flex-start; flex-direction: column; gap: 6px; }
}

@media (max-width: 360px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .grid { gap: 0; }
  .cell { min-height: 50px; padding: 4px 2px; }
  .cell .solar { font-size: 14px; }
  .cell .lunar { font-size: 9px; }
  .cell .rest-badge, .cell .work-badge { display: none; }
  .info-grid, .pair-list { grid-template-columns: 1fr; }
  .legend { font-size: 10px; gap: 5px 7px; }
  .notes-head, .notes-body { padding-left: 10px; padding-right: 10px; }
  .ns-item b { font-size: 17px; }
  .ni-actions { flex-direction: column; }
  .ni-btn { width: 28px; height: 28px; }
  .quick-grid { grid-template-columns: 1fr; }
  .hl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 横屏手机 / 矮窗口 */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { margin-bottom: 10px; }
  .hero { margin-bottom: 10px; padding: 12px 16px; }
  .hero-yiji { margin-top: 10px; }
  .toolbar { margin-bottom: 10px; padding: 9px 12px; }
  .detail-card { position: static; max-height: none; overflow: visible; }
  .cell { min-height: 50px; }
  .toast { bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* 无 hover 的触摸设备 */
@media (hover: none) {
  .icon-btn, .nav-btn { min-width: 42px; min-height: 42px; }
  .menu-item { min-height: 44px; }
  .auspicious-day, .btn, .notes-tab { min-height: 40px; }
  .notes-icon-btn, .note-opt-btn { min-width: 40px; min-height: 40px; }
  .ni-btn { min-width: 34px; min-height: 34px; }
  .ni-check { min-width: 24px; min-height: 24px; }
  .icon-btn:hover, .nav-btn:hover, .today-btn:hover, .btn-primary:hover, .cell:hover { transform: none; }
  .countdown-card:hover { transform: none; }
}

/* 尊重系统「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .cell:hover, .icon-btn:hover, .today-btn:hover, .btn-primary:hover, .countdown-card:hover { transform: none; }
  .cd-ring-fg { transition: none; }
}

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 10mm; }
  html, body { background: #fff !important; color: #111 !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .toolbar, .auspicious-card, .notes-card, .hero, .toast, .detail-card,
  .year-view-actions, .bd-reminder, .modal, .note-undo, .cmd-overlay,
  .timeline-panel, .footer, .week-view, .nav-btn, .year-view-title .nav-btn,
  .sr-file { display: none !important; }
  .app { max-width: 100%; padding: 0; }
  .layout { display: block; }
  .calendar-card, .year-view, .mini-month { box-shadow: none; border-color: #ccc; }
  .calendar-card { padding: 0; }
  .cal-head-actions { display: none; }
  .year-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .year-view-head { margin-bottom: 8px; }
  .year-view-title h2 { font-size: 17px; }
  .grid, .cell, .md, .weekdays { border-color: #ddd !important; }
  .cell { min-height: 62px; }
  .cell.muted { opacity: .3; }
  .cell.selected { box-shadow: inset 0 0 0 2px #a83b30; }
  .legend { color: #555; }
  .mini-month, .cell, .md, .chip, .badge-rest, .badge-work, .rest-badge, .work-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
