:root {
  --radius: 16px;
  --radius-sm: 8px;
  --gap: 24px;
  --pad: 20px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --border: 1px solid rgba(255, 255, 255, 0.2);
  --text: #ffffff;
  --text-secondary: #e5e5e5;
  --text-muted: #b3b3b3;
  --ease: all 0.25s ease-in-out;
  --accent: #3b82f6;
  --wallpaper-blur: 12px;
  --wallpaper-opacity: 0.85;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background: #0f172a;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--wallpaper-opacity);
  filter: blur(var(--wallpaper-blur));
  transform: scale(1.05);
  transition: opacity 0.4s ease, filter 0.4s ease;
  overflow: hidden;
}

.wallpaper.is-stars {
  filter: none;
  transform: none;
  background: #030712;
}

.star-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.star-canvas[hidden] {
  display: none !important;
}

.wallpaper-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(15, 23, 42, 0.35);
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

/* 三栏布局 */
.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 360px;
  min-height: 100vh;
  width: 100%;
}

.app-shell.left-collapsed {
  grid-template-columns: 0 minmax(0, 1fr) 360px;
}

.app-shell.right-collapsed {
  grid-template-columns: 240px minmax(0, 1fr) 0;
}

.app-shell.left-collapsed.right-collapsed {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}

.side-left,
.side-right {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.08);
  /* 高于 .side-mask(4)，保证侧栏可点 */
  z-index: 5;
  pointer-events: auto;
}

.side-left {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.side-right {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.app-shell.left-collapsed .side-left,
.app-shell.right-collapsed .side-right {
  width: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.side-head h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.side-collapse {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.side-tools {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 8px 20px;
  -webkit-overflow-scrolling: touch;
}

.side-search-wrap {
  padding: 8px 10px 4px;
  flex-shrink: 0;
}

.side-search {
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  outline: none;
}

.side-search:focus {
  border-color: rgba(59, 130, 246, 0.65);
}

.side-search::placeholder {
  color: var(--text-muted);
}

.side-tool-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.side-tool-cat {
  margin-bottom: 12px;
}

.side-tool-cat-title {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px 6px;
  text-transform: none;
}

.side-tool-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: var(--ease);
}

.side-tool-item:hover,
.side-tool-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.side-tool-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.side-tool-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.ai-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-open {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.ai-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  min-height: 0;
}

.ai-frame[hidden] {
  display: none !important;
}

.ai-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-hero {
  text-align: center;
  padding: 8px 4px 4px;
}

.ai-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #3b82f6, #06b6d4);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.ai-lead {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.ai-desc {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
}

.ai-compose {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-compose textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.5;
  outline: none;
}

.ai-compose textarea:focus {
  border-color: rgba(59, 130, 246, 0.7);
}

.ai-send {
  width: 100%;
  justify-content: center;
}

.ai-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-suggest button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.ai-suggest button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.ai-direct {
  margin-top: 8px;
  text-align: center;
  color: #93c5fd;
  font-size: 13px;
  text-decoration: none;
  flex-shrink: 0;
}

.ai-direct:hover {
  text-decoration: underline;
}

.hot-news {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}

.hot-news-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.hot-news-head h3 {
  font-size: 13px;
  font-weight: 700;
}

.hot-refresh {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}

.hot-refresh:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.14);
}

.hot-news-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 120px;
  max-height: none;
  flex: 1;
}

.hot-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 12px;
}

.hot-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.hot-no {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.hot-item:nth-child(1) .hot-no { background: #ef4444; }
.hot-item:nth-child(2) .hot-no { background: #f97316; }
.hot-item:nth-child(3) .hot-no { background: #eab308; color: #111; }

.hot-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hot-score {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hot-empty {
  padding: 16px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.ai-fallback {
  flex: 1;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
}

.ai-fallback[hidden] {
  display: none !important;
}

.side-mask[hidden] {
  display: none !important;
}

.side-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  /* 低于侧栏(5/180)、高于主栏；与侧栏同属 app-shell 层叠上下文 */
  z-index: 4;
  pointer-events: auto;
}

.tool-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tool-drawer.open {
  display: flex;
}

.tool-drawer-inner {
  width: min(720px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: rgba(30, 41, 59, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px 18px 20px;
  box-shadow: var(--shadow-hover);
}

.mobile-only {
  display: none !important;
}

.desktop-hide {
  display: none !important;
}

.mobile-hot-card {
  display: none;
}

.hot-source {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.mobile-dock {
  display: none;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* 排行榜 */
.rankings-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.rank-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}

.rank-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.rank-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.rank-source {
  font-size: 11px;
  color: var(--text-muted);
}

.rank-more {
  font-size: 12px;
  color: #7dd3fc;
  text-decoration: none;
}

.rank-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.rank-tab {
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.rank-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 6px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--ease);
}

.rank-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.rank-no {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  flex-shrink: 0;
}

.rank-item:nth-child(1) .rank-no { background: #ef4444; color: #fff; }
.rank-item:nth-child(2) .rank-no { background: #f97316; color: #fff; }
.rank-item:nth-child(3) .rank-no { background: #eab308; color: #111; }

.rank-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-hot {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ========== Header / Search ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 30px 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(15, 23, 42, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.header-meta {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 16px;
  min-width: 0;
  margin: 0 8px;
}

.meta-datetime {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.meta-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.5px;
}

.meta-weather {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 12px;
  max-width: min(280px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-icon {
  flex-shrink: 0;
}

.logo {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  text-decoration: none;
  user-select: none;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
}

.logo-mark.has-img {
  background: #fff;
  padding: 0;
}

.logo-mark.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn,
.icon-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--glass);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--ease);
  opacity: 0.9;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.action-btn .action-ico {
  display: grid;
  place-items: center;
  line-height: 1;
}

.action-btn .action-txt {
  letter-spacing: 0.5px;
}

.action-btn:hover,
.icon-btn:hover {
  opacity: 1;
  background: var(--glass-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

.search-area {
  width: min(720px, 100%);
  margin: 0 auto;
}

.engine-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.engine-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: var(--ease);
}

.engine-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.engine-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.engine-tab-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  flex-shrink: 0;
}

.engine-tab.active .engine-tab-icon {
  background: rgba(255, 255, 255, 0.95);
  color: var(--accent);
}

.search-box {
  display: flex;
  align-items: center;
  height: 52px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(59, 130, 246, 0.55);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: var(--ease);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 6px 28px rgba(59, 130, 246, 0.25);
}

.search-engine-icon {
  flex-shrink: 0;
  margin-left: 14px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
}

.search-input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: #1e293b;
  font-size: 15px;
  padding: 0 12px;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-go {
  flex-shrink: 0;
  width: 52px;
  height: 100%;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--ease);
}

.search-go:hover {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

/* 常用网址 */
.frequent {
  margin-top: 14px;
}

.frequent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.frequent-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.frequent-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--ease);
}

.frequent-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.frequent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.frequent-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
}

.frequent-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 6px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  transition: var(--ease);
  max-width: 160px;
}

.frequent-item:hover {
  background: var(--glass-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.frequent-item .fi-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.frequent-item .fi-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== Main / Bento ========== */
.main {
  flex: 1;
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: var(--gap) 0 40px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.paired-zones {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.paired-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.paired-col .bento-card,
.paired-col .rank-card {
  width: 100%;
}

.paired-col .rank-card {
  flex: 1;
}

.bento-card {
  min-width: 0;
  min-height: 0;
  height: auto;
  padding: 16px 14px 14px;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--border);
  box-shadow: var(--shadow);
  transition: var(--ease);
  user-select: none;
  overflow: visible;
}

.bento-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.bento-card.dragging {
  opacity: 0.8;
  transform: scale(1.02);
  z-index: 50;
}

.bento-card.drag-over {
  outline: 2px dashed rgba(255, 255, 255, 0.4);
  outline-offset: -4px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  cursor: grab;
}

.card-head:active {
  cursor: grabbing;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: var(--ease);
}

.bento-card:hover .edit-btn,
.bento-card.editing .edit-btn {
  opacity: 1;
}

.edit-btn:hover,
.bento-card.editing .edit-btn {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px 4px;
  width: 100%;
}

.site-item {
  width: 100%;
  min-width: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--text-secondary);
  position: relative;
  padding: 14px 2px 4px;
  border-radius: var(--radius-sm);
  transition: var(--ease);
  cursor: pointer;
}

.site-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.site-item.dragging {
  opacity: 0.75;
  transform: scale(1.03);
}

.site-badge {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  transform: none;
  z-index: 6;
  font-size: 10px;
  line-height: 1.2;
  padding: 2px 5px;
  border-radius: 4px;
  background: #ef4444;
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  letter-spacing: 0;
}

.site-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
  flex-shrink: 0;
}

.site-icon img {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.site-icon .fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  z-index: 0;
  line-height: 1;
}

.site-icon.fallback-on .fallback {
  display: grid;
}

.site-icon.fallback-on img {
  display: none;
}

.site-name {
  font-size: 11px;
  text-align: center;
  line-height: 1.25;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 1px;
}

.site-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  place-items: center;
}

.bento-card.editing .site-remove {
  display: grid;
}

.site-add {
  width: 100%;
  min-width: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--ease);
}

.bento-card.editing .site-add {
  display: flex;
}

.site-add:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
}

.site-add-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

/* ========== Tools catalog ========== */
.tools-card {
  width: 100%;
  padding: var(--pad);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--border);
  box-shadow: var(--shadow);
}

.tools-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.tools-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.tools-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.tools-catalog {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px 20px;
}

.tool-cat-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-cat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: var(--ease);
}

.tool-chip:hover,
.tool-chip.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.tool-chip-icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
  overflow: hidden;
}

.tool-chip-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.tool-panel {
  display: none;
  margin-top: 16px;
  max-height: 480px;
  overflow: auto;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tool-panel.open {
  display: block;
}

.tool-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tool-panel-head h4 {
  font-size: 15px;
  color: var(--text);
}

.tool-panel-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.tool-panel-body {
  color: var(--text-secondary);
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.tool-input,
.tool-select,
.tool-textarea {
  border-radius: var(--radius-sm);
  border: var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.tool-input,
.tool-select {
  height: 40px;
  min-width: 140px;
  flex: 1;
}

.tool-textarea {
  width: 100%;
  padding: 10px 12px;
  resize: vertical;
  margin-bottom: 10px;
  font-family: inherit;
  line-height: 1.5;
}

.tool-select option {
  background: #1e293b;
  color: #fff;
}

.tool-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(56, 189, 248, 0.85);
  color: #0f172a;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ease);
}

.tool-btn:hover {
  background: #38bdf8;
  transform: translateY(-1px);
}

.tool-btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.tool-result {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  word-break: break-all;
}

.tool-result img,
.tool-result canvas {
  max-width: 200px;
  border-radius: var(--radius-sm);
  background: #fff;
  margin-top: 8px;
}

.tool-panel-body label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tool-panel-body input[type="range"] {
  vertical-align: middle;
}

.tool-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.http-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.diff-line {
  font-size: 12px;
  margin-top: 4px;
  color: #fca5a5;
}

.symbol-group {
  margin-bottom: 14px;
}

.symbol-group h5 {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.symbol-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symbol-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: var(--ease);
}

.symbol-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-mask.open {
  display: flex;
}

.modal {
  width: min(480px, 100%);
  max-height: 85vh;
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius);
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(20px);
  border: var(--border);
  box-shadow: var(--shadow-hover);
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

.modal input[type="text"],
.modal input[type="url"],
.modal input[type="range"] {
  width: 100%;
}

.modal input[type="text"],
.modal input[type="url"] {
  height: 40px;
  border-radius: var(--radius-sm);
  border: var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.wallpaper-swatch {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.wallpaper-swatch.active {
  border-color: #38bdf8;
}

.wallpaper-swatch span {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  padding: 2px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row span {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-list button {
  height: 44px;
  border-radius: var(--radius-sm);
  border: var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 0 14px;
  transition: var(--ease);
}

.settings-list button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 400;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: rgba(30, 41, 59, 0.95);
  border: var(--border);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== Responsive ========== */
@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr) 300px;
  }
}

/* 平板 / 窄屏：侧栏改为抽屉，主栏全宽 */
@media (max-width: 900px) {
  :root {
    --gap: 14px;
    --pad: 14px;
    --radius: 14px;
  }

  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-left,
  .side-right {
    position: fixed;
    top: 0;
    /* 留出底栏，避免抽屉盖住快捷导航 */
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    width: min(320px, 88vw);
    height: auto;
    max-height: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
    transition: transform 0.28s ease, opacity 0.2s ease;
    /* 与 mask 同属 app-shell，必须高于 mask(4) */
    z-index: 8 !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }

  .side-left {
    left: 0;
    transform: translateX(-105%);
  }

  .side-right {
    right: 0;
    width: min(400px, 92vw);
    transform: translateX(105%);
  }

  .app-shell.mobile-left-open .side-left,
  .app-shell.mobile-right-open .side-right {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
    width: min(320px, 88vw) !important;
  }

  .app-shell.mobile-right-open .side-right {
    width: min(400px, 92vw) !important;
  }

  /* 移动端忽略桌面折叠态对抽屉的影响 */
  .app-shell.left-collapsed .side-left,
  .app-shell.right-collapsed .side-right {
    width: min(320px, 88vw) !important;
    border-color: rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    pointer-events: none !important;
  }

  .app-shell.mobile-left-open.left-collapsed .side-left,
  .app-shell.mobile-right-open.right-collapsed .side-right,
  .app-shell.mobile-left-open .side-left,
  .app-shell.mobile-right-open .side-right {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .side-mask {
    z-index: 6 !important;
    /* 底栏上方结束，避免挡住 dock */
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    top: 0;
    left: 0;
    right: 0;
    inset: auto;
  }

  .tool-drawer {
    z-index: 220 !important;
  }

  .mobile-dock {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200 !important;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto !important;
  }

  .desktop-hide,
  .mobile-only {
    display: inline-flex !important;
  }

  .header {
    padding: 10px 14px 14px;
  }

  .header-top {
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 12px;
  }

  .logo-text {
    font-size: 16px;
  }

  .header-meta {
    order: 3;
    flex: 1 1 100%;
    justify-content: space-between;
    margin: 0;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .meta-datetime {
    font-size: 12px;
    gap: 8px;
  }

  .meta-time {
    font-size: 14px;
  }

  .meta-weather {
    max-width: min(58vw, 220px);
    padding: 4px 8px;
    font-size: 11px;
  }

  .header-actions {
    gap: 6px;
    margin-left: auto;
  }

  .action-btn {
    min-height: 36px;
    padding: 0 10px;
  }

  .action-txt {
    font-size: 12px;
  }

  .search-area {
    gap: 10px;
  }

  .engine-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .engine-tabs::-webkit-scrollbar {
    display: none;
  }

  .engine-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .search-box {
    height: 50px;
    border-radius: 14px;
  }

  .frequent-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .frequent-list::-webkit-scrollbar {
    display: none;
  }

  .frequent-item {
    flex: 0 0 auto;
    min-width: 72px;
  }

  .main {
    width: calc(100% - 24px);
    padding-bottom: 12px;
  }

  /* 移动端主栏展示热点 */
  .mobile-hot-card {
    display: block;
    margin: 0 0 16px;
    padding: 12px 12px 8px;
    border-radius: var(--radius);
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: var(--border);
    box-shadow: var(--shadow);
  }

  .mobile-hot-card .hot-news-list {
    max-height: none;
  }

  .mobile-hot-card .hot-item {
    padding: 10px 4px;
  }

  /* 右侧栏里的热点在移动抽屉中可保留，主栏已有一份 */
  .side-right .hot-news {
    display: none;
  }

  .bento-grid,
  .paired-zones {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .site-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 6px;
  }

  .site-icon,
  .site-add-icon {
    width: 44px;
    height: 44px;
  }

  .site-name {
    font-size: 11px;
    line-height: 1.25;
  }

  .bento-card {
    padding: 12px;
  }

  .edit-btn {
    opacity: 1;
  }

  .rank-card {
    padding: 12px;
  }

  .footer {
    padding: 16px 12px 24px;
    font-size: 12px;
  }

  .dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    border-radius: 10px;
    min-height: 44px;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .dock-item:active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
  }

  .dock-ico {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #7dd3fc;
  }

  .tool-drawer {
    padding: 12px;
    align-items: flex-end;
  }

  .tool-drawer-inner {
    width: 100%;
    max-height: 82dvh;
    border-radius: 16px 16px 12px 12px;
  }

  .modal {
    width: min(100%, 420px);
    max-height: 88dvh;
    overflow: auto;
  }

  .wallpaper-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tool-compare {
    grid-template-columns: 1fr;
  }

  .ai-hero {
    padding-top: 4px;
  }

  .ai-compose textarea {
    min-height: 72px;
  }
}

@media (max-width: 480px) {
  .logo-text {
    max-width: 5.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions .action-btn#wallpaperBtn .action-txt,
  .header-actions .action-btn#settingsBtn .action-txt {
    display: none;
  }

  .site-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .site-icon,
  .site-add-icon {
    width: 40px;
    height: 40px;
  }

  .site-name {
    font-size: 10px;
  }

  .search-engine-icon {
    display: none;
  }

  .meta-datetime #metaDate {
    display: none;
  }
}
