/* ---------- 设计基线 ---------- */
:root {
  --bg: #f3f2ee;
  --panel: #fffefb;
  --panel-2: #faf9f5;
  --line: #e2ded4;
  --line-strong: #cfc9bb;
  --ink: #1b1a17;
  --ink-2: #57534a;
  --ink-3: #8d8779;
  --accent: #33574a;
  --accent-soft: #e8ede9;
  --up: #b23a2f;
  --down: #1f7a56;
  --warn: #9a6a1e;
  --rain: #3d6ea8;
  --radius: 5px;
  /* 字号倍率：设置页可改，JS 写到行内样式覆盖这里 */
  --fs: 1;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #141513;
  --panel: #1c1d1a;
  --panel-2: #212220;
  --line: #2e302b;
  --line-strong: #41443d;
  --ink: #e9e6df;
  --ink-2: #a9a49a;
  --ink-3: #7b766c;
  --accent: #8fb5a2;
  --accent-soft: #26302b;
  --up: #d4675c;
  --down: #59b18c;
  --warn: #c79a4e;
  --rain: #7ba6d8;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  /* 底色 + 纹理分两层：纹理用 background-image，透明度烘进 SVG 的 fill-opacity，
     这样不用为了叠图案再加一个 position:fixed 的层，也不会挡点击 */
  background-color: var(--bg);
  background-image: var(--pattern-image, none);
  background-size: var(--pattern-size, auto);
  background-repeat: repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: calc(14px * var(--fs));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 52px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: calc(13px * var(--fs));
  font-weight: 600;
  letter-spacing: 0.06em;
}
.brand small {
  font-family: var(--mono);
  font-size: calc(10px * var(--fs));
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a {
  padding: 5px 10px;
  border-radius: 4px;
  font-size: calc(13px * var(--fs));
  color: var(--ink-2);
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { color: var(--ink); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }

/* 工具下拉 */
.nav-item { position: relative; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: calc(13px * var(--fs));
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-btn:hover { background: var(--panel-2); color: var(--ink); }
.nav-btn.active { color: var(--ink); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.nav-btn svg { transition: transform .14s ease; opacity: .7; }
.nav-item.open .nav-btn svg { transform: rotate(180deg); }

/* 下拉用 fixed 定位、坐标由 JS 算：顶栏在窄屏有 overflow 滚动，absolute 会被裁掉 */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 140px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 10px 24px -12px rgba(20, 18, 14, .45);
}
.menu[hidden] { display: none; }
.menu a {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: calc(13px * var(--fs));
  color: var(--ink-2);
}
.menu a:hover, .menu a:focus-visible { background: var(--panel-2); color: var(--ink); outline: none; }
.menu a.active { color: var(--accent); background: var(--accent-soft); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.clock {
  font-family: var(--mono);
  font-size: calc(12px * var(--fs));
  color: var(--ink-3);
  letter-spacing: .02em;
}

/* ---------- 布局 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 22px 80px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 18px;
}
.page-head h1 { margin: 0; font-size: calc(19px * var(--fs)); font-weight: 600; letter-spacing: .01em; }
.page-head p { margin: 3px 0 0; font-size: calc(12.5px * var(--fs)); color: var(--ink-3); }
.head-actions { display: flex; gap: 8px; }

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  /* 每张卡按自己内容定高：等高会把内容少的卡拉出一大片空白，也会让「调高一张」牵连同排 */
  align-items: start;
}
.card {
  grid-column: span var(--w, 6);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  min-width: 0;
  position: relative;
  transition: border-color .14s;
}
.card:hover { border-color: var(--line-strong); }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title {
  font-size: calc(12px * var(--fs));
  letter-spacing: .1em;
  color: var(--ink-3);
  margin: 0;
  font-weight: 500;
  text-transform: uppercase;
}
.card-meta { margin-left: auto; font-size: calc(11.5px * var(--fs)); color: var(--ink-3); font-family: var(--mono); }
.card-link { font-size: calc(12px * var(--fs)); color: var(--accent); }
.card-link:hover { text-decoration: underline; }

/* ---------- 数字排版 ---------- */
.metric { display: flex; align-items: baseline; gap: 8px; }
.metric .n {
  font-family: var(--mono);
  font-size: calc(30px * var(--fs));
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric .u { font-size: calc(12px * var(--fs)); color: var(--ink-3); }
.delta { font-family: var(--mono); font-size: calc(13px * var(--fs)); font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink-3); }

.kv { display: flex; gap: 14px; flex-wrap: wrap; font-size: calc(12.5px * var(--fs)); color: var(--ink-2); }
.kv b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- 金价行 ---------- */
.quotes { display: flex; flex-direction: column; }
.quote {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.quote:first-child { border-top: 0; }
.quote .qname { font-size: calc(13.5px * var(--fs)); }
.quote .qname em { font-style: normal; color: var(--ink-3); font-size: calc(11px * var(--fs)); margin-left: 6px; font-family: var(--mono); }
.quote .qprice {
  font-family: var(--mono);
  font-size: calc(17px * var(--fs));
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 90px;
}
.quote .qpct { font-family: var(--mono); font-size: calc(12.5px * var(--fs)); width: 74px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 纪念日卡片（首页） ---------- */
.mem-list { display: flex; flex-direction: column; }
.mem-row {
  display: grid;
  /* [单行] 原来是 3 列但有 4 个子元素，数字被挤到第二行；
     改成 4 列：色条 | 名称 | 天数 | 日期 */
  grid-template-columns: 3px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.mem-row:first-child { border-top: 0; }
.mem-bar { align-self: stretch; border-radius: 2px; background: var(--evc, var(--accent)); }
.mem-txt { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.mem-name { font-size: calc(13.5px * var(--fs)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-tag {
  flex: 0 0 auto; font-style: normal; font-size: calc(10.5px * var(--fs)); color: var(--ink-3);
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 0 6px; line-height: 1.6;
}
.mem-sub { flex: 0 0 auto; font-size: calc(11px * var(--fs)); color: var(--ink-3); font-family: var(--mono); white-space: nowrap; }
.mem-num { font-family: var(--mono); font-size: calc(15px * var(--fs)); color: var(--accent); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.mem-num small { font-size: calc(11px * var(--fs)); color: var(--ink-3); margin-left: 2px; }
.mem-row.passed { opacity: .55; }
.mem-row.passed .mem-num { color: var(--ink-3); }
.mem-row.is-today .mem-num { font-weight: 600; }
.mem-foot { align-items: center; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
/* 窄屏一行塞不下「满 62 岁 + 农历二月初八」，让农历先走，纪念日页里还能看到 */
@media (max-width: 560px) { .mem-lun { display: none; } }

/* ---------- 天气 ---------- */
.wx-now { display: flex; align-items: flex-start; gap: 18px; }
.wx-temp { font-family: var(--mono); font-size: calc(40px * var(--fs)); line-height: 1; font-variant-numeric: tabular-nums; }
.wx-temp span { font-size: calc(15px * var(--fs)); color: var(--ink-3); }
.wx-desc { font-size: calc(13px * var(--fs)); color: var(--ink-2); }
.wx-desc strong { display: block; font-weight: 500; color: var(--ink); font-size: calc(14px * var(--fs)); margin-bottom: 2px; }
.wx-days { display: flex; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.wx-day { flex: 1; min-width: 0; }
.wx-day .d { font-size: calc(11px * var(--fs)); color: var(--ink-3); font-family: var(--mono); }
.wx-day .t { font-size: calc(12.5px * var(--fs)); margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-day .r { font-family: var(--mono); font-size: calc(12px * var(--fs)); color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* 12 小时预报：等分 12 格，不滚动 */
.wx-hours {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.wx-hour { min-width: 0; text-align: center; padding: 0 1px; border-left: 1px solid var(--line); }
.wx-hour:first-child { border-left: 0; }
.wx-hour .h { display: block; font-family: var(--mono); font-size: calc(10.5px * var(--fs)); color: var(--ink-3); letter-spacing: -.03em; white-space: nowrap; }
.wx-hour:first-child .h { color: var(--ink-2); }
.wx-hour .t { display: block; font-family: var(--mono); font-size: calc(13px * var(--fs)); font-variant-numeric: tabular-nums; line-height: 1.45; }
.wx-hour .p { display: block; font-size: calc(10px * var(--fs)); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 手机宽度下 12 格并排每格只剩 30px，“22时”这种就糊成一片了，拆成 6 列两行 */
@media (max-width: 560px) {
  .wx-hours { grid-template-columns: repeat(6, minmax(0, 1fr)); row-gap: 10px; }
  .wx-hour:nth-child(6n + 1) { border-left: 0; }
}
.wx-hour .p.rain { color: var(--rain); }

/* ---------- 按钮与表单 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  font-size: calc(13px * var(--fs));
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .btn.primary { color: #111; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn.sm { height: 26px; padding: 0 9px; font-size: calc(12px * var(--fs)); }
.btn.danger { color: var(--up); border-color: color-mix(in srgb, var(--up) 35%, var(--line)); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* 只有图标的按钮：30×30 的方框，图标居中 */
.btn.icon {
  width: 30px;
  padding: 0;
  justify-content: center;
}
.btn.icon svg { display: block; }
.btn.icon.spin svg { animation: wb-spin .7s linear infinite; }
@keyframes wb-spin { to { transform: rotate(360deg); } }

.input, .textarea, .select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: calc(12px * var(--fs)); color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: calc(11.5px * var(--fs)); color: var(--ink-3); margin-top: 5px; line-height: 1.5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- 外观：配色卡与取色器 ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px 5px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: calc(12.5px * var(--fs));
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.swatch:hover { border-color: var(--ink-3); color: var(--ink); }
.swatch.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.swatch .dots { display: inline-flex; }
.swatch .dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.swatch .dot + .dot { margin-left: -5px; }

.color-row { display: flex; gap: 8px; align-items: center; }
.color-row .input { flex: 1; min-width: 0; }
.color-chip {
  flex: 0 0 auto;
  width: 40px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  cursor: pointer;
}
.color-chip::-webkit-color-swatch-wrapper { padding: 0; }
.color-chip::-webkit-color-swatch { border: 0; border-radius: 3px; }
.color-chip::-moz-color-swatch { border: 0; border-radius: 3px; }

/* 背景纹理选择器 */
.pats { display: flex; flex-wrap: wrap; gap: 8px; }
.pat {
  width: 88px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: calc(11.5px * var(--fs));
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: border-color .12s, color .12s;
}
.pat:hover { border-color: var(--ink-3); color: var(--ink); }
.pat.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.pat .thumb {
  display: block;
  height: 52px;
  background-color: var(--bg);
  background-repeat: repeat;
  background-position: center;
  border-bottom: 1px solid var(--line);
}
.pat .lab { display: block; padding: 4px 8px 5px; }

/* 滑杆：轨道细、滑块小，和按钮的克制风格一致 */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-strong); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.range::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.range::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-strong); }
.range::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }
.range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 杂项 ---------- */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: calc(11px * var(--fs));
  margin: 0 5px 5px 0;
}
.muted { color: var(--ink-3); }
.xs { font-size: calc(12px * var(--fs)); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--ink-3);
  font-size: calc(13px * var(--fs));
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
}
.err {
  font-size: calc(12.5px * var(--fs));
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: 4px;
  padding: 8px 10px;
  line-height: 1.55;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: calc(13px * var(--fs));
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 编辑模式 ---------- */
body.editing .card { border-style: dashed; border-color: var(--line-strong); }
body.editing .card.dragging { opacity: .45; }
body.editing .card.is-hidden { opacity: .38; }
body.editing .card.is-hidden .card-body { filter: grayscale(1); }
body.editing .card.over { border-color: var(--accent); background: var(--accent-soft); }
.card-tools { display: none; align-items: center; gap: 4px; margin-left: 6px; }
body.editing .card-tools { display: flex; }
/* 编辑模式下工具栏独占一行，避免窄卡片把标题挤换行 */
body.editing .card-head { flex-wrap: wrap; }
body.editing .card-tools { order: 3; flex-basis: 100%; flex-wrap: wrap; margin: 2px 0 8px; }
.card-tools button {
  height: 22px;
  min-width: 24px;
  padding: 0 6px;
  font-size: calc(11px * var(--fs));
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 3px;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
}
.card-tools button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .card-tools button.on { color: #111; }
.grip { cursor: grab; color: var(--ink-3); font-family: var(--mono); user-select: none; letter-spacing: 1px; }
body.editing .grip { cursor: grab; }

/* ---------- 卡片尺寸：高度可拖 / 可滚轮调 ---------- */
/* 只有首页的网格卡片走纵向 flex，设置页那些 .card 不在 .grid 里，不受影响 */
.grid .card { display: flex; flex-direction: column; }
.grid .card > .card-head { flex: 0 0 auto; }
/* 卡片主体一直是滚动容器（自动高时不会溢出，也就没有滚动条），
   滚动条本身藏掉：Firefox 认 scrollbar-width，老 Edge 认 -ms-，其余走 ::-webkit-scrollbar。
   只是不画，滚轮 / 触摸 / 键盘 / 程序滚动全都照常。 */
.grid .card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
/* 通用工具类：只藏条、不关滚动，别处的滚动容器想用直接加 class */
.sb-hide {
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.grid .card > .card-body::-webkit-scrollbar,
.sb-hide::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* 条藏起来以后，定高卡片看着就像被切断了；底部压一层渐隐，滚到底自动消失，
   既是"下面还有"的提示，也不至于重新长出一条灰条破坏观感 */
.card.has-more::after {
  content: '';
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  height: 28px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(to bottom, transparent, var(--panel) 78%);
  pointer-events: none;
}
/* --h 必须真的被消费掉，否则 JS 里改了高度也只是改了个没人用的变量（踩过） */
.grid .card.is-fixed { height: var(--h); align-self: start; }
.grid .card.is-fixed > .card-body { overflow: auto; overscroll-behavior: contain; }
.grid .card.resizing { box-shadow: 0 10px 28px rgba(0, 0, 0, .16); }
body.rs-lock { user-select: none; }

.rs-handle {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 15px;
  height: 15px;
  display: none;
  cursor: nwse-resize;
  opacity: .55;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  border-bottom-right-radius: 3px;
  touch-action: none;
}
body.editing .rs-handle { display: block; }
body.editing .card:hover .rs-handle { opacity: 1; }

.rs-tip {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%) translateY(4px);
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: calc(11px * var(--fs));
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 6;
}
.rs-tip.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 空卡片折叠 ---------- */
/* 内容区为空时只留一条标题栏（编辑模式下工具条还在，宽/高/隐藏照样能点），
   主体整个 display:none，卡片高度就只剩这一条，几十像素而不是几百。 */
.grid .card.is-collapsed { padding: 9px 16px; height: auto; }
.grid .card.is-collapsed > .card-body { display: none; }
.grid .card.is-collapsed > .card-head { margin-bottom: 0; }
.grid .card.is-collapsed > .rs-handle { display: none; }
/* 空卡的 meta 本来就是空的，干脆让位给「展开」按钮，别两个 auto 边距互相挤 */
.grid .card.is-empty > .card-head > .card-meta { display: none; }
body.editing .grid .card.is-collapsed .card-tools { margin: 4px 0 0; }

.fold-note {
  display: none;
  font-size: calc(11.5px * var(--fs));
  color: var(--ink-3);
  letter-spacing: .02em;
}
.grid .card.is-collapsed .fold-note { display: inline; }

.unfold-btn {
  margin-left: auto;
  padding: 0 4px;
  height: 18px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: calc(11.5px * var(--fs));
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.unfold-btn:hover { background: var(--accent-soft); }
.unfold-btn[hidden] { display: none; }

/* ---------- 瀑布流落位（JS 算坐标） ---------- */
/* 为什么不用 grid 自动排：grid 的行高由整行最高的那张卡决定，空卡折叠成一条后
   它下面那块空白是"行"留下的，grid-auto-flow:dense 只补格子、补不了高度。
   所以有折叠卡时由 JS 把每张卡的 translate 算出来，卡片脱离网格流。
   没有折叠卡时 .masonry 不会挂上，走的就是原生 grid，和以前完全一样。 */
.grid.masonry { display: block; position: relative; }
.grid.masonry > .card { position: absolute; top: 0; left: 0; margin: 0; }

/* ---------- 节假日卡片 ---------- */
.hol-hero { display: flex; align-items: baseline; gap: 14px; }
.hol-big {
  font-family: var(--mono);
  font-size: calc(34px * var(--fs));
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.hol-big span { font-size: calc(12px * var(--fs)); color: var(--ink-3); margin-left: 5px; font-family: var(--sans); }
.hol-info strong { font-size: calc(15px * var(--fs)); font-weight: 600; }
.hol-when { font-size: calc(11.5px * var(--fs)); color: var(--ink-3); margin-top: 4px; font-family: var(--mono); }
.hol-bar { height: 4px; border-radius: 2px; background: var(--line); margin: 13px 0 7px; overflow: hidden; }
.hol-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .4s; }
.hol-bar-foot { justify-content: space-between; font-size: calc(11.5px * var(--fs)); }
.hol-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.hol-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink-2);
  font-size: calc(11.5px * var(--fs));
  text-decoration: none;
  white-space: nowrap;
}
.hol-chip i { font-style: normal; font-family: var(--mono); font-size: calc(10.5px * var(--fs)); color: var(--ink-3); }
.hol-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.hol-chip.on i { color: rgba(255, 255, 255, .8); }
[data-theme="dark"] .hol-chip.on { color: #111; }
[data-theme="dark"] .hol-chip.on i { color: rgba(0, 0, 0, .6); }
.hol-chip.pickable { cursor: pointer; font-family: inherit; }
.hol-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hol-pick {
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  padding: 11px 12px;
  margin-bottom: 13px;
  background: var(--panel-2);
}
.hol-foot { margin-top: 11px; text-align: right; }
.hol-sub { margin: 11px 0 6px; font-size: calc(11px * var(--fs)); color: var(--ink-3); letter-spacing: .04em; }
button.card-link.plain { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; line-height: 1; }

/* ---------- 万年历卡片 ---------- */
.cal-top { display: flex; align-items: center; gap: 13px; text-decoration: none; color: inherit; }
.cal-day {
  font-family: var(--mono);
  font-size: calc(30px * var(--fs));
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cal-side { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-md { font-size: calc(11.5px * var(--fs)); color: var(--ink-3); }
.cal-lunar { font-size: calc(12.5px * var(--fs)); }
.cal-fields { display: flex; flex-direction: column; margin-top: 11px; }
.cal-field {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  font-size: calc(12.5px * var(--fs));
}
.cal-field em { font-style: normal; color: var(--ink-3); flex: 0 0 auto; }
.cal-field span { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 分段选择 ---------- */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.seg button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  font-size: calc(12px * var(--fs));
  font-family: inherit;
  cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--panel-2); }
.seg button.on { background: var(--accent); color: #fff; }
[data-theme="dark"] .seg button.on { color: #111; }

/* ---------- 数据存储 ---------- */
.store-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto auto auto;
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: calc(12.5px * var(--fs));
}
.store-row:first-child { border-top: 0; }
.store-row .nm { min-width: 0; }
.store-row .nm b { font-weight: 500; }
.store-row .nm span { display: block; font-family: var(--mono); font-size: calc(11px * var(--fs)); color: var(--ink-3); margin-top: 2px; word-break: break-all; }
.store-row .num { font-family: var(--mono); font-size: calc(12px * var(--fs)); color: var(--ink-2); text-align: right; white-space: nowrap; }
.store-row .miss { color: var(--ink-3); }

/* ---------- Hermes 对话面板 ---------- */
.grid .card .chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 10px;
}
.chat-msg {
  max-width: 88%;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: calc(13px * var(--fs));
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--ink);
  border-bottom-right-radius: 3px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}
.chat-msg.err { color: var(--up); border-color: var(--up); }
.chat-empty {
  color: var(--ink-3);
  font-size: calc(12.5px * var(--fs));
  padding: 4px 2px;
}
.chat-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 4px;
}
.chat-input {
  flex: 1 1 auto;
  min-height: 36px;
  max-height: 120px;
  resize: none;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: calc(13px * var(--fs));
  line-height: 1.5;
  font-family: inherit;
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: calc(13px * var(--fs));
  cursor: pointer;
}
[data-theme="dark"] .chat-send { color: #111; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-clear {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: calc(12px * var(--fs));
  cursor: pointer;
}
.chat-clear:hover { background: var(--panel-2); }
.chat-tip {
  margin-top: 6px;
  color: var(--ink-3);
  font-size: calc(12px * var(--fs));
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .card { grid-column: span 12 !important; }
  /* 手机上一屏就一张卡，定高只会把内容切掉（12 小时预报会折成两行），高度还给内容 */
  .grid .card.is-fixed { height: auto; }
  .wrap { padding: 16px 14px 60px; }
  .topbar { padding: 0 14px; gap: 12px; overflow-x: auto; }
  .nav a { padding: 5px 8px; }
  .clock { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
}

/* ---------- Hermes 悬浮对话（客服式，右下角） ---------- */
.chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.chat-fab-btn {
  width: 62px;
  height: 62px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-fab-btn:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22); }
.chat-fab-btn.is-open { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.26); }
.chat-fab-icon { display: block; width: 100%; height: 100%; }
.chat-fab-icon svg { display: block; width: 100%; height: 100%; }

.chat-fab-panel {
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.chat-fab-panel[hidden] { display: none; }
.chat-fab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.chat-fab-title {
  font-size: calc(14px * var(--fs));
  font-weight: 600;
  color: var(--ink);
}
.chat-fab-close {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.chat-fab-close:hover { color: var(--ink); }
.chat-fab-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-fab-body .chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 2px 10px;
}
.chat-fab-body .chat-log::-webkit-scrollbar { width: 6px; }
.chat-fab-body .chat-log::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.chat-fab-body .chat-bar { flex: 0 0 auto; }

/* 手机上悬浮面板贴边，按钮略小 */
@media (max-width: 560px) {
  .chat-fab { right: 14px; bottom: 14px; }
  .chat-fab-btn { width: 56px; height: 56px; }
}


/* ===== 简化改造：纪念日分组 ===== */
.mem-group { margin-top: 7px; }
.mem-group:first-child { margin-top: 0; }
.mem-group-h,
.mem-fold > summary {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0 4px;
  font-family: var(--mono);
  font-size: calc(10px * var(--fs));
  letter-spacing: .06em;
  color: var(--ink-3);
}
.mem-group-h i,
.mem-fold > summary i { font-style: normal; opacity: .55; }
.mem-fold > summary { cursor: pointer; list-style: none; }
.mem-fold > summary::-webkit-details-marker { display: none; }
.mem-fold > summary::before {
  content: "\25B8";
  font-size: 9px;
  opacity: .5;
  transition: transform .12s;
}
.mem-fold[open] > summary::before { transform: rotate(90deg); }

/* 今天：整行浅底 + 左侧色条加粗，一眼能抓住 */
.mem-row.is-today {
  background: var(--accent-soft);
  border-radius: 4px;
  padding-left: 4px;
  padding-right: 4px;
}
.mem-row.is-today .mem-bar { width: 3px; }
.mem-row.is-today .mem-num { color: var(--accent); }

/* 7 天内：数字转警示色 */
.mem-row.soon .mem-num { color: var(--warn); }


/* ===== 首页「应用」卡片 ===== */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 8px;
}
.app-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 10px 6px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .12s;
}
.app-item:hover { background: var(--panel-2); }
.app-icon {
  width: 40px; height: 40px;
  border-radius: 9px;
  object-fit: contain;
  background: var(--panel-2);
}
.app-name { font-size: calc(11px * var(--fs)); color: var(--ink-2); text-align: center; line-height: 1.3; }
.app-desc { font-size: calc(9.5px * var(--fs)); color: var(--ink-3); text-align: center; line-height: 1.2; }

/* 天气卡整卡可点击跳官网 */
.wx-link { display: block; color: inherit; text-decoration: none; }
.wx-link:hover .wx-temp { color: var(--accent); }


/* ===== 首页月历卡片 ===== */
.mcal { display: flex; flex-direction: column; }
.mcal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mcal-title { font-size: calc(13px * var(--fs)); font-weight: 600; letter-spacing: .02em; }
.mcal-nav { display: flex; gap: 4px; }
.mcal-nav button {
  width: 22px; height: 22px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-2); border-radius: 5px; cursor: pointer;
  font-size: 13px; line-height: 1;
  transition: border-color .12s, color .12s;
}
.mcal-nav button:hover { border-color: var(--line-strong); color: var(--ink); }

.mcal-week, .mcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mcal-week span {
  text-align: center; padding: 3px 0 6px;
  font-size: calc(10px * var(--fs)); color: var(--ink-3);
}
.mcal-cell {
  text-align: center; padding: 6px 0;
  font-size: calc(12px * var(--fs)); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
}
.mcal-cell.is-out { color: var(--ink-3); opacity: .4; }
.mcal-cell.is-today {
  background: var(--accent);
  color: var(--panel);
  font-weight: 600;
}
.mcal-foot { margin-top: 8px; display: flex; justify-content: flex-end; min-height: 16px; }


/* ===== 编辑模式：布局工具栏 ===== */
.layout-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lb-label {
  font-size: calc(11px * var(--fs));
  color: var(--ink-3);
  margin-right: 2px;
}
.lb-btn {
  padding: 4px 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  border-radius: 5px;
  font-size: calc(12px * var(--fs));
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.lb-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.lb-btn.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}
.lb-hint {
  margin-left: auto;
  font-size: calc(11px * var(--fs));
  color: var(--ink-3);
}
@media (max-width: 640px) {
  .lb-hint { display: none; }
}


/* ==========================================================================
   高端仪表盘外观（覆盖层）
   - 大圆角面板 + 柔和阴影，卡片从"描边盒子"变成"浮起的纸片"
   - 动效统一走 ease-out，位移只在 hover / 拖拽时出现
   - 全部用覆盖写法，不改动上面的原始规则，方便随时回滚
   ========================================================================== */
:root {
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 9px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-2: 0 4px 14px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-3: 0 18px 44px rgba(16, 24, 40, .14);
  --ease-out: cubic-bezier(.32, .72, 0, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
}

[data-theme="dark"] {
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .5), 0 2px 4px rgba(0, 0, 0, .35);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, .62);
}

/* ---------- 卡片：浮起 ---------- */
.card {
  border-radius: var(--r-lg);
  border-color: transparent;
  box-shadow: var(--shadow-1);
  padding: 18px 20px 20px;
  transition:
    box-shadow .3s var(--ease-out),
    transform .3s var(--ease-out),
    border-color .3s var(--ease-out);
}
.card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

/* 面板（设置页 / 列表页的大块容器） */
.panel {
  border-radius: var(--r-lg);
  border-color: transparent;
  box-shadow: var(--shadow-1);
}

/* 拖拽中：抬起来的感觉 */
body.editing .card.dragging,
.card.dragging {
  opacity: .96;
  transform: scale(1.015) rotate(.25deg);
  box-shadow: var(--shadow-3);
  z-index: 30;
  cursor: grabbing;
}
/* 拖到目标位置时的落点提示 */
body.editing .card.over {
  border-color: var(--accent);
  box-shadow: var(--shadow-2);
}

/* 自由摆放模式下拖动时不要跟 hover 的位移打架 */
.grid.free .card:hover { transform: none; }

/* ---------- 按钮 ---------- */
.btn {
  border-radius: var(--r-sm);
  transition:
    background .18s var(--ease-out),
    border-color .18s var(--ease-out),
    color .18s var(--ease-out),
    transform .14s var(--ease-out),
    box-shadow .18s var(--ease-out);
}
.btn:hover { box-shadow: var(--shadow-1); }
.btn:active { transform: scale(.97); box-shadow: none; }
.btn.primary:hover { box-shadow: var(--shadow-2); }

/* ---------- 输入框 ---------- */
.input, .textarea, .select {
  border-radius: var(--r-sm);
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}
.input:focus, .textarea:focus, .select:focus {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 顶栏 / 导航 ---------- */
.topbar {
  border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--shadow-1);
}
.nav .nav-btn, .nav a {
  border-radius: var(--r-sm);
  transition: background .18s var(--ease-out), color .18s var(--ease-out);
}
.menu {
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  border-color: transparent;
}

/* ---------- 设置页侧栏 ---------- */
.set-nav {
  border-radius: var(--r-lg);
  border-color: transparent;
  box-shadow: var(--shadow-1);
}
.set-nav a { border-radius: var(--r-sm); }

/* ---------- 月历 ---------- */
.mcal-nav button { border-radius: var(--r-sm); }
.mcal-cell { border-radius: var(--r-sm); transition: background .18s var(--ease-out); }
.mcal-cell:hover:not(.is-today) { background: var(--panel-2); }

/* ---------- 布局工具栏 ---------- */
.layout-bar {
  border-radius: var(--r-lg);
  border-color: transparent;
  box-shadow: var(--shadow-1);
}
.lb-btn { border-radius: var(--r-sm); transition: all .18s var(--ease-out); }

/* ---------- 应用图标 ---------- */
.app-item { border-radius: var(--r-md); }
.app-icon { border-radius: var(--r-md); }

/* ---------- 无障碍：尊重"减少动效" ---------- */
@media (prefers-reduced-motion: reduce) {
  .card, .btn, .input, .mcal-cell, .lb-btn {
    transition: none !important;
  }
  .card:hover { transform: none; }
}


/* ===== 备案号页脚 ===== */
.lg-beian,
.site-footer {
  text-align: center;
  font-size: calc(10.5px * var(--fs));
  color: var(--ink-3);
  line-height: 1.6;
}
.lg-beian { margin-top: 16px; }
.site-footer { padding: 22px 0 30px; }
.lg-beian a,
.site-footer a {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}
.lg-beian a:hover,
.site-footer a:hover {
  color: var(--ink-2);
  text-decoration: underline;
}


/* ===== 首页书签卡片 ===== */
.bm-list { display: flex; flex-direction: column; }
.bm-item { border-top: 1px solid var(--line); }
.bm-item:first-child { border-top: 0; }
.bm-item > summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
  min-width: 0;
}
.bm-item > summary::-webkit-details-marker { display: none; }
.bm-title {
  font-size: calc(13px * var(--fs));
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}
.bm-url {
  font-family: var(--mono);
  font-size: calc(10.5px * var(--fs));
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.bm-caret {
  flex: 0 0 auto;
  color: var(--ink-3);
  font-size: 12px;
  transition: transform .18s var(--ease-out, ease);
}
.bm-item[open] .bm-caret { transform: rotate(90deg); }

.bm-detail { padding: 0 0 10px; }
.bm-kv {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  font-size: calc(11.5px * var(--fs));
  color: var(--ink-2);
  min-width: 0;
}
.bm-kv b {
  flex: 0 0 auto;
  min-width: 32px;
  font-weight: 500;
  color: var(--ink-3);
  font-size: calc(10.5px * var(--fs));
}
.bm-kv span,
.bm-kv a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
}
.bm-kv a { color: var(--accent); text-decoration: none; }
.bm-kv a:hover { text-decoration: underline; }
.bm-pass { font-family: var(--mono); letter-spacing: 1px; }
.bm-eye {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-3);
  border-radius: 4px;
  font-size: calc(10px * var(--fs));
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.bm-eye:hover { border-color: var(--line-strong); color: var(--ink); }


/* ===== 首页书签卡片（纯链接） ===== */
.bk-list { display: flex; flex-direction: column; }
.bk-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line);
}
.bk-item:first-child { border-top: 0; }
.bk-link {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 0;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  transition: color .15s;
}
.bk-name {
  font-size: calc(13px * var(--fs));
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}
.bk-host {
  font-family: var(--mono);
  font-size: calc(10.5px * var(--fs));
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.bk-link:hover .bk-name { color: var(--accent); }
.bk-act {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.bk-item:hover .bk-act { opacity: 1; }
.bk-act button {
  width: 22px; height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.bk-act button:hover { background: var(--panel-2); color: var(--ink); }

.bk-foot { margin-top: 8px; }
.bk-add {
  width: 100%;
  padding: 7px 0;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-3);
  border-radius: 6px;
  font-size: calc(11.5px * var(--fs));
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.bk-add:hover { border-color: var(--accent); color: var(--accent); }

.bk-empty {
  padding: 14px 0;
  text-align: center;
  font-size: calc(11.5px * var(--fs));
  color: var(--ink-3);
}
.bk-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.bk-form .input { font-size: calc(12px * var(--fs)); }
.bk-form-act { display: flex; gap: 6px; justify-content: flex-end; }

/* 全站搜索 */
.search-layer { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 11vh 16px 16px; background: rgba(20, 18, 22, .34); backdrop-filter: blur(2px); }
.search-layer[hidden] { display: none; }
.search-panel { width: min(680px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 44px rgba(0, 0, 0, .22); }
.search-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.search-input { flex: 1 1 auto; }
.search-body { overflow: auto; padding: 4px 6px 12px; }
.search-group { margin: 10px 0 2px; padding: 0 8px; font-size: calc(11px * var(--fs)); color: var(--ink-3); letter-spacing: .04em; }
.search-item { display: block; padding: 8px 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.search-item:hover, .search-item.is-active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.search-item .si-title { font-size: calc(13.5px * var(--fs)); font-weight: 600; }
.search-item .si-snip { margin-top: 2px; font-size: calc(12px * var(--fs)); color: var(--ink-2); }
.search-item mark { padding: 0 1px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 26%, transparent); color: inherit; }

/* 待办卡 */
.todo-list { display: flex; flex-direction: column; gap: 2px; }
.todo-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.todo-row:last-child { border-bottom: 0; }
.todo-check { flex: 0 0 auto; width: 17px; height: 17px; display: grid; place-items: center; padding: 0; font-size: 11px; line-height: 1; color: #fff; background: transparent; border: 1.4px solid var(--ink-3); border-radius: 5px; cursor: pointer; }
.todo-row.is-done .todo-check { background: var(--accent); border-color: var(--accent); }
.todo-text { flex: 1 1 auto; min-width: 0; font-size: calc(13px * var(--fs)); line-height: 1.6; overflow-wrap: anywhere; }
.todo-row.is-done .todo-text { color: var(--ink-3); text-decoration: line-through; }
.todo-del { flex: 0 0 auto; padding: 0 4px; font-size: 15px; line-height: 1; color: var(--ink-3); background: transparent; border: 0; cursor: pointer; opacity: 0; transition: opacity .12s; }
.todo-row:hover .todo-del, .todo-del:focus-visible { opacity: 1; }
.todo-foot { display: flex; gap: 6px; margin-top: 8px; }
.todo-foot .input { flex: 1 1 auto; font-size: calc(12.5px * var(--fs)); }
.todo-meta { margin-top: 4px; font-size: calc(11px * var(--fs)); color: var(--ink-3); }

/* 服务器状态卡 */
.sys { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.sys-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sys-k { font-size: calc(10.5px * var(--fs)); letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
.sys-v { font-family: var(--mono); font-size: calc(22px * var(--fs)); line-height: 1.1; font-variant-numeric: tabular-nums; }
.sys-u { margin-left: 2px; font-size: calc(11px * var(--fs)); color: var(--ink-3); }
.sys-bar { display: block; height: 3px; margin-top: 2px; overflow: hidden; border-radius: 2px; background: color-mix(in srgb, var(--ink-3) 20%, transparent); }
.sys-bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width .4s ease; }
.sys-bar i.hi { background: var(--up); }

/* ---------- 大肥鱼女仆 · 对话挂件 ---------- */
/* 配色一律取站点变量，浅色/深色与强调色改了这里跟着变 */
.chat-fab-btn {
  width: 78px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  transition: transform .2s var(--ease-out);
}
.chat-fab-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: none;
}
.chat-fab-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 50%;
}
.chat-fab-btn.is-open { box-shadow: none; }

.chat-fab-icon .whale-img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 5px 11px color-mix(in srgb, var(--ink) 24%, transparent));
}

.chat-fab-panel {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
.chat-fab-head {
  background: var(--panel-2);
  border-bottom-color: var(--line);
}
.chat-fab-title { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.chat-fab-close { color: var(--ink-3); }
.chat-fab-close:hover { color: var(--ink); }

/* 气泡沿用站点强调色，深色模式下强调色偏浅，字色反过来 */
.chat-msg.user {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .chat-msg.user { color: #141513; }
.chat-msg.assistant {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
}
.chat-msg.err {
  background: transparent;
  border-color: var(--up);
  color: var(--up);
}

.chat-empty { display: flex; align-items: center; gap: 10px; color: var(--ink-3); }

.chat-input {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.chat-input::placeholder { color: var(--ink-3); }
.chat-input:focus { border-color: var(--accent); }

.chat-clear { border-color: var(--line); color: var(--ink-2); }
.chat-clear:hover { background: var(--panel-2); }
.chat-tip { color: var(--ink-3); }
.chat-tip .card-link { color: var(--accent); }

.fish-ava { display: inline-flex; flex: 0 0 auto; width: 26px; height: 26px; }
.fish-ava.lg { width: 62px; height: 62px; }
.whale-img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: 50% 38%; }
.chat-fab-icon { display: flex; align-items: center; justify-content: center; }
.chat-fab-title .fish-ava { width: 30px; height: 30px; }

@media (max-width: 560px) {
  .chat-fab-btn { width: 64px; height: 64px; }
}

/* 大肥鱼逐帧动画容器 */
.pet-anim {
  display: block;
  background-repeat: no-repeat;
  background-size: auto;
  image-rendering: -webkit-optimize-contrast;
  pointer-events: none;
  will-change: background-position;
}
.chat-fab-btn {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  transition: transform .18s var(--ease-out);
}
.chat-fab-btn:hover { transform: translateY(-2px); }
.chat-fab-btn:active { transform: translateY(0) scale(.97); }
.chat-fab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 50%; }
.chat-fab-icon { display: block; width: auto; height: auto; }
.chat-fab-btn .pet-anim {
  filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--ink) 22%, transparent));
}
@media (max-width: 560px) {
  .chat-fab-btn { width: auto; height: auto; }
}

/* ---------- 对话框缩放 ---------- */
.chat-fab-panel { position: relative; }
.chat-fab-panel.is-resizing { transition: none; user-select: none; }
.chat-fab-panel.is-resizing iframe { pointer-events: none; }

.chat-fab-resize {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
  opacity: 0;
  transition: opacity .15s;
  background:
    linear-gradient(45deg, transparent 46%, var(--ink-3) 46%, var(--ink-3) 54%, transparent 54%) 0 100% / 5px 5px no-repeat,
    linear-gradient(45deg, transparent 46%, var(--ink-3) 46%, var(--ink-3) 54%, transparent 54%) 5px 5px / 5px 5px no-repeat;
}
.chat-fab-panel:hover .chat-fab-resize,
.chat-fab-panel:focus-within .chat-fab-resize,
.chat-fab-panel.is-resizing .chat-fab-resize { opacity: .55; }

/* 输入框：去掉原生缩放柄与滚动条，高度交给 JS */
.chat-input {
  resize: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overflow-y: auto;
}
.chat-input::-webkit-scrollbar { width: 0; height: 0; display: none; }
.chat-input::-webkit-resizer { display: none; }

/* 面板可被撑高后，聊天记录占满剩余空间 */
.chat-fab-panel .chat-fab-body { flex: 1 1 auto; min-height: 0; }
.chat-fab-panel .chat-log { flex: 1 1 auto; min-height: 0; }

/* 对话里的操作记录 */
.chat-tool {
  align-self: flex-start;
  max-width: 88%;
  margin: 2px 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--ink-2);
  font-size: calc(11.5px * var(--fs));
  line-height: 1.6;
}
.chat-tool.is-fail {
  background: color-mix(in srgb, var(--up) 12%, transparent);
  color: var(--up);
}

/* 日历格子日期下方的小字：班 / 休 / 节气 / 农历 */
.mcal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 0 5px;
  line-height: 1.15;
}
.mcal-cell .mc-d { font-size: calc(12px * var(--fs)); font-variant-numeric: tabular-nums; }
.mcal-cell .mc-s {
  font-size: calc(8.5px * var(--fs));
  letter-spacing: -.01em;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}
.mcal-cell .mc-s.is-work { color: var(--up); font-weight: 600; }
.mcal-cell .mc-s.is-rest { color: var(--down); font-weight: 600; }
.mcal-cell .mc-s.is-term { color: var(--rain); }
.mcal-cell.is-today .mc-s { color: inherit; opacity: .85; }

.cal-cell .cl.is-work { color: var(--up); font-weight: 600; }
.cal-cell .cl.is-rest { color: var(--down); font-weight: 600; }
.cal-cell .cl.is-term { color: var(--rain); }
.cal-cell.today .cl { opacity: .85; }
