/* ============================================================
   lite-nav · design system v1.3
   零构建纯 CSS,token 化 + 明/暗主题 + 玻璃质感 + 响应式
   ============================================================ */

/* ===== Design Tokens (theme-agnostic) ===== */
:root {
  /* Spacing — 4px base, 8px rhythm */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Type scale */
  --fs-2xs: 10px; --fs-xs: 11px; --fs-sm: 12px;
  --fs-base: 13px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 32px;

  /* Radius */
  --r-sm: 6px;  --r-md: 10px; --r-lg: 14px;
  --r-xl: 18px; --r-2xl: 24px; --r-full: 9999px;

  /* Motion */
  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.4, 0, 0.2, 1);

  /* Z layers */
  --z-sticky: 10; --z-suggest: 100; --z-modal: 200; --z-toast: 300;

  /* Font stack — system fonts + best CJK on each OS */
  --font-sans: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont,
               'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Source Han Sans SC', 'Noto Sans CJK SC',
               system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Menlo',
               'Consolas', 'Liberation Mono', monospace;
}

/* ===== Light theme (default) ===== */
:root, :root[data-theme="light"] {
  --bg-base: #f6f8fb;
  --bg-base-grad: radial-gradient(1200px 600px at 85% -10%, rgba(14,165,233,0.08), transparent 60%),
                  radial-gradient(900px 500px at 0% 100%, rgba(124,58,237,0.06), transparent 60%);
  --bg-elev-1: #ffffff;
  --bg-elev-2: rgba(255, 255, 255, 0.78);
  --bg-elev-3: #eef2f7;
  --bg-glass: rgba(255, 255, 255, 0.65);
  --bg-overlay: rgba(15, 23, 42, 0.32);
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-active: rgba(14, 165, 233, 0.10);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverted: #ffffff;

  --border-subtle: rgba(15, 23, 42, 0.06);
  --border-strong: rgba(15, 23, 42, 0.12);

  --accent: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-bg: rgba(14, 165, 233, 0.10);
  --accent-bg-strong: rgba(14, 165, 233, 0.16);

  --emerald: #059669;
  --emerald-bg: rgba(5, 150, 105, 0.10);
  --rose: #dc2626;
  --rose-bg: rgba(220, 38, 38, 0.10);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.12);
  --purple: #7c3aed;
  --purple-bg: rgba(124, 58, 237, 0.10);

  --shadow-sm:   0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md:   0 4px 14px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg:   0 18px 50px rgba(15, 23, 42, 0.12), 0 6px 16px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 0 3px rgba(14, 165, 233, 0.18);

  --skel-base: rgba(15, 23, 42, 0.06);
  --skel-shine: rgba(15, 23, 42, 0.02);
}

/* ===== Dark theme ===== */
:root[data-theme="dark"] {
  --bg-base: #08101f;
  --bg-base-grad: radial-gradient(1200px 600px at 85% -10%, rgba(34,211,238,0.10), transparent 60%),
                  radial-gradient(900px 500px at 0% 100%, rgba(167,139,250,0.08), transparent 60%);
  --bg-elev-1: #0f172a;
  --bg-elev-2: rgba(15, 23, 42, 0.72);
  --bg-elev-3: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.55);
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --bg-hover: rgba(241, 245, 249, 0.05);
  --bg-active: rgba(34, 211, 238, 0.12);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;
  --text-inverted: #0f172a;

  --border-subtle: rgba(241, 245, 249, 0.06);
  --border-strong: rgba(241, 245, 249, 0.14);

  --accent: #22d3ee;
  --accent-hover: #67e8f9;
  --accent-bg: rgba(34, 211, 238, 0.12);
  --accent-bg-strong: rgba(34, 211, 238, 0.20);

  --emerald: #34d399;
  --emerald-bg: rgba(52, 211, 153, 0.14);
  --rose: #fb7185;
  --rose-bg: rgba(251, 113, 133, 0.14);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.14);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.14);

  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg:   0 20px 60px rgba(0, 0, 0, 0.6), 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 0 3px rgba(34, 211, 238, 0.30);

  --skel-base: rgba(241, 245, 249, 0.06);
  --skel-shine: rgba(241, 245, 249, 0.12);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  min-height: 100vh;
  background: var(--bg-base);
  background-image: var(--bg-base-grad);
  background-attachment: fixed;
  display: flex; justify-content: center;
  font-family: var(--font-sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  color: var(--text-primary);
  padding: var(--sp-4) 0 var(--sp-8);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-base) var(--ease-snap),
              color var(--dur-base) var(--ease-snap);
}

/* ===== Layout ===== */
.page-layout {
  display: flex; align-items: flex-start;
  gap: var(--sp-4);
  width: 100%; max-width: 1320px;
  padding: 0 var(--sp-4);
}
.sidebar {
  flex: 0 0 304px;
  display: flex; flex-direction: column;
  gap: var(--sp-3);
  position: sticky; top: var(--sp-4);
}
.main-wrapper {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-4);
  flex: 1 1 0; min-width: 0; max-width: 840px;
}

/* ===== Generic card surface ===== */
.card,
.finance-bar,
.hot-panel,
.clock-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-snap);
}

/* ===== City clocks ===== */
.city-clocks {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: var(--sp-2); width: 100%;
}
.clock-card {
  padding: var(--sp-2) var(--sp-2);
  text-align: center; cursor: pointer; min-width: 0;
}
.clock-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.clock-city {
  font-size: var(--fs-xs); color: var(--text-tertiary);
  margin-bottom: 3px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.01em;
}
.clock-time {
  font-size: 18px; font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.clock-date {
  font-size: var(--fs-2xs); color: var(--text-muted);
  margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ===== Module A (date / lunar / weekend / weather / almanac / countdown) =====
   Now a soft glass card with internal sectioning via hairline dividers,
   info chunks as chips/pills instead of plain inline text. */
.module-a {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              background-color var(--dur-base) var(--ease-snap);
}

/* Date headline */
.date-row {
  display: flex; align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap; justify-content: center;
}
.solar-date {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.date-divider {
  display: inline-block;
  width: 1px; height: 22px;
  background: var(--border-strong);
  font-size: 0; color: transparent;
  vertical-align: middle;
}
.lunar-date {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Weekend / month countdown — caption text under date */
.weekend-row {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  display: inline-flex; align-items: center;
  gap: var(--sp-1);
}
.weekend-row b {
  color: var(--amber);
  font-weight: 700;
  margin: 0 2px;
}
.weekend-row .countdown-sep {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
  color: transparent; font-size: 0;
  margin: 0 var(--sp-2);
  vertical-align: middle;
}

/* Live info row: 北京时间 + IP chips + weather pill */
.info-row {
  display: flex; align-items: center; flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}
/* Replace dot separators with small visual gap dots */
.info-sep {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--border-strong);
  color: transparent; font-size: 0;
  margin: 0 var(--sp-1);
  vertical-align: middle;
}

/* Beijing time as a pill with pulse dot */
#bj-time {
  display: inline-flex; align-items: center;
  gap: 6px;
  padding: 4px var(--sp-3);
  background: var(--bg-elev-3);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}
#bj-time::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-bg);
  animation: livePulse 2s var(--ease-out) infinite;
  flex-shrink: 0;
}
@keyframes livePulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.85); }
}

/* IP entries: each as a chip */
#ip-loc {
  display: inline-flex; flex-wrap: wrap;
  gap: var(--sp-1);
  align-items: center;
}
.ip-entry {
  display: inline-flex; align-items: center;
  gap: 5px;
  padding: 3px var(--sp-2) 3px 7px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.ip-entry:hover { border-color: var(--accent); }
.ip-entry-label {
  font-size: 9px; font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  background: var(--bg-hover);
  border-radius: var(--r-full);
  margin-right: 1px;
}
.ip-entry-addr {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  margin-left: 3px;
}

/* Weather: branded accent pill */
#weather-info {
  display: inline-flex; align-items: center;
  gap: 5px;
  padding: 4px var(--sp-3);
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
#weather-info:hover {
  background: var(--accent-bg-strong);
  transform: translateY(-1px);
}

/* Almanac section: clearly grouped, full-width with hairline above */
.almanac-row {
  display: flex; flex-wrap: wrap;
  justify-content: center; align-items: center;
  gap: var(--sp-1) var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
  width: 100%;
  cursor: help;
}
.almanac-yi-label, .almanac-ji-label {
  font-size: var(--fs-2xs);
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-weight: 700; margin-right: 5px;
  letter-spacing: 0.04em;
}
.almanac-yi-label { color: var(--emerald); background: var(--emerald-bg); }
.almanac-ji-label { color: var(--rose);    background: var(--rose-bg); }
.almanac-shen {
  font-size: var(--fs-2xs);
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.almanac-shen.huang { color: var(--amber);          background: var(--amber-bg); }
.almanac-shen.hei   { color: var(--text-tertiary);  background: var(--bg-hover); }
.almanac-sep {
  display: inline-block;
  width: 1px; height: 12px;
  background: var(--border-subtle);
  color: transparent; font-size: 0;
  margin: 0 4px;
  vertical-align: middle;
}

/* Country countdown chips — STRICTLY single line; horizontal scroll fallback */
.countdown-row {
  display: flex; flex-wrap: nowrap;        /* never wrap */
  justify-content: safe center;            /* 放得下→居中;放不下→退回左对齐可滚动,不裁切 */
  gap: 6px;
  padding-top: var(--sp-3);
  padding-bottom: 2px;                      /* room for scrollbar */
  border-top: 1px solid var(--border-subtle);
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  /* Soft fade at edges to hint scroll */
  mask-image: linear-gradient(to right, transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 10px, black calc(100% - 10px), transparent 100%);
}
.countdown-row::-webkit-scrollbar { height: 4px; }
.countdown-row::-webkit-scrollbar-track { background: transparent; }
.countdown-row::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}
.countdown-row::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* dot separators between items: not needed with chip layout */
.countdown-row > .countdown-sep { display: none; }

.countdown-item {
  display: inline-flex; align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 7px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);                  /* 11px — compact */
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;                            /* never squish */
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.countdown-item:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
}
.countdown-item b {
  color: var(--amber);
  font-weight: 700;
  margin: 0 1px;
}
.countdown-item img {
  width: 14px !important;
  height: 10px !important;
}

/* Picker pseudo-chip ("⚙ 国家"): dashed accent, overrides inline color */
#countryPickerBtn {
  background: transparent !important;
  border-style: dashed;
  border-color: var(--accent);
  color: var(--accent) !important;
  font-weight: 600;
}
#countryPickerBtn:hover {
  background: var(--accent-bg) !important;
}

/* Holiday name (clickable): override inline underline color to respect theme */
.holiday-name {
  text-decoration-color: var(--border-strong) !important;
  text-underline-offset: 3px !important;
  font-weight: 500;
  color: var(--text-primary);
}

/* Online/local source: tiny colored dot (text hidden, kept for screen readers via title) */
.holiday-src {
  display: inline-block;
  width: 6px; height: 6px;
  padding: 0; margin-left: 3px;
  border-radius: 50%;
  vertical-align: middle;
  font-size: 0;                /* hide "在线"/"本地" text */
  line-height: 0;
  flex-shrink: 0;
}
.holiday-src-online { background: var(--emerald); }
.holiday-src-local  { background: var(--text-muted); opacity: 0.6; }

/* ===== Finance ===== */
.finance-bar {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  overflow: hidden;
}
.finance-grid {
  display: flex; flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--sp-1) var(--sp-2);
}
/* Items grow to fill the row (no side gaps), never shrink below 260px content
   width (so columns never overlap). Auto-wrap: 3-col wide, 2-col squeezed,
   1-col phone. Internal 5-col grid is fixed px → values align across items. */
.finance-item {
  flex: 1 0 260px;
  display: grid;
  grid-template-columns: 62px 24px 56px 50px 36px;
  align-items: baseline;
  column-gap: 5px;
  padding: var(--sp-1) 6px;
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease-out);
}
.finance-item:hover { background: var(--bg-hover); }
.fin-label {
  font-size: var(--fs-xs); color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.02em;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.fin-value, .fin-change { min-width: 0; }
.fin-value {
  font-size: var(--fs-base); font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.fin-change {
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 500;
  white-space: nowrap;
}
.fin-up   { color: var(--emerald); }
.fin-down { color: var(--rose); }
.fin-flat { color: var(--text-muted); }

.finance-item-dual { row-gap: 2px; }
.finance-item-dual .fin-label {
  grid-row: 1 / 3; align-self: center;
}
.fin-pair-tag {
  grid-column: 2;
  font-size: var(--fs-2xs);
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}
.fin-mkt {
  grid-column: 5;
  font-size: 9px;
  padding: 2px 6px; border-radius: var(--r-full);
  font-weight: 600;
  justify-self: start;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.fin-mkt-open    { color: var(--emerald); background: var(--emerald-bg); }
.fin-mkt-delayed { color: var(--amber);   background: var(--amber-bg); }
.fin-mkt-closed  { color: var(--rose);    background: var(--rose-bg); }
.finance-note {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
  text-align: right;
  opacity: 0.7;
}

/* ===== Search ===== */
.search-section {
  width: 100%; display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-3);
}
.engine-tabs {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-1);
}
.engine-btn {
  position: relative;
  padding: 6px var(--sp-3);
  border: none; border-radius: var(--r-full);
  background: transparent; color: var(--text-tertiary);
  cursor: pointer; font-size: var(--fs-sm);
  font-family: inherit; font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.engine-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.engine-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.search-box {
  display: flex; width: 100%; position: relative;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-2xl);
  transition: box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              border-radius var(--dur-fast);
}
.search-box:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.search-box.sug-open {
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
}
.search-input {
  flex: 1; padding: 13px var(--sp-4);
  background: transparent; border: none; outline: none;
  font-size: var(--fs-lg); color: var(--text-primary);
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-muted); }
.search-btn {
  padding: 0 var(--sp-5);
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center;
  transition: color var(--dur-fast) var(--ease-out);
}
.search-btn:hover { color: var(--accent); }
.search-btn svg { width: 20px; height: 20px; fill: currentColor; }
#engineIcon { border-radius: var(--r-sm); }

/* Search suggestions */
.search-suggestions {
  display: none; position: absolute;
  top: calc(100% + 1px); left: -1px; right: -1px;
  z-index: var(--z-suggest);
  background: var(--bg-elev-1);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-box.sug-open .search-suggestions { display: block; }
.sug-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-5);
  cursor: pointer;
  font-size: var(--fs-md); color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.sug-item:hover, .sug-item.sug-active { background: var(--bg-hover); }
.sug-icon { width: 15px; height: 15px; fill: var(--text-muted); flex-shrink: 0; }

/* ===== Search history chips ===== */
.search-history {
  display: flex; flex-wrap: wrap;
  gap: var(--sp-1); width: 100%; min-height: 0;
}
.hist-chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 4px var(--sp-2) 4px var(--sp-3);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-size: var(--fs-sm); color: var(--text-tertiary);
  cursor: pointer; max-width: 140px; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  position: relative;
}
.hist-chip:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  max-width: none; z-index: 10;
}
.hist-chip-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 110px;
}
.hist-chip:hover .hist-chip-text { max-width: none; overflow: visible; }
.hist-del {
  flex-shrink: 0; width: 15px; height: 15px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: var(--fs-xs); line-height: 1;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.hist-del:hover { background: var(--rose); color: #fff; }

/* ===== Nav groups ===== */
.nav-groups {
  width: 100%; display: flex; flex-direction: column;
  gap: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--sp-4);
}
.nav-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.nav-group-header {
  display: flex; align-items: center; justify-content: space-between;
}
.nav-group-title {
  font-size: var(--fs-xs); font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.10em; text-transform: uppercase;
}
.nav-group-edit-btn {
  font-size: var(--fs-xs); color: var(--accent);
  cursor: pointer; padding: 3px var(--sp-2);
  border-radius: var(--r-sm); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.nav-group-edit-btn:hover { background: var(--accent-bg); }
.nav-group-sites {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}
.site-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px var(--sp-3);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-primary);
  text-decoration: none;
  user-select: none; white-space: nowrap; position: relative;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.site-chip:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.site-chip.editing {
  border-style: dashed;
  border-color: var(--amber);
  cursor: default;
}
.site-chip.editing:hover {
  background: var(--amber-bg);
  border-color: var(--amber);
  color: var(--amber);
  transform: none;
}
.site-chip img {
  width: 14px; height: 14px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.site-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  background: var(--border-strong);
  border-radius: var(--r-full);
  font-size: var(--fs-2xs); color: var(--text-tertiary);
  margin-left: 2px; cursor: pointer; line-height: 1;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.site-remove:hover { background: var(--rose); color: #fff; }
.site-add-chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 6px var(--sp-3);
  border: 1px dashed var(--accent);
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: var(--fs-sm); color: var(--accent);
  background: transparent;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.site-add-chip:hover { background: var(--accent-bg); }
.nav-group-divider { border-top: 1px solid var(--border-subtle); }

/* ===== Hot lists ===== */
.hot-panel {
  overflow: hidden;
}
.hot-panel:hover { box-shadow: var(--shadow-md); }
.hot-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--border-subtle);
}
.hot-panel-title {
  font-size: var(--fs-sm); font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.hot-panel-source {
  font-size: var(--fs-2xs); color: var(--text-muted);
  font-weight: 500;
}
.hot-panel-refresh {
  font-size: var(--fs-xs); color: var(--accent);
  cursor: pointer; padding: 3px 6px;
  border-radius: var(--r-sm); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out);
  user-select: none;
}
.hot-panel-refresh:hover { background: var(--accent-bg); }
.hot-list { list-style: none; padding: var(--sp-1) 0; }
.hot-item {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 6px var(--sp-3);
  cursor: pointer; text-decoration: none; color: inherit;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.hot-item:hover { background: var(--bg-hover); }
.hot-rank {
  flex-shrink: 0; width: 18px;
  font-size: var(--fs-xs); font-weight: 700;
  color: var(--text-muted);
  margin-top: 1px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.hot-rank.top1 { color: var(--rose); }
.hot-rank.top2 { color: var(--amber); }
.hot-rank.top3 { color: #f59e0b; }
.hot-title {
  font-size: var(--fs-sm); color: var(--text-primary);
  line-height: 1.5; word-break: break-all;
}
.hot-panel-loading {
  padding: var(--sp-4) var(--sp-3);
  text-align: center; font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* Skeleton shimmer for loading states */
.hot-panel-loading::before {
  content: '';
  display: block;
  height: 12px;
  margin: 0 auto var(--sp-2);
  width: 60%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg,
    var(--skel-base) 0%,
    var(--skel-shine) 50%,
    var(--skel-base) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  align-items: center; justify-content: center;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  width: 360px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  font-size: var(--fs-lg); font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
  letter-spacing: -0.01em;
}
.modal-field { margin-bottom: var(--sp-3); }
.modal-label {
  font-size: var(--fs-xs); color: var(--text-tertiary);
  margin-bottom: 6px; font-weight: 500;
}
.modal-input {
  width: 100%; padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-md); color: var(--text-primary);
  outline: none; font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.modal-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.modal-input:disabled {
  background: var(--bg-hover); color: var(--text-muted);
}
.modal-hint {
  font-size: var(--fs-xs); color: var(--text-muted);
  margin-top: var(--sp-1);
}
.city-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.city-row  { display: flex; align-items: center; gap: var(--sp-2); }
.city-tag  {
  font-size: var(--fs-xs); color: var(--text-tertiary);
  width: 36px; flex-shrink: 0; font-weight: 600;
}
.city-row input {
  flex: 1; padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: var(--fs-base); color: var(--text-primary);
  outline: none; font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.city-row input:focus { border-color: var(--accent); }
.city-row input:disabled { background: var(--bg-hover); color: var(--text-muted); }

.modal-actions {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  margin-top: var(--sp-1);
}
.btn {
  padding: 8px var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600;
  cursor: pointer; border: none;
  font-family: inherit;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent); color: var(--text-inverted);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover); color: var(--text-primary);
}

/* ===== Theme toggle button (fixed top-right) ===== */
.theme-toggle {
  position: fixed; top: var(--sp-3); right: var(--sp-3);
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  cursor: pointer; z-index: var(--z-sticky);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== Responsive ===== */

/* Tablet: hide sidebars */
@media (max-width: 1260px) {
  .sidebar { display: none; }
  .page-layout { justify-content: center; }
}

/* Tablet narrow — finance auto-wraps via fixed 256px items, no override needed */
@media (max-width: 768px) {
  body { padding: var(--sp-2) 0 var(--sp-6); }
  .page-layout { padding: 0 var(--sp-3); gap: var(--sp-3); }
  .main-wrapper { gap: var(--sp-3); }
  .city-clocks { grid-template-columns: repeat(3, 1fr); }
  .module-a { padding: var(--sp-4) var(--sp-3); gap: var(--sp-2); }
  .date-row { gap: var(--sp-2); }
  .solar-date { font-size: var(--fs-xl); }
  .lunar-date { font-size: var(--fs-md); }
  .date-divider { display: none; }
  .search-input { font-size: var(--fs-md); padding: 11px var(--sp-3); }
  .modal-box { width: calc(100vw - var(--sp-6)); max-width: 380px; }
  .theme-toggle { top: var(--sp-2); right: var(--sp-2); }
}

/* Phone: stack everything */
@media (max-width: 480px) {
  .city-clocks { grid-template-columns: repeat(2, 1fr); }
  .finance-item { flex: 1 1 100%; }
  .engine-tabs { gap: 2px; }
  .engine-btn { padding: 5px var(--sp-2); font-size: var(--fs-xs); }
  .info-row { font-size: var(--fs-sm); }
  .info-sep { margin: 0 6px; }
}

/* 4K / ultra-wide */
@media (min-width: 2560px) {
  .page-layout  { max-width: 1800px; padding: 0 var(--sp-6); gap: var(--sp-6); }
  .sidebar      { flex: 0 0 360px; }
  .main-wrapper { max-width: 1040px; gap: var(--sp-4); }
  .city-clocks  { gap: var(--sp-3); }
  .clock-city   { font-size: var(--fs-sm); }
  .clock-time   { font-size: var(--fs-xl); }
  .clock-date   { font-size: var(--fs-xs); }
  .solar-date   { font-size: var(--fs-2xl); }
  .lunar-date   { font-size: 19px; }
  .info-row     { font-size: 15px; }
  .ip-entry, .ip-entry-label, .ip-entry-addr { font-size: 13px; }
  .countdown-row { font-size: 13px; }
  .finance-item { flex: 1 0 326px; grid-template-columns: 84px 28px 74px 64px 44px; }
  .fin-label    { font-size: var(--fs-sm); }
  .fin-value    { font-size: 15px; }
  .fin-change   { font-size: var(--fs-sm); }
  .finance-note { font-size: var(--fs-xs); }
  .engine-btn   { font-size: var(--fs-md); }
  .search-input { padding: 16px var(--sp-5); font-size: var(--fs-lg); }
  .search-btn svg { width: 22px; height: 22px; }
  #engineIcon   { width: 20px !important; height: 20px !important; }
  .sug-item     { font-size: 15px; }
  .hist-chip    { font-size: var(--fs-base); }
  .nav-group-title { font-size: var(--fs-base); }
  .site-chip       { font-size: var(--fs-md); padding: 7px var(--sp-3); }
  .site-chip img   { width: 16px; height: 16px; }
  .hot-panel-title  { font-size: var(--fs-md); }
  .hot-panel-source { font-size: var(--fs-xs); }
  .hot-rank         { font-size: var(--fs-base); width: 20px; }
  .hot-title        { font-size: var(--fs-base); }
}

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

/* ===== SEO-only (visually hidden, screen-reader/crawler accessible) ===== */
.seo-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
