/* ============================================================
   长安自用导航 · 设计系统
   活泼现代风：奶油暖底 + 橘子橙主色 + 分类轮转色板
   移动优先 · OKLCH 色彩 · 深浅双主题 · reduced-motion 支持
   ============================================================ */

/* ---------- Token 层 ---------- */
:root {
  /* 浅色语义色 */
  --bg: oklch(97.3% 0.012 85);
  --bg-soft: oklch(95.2% 0.016 85);
  --surface: oklch(99.3% 0.006 85);
  --surface-2: oklch(98.2% 0.01 85);
  --text: oklch(27% 0.03 55);
  --text-2: oklch(44% 0.025 60);
  --text-3: oklch(57% 0.02 62);
  --brand: oklch(66% 0.17 48);
  --brand-strong: oklch(55% 0.17 45);
  --brand-soft: oklch(92.5% 0.05 62);
  --on-brand: oklch(24% 0.05 50);
  --line: oklch(89.5% 0.02 75);
  --line-strong: oklch(84% 0.025 75);
  --mark: oklch(88% 0.11 95);
  --mark-text: oklch(30% 0.06 75);
  --shadow-1: 0 1px 2px oklch(30% 0.05 55 / 0.06), 0 2px 8px oklch(30% 0.05 55 / 0.05);
  --shadow-2: 0 6px 16px -6px oklch(35% 0.08 50 / 0.16), 0 2px 6px oklch(35% 0.08 50 / 0.06);
  --mask: oklch(25% 0.04 55 / 0.42);

  /* 分类轮转色板 */
  --c1: oklch(66% 0.17 48);   /* 橘 */
  --c2: oklch(64% 0.14 130);  /* 青柠 */
  --c3: oklch(62% 0.13 230);  /* 天蓝 */
  --c4: oklch(66% 0.16 10);   /* 粉 */
  --c5: oklch(60% 0.15 300);  /* 紫罗兰 */
  --c6: oklch(72% 0.14 85);   /* 琥珀 */

  /* 布局 */
  --sidebar-w: 238px;
  --sidebar-w-c: 76px;
  --topbar-h: 64px;
  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;

  /* 动效 token */
  --e-out: cubic-bezier(0.22, 1, 0.36, 1);
  --e-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 130ms;
  --t-med: 260ms;
  --t-slow: 420ms;

  /* 字体 */
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei",
          "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg: oklch(17% 0.014 60);
  --bg-soft: oklch(20.5% 0.016 60);
  --surface: oklch(22% 0.018 60);
  --surface-2: oklch(25% 0.02 60);
  --text: oklch(91% 0.02 85);
  --text-2: oklch(72% 0.018 80);
  --text-3: oklch(56% 0.018 75);
  --brand: oklch(72% 0.15 55);
  --brand-strong: oklch(78% 0.14 62);
  --brand-soft: oklch(30% 0.05 55);
  --on-brand: oklch(20% 0.04 55);
  --line: oklch(30% 0.02 60);
  --line-strong: oklch(36% 0.024 60);
  --mark: oklch(42% 0.08 95);
  --mark-text: oklch(90% 0.05 95);
  --shadow-1: 0 1px 2px oklch(0% 0 0 / 0.25);
  --shadow-2: 0 8px 20px -8px oklch(0% 0 0 / 0.45);
  --mask: oklch(0% 0 0 / 0.55);
}

/* ---------- 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-med) var(--e-inout), color var(--t-med) var(--e-inout);
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

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

/* 焦点可见性 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 8px 14px;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius-s);
  font-weight: 600;
  transform: translateY(-64px);
  transition: transform var(--t-fast) var(--e-out);
}
.skip-link:focus-visible { transform: translateY(0); }

kbd {
  font-family: var(--font);
  font-size: 12px;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-3);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 90;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: width var(--t-med) var(--e-out), transform var(--t-med) var(--e-out);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  min-height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  flex: none;
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--c4));
  color: var(--on-brand);
  font-weight: 800;
  font-size: 17px;
  box-shadow: var(--shadow-1);
}

.brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close { margin-left: auto; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 12px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

/* 分组 */
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-3);
  white-space: nowrap;
}
.nav-group-title svg { flex: none; opacity: 0.75; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-top: 2px;
  border: 0;
  border-radius: var(--radius-s);
  background: none;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out);
}

.nav-item .dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--item-c, var(--brand));
  opacity: 0.5;
  transition: opacity var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
}

.nav-item .cnt {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item:hover .dot { opacity: 1; transform: scale(1.15); }

.nav-item.active {
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active .dot { opacity: 1; transform: scale(1.25); }

.sidebar-foot {
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
}

/* 折叠态（桌面） */
.sidebar.collapsed { width: var(--sidebar-w-c); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item .lbl,
.sidebar.collapsed .nav-item .cnt,
.sidebar.collapsed .nav-group-title span { display: none; }
.sidebar.collapsed .sidebar-head,
.sidebar.collapsed .sidebar-foot { justify-content: center; padding-inline: 10px; }
.sidebar.collapsed .brand { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding-inline: 10px; }

/* ---------- 遮罩与抽屉 ---------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: var(--mask);
  opacity: 0;
  transition: opacity var(--t-med) var(--e-inout);
}
.mask.show { opacity: 1; }

/* ---------- 主布局 ---------- */
.layout {
  min-height: 100dvh;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-med) var(--e-out);
}
.layout.collapsed { margin-left: var(--sidebar-w-c); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 10px clamp(14px, 3vw, 28px);
  padding-left: max(clamp(14px, 3vw, 28px), env(safe-area-inset-left));
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t-med) var(--e-out);
}
.topbar.scrolled { border-bottom-color: var(--line); }

.menu-btn { display: grid; }

.greet { min-width: 0; margin-right: auto; }

.greet-hi {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.greet-date {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 搜索框 */
.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(420px, 42vw);
  padding: 0 10px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--e-out), box-shadow var(--t-fast) var(--e-out), width var(--t-med) var(--e-out);
}
.search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search-ico { flex: none; color: var(--text-3); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }

.search-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-2);
  transition: background-color var(--t-fast) var(--e-out);
}
.search-clear:hover { background: var(--line); }

.search-kbd { flex: none; }

.search-go {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: var(--on-brand);
  transition: background-color var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
}
.search-go:hover { background: var(--brand-strong); color: var(--on-brand); }
.search-go:active { transform: scale(0.92); }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  transition: background-color var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out), border-color var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

#themeBtn .ico-moon { display: none; }
[data-theme="dark"] #themeBtn .ico-sun { display: none; }
[data-theme="dark"] #themeBtn .ico-moon { display: block; }

/* ---------- 移动端分类 chips ---------- */
.chips-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 60;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  padding-block: 8px;
}

.cat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px clamp(14px, 3vw, 28px);
  scrollbar-width: none;
}
.cat-chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out), border-color var(--t-fast) var(--e-out);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--item-c, var(--brand)); opacity: 0.65; }
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}
.chip.active .dot { background: var(--on-brand); opacity: 0.85; }

/* ---------- 主内容 ---------- */
main {
  flex: 1;
  width: 100%;
  padding: 8px clamp(14px, 3vw, 28px) 32px;
  padding-left: max(clamp(14px, 3vw, 28px), env(safe-area-inset-left));
}

/* 欢迎区 */
.hero {
  position: relative;
  overflow: hidden;
  margin-top: 10px;
  padding: clamp(22px, 4vw, 40px) clamp(20px, 4vw, 36px);
  border-radius: var(--radius-l);
  background:
    radial-gradient(520px 220px at 88% -30%, var(--brand-soft) 0%, transparent 65%),
    var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 32px);
}

.hero-copy { min-width: 0; flex: 1; }

.hero-title {
  font-size: clamp(22px, 3.4vw, 34px);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--brand), var(--c4) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hero-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.hero-dot-1 { width: 120px; height: 120px; right: -34px; top: -34px; background: var(--brand-soft); }
.hero-dot-2 { width: 46px; height: 46px; right: 14%; bottom: -12px; background: var(--c2); opacity: 0.35; }
.hero-dot-3 { width: 22px; height: 22px; right: 7%; top: 34%; background: var(--c3); opacity: 0.5; }

/* 时钟 · 农历 · 天气信息卡 */
.hero-info {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.hi-clock {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hi-time {
  font-size: clamp(34px, 3.6vw, 46px);
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(120deg, var(--text), var(--text-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hi-sec {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand);
  min-width: 2ch;
  text-align: left;
}

.hi-date {
  margin-top: 7px;
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

.hi-weather {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.hi-w-ico { display: grid; color: var(--brand); flex: none; }
.hi-w-ico svg { width: 30px; height: 30px; }

.hi-w-main { display: flex; flex-direction: column; min-width: 0; }
.hi-w-temp {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.hi-w-temp i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 1px; }
.hi-w-txt { margin-top: 2px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.hi-w-range { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 天气详情（右侧信息栏详细版） */
.w-now { display: flex; align-items: center; gap: 12px; min-width: 0; }
.w-now .hi-w-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-now .hi-w-range { white-space: nowrap; }

.w-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
}
.w-gi {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.w-gi b {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.w-sun {
  margin-top: 11px;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.w-fc {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.w-src {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-3);
  opacity: 0.85;
}
.w-fd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 8px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
}
.w-fd .fd-day { font-size: 11.5px; color: var(--text-3); }
.w-fd .fd-ico { display: grid; color: var(--text-2); }
.w-fd .fd-ico svg { width: 21px; height: 21px; }
.w-fd .fd-range {
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.w-fd:first-child .fd-day { color: var(--brand); font-weight: 700; }

.hi-w-skel {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-soft);
  animation: skel-pulse 1.2s ease-in-out infinite;
}
@keyframes skel-pulse { 50% { opacity: 0.45; } }

/* 天气卡：切换地区按钮 */
.w-wrap { position: relative; }
.w-city-btn, .w-refresh-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-3);
  transition: color var(--t-fast) var(--e-out), border-color var(--t-fast) var(--e-out), background-color var(--t-fast) var(--e-out);
}
.w-city-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.w-refresh-btn { right: 36px; }
.w-refresh-btn.spin svg { animation: w-spin 0.8s linear; }
@keyframes w-spin { to { transform: rotate(360deg); } }

/* 城市切换弹窗 */
.city-hot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.city-chip {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  transition: border-color var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out);
}
.city-chip:hover { border-color: var(--brand); color: var(--brand); }

.city-results {
  margin-top: 4px;
  max-height: 210px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.city-result {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 13px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  transition: border-color var(--t-fast) var(--e-out), background-color var(--t-fast) var(--e-out);
}
.city-result:hover { border-color: var(--brand); background: var(--brand-soft); }
.city-result .r-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 右侧常驻信息栏 ---------- */
.body-row { display: block; }
.rail { display: none; }

/* 信息栏显隐把手：仅桌面端 ≥1200px 出现 */
.rail-toggle { display: none; }

.rail-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 16px 18px;
}

.rail-clock .hi-time { font-size: 42px; }
.rail-clock .hi-date { white-space: normal; text-align: left; }

.rail-weather {
  width: 100%;
  display: block;
  text-align: left;
  color: var(--text);
}

.hk-txt {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.hk-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3);
  min-height: 22px;
}
.hk-from { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hk-refresh {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: none;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--brand);
  transition: background-color var(--t-fast) var(--e-out);
}
.hk-refresh:hover { background: var(--bg-soft); }

.rail-actions { display: flex; gap: 10px; padding: 12px; }
.rail-act {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--t-med) var(--e-out), color var(--t-med) var(--e-out), background-color var(--t-med) var(--e-out);
}
.rail-act:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.rail-act:active { transform: scale(0.98); }

/* ≥1200px：启用右侧信息栏，隐藏 hero 内信息卡 */
@media (min-width: 1200px) {
  .body-row {
    display: flex;
    align-items: flex-start;
  }
  main {
    flex: 1;
    min-width: 0;
    padding-right: clamp(8px, 1vw, 16px);
  }
  .rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: none;
    width: 288px;
    position: sticky;
    top: calc(var(--topbar-h) + 12px);
    margin: 10px clamp(14px, 3vw, 28px) 32px 0;
  }
  .rail .hi-date { text-align: left; }
  .hero-info { display: none; }

  /* 右侧信息栏显隐把手 */
  .rail-toggle {
    display: grid;
    place-items: center;
    position: fixed;
    right: 0;
    top: calc(var(--topbar-h) + 16px);
    z-index: 40;
    width: 20px;
    height: 54px;
    padding: 0;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 10px 0 0 10px;
    background: var(--surface);
    color: var(--text-3);
    box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.06);
    transition: color var(--t-fast) var(--e-out), background-color var(--t-fast) var(--e-out), border-color var(--t-fast) var(--e-out);
  }
  .rail-toggle:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
  .rail-toggle svg { transition: transform 0.28s var(--e-out); }
  body.rail-hidden .rail-toggle svg { transform: rotate(180deg); }
  /* 隐藏信息栏：主内容占满全宽，hero 内信息卡恢复显示 */
  body.rail-hidden .rail { display: none; }
  body.rail-hidden .hero-info { display: flex; }
}

/* 搜索结果提示 */
.search-hint {
  margin: 18px 2px 0;
  font-size: 13px;
  color: var(--text-2);
}
.search-hint strong { color: var(--brand-strong); font-variant-numeric: tabular-nums; }

/* 分类区块 */
.cat-section { margin-top: clamp(26px, 4vw, 44px); }

.cat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(17px, 2vw, 20px);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.cat-title::before {
  content: "";
  width: 8px; height: 22px;
  border-radius: 4px;
  background: var(--item-c, var(--brand));
  transform: rotate(8deg);
}

.cat-count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.cat-divider {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
  align-self: center;
}

/* 站点卡片网格 */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(225px, 100%), 1fr));
  gap: 12px;
}

/* 卡片单元格：容纳卡片与删除按钮 */
.site-cell { position: relative; min-width: 0; }

.site-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-med) var(--e-out), box-shadow var(--t-med) var(--e-out),
              border-color var(--t-med) var(--e-out), background-color var(--t-med) var(--e-inout);
}

/* 自定义站点闪烁高亮 */
.site-cell.flash .site-card {
  animation: card-flash 1.6s var(--e-out) 1;
}
@keyframes card-flash {
  0%, 55% {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
    background: var(--brand-soft);
  }
  100% { border-color: var(--line); }
}

.site-card .logo {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 11px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* logo 加载失败 → 首字母色块 */
.site-card .logo-fallback {
  flex: none;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 800;
  color: oklch(30% 0.04 60);
}

.site-card .meta { min-width: 0; }

.site-card .name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-card .desc {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-card .go {
  flex: none;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-3);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
}

/* 交互反馈：仅支持 hover 的设备启用 */
@media (hover: hover) {
  .site-card:hover {
    transform: translateY(-3px);
    border-color: var(--item-c, var(--brand));
    box-shadow: var(--shadow-2);
  }
  .site-card:hover .go { opacity: 1; transform: translateX(0); }
}

@media (hover: none) {
  .site-card:active { transform: scale(0.98); background: var(--bg-soft); }
  .site-card .go { display: none; }
}

/* 自定义站点删除按钮 */
.site-cell .del {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 6;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-1);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out),
              background-color var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out);
}
@media (hover: hover) {
  .site-cell:hover .del { opacity: 1; transform: scale(1); }
  .site-cell .del:focus-visible { opacity: 1; transform: scale(1); }
}
@media (hover: none) {
  .site-cell .del { opacity: 1; transform: scale(1); width: 24px; height: 24px; }
}
.site-cell .del:hover { background: oklch(93% 0.05 25); color: oklch(48% 0.19 25); border-color: oklch(85% 0.08 25); }
[data-theme="dark"] .site-cell .del:hover { background: oklch(32% 0.09 25); color: oklch(85% 0.08 25); }

/* 卡片 URL 提示（hover 设备） */
@media (hover: hover) and (pointer: fine) {
  .site-card::after {
    content: attr(data-url);
    position: absolute;
    left: 14px; bottom: calc(100% + 6px);
    max-width: calc(100% - 28px);
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--text);
    color: var(--bg);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
    z-index: 5;
  }
  .site-card:hover::after { opacity: 1; transform: translateY(0); }
}

/* 搜索高亮（保留给未来功能使用）
mark {
  background: var(--mark);
  color: var(--mark-text);
  border-radius: 3px;
  padding: 0 2px;
}
*/

/* ---------- 添加网站模态框 ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: var(--mask);
  opacity: 0;
  transition: opacity var(--t-med) var(--e-inout);
}
.modal-root.show .modal-mask { opacity: 1; }

.modal {
  position: relative;
  width: min(460px, 100%);
  max-height: min(86dvh, 720px);
  overflow-y: auto;
  border-radius: var(--radius-l);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  padding: 20px 22px;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: opacity var(--t-med) var(--e-out), transform var(--t-med) var(--e-out);
}
.modal-root.show .modal {
  opacity: 1;
  transform: none;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title { font-size: 17px; font-weight: 800; letter-spacing: 0.01em; }
.modal-close { width: 34px; height: 34px; border: 0; background: var(--bg-soft); }

.field { display: block; margin-top: 12px; min-width: 0; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field-label .req { color: var(--brand-strong); font-style: normal; }
.field-label .opt { color: var(--text-3); font-weight: 400; }

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast) var(--e-out), box-shadow var(--t-fast) var(--e-out);
}
.field input:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field input::placeholder { color: var(--text-3); }
.field select { cursor: pointer; }

.form-err {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  background: oklch(93% 0.05 25);
  color: oklch(48% 0.19 25);
  font-size: 13px;
}
[data-theme="dark"] .form-err {
  background: oklch(32% 0.09 25);
  color: oklch(85% 0.08 25);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.modal-manage { display: flex; align-items: center; gap: 14px; min-width: 0; }

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-3);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.link-btn:hover { color: var(--brand-strong); }
.link-btn.danger:hover { color: oklch(52% 0.19 25); }

.btn-primary {
  flex: none;
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 14px;
  font-weight: 700;
  transition: background-color var(--t-fast) var(--e-out), transform var(--t-fast) var(--e-out);
}
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:active { transform: scale(0.97); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  z-index: 140;
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--e-out), transform var(--t-med) var(--e-out);
  max-width: min(86vw, 480px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 页脚 ---------- */
.foot {
  margin-top: auto;
  padding: 22px clamp(14px, 3vw, 28px) calc(26px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-3);
}
.foot a { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
.foot a:hover { color: var(--brand-strong); }

.foot-icp {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
}
.foot-icp a { color: var(--text-3); }
.foot-icp a:hover { color: var(--text-2); }

/* ---------- 返回顶部 ---------- */
.to-top {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 80;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--t-med) var(--e-out), transform var(--t-med) var(--e-out), background-color var(--t-fast) var(--e-out);
}
.to-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { background: var(--bg-soft); color: var(--text); }

/* ---------- 入场动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
}
.reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity var(--t-slow) var(--e-out), transform var(--t-slow) var(--e-out);
  transition-delay: calc(var(--i, 0) * 45ms);
}

/* ---------- 响应式：平板与手机 ---------- */
@media (max-width: 999px) {
  .sidebar {
    width: min(300px, 84vw);
    transform: translateX(-105%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-2);
  }
  .sidebar.collapsed { width: min(300px, 84vw); }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-item .lbl,
  .sidebar.collapsed .nav-item .cnt,
  .sidebar.collapsed .nav-group-title span { display: initial; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; }

  .sidebar-close { display: grid; }

  .layout, .layout.collapsed { margin-left: 0; }

  .chips-bar { display: block; }

  .greet { display: none; }
  .search { width: 100%; flex: 1; }
  .search-kbd { display: none; }

  .hero { margin-top: 14px; }
  .hero-tip { display: none; }
  .hero-dot-2, .hero-dot-3 { display: none; }

  /* 信息卡：移动端改为横向布局（时钟+天气一行，日期换行） */
  .hero { flex-direction: column; align-items: stretch; }
  .hero-info {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    text-align: left;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
  }
  .hi-time { font-size: 30px; }
  .hi-date { width: 100%; order: 3; margin-top: 0; white-space: normal; }
  .hi-weather { margin-top: 0; }
  .hi-weather:hover { transform: none; }
}

@media (max-width: 520px) {
  .site-grid { gap: 10px; }
  .site-card { padding: 11px 12px; }
  .site-card .logo, .site-card .logo-fallback { width: 36px; height: 36px; border-radius: 10px; }
  .site-card .name { font-size: 13.5px; }
  .site-card .desc { font-size: 12px; }
  .topbar { padding-block: 8px; }
}

/* 触屏设备：加大点击热区 */
@media (pointer: coarse) {
  .nav-item, .chip { min-height: 44px; }
}

/* ---------- 动效减弱 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .chips-bar, .to-top, .mask, .hero-dot { display: none !important; }
  .layout { margin-left: 0 !important; }
  .site-card { break-inside: avoid; }
}
