/* ==========================================================================
   主页 · 个人启动页
   视觉：极简 / 克制 / 清晰的三级层次 / 有构图的留白
   所有圆角、阴影、间距、字号统一走 token，模块里不再写裸数值
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: light;

  /* 表面 */
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --input-bg: #ffffff;

  /* 文字三级：Primary 深、Secondary 中灰、Tertiary 浅灰 */
  --text: #0e0f13;
  --text-2: #4c4f5a;
  --text-3: #6d7280;

  /* 描边 */
  --border: rgba(14, 16, 24, 0.07);
  --border-2: rgba(14, 16, 24, 0.12);
  --border-3: rgba(14, 16, 24, 0.18);

  /* 强调色 */
  --accent: #3d63dd;
  --accent-ink: #ffffff;
  --accent-soft: rgba(61, 99, 221, 0.07);
  --focus-line: rgba(61, 99, 221, 0.11);
  --halo: rgba(61, 99, 221, 0.028);
  --text-muted: #51545d;
  --shadow-search: 0 1px 1px rgba(14, 16, 24, 0.018), 0 2px 6px -2px rgba(14, 16, 24, 0.026);
  --edit-tint: rgba(61, 99, 221, 0.045);
  --ambient: rgba(61, 99, 221, 0.032);

  /* 壁纸蒙层：把每日图压成很淡的背景底纹 */
  --wallpaper-veil: rgba(248, 249, 251, 0.88);
  /* 全景态舞台底色：图片 contain 留白时的中性深色兜底 */
  --wallpaper-stage: #0b0b0e;

  --ok: #35a05a;
  --warn: #cf8f2a;

  --danger: #c93b3b;
  --danger-soft: rgba(201, 59, 59, 0.09);

  /* 阴影：只用来分离层次，不做「浮起来」的效果 */
  --shadow-1: 0 1px 1px rgba(14, 16, 24, 0.025), 0 1px 3px rgba(14, 16, 24, 0.030);
  --shadow-2: 0 1px 2px rgba(14, 16, 24, 0.030), 0 10px 24px -14px rgba(14, 16, 24, 0.115);
  --shadow-3: 0 24px 60px -22px rgba(14, 16, 24, 0.220);
  --shadow-pill: 0 1px 2px rgba(14, 16, 24, 0.060);

  /* 圆角 */
  --r-xs: 7px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 22px;

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 6px;
  --sp-3: 8px;
  --sp-4: 12px;
  --sp-5: 16px;
  --sp-6: 20px;
  --sp-7: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-22: 88px;

  /* 字号 */
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-lg: 14px;
  --fs-xl: 16px;
  --fs-2xl: 18px;
  --fs-3xl: 26px;

  /* 页面级垂直节奏（已按首屏无需滚动收紧，见文末低高度桌面查询） */
  --gap-hero: 64px;          /* 顶栏 → 搜索 */
  --gap-categories: 30px;    /* 搜索源 → 分类 */
  --gap-footer: 24px;

  /* 尺寸 */
  --page-max: 1120px;
  --search-w: 720px;
  --search-h: 58px;
  --icon-btn: 34px;
  --link-icon: 46px;
  --search-gap: 14px;
  --fs-title: 15px;
  --fs-link: 14px;
  --link-pad-x: 2px;

  /* 动效 */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur: 170ms;
}

[data-theme='dark'] {
  color-scheme: dark;

  --bg: #101113;
  --surface: #17181b;
  --surface-2: #1e2024;
  --input-bg: #141517;

  --text: #f5f6f8;
  --text-2: #b2b6c0;
  --text-3: #969ca8;

  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);
  --border-3: rgba(255, 255, 255, 0.18);

  --accent: #8296ff;
  --accent-ink: #101113;
  --accent-soft: rgba(130, 150, 255, 0.11);
  --focus-line: rgba(130, 150, 255, 0.14);
  --halo: rgba(130, 150, 255, 0.040);
  --text-muted: #8f939e;
  --shadow-search: 0 1px 1px rgba(0, 0, 0, 0.22), 0 2px 6px -2px rgba(0, 0, 0, 0.28);
  --edit-tint: rgba(130, 150, 255, 0.055);
  --ambient: rgba(130, 150, 255, 0.045);

  --wallpaper-veil: rgba(16, 17, 19, 0.88);

  --ok: #4dbd74;
  --warn: #e0a63c;

  --danger: #ff8080;
  --danger-soft: rgba(255, 128, 128, 0.12);

  --shadow-1: 0 1px 1px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.30), 0 10px 24px -14px rgba(0, 0, 0, 0.65);
  --shadow-3: 0 24px 60px -22px rgba(0, 0, 0, 0.80);
  --shadow-pill: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
               'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 240ms var(--ease), color 240ms var(--ease);
}

/* 页面三层层级（同一个根层叠上下文，不用 z-index:-1 以免落到 body 背景之后）：
   0 壁纸层 .wallpaper → 1 环境光 body::before → 2 主体 .page */

/* 壁纸层：Bing zh-CN 每日图 + 蒙层（很淡，不加 blur）；
   图片加载并解码成功后才切 is-ready 淡入，失败则整层保持隐藏 */
.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.wallpaper-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 700ms var(--ease);
}

.wallpaper.is-ready .wallpaper-img { opacity: 1; }

.wallpaper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--wallpaper-veil);
  opacity: 1;
  transition: opacity 320ms var(--ease);
}

/* 全景态：在页面顶部继续拉动后进入。
   撤掉淡蒙层与主体遮挡，图片改用 contain 完整显示，留白由中性深色底兜底；
   图片始终清晰，不使用任何模糊滤镜。
   entered via body.is-wallpaper-full（由 wallpaper.js 的交互挂上/摘掉） */
body.is-wallpaper-full { overflow: hidden; }

body.is-wallpaper-full .wallpaper {
  z-index: 5;
  background: var(--wallpaper-stage);
}

body.is-wallpaper-full .wallpaper-img { object-fit: contain; }

body.is-wallpaper-full .wallpaper::after { opacity: 0; }

body.is-wallpaper-full .page {
  opacity: 0;
  visibility: hidden;
  /* 进入全景态：先淡出 360ms，动画结束再隐藏（避免瞬间消失的跳闪） */
  transition: opacity 360ms var(--ease), visibility 0s linear 360ms;
}

body.is-wallpaper-full::before { opacity: 0; }

/* 沉浸态说明：当天壁纸的标题 / 地点 / 版权，只在无遮挡全景态淡入。
   普通主页 opacity:0 且绝对定位，不参与布局；文本由 wallpaper.js 从
   wallpaper.json 的 title / location / copyright 写入（textContent）。 */
.wallpaper-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--sp-6) var(--sp-7) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 380ms var(--ease);
}

.wallpaper-meta[hidden] { display: none; }

body.is-wallpaper-full .wallpaper-meta { opacity: 1; }

.wallpaper-meta-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  line-height: 1.45;
}

.wallpaper-meta-loc {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.78);
}

.wallpaper-meta-copy {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.62);
}

/* 顶部环境光：只托住搜索区，保持清透，不要灰雾 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 480px;
  background: radial-gradient(46% 100% at 50% 0%, var(--ambient), transparent 66%);
  pointer-events: none;
  z-index: 1;
  opacity: 1;
  transition: opacity 320ms var(--ease);
}

body.is-locked { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- 3. Layout ---------- */
.page {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 40px) 32px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  opacity: 1;
  /* 退出全景态：主体立刻恢复可见并淡入 */
  transition: opacity 360ms var(--ease), visibility 0s linear;
}

/* 桌面明确两栏：左侧常驻日历，右侧承载时钟 / 一句 / 搜索 / 快捷网站。
   （此前是 320px + 内容 + 320px 的补偿三列，右列常年为空） */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  grid-template-rows: min-content 1fr;
  align-items: start;
  gap: 26px;
}

.calendar-sidebar,
.home-intro,
.home-content { min-width: 0; }

.calendar-sidebar { grid-column: 1; grid-row: 1 / span 2; }
.home-intro { grid-column: 2; grid-row: 1; width: 100%; }
.home-content { grid-column: 2; grid-row: 2; }

/* ---------- 4. Topbar ---------- */
/* 顶部信息组（日期天气 / 农历节气历史）已并入右主内容区（.home-intro 的第一个子节点），
   不再作为 .main 之前的整页兄弟独占一行；日历因此可自 .main 顶部起，与信息齐平。
   基础态允许换行：宽度不足时编辑/设置自动落到下一行并靠右，避免遮挡信息。 */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  min-height: 0;
}

.topbar-left { min-width: 0; flex: 1 1 auto; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; margin-left: auto; }

.today {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  text-align: left;
}

.today-stack { min-width: 0; }

/* 第一行：9月19日 · 星期六 */
.today-date {
  display: flex;
  align-items: center;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-2);
}

.today-date em {
  font-style: normal;
  color: var(--text-muted);
}

.today-date em::before {
  content: '·';
  margin: 0 7px 0 3px;
  color: var(--text-3);
}

/* 常驻侧栏月历卡片：自然占位，随内容增长 */
.calendar-panel {
  width: 100%;
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--border-2);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text);
  text-align: left;
}
.calendar-heading,
.calendar-footer,
.calendar-editor-actions { display: flex; align-items: center; justify-content: space-between; }
.calendar-heading-text { display: flex; flex-direction: column; gap: 2px; }
.calendar-eyebrow { color: var(--text-3); font-size: 12px; }
.calendar-month { font-size: 23px; font-weight: 650; letter-spacing: -0.04em; line-height: 1.15; }
.calendar-controls { display: flex; gap: var(--sp-2); }
/* 视觉 32px、命中区扩到 40px：触屏更好点，卡片里视觉不放大 */
.calendar-nav {
  position: relative;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 22px;
  line-height: 1;
}
.calendar-nav::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
}
.calendar-nav:hover { background: var(--surface-2); color: var(--text); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 14px; }
.calendar-weekday { padding-bottom: var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); text-align: center; }
/* 日期格固定高度，不再用 aspect-ratio 随卡宽膨胀；移动端在 ≤720px 提到 43px */
.calendar-day,
.calendar-empty { position: relative; display: grid; place-items: center; width: 100%; height: 38px; border-radius: var(--r-sm); font-size: var(--fs-md); font-variant-numeric: tabular-nums; transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.calendar-day:hover { background: var(--surface-2); }
.calendar-day.is-today { color: var(--accent); font-weight: 700; }
.calendar-day.is-today:not(.is-selected) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.calendar-day.is-selected { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.calendar-day.is-selected:hover { background: var(--accent); }
.calendar-day.has-events::after { content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.calendar-day.is-selected.has-events::after { background: var(--accent-ink); }
.calendar-agenda { display: flex; flex-direction: column; gap: 3px; margin-top: var(--sp-3); }
.calendar-empty-note { padding: var(--sp-3) 0; color: var(--text-3); font-size: var(--fs-sm); }
.calendar-event { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: var(--sp-3); border-radius: var(--r-sm); text-align: left; font-size: var(--fs-sm); }
.calendar-event:hover { background: var(--surface-2); }
.calendar-event-time { flex-shrink: 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.calendar-event-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event-reminder { color: var(--text-3); font-size: var(--fs-xs); }
.calendar-footer { gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.calendar-add,
.calendar-today { padding: 5px 2px; border-radius: var(--r-xs); color: var(--accent); font-size: var(--fs-sm); font-weight: 600; }
.calendar-today { color: var(--text-muted); font-weight: 500; }
.calendar-add:hover,
.calendar-today:hover { text-decoration: underline; text-underline-offset: 3px; }
.calendar-editor-heading { font-size: var(--fs-2xl); font-weight: 650; }
.calendar-editor { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-6); }
.calendar-editor input,
.calendar-editor select { width: 100%; min-width: 0; height: 40px; padding: 0 var(--sp-4); border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--input-bg); color: var(--text); font-size: var(--fs-md); }
.calendar-editor-row { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: var(--sp-3); }
.calendar-editor select:disabled { opacity: .48; }
.calendar-editor-actions { gap: var(--sp-3); margin-top: var(--sp-3); }
.calendar-cancel,
.calendar-delete,
.calendar-save { padding: 8px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.calendar-cancel { margin-left: auto; color: var(--text-muted); }
.calendar-delete { color: var(--danger); }
.calendar-save { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.calendar-cancel:hover,
.calendar-delete:hover { background: var(--surface-2); }

/* 第二行：图标 + 温度 + 描述 + 高低温 */
.today-weather {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 3px;
  min-height: 32px;
  font-size: var(--fs-md);
  color: var(--text-2);
}

.today-weather.is-clickable { cursor: pointer; }
.today-weather.is-clickable:hover .weather-desc { color: var(--text); }

.weather-icon {
  width: 22px;
  height: 22px;
  align-self: center;
  color: var(--text-2);
  flex-shrink: 0;
}
.weather-icon svg { width: 100%; height: 100%; }

.weather-temp {
  font-size: var(--fs-3xl);
  font-weight: 600;
  letter-spacing: -0.028em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.weather-desc {
  color: var(--text-2);
  font-weight: 500;
  transition: color var(--dur) var(--ease);
}

.weather-range {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.weather-range::before {
  content: '·';
  margin: 0 7px 0 0;
  color: var(--text-3);
}

.weather-note { font-size: var(--fs-md); color: var(--text-muted); }

/* 天气右侧：农历 / 节气 / 传统节日 / 历史上的今天（算不出来就整块不出现） */
.today-almanac {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: var(--sp-5);
  border-left: 1px solid var(--border-2);
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-muted);
  white-space: nowrap;
}

.almanac-lunar {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--text-2);
  font-weight: 500;
}

.almanac-festival { color: var(--accent); }

.almanac-term { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px; }
.almanac-term.is-today { color: var(--accent); }
.almanac-term-count { color: inherit; }
.solar-term-link {
  appearance: none;
  border: 0;
  border-radius: 2px;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  text-decoration: underline dotted;
  text-decoration-color: var(--text-3);
  text-underline-offset: 2px;
  cursor: pointer;
}
.solar-term-link:hover,
.solar-term-link:focus-visible { color: var(--text); text-decoration-style: solid; text-decoration-color: currentColor; }
.solar-term-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 历史上的今天：服务端已保证是完整短句，这里整句直接显示、不做截断；
   多条时整行可点，按固定顺序换下一条 */
.almanac-history {
  display: block;
  max-width: 34em;
  white-space: normal;
  line-height: 1.4;
  text-align: left;
  color: var(--text-2);
}

button.almanac-history {
  width: 100%;
  padding: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}

button.almanac-history:hover { text-decoration: underline; text-decoration-color: var(--border-3); text-underline-offset: 2px; }

button.almanac-history:hover,
button.almanac-history:focus-visible { color: var(--text); }

/* 还有下一条时，句末给一个克制的循环提示 */
.almanac-history.is-cyclable::after {
  content: '↻';
  margin-left: 5px;
  font-size: 0.9em;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}

button.almanac-history.is-cyclable:hover::after,
button.almanac-history.is-cyclable:focus-visible::after { opacity: 1; color: var(--accent); }

.weather-loading {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--border-3);
  border-top-color: var(--text-3);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--icon-btn);
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}

.btn svg { width: 15px; height: 15px; }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-soft {
  background: var(--surface);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-1);
  color: var(--text);
}
.btn-soft:hover { border-color: var(--border-3); }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(0.985); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-dashed {
  width: 100%;
  height: var(--sp-12);
  border: 1px dashed var(--border-3);
  border-radius: var(--r-lg);
  color: var(--text-3);
  font-size: var(--fs-md);
}
.btn-dashed:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-sm { height: 30px; padding: 0 var(--sp-4); font-size: var(--fs-sm); border-radius: var(--r-xs); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-btn);
  height: var(--icon-btn);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* 顶栏的「编辑主页」只在编辑模式出现，平时右上角只有一个齿轮 */
#editToggle { display: none; color: var(--text-2); }
body.is-editing #editToggle { display: inline-flex; }

/* ---------- 时钟：居中大字秒级 ---------- */
.clock-block {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

/* 时钟 → 每日一句 → 搜索：把原来的大留白拆成两段（12–16 / 20–24） */
.clock-block + .quote-block { margin-top: 14px; }
.quote-block + .hero { margin-top: 22px; }

.clock {
  --clock-size: clamp(44px, 6.2vw, 66px);

  display: inline-flex;
  align-items: baseline;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  line-height: 1;
  cursor: default;
}

.clock-hm {
  font-size: var(--clock-size);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.clock-sec {
  font-size: calc(var(--clock-size) * 0.46);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-3);
}

/* 冒号是独立节点，JS 只改写数字，冒号保持静态不重绘 */
.clock-sep { margin-right: 0.06em; }

/* ---------- 5·补. 每日一句：时钟下、搜索上，纯文字，不加大卡 ---------- */
.quote-block {
  display: flex;
  justify-content: center;
  margin-top: 22px;
  padding: 0 4px;
}

.quote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
  max-width: var(--search-w);
  text-align: center;
}

/* 正文就是主角：整句可点，点一下看全文与出处 */
.quote-text {
  display: block;
  max-width: 30em;
  border-radius: var(--r-sm);
  font-size: clamp(15px, 1.55vw, 18px);
  font-weight: 400;
  line-height: 1.72;
  letter-spacing: 0.012em;
  color: var(--text);
  transition: color var(--dur) var(--ease);
}

.quote-text:hover,
.quote-text:focus-visible { color: var(--accent); }

.quote-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* 来源：点开看详情（公版给全文，摘句只给来源） */
.quote-source {
  max-width: 20em;
  overflow: hidden;
  border-radius: var(--r-xs);
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}

.quote-source:hover,
.quote-source:focus-visible {
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: var(--border-3);
  text-underline-offset: 2px;
}

.quote-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;          /* 空间不够时压缩来源文字，而不是挤扁图标 */
  width: 24px;
  height: 24px;
  border-radius: var(--r-xs);
  color: var(--text-3);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}

.quote-icon svg { width: 15px; height: 15px; }
.quote-icon:hover { color: var(--text-2); background: var(--surface-2); }
.quote-icon:active { transform: scale(0.94); }

.quote-fav.is-on { color: var(--danger); }
.quote-fav.is-on svg { fill: currentColor; }

/* 切换：正文轻轻上浮淡入（prefers-reduced-motion 时由文末全局规则关掉） */
.quote.is-switching .quote-text { animation: quote-in 260ms var(--ease); }

@keyframes quote-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* 详情层 */
.quote-detail {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.quote-detail-cat {
  align-self: flex-start;
  padding: 2px 9px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.quote-detail-text {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
}

.quote-detail-note { font-size: var(--fs-sm); line-height: 1.6; color: var(--text-3); }

.quote-detail-linkWrap { margin: 0; }
.quote-detail-link {
  color: var(--accent);
  font-size: var(--fs-md);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.quote-detail-link:hover,
.quote-detail-link:focus-visible { color: var(--text); }

/* 作品名 / 作者：详情顶部的标题块 */
.quote-detail-head { display: flex; flex-direction: column; gap: 2px; }
.quote-detail-work {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.quote-detail-byline { font-size: var(--fs-md); color: var(--text-2); }

/* 背景 / 赏析：各自成块的文字分区，和原文分段隔开 */
.quote-detail-section { display: flex; flex-direction: column; gap: var(--sp-2); }
.quote-detail-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.quote-detail-body { font-size: var(--fs-md); line-height: 1.8; color: var(--text-2); }
.quote-detail-translation { white-space: pre-wrap; }
.quote-detail-original { white-space: pre-wrap; }

/* 详情要放下全文 + 背景 + 赏析，比默认弹窗宽一档；窄屏仍占满宽度 */
.modal.modal-quote { max-width: 560px; }

/* 我的收藏：每行一句，点正文看详情，右侧心形取消收藏 */
.modal.modal-favorites { max-width: 560px; }

.fav-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }

.fav-item { display: flex; align-items: flex-start; gap: var(--sp-1); }
.fav-item + .fav-item { border-top: 1px solid var(--border); }

.fav-open {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 11px 10px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background-color var(--dur) var(--ease);
}
.fav-open:hover,
.fav-open:focus-visible { background: var(--surface-2); }

.fav-quote {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--fs-md);
  line-height: 1.62;
  color: var(--text);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.fav-source {
  overflow: hidden;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 库里已找不到的收藏：保留但标灰，仍可手动移除 */
.fav-item.is-missing .fav-quote { color: var(--text-3); }

.fav-item .quote-fav-remove { margin: 8px 6px 0 0; }

.fav-empty { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4) 2px var(--sp-2); }
.fav-empty-title { font-size: var(--fs-lg); color: var(--text-2); }
.fav-empty-hint { font-size: var(--fs-sm); line-height: 1.7; color: var(--text-3); }

/* ---------- 6. Hero：搜索 ---------- */
.hero {
  margin-top: var(--gap-hero);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 默认：只有极淡描边 + 很轻的阴影，没有任何蓝色 */
.searchbar {
  position: relative;
  width: 100%;
  max-width: var(--search-w);
  height: var(--search-h);
  display: flex;
  align-items: center;
  gap: var(--search-gap);
  padding: 0 var(--sp-7);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-search);
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.searchbar:hover { border-color: var(--border-2); }

/* 注意：页面加载会自动 focus 搜索框。
   这里刻意不给 :focus-within 任何样式 —— 否则「默认状态」就带上了聚焦效果。
   只有用户自己点进来（:focus-visible）才有反馈。 */
.searchbar:has(.searchbar-input:focus-visible) {
  border-color: var(--focus-line);
  box-shadow: 0 0 0 4px var(--halo), var(--shadow-2);
}

.searchbar-icon {
  width: 20px;
  height: 20px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: color 200ms var(--ease);
}
.searchbar:focus-within .searchbar-icon { color: var(--text-2); }

.searchbar-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  font-size: var(--fs-2xl);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
}
.searchbar-input::placeholder { color: var(--text-muted); }
.searchbar-input:focus-visible { outline: none; }

/* 搜索源：未选中也要看得清，选中只靠浅底 + 轻阴影 */
.engines {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: top;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.engine {
  flex: 0 0 auto;
  white-space: nowrap;
  height: 34px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-xs);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.engine:hover { color: var(--text); }

.engine.is-active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  box-shadow: var(--shadow-pill);
}

[data-theme='dark'] .engine.is-active { background: #26282d; }

/* ---------- 7. 分类卡片 ---------- */
/* 快捷网站：按实际可用宽度自适应列数，卡宽不足约 280px 时自然减列 */
.categories {
  margin-top: var(--gap-categories);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-6);
  align-items: stretch;
}

.home-content > .categories { margin-top: 0; }

/* 卡片：主要靠背景差 + 极淡描边区分，阴影只做一点点分离 */
.category {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-1);
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.category:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-2);
}

.category-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 24px;
}

.category-name {
  font-size: var(--fs-title);
  font-weight: 650;
  letter-spacing: -0.005em;
  color: var(--text);
}

.category-count {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.category-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.cat-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r-xs);
  color: var(--text-3);
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.cat-tool svg { width: 14px; height: 14px; }
.cat-tool:hover { background: var(--surface-2); color: var(--text); }

/* 标题与图标区之间的呼吸 */
.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  margin-top: 10px;
}

/* 整个书签（图标 + 名称 + 四周留白）都是一个点击区域，
   hover 也只铺一层很浅的圆角底色，不加卡片 / 描边 / 阴影 */
.link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 68px;
  padding: 6px var(--link-pad-x);
  border-radius: var(--r-md);
  background: transparent;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.link:hover { background: var(--surface-2); transform: translateY(-1px); }
.link:active { transform: none; }

.link-icon {
  width: var(--link-icon);
  height: var(--link-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  background: transparent;
  transition: transform var(--dur) var(--ease);
}

.link:hover .link-icon { transform: scale(1.04); }

.link-icon img { width: 100%; height: 100%; object-fit: contain; }

.link-icon.is-letter {
  font-size: var(--fs-md);
  font-weight: 600;
  color: #fff;
}

.link-name {
  max-width: 100%;
  font-size: var(--fs-link);
  line-height: 1.25;
  color: var(--text-2);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color var(--dur) var(--ease);
}

.link:hover .link-name { color: var(--text); }

.empty-category {
  grid-column: 1 / -1;
  padding: var(--sp-7) var(--sp-4);
  border-radius: var(--r-md);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.categories-empty {
  grid-column: 1 / -1;
  padding: 64px var(--sp-6);
  text-align: center;
  font-size: var(--fs-md);
  color: var(--text-3);
}

.category-add { margin-top: var(--sp-6); }

/* ---------- 8. 编辑模式 ---------- */

/* 分类名本身就是明确的「重命名」按钮 */
.category-name.is-button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 26px;
  padding: 0 9px 0 10px;
  border: 1px dashed var(--border-3);
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}

.category-name.is-button svg { width: 11px; height: 11px; opacity: 0.45; }

.category-name.is-button:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.category-name.is-button:hover svg { opacity: 1; }

/* 编辑态：入口带一层极淡底色，一眼看出可以点、可以拖 */
body.is-editing .link { background: var(--edit-tint); cursor: grab; }
body.is-editing .link:hover { background: var(--surface-2); }
body.is-editing .link:active { cursor: grabbing; }

body.is-editing .link-edit { opacity: 1; }

.link-edit {
  position: absolute;
  top: var(--sp-1);
  right: var(--sp-1);
  width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  opacity: 0;
  transition: opacity 140ms var(--ease), background-color 140ms var(--ease),
              color 140ms var(--ease), border-color 140ms var(--ease);
}
.link-edit svg { width: 10px; height: 10px; }
.link:hover .link-edit { opacity: 1; }
.link-edit:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.link.is-dragging { opacity: 0.35; }

.link.drop-before::before,
.link.drop-after::after {
  content: '';
  position: absolute;
  top: var(--sp-3);
  bottom: var(--sp-3);
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.link.drop-before::before { left: -3px; }
.link.drop-after::after { right: -3px; }

.links.is-drop-target { border-radius: var(--r-md); outline: 1.5px dashed var(--accent); outline-offset: 4px; }

/* ---------- 网络状态条 ---------- */
.netstatus {
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color 200ms var(--ease);
}

.netstatus:hover { border-color: var(--border-2); }

/* 头部两行：第一行是结论 + 节点状态，第二行是采集来源 + 今日切换。
   grid 让两行共用左侧内容列、右侧只放展开箭头，行高与左右留白都稳定。
   任一子项都不可被压扁（flex 0 0 auto），空间不足时整块折行，绝不把中文挤成竖排。 */
.netstatus-head {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  text-align: left;
  transition: background-color var(--dur) var(--ease);
}

.netstatus-head:hover { background: var(--surface-2); }

.netstatus-line {
  grid-column: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: var(--sp-2);
  min-width: 0;
}

.netstatus-line-top { grid-row: 1; column-gap: var(--sp-3); }

/* 次级信息：来源靠左、今日切换靠右，构成第二行的两端 */
.netstatus-line-bottom {
  grid-row: 2;
  justify-content: space-between;
  column-gap: var(--sp-5);
}

.netstatus-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-3);
}

.netstatus-dot[data-state='healthy'] { background: var(--ok); }
.netstatus-dot[data-state='degraded'] { background: var(--danger); }

.netstatus-primary {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}

.netstatus-nodes {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-5);
  /* 允许在窄屏收缩到可用宽度，从而触发节点之间的换行，而不是整块溢出 */
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
}

.netstatus-node {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.netstatus-node-name { color: var(--text-3); }

.netstatus-node-value {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.netstatus-node-value.is-stale { color: var(--text-3); opacity: 0.65; }
.netstatus-node-value.is-bad { color: var(--danger); }
.netstatus-node.is-empty { color: var(--text-3); }

.netstatus-alert {
  border-top: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-6);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.netstatus-source {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.netstatus-today {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.netstatus-chevron {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  display: inline-flex;
  color: var(--text-3);
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.netstatus-chevron svg { width: 15px; height: 15px; }
.netstatus-head:hover .netstatus-chevron { color: var(--text-2); }
.netstatus[data-open='true'] .netstatus-chevron svg { transform: rotate(180deg); }

.netstatus-history {
  border-top: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-6) var(--sp-5);
  animation: netstatus-in 180ms var(--ease);
}

@keyframes netstatus-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}

.netstatus-daylabel {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.netstatus-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding: 5px 0;
  font-size: var(--fs-sm);
}

.netstatus-time {
  flex-shrink: 0;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.netstatus-route { color: var(--text-2); }

.netstatus-arrow { margin: 0 6px; color: var(--text-3); }

.netstatus-reason {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-3);
}

.netstatus-reason[data-kind='recover'] { color: var(--ok); }
.netstatus-reason[data-kind='perf'] { color: var(--warn); }
.netstatus-reason[data-kind='fault'] { color: var(--danger); }

.netstatus-groups {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

.netstatus-empty {
  padding: var(--sp-3) 0;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ---------- 9. Footer ---------- */
.footer {
  margin-top: var(--gap-footer);
  min-height: 16px;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ---------- 10. Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7);
  background: rgba(12, 13, 16, 0.26);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: overlay-in 160ms var(--ease);
}

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  animation: modal-in 200ms var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-5);
}

.modal-body { display: flex; flex-direction: column; gap: var(--sp-4); }

.modal-actions { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-6); }
.modal-actions .spacer { flex: 1; }

/* ---------- 10·补. 使用者门禁 ---------- */
/* 首次访问（或身份值损坏）时的设备本地选择层。
   是否显示完全由 html.is-user-pending 决定：head 里的内联脚本在首帧前就挂好这个
   class，主体随即隐藏，所以不会出现「主页先闪一下再弹选择」。*/
.user-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7);
  background: var(--bg);
}

html.is-user-pending .user-gate { display: flex; }

/* visibility 不触发重排，选中后主体立刻出现且无跳变 */
html.is-user-pending .page { visibility: hidden; }

.user-gate-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.user-gate-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.user-gate-hint {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.user-gate-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-7);
}

.user-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease),
              transform var(--dur) var(--ease);
}

.user-option:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.user-option:active { transform: none; }

.user-option-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-2xl);
  font-weight: 600;
}

.user-option[data-user='99'] .user-option-avatar { background: #4f9d8b; color: #fff; }

.user-option-name {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text);
}

/* ---------- 11. Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }

.field-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }

.field-hint { font-size: var(--fs-xs); line-height: 1.5; color: var(--text-3); }

.input {
  width: 100%;
  height: 38px;
  padding: 0 var(--sp-4);
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  outline: none;
  font-size: var(--fs-lg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.input::placeholder { color: var(--text-3); }

.input:focus {
  border-color: var(--focus-line);
  box-shadow: 0 0 0 3px var(--halo);
}

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f9b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: var(--sp-8);
  cursor: pointer;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.segmented button {
  flex: 1;
  height: 30px;
  border-radius: var(--r-xs);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

.segmented button:hover { color: var(--text); }

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pill);
}

[data-theme='dark'] .segmented button.is-active { background: #26282d; }

.row { display: flex; gap: var(--sp-3); align-items: center; }
.row .input { flex: 1; }

.city-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
}

.city-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 9px 11px;
  border-radius: var(--r-xs);
  font-size: var(--fs-md);
  color: var(--text-2);
  text-align: left;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}

.city-result:hover { background: var(--surface-2); color: var(--text); }
.city-result small { font-size: var(--fs-xs); color: var(--text-3); }

.current-city {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: var(--fs-md);
  color: var(--text);
}

/* ---------- 12. Toast ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: var(--sp-8);
  z-index: 200;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  pointer-events: none;
}

.toast {
  padding: 9px var(--sp-5);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-md);
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

.toast.is-visible { opacity: 1; transform: none; }

/* ---------- 13. Responsive ---------- */
@media (min-width: 1440px) {
  .home-intro > .hero {
    width: 100%;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
  }
  .home-intro > .hero .searchbar { max-width: 860px; }
}

@media (min-width: 901px) and (max-width: 1350px) {
  .main { grid-template-columns: 300px minmax(0, 1fr); gap: 24px; }
}

/* 桌面（≥901px）：右列顶部信息组整组居中、内部左对齐，编辑/设置靠右并预留空间；
   垂直节奏与日历卡按「首屏尽量不滚动」收紧。日历在左列自 .main 顶部起，与信息齐平。 */
@media (min-width: 901px) {
  .page { padding-top: 18px; padding-bottom: 16px; }

  /* 顶部信息组：居中限宽，两组轻分隔；编辑/设置在右端预留 80–100px */
  .topbar-left { display: flex; justify-content: center; }
  .topbar-right { min-width: 84px; justify-content: flex-end; }
  .topbar .today { width: 100%; max-width: 660px; gap: 0; }
  .topbar .today-almanac { padding-left: 14px; }

  /* 垂直节奏：信息→时钟 12 / 时钟→一句 10 / 一句→搜索 14 */
  .clock-block { margin-top: 12px; }
  .clock-block + .quote-block { margin-top: 10px; }
  .quote-block + .hero,
  .home-intro > .hero { margin-top: 14px; }
  .engines { margin-top: 10px; }

  /* 日历卡桌面紧凑尺寸：年/月约 45、日期格 34 gap 2（五周约 200、六周 236） */
  .calendar-panel { padding: 15px; }
  .calendar-heading { min-height: 45px; }
  .calendar-heading-text { gap: 1px; }
  .calendar-month { font-size: 22px; }
  .calendar-grid { margin-top: 9px; gap: 2px; }
  .calendar-weekday { display: flex; align-items: center; justify-content: center; height: 20px; padding-bottom: 0; }
  .calendar-day,
  .calendar-empty { height: 34px; font-size: var(--fs-md); }
  .calendar-event { padding: 6px 8px; }

  /* 底部动作前后间距 10 */
  .calendar-footer { margin-top: 10px; padding-top: 10px; }
}

/* ≤900：单栏，顺序为 时钟/一句/搜索 → 快捷网站/网络状态 → 日历日程；
   日历自然展开、不做固定高度裁切。 */
@media (max-width: 900px) {
  .main { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, min-content); gap: 24px; }
  .home-intro,
  .calendar-sidebar,
  .home-content { grid-column: 1; width: 100%; }
  .home-intro { grid-row: 1; }
  .home-content { grid-row: 2; }
  .calendar-sidebar { grid-row: 3; }
}

@media (max-width: 720px) {
  .page { padding: var(--sp-6) 18px var(--sp-12); }
  .topbar { min-height: 0; gap: var(--sp-4); }
  .calendar-panel { padding: var(--sp-5); }

  .clock { --clock-size: clamp(36px, 14vw, 52px); }
  .clock-block { margin-top: var(--sp-8); }
  .clock-block + .quote-block { margin-top: var(--sp-5); }
  .quote-block + .hero { margin-top: var(--sp-6); }
  .quote { gap: 6px; }
  .quote-text { font-size: 15px; line-height: 1.65; }
  .quote-source { max-width: 58vw; }

  /* 触屏命中区：图标视觉尺寸不变，伪元素把心形 / 换一句扩到 40×40 可点 */
  .quote-meta { column-gap: 16px; }
  .quote-icon { position: relative; }
  .quote-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
  }

  /* 窄屏放不下并排，农历 / 节气 / 历史换到天气下面一行 */
  .today { flex-wrap: wrap; align-items: flex-start; gap: var(--sp-3); }
  .today-almanac { padding-left: 0; border-left: 0; }
  .almanac-history { max-width: 78vw; }

  .hero { margin-top: var(--sp-10); }
  .searchbar {
    height: 56px;
    padding: 0 18px;
    gap: 11px;
    border-radius: var(--r-lg);
  }
  .searchbar-input { font-size: var(--fs-xl); }
  .searchbar-icon { width: 18px; height: 18px; }

  .engines { margin-top: var(--sp-4); }
  .engine { height: 36px; padding: 0 10px; font-size: var(--fs-sm); }

  .categories { gap: var(--sp-4); margin-top: var(--sp-12); }
  /* 移动端日期格固定 43px（去掉随卡宽膨胀的 aspect-ratio） */
  .calendar-day,
  .calendar-empty { height: 43px; }
  .category { padding: var(--sp-5); border-radius: var(--r-lg); }
  .links { margin-top: var(--sp-4); }

  .netstatus-head { row-gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); }
  .netstatus-chevron { grid-row: 1; }
  .netstatus-line-top { column-gap: var(--sp-2); }
  .netstatus-line-bottom {
    grid-column: 1 / -1;
    justify-content: flex-start;
    column-gap: var(--sp-4);
  }
  .netstatus-today { margin-left: auto; }
  .netstatus-history { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
  .netstatus-alert { padding: var(--sp-3) var(--sp-5); }
  .netstatus-row { flex-wrap: wrap; row-gap: 3px; }
  .netstatus-groups { margin-left: 0; width: 100%; }

  .footer { margin-top: var(--sp-10); }

  .modal-overlay { padding: var(--sp-5); align-items: flex-end; }
  .modal { max-width: 100%; border-radius: var(--r-xl) var(--r-xl) var(--r-lg) var(--r-lg); }
  .modal.modal-quote,
  .modal.modal-favorites { max-width: 100%; }
  .quote-detail-body { font-size: var(--fs-lg); }

  .user-gate { padding: var(--sp-5); }
}

@media (max-width: 420px) {
  .weather-temp { font-size: 23px; }
  .engine { padding: 0 8px; font-size: 12px; }
}

/* 低高度桌面（笔记本视口，如 1474×687 / 1366×768 / 1180×700）：
   在桌面基调上再收紧一档，让日历卡、时钟、搜索、分类与网络状态尽量完整落在首屏。
   原规则是 (min-width:721px)+(max-height:860px)，这里只把宽度界限改到 901，避免影响
   平板（721–900），高度界限保持原值，使 768 高的两个重点视口也纳入紧凑策略。 */
@media (min-width: 901px) and (max-height: 860px) {
  .page { padding-top: 10px; padding-bottom: 4px; }
  .main { gap: 18px; }

  .clock { --clock-size: clamp(44px, 5vw, 48px); }
  .clock-block { margin-top: 10px; }

  .searchbar { height: 48px; }
  .engines { margin-top: 8px; padding: 2px; }
  .engine { height: 28px; }

  .categories { gap: 18px; }
  .category { padding: 10px 14px; }
  .links { margin-top: 5px; gap: 10px; }
  .link { min-height: 50px; padding: 2px var(--link-pad-x); gap: 2px; }
  .link-icon { width: 36px; height: 36px; }
  .link-name { font-size: 13px; line-height: 1.15; }

  .netstatus { margin-top: 12px; }
  .netstatus-head { padding: 6px 16px; }

  .footer { margin-top: 8px; }

  /* 日历在最矮视口再压一档：日期格 32，段距更紧，保证今天日程与提醒空态落在首屏 */
  .calendar-panel { padding: 14px; }
  .calendar-grid { margin-top: 8px; }
  .calendar-day,
  .calendar-empty { height: 32px; }
  .calendar-agenda { margin-top: 10px; }
  .calendar-apple-reminders { margin-top: 10px; padding-top: 8px; }
  .calendar-footer { margin-top: 8px; padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* iCloud connection and selected calendar */
.calendar-source { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-4); min-height: 28px; color: var(--text-3); font-size: var(--fs-xs); }
.calendar-source select { flex: 1; min-width: 0; max-width: 100%; border: 0; background: transparent; color: var(--text-2); font-size: var(--fs-sm); padding: 4px 0; }
.calendar-source-action { flex-shrink: 0; padding: 4px 6px; border-radius: var(--r-xs); color: var(--text-muted); }
.calendar-source-action:hover { color: var(--accent); background: var(--accent-soft); }
.calendar-error { margin-top: var(--sp-3); color: var(--danger); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.calendar-connect-note { margin-top: var(--sp-3); font-size: var(--fs-sm); line-height: 1.65; color: var(--text-muted); }
.calendar-connect-note a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.calendar-editor textarea { width: 100%; min-width: 0; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--input-bg); color: var(--text); font: inherit; font-size: var(--fs-md); resize: vertical; }
.calendar-add:disabled, .calendar-editor button:disabled { opacity: .5; cursor: default; }

/* 日程：标题 15px、正文 13.5px、元信息 12px；标题到内容 8px、段间 16px；长事件换行。 */
.calendar-agenda { margin-top: var(--sp-5); }
.calendar-agenda-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.calendar-agenda-heading { font-size: 15px; font-weight: 650; color: var(--text); }
.calendar-agenda-context { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 8px; max-width: 100%; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.calendar-agenda-dot { color: var(--text-3); }
.calendar-agenda-festival { color: var(--accent); }
.calendar-agenda-term { color: var(--accent); font-size: inherit; }
.calendar-agenda-subtitle { color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.calendar-today-agenda { padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.calendar-event-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.calendar-event-content .calendar-event-title { font-size: var(--fs-md); overflow: visible; white-space: normal; line-height: 1.5; overflow-wrap: anywhere; }
.calendar-event-meta { font-size: 12px; color: var(--text-3); line-height: 1.45; }
/* 生日：只读来源，不可点击、无悬停反馈（不是可编辑的日程）。 */
.calendar-event.is-birthday { cursor: default; }
.calendar-event.is-birthday:hover { background: transparent; }
.calendar-event.is-birthday .calendar-event-time { color: var(--text-3); }
.calendar-event.is-birthday .calendar-event-title { font-weight: 600; }

.calendar-apple-reminders { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.reminder-group-title { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; margin: 14px 0 6px; }
.reminder-group-title.is-overdue { color: #b45a48; }
.reminder-item { display: flex; gap: 10px; padding: 9px 0; align-items: flex-start; }
.reminder-circle { width: 20px; height: 20px; padding: 0; border: 1.5px solid var(--text-3); border-radius: 50%; background: transparent; flex-shrink: 0; margin-top: 1px; position: relative; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.reminder-circle:hover:not(:disabled) { border-color: #3d63dd; }
.reminder-circle:focus-visible { outline: 2px solid #3d63dd; outline-offset: 2px; }
.reminder-circle:disabled { cursor: default; }
.reminder-item.is-sending .reminder-circle, .reminder-item.is-pending .reminder-circle, .reminder-item.is-queued .reminder-circle { border-style: dashed; }
.reminder-item.is-sending .reminder-circle::after, .reminder-item.is-pending .reminder-circle::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid transparent; border-top-color: var(--text-3); animation: reminder-spin .8s linear infinite; }
.reminder-item.is-failed .reminder-circle { border-color: #b45a48; }
.reminder-item.is-failed .reminder-circle::after { content: ''; position: absolute; left: 6px; top: 4px; width: 4px; height: 8px; border: solid #b45a48; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.reminder-status { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.reminder-status.is-failed { color: #b45a48; }
@keyframes reminder-spin { to { transform: rotate(360deg); } }
.reminder-item .calendar-event-title { white-space: normal; overflow: visible; overflow-wrap: anywhere; font-size: var(--fs-md); line-height: 1.5; }
.reminder-connect { margin-top: 10px; }
.reminder-pair-code { display: block; font: 14px/1.6 ui-monospace, monospace; overflow-wrap: anywhere; padding: 16px; background: var(--surface-2); border-radius: 12px; user-select: all; }

/* ---------- 14. 日历节奏覆盖（桌面） ----------
   上面「日程 / 提醒」的基础规则定义在响应式段之后，同优先级会反超先前的媒体查询，
   所以这些覆盖必须放在文件末尾声明才能生效：月历至日程分隔 12、标题至副标题 4、
   至事件 6；日程/提醒段距 12、分隔后 10；事件/提醒行 padding 6；底部动作前后 10。 */
@media (min-width: 901px) {
  .calendar-source { margin-top: 8px; min-height: 28px; }
  .calendar-agenda { margin-top: 12px; }
  .calendar-agenda-head { margin-bottom: 4px; }
  .calendar-agenda-context { margin-bottom: 6px; }
  .calendar-agenda-subtitle { margin-bottom: 6px; }
  .calendar-today-agenda { padding-top: 12px; }
  .calendar-apple-reminders { margin-top: 12px; padding-top: 10px; }
  .reminder-group-title { margin: 12px 0 6px; }
  .reminder-item { padding: 6px 0; }
  .reminder-status { font-size: var(--fs-sm); }
  .reminder-connect { margin-top: 10px; }
}

@media (min-width: 901px) and (max-height: 860px) {
  .calendar-agenda { margin-top: 10px; }
  .calendar-apple-reminders { margin-top: 10px; padding-top: 8px; }
  .reminder-group-title { margin: 10px 0 6px; }
}

/* ---------- 15. 统一桌面轴线与窄屏顶栏 ---------- */
@media (min-width: 901px) {
  .main { grid-template-columns: clamp(260px, 22vw, 310px) minmax(0, 1fr); gap: 24px; }
  .topbar { flex-wrap: nowrap; }
  .topbar-left { justify-content: flex-start; }
  .topbar-right { min-width: 34px; }
  .topbar .today { max-width: none; flex-wrap: wrap; row-gap: 8px; }
  .today-stack { flex: 0 0 auto; }
  .topbar .today-almanac { min-width: 0; flex: 1 1 220px; }
  .almanac-history { max-width: 100%; overflow-wrap: anywhere; }
  .home-intro > .hero { width: 100%; max-width: 720px; margin: 16px auto 0; }
  .home-intro > .hero .searchbar { max-width: 100%; }
  .home-content > .categories { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
}
@media (min-width: 901px) and (max-height: 860px) {
  .main { gap: 18px; }
}
@media (max-width: 720px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; }
  .topbar-right { align-self: start; }
  .today { gap: 8px; }
  .today-almanac { flex-basis: 100%; min-width: 0; }
  .almanac-history { max-width: 100%; overflow-wrap: anywhere; }
  .clock-block { margin-top: 24px; }
  .quote-source { max-width: 50vw; }
}
