:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --fg: #1f2328;
  --fg-soft: #424a53;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d0d7de;
  --accent: #1f6feb;
  --accent-soft: #e8f1ff;
  --warn: #c2410c;
  --ok: #1a7f37;
  /* 涨跌配色：遵循 A 股习惯 —— 涨红、跌绿（与欧美相反）。
     注意：--up / --down / --flat 与下面的品牌色都归主题包管，运行时由 app.js 的
     applyThemePack() 注入覆盖，这里只是首帧兜底（取「投资」主题的值）。 */
  --up: #d92b2b;
  --down: #12833f;
  --flat: #6b7280;
  /* 品牌渐变：logo 与强调装饰 */
  --brand-from: #7f1d1d;
  --brand-to: #dc2626;
  --shadow: 0 1px 2px rgba(27, 31, 36, .04), 0 8px 24px rgba(27, 31, 36, .06);
  --shadow-lg: 0 12px 40px rgba(27, 31, 36, .16);
  --radius: 14px;
  --radius-sm: 9px;
  /* 顶栏实际高度：首帧兜底值，运行时由 ResizeObserver 写入真实像素值 */
  --topbar-h: 64px;
  /* 标签栏实际高度：同上，首帧兜底值 */
  --tabbar-h: 42px;
  /* 触控目标最小边长（窄屏生效） */
  --tap: 44px;
}

/* 安全区：无安全区的设备取值为 0，配合 max() / calc() 不引入多余留白 */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html[data-theme='dark'] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1b2129;
  --fg: #e6edf3;
  --fg-soft: #c9d1d9;
  --muted: #8b949e;
  --line: #2a313a;
  --line-strong: #3d444d;
  --accent: #4f9bff;
  --accent-soft: #12243c;
  --warn: #ff9e64;
  --ok: #3fb950;
  /* 深色底下的红绿要提亮，否则红字几乎不可读 */
  --up: #ff6b6b;
  --down: #3fb950;
  --flat: #8b949e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

/* 作者样式里的 display 会覆盖 UA 的 [hidden]，这里显式兜底 */
.drawer[hidden], .scrim[hidden], .edit-bar[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(13px + var(--safe-top)) max(26px, var(--safe-right)) 13px max(26px, var(--safe-left));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

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

.logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.5px;
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.2px;
  /* 站点标题可被自定义得很长，窄屏靠省略号收敛，避免把顶栏顶换行 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.brand-text { min-width: 0; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 内容主题切换器（投资 / 程序员 …）：分段按钮。
   与顶栏右侧的明暗开关（#btnTheme）是两件事 —— 前者换内容与品牌，后者只换明暗。 */
.pack-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  flex: none;
}
.pack-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.pack-btn:hover { color: var(--fg); }
.pack-btn.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(27, 31, 36, .1); }
.pk-icon { font-size: 13px; }

/* 语言切换（中 / EN）：复用分段按钮，只是更紧凑、字重更高，避免和内容主题切换器抢视觉 */
.lang-switch .pack-btn { padding: 5px 9px; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.lang-switch .pack-btn.active { color: var(--accent); }

/* 主题选择面板：窄屏点击切换器时从抽屉弹出 */
.pack-list { display: flex; flex-direction: column; gap: 8px; }
.pack-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.pack-item:hover { border-color: var(--line-strong); }
.pack-item.active { border-color: var(--accent); background: var(--accent-soft); }
.pi-icon { font-size: 20px; line-height: 1; flex: none; }
.pi-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pi-text b { font-size: 14px; }
.pi-text small { font-size: 12px; color: var(--muted); }
.pi-badge { margin-left: auto; flex: none; font-size: 11.5px; font-weight: 700; color: var(--accent); }

.today-label {
  font-size: 12.5px;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: 8px;
  padding: 6.5px 13px;
  font-size: 13px;
  font-weight: 500;
  transition: .16s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger:hover { border-color: #d1242f; color: #d1242f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 「⋯」入口与文案切换默认都走桌面形态，窄屏媒体查询里翻转 */
.more-btn { display: none; font-size: 17px; line-height: 1; padding: 4px 12px; }
.lbl-narrow { display: none; }

/* ---------- 标签栏 ----------
   吸在顶栏正下方，自身横向滚动；编辑栏再吸在它下方（top 由两个实测变量相加得出）。 */
.tabbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 38;
  display: flex;
  flex-wrap: nowrap;
  /* 标签总宽超出时只在这里横向滚动，不换行撑高、不让页面出现横向滚动条 */
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  gap: 4px;
  padding: 7px max(26px, var(--safe-right)) 0 max(26px, var(--safe-left));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabbar::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px 9px;
  border-radius: 9px 9px 0 0;
  white-space: nowrap;
  /* 这里是滚动容器而非手势发起点：横向滑动交给浏览器，不加 touch-action: none */
  touch-action: pan-x pan-y;
}
.tab .tab-label {
  display: block;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab:hover { color: var(--fg-soft); background: var(--surface-2); }
/* 选中态 = 指示条 + 加粗 + 底色，不只靠颜色传达 */
.tab.active { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.tab.active::after {
  content: '';
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}
/* 编辑模式禁用切换：要能看出来「点了没反应」是有意为之 */
.tab[aria-disabled='true'] { opacity: .45; cursor: not-allowed; }
.tab[aria-disabled='true']:hover { background: transparent; color: var(--muted); }

/* ---------- 编辑栏 ---------- */
.edit-bar {
  position: sticky;
  /* 由顶栏 + 标签栏的实际高度决定，不再用断点常量 */
  top: calc(var(--topbar-h) + var(--tabbar-h));
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px max(26px, var(--safe-right)) 9px max(26px, var(--safe-left));
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--fg-soft);
  flex-wrap: wrap;
}
.edit-bar .hint { margin-right: auto; }

/* ---------- 版面 ---------- */
.board {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px max(26px, var(--safe-right)) calc(60px + var(--safe-bottom)) max(26px, var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section { margin-bottom: 12px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 11px;
  min-height: 30px;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.section-head .line { flex: 1; height: 1px; background: var(--line); min-width: 12px; }
.section-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.section-tools .btn { padding: 3px 8px; font-size: 11.5px; }

.section-title-input {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  border: 1px dashed var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: 6px;
  padding: 3px 8px;
  width: 190px;
  max-width: 100%;
  font-family: inherit;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 14px;
  min-height: 60px;
}
.grid.drag-over { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: var(--radius); }

/* ---------- 卡片 ---------- */
.widget {
  grid-column: span var(--span, 1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .18s, border-color .18s, transform .18s;
  min-width: 0;
}
.widget:hover { box-shadow: var(--shadow-lg); }
.widget.error-state { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }

/* 编辑模式：拖拽从卡片头部（含手柄）发起，正文保留滚动与链接点击 */
.widget.edit-mode { -webkit-touch-callout: none; touch-action: pan-y; }
.widget.edit-mode .widget-head,
.widget.edit-mode .drag-handle { touch-action: none; }

/* 拾起中：与普通卡片明确区分 */
.widget.dragging {
  opacity: .96;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: var(--shadow-lg);
  transform: scale(1.012);
  position: relative;
  z-index: 5;
  touch-action: none;
}
.widget.dragging .widget-head { cursor: grabbing; }
body.dragging-active { user-select: none; -webkit-user-select: none; }

.widget-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.widget.edit-mode .widget-head { cursor: grab; }
.widget-head .w-icon { font-size: 15px; line-height: 1; flex: none; }
.widget-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.widget-head .w-uptime { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.widget-tools { display: flex; align-items: center; gap: 3px; flex: none; }
.widget-tools button {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: 13px;
  padding: 0;
}
.widget-tools button:hover { background: var(--surface-2); color: var(--accent); }
.drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -2px;
  user-select: none;
  -webkit-user-select: none;
  padding: 0 2px;
  flex: none;
}
.drag-handle:active { cursor: grabbing; }

.widget-body { padding: 4px 0 6px; flex: 1; }

/* ---------- 条目 ---------- */
.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item:hover { background: var(--surface-2); }

.item-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--fg);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 22px;
}
.item-title:hover { color: var(--accent); text-decoration: none; }
.item-title .rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  min-width: 18px;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.item-title .t {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  min-width: 0;
  flex: 1;
}
/* 行情类卡片右侧的大号数值：定宽数字 + 按涨跌着色 */
.item-value {
  margin-left: auto;
  padding-left: 10px;
  flex: none;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dir-up { color: var(--up); }
.dir-down { color: var(--down); }
.dir-flat { color: var(--flat); }
.item-meta .dir-up,
.item-meta .dir-down { font-weight: 700; }
.item-ico {
  width: 17px; height: 17px;
  border-radius: 4px;
  object-fit: cover;
  flex: none;
  align-self: center;
  background: var(--surface-2);
}
.item-desc {
  margin: 3px 0 0 25px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.item-meta {
  margin: 4px 0 0 25px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  word-break: break-word;
}
.item-meta .sep { color: var(--line-strong); }
.item-meta .hot { color: var(--warn); font-weight: 700; }

/* ---------- 状态 ---------- */
.skeleton-row { padding: 9px 14px; }
.skeleton-bar {
  height: 11px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  margin-bottom: 6px;
}
.skeleton-bar.short { width: 45%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.notice { padding: 14px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.notice.error { color: var(--warn); }
.notice .btn { margin-top: 8px; }

.widget-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stale-tag {
  font-size: 11px;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  padding: 2px 7px;
  border-radius: 999px;
}

/* ---------- 抽屉 ---------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(15, 20, 28, .35);
  backdrop-filter: blur(2px);
  z-index: 60;
}
.drawer {
  position: fixed;
  top: 0; right: 0;
  /* 动态视口高度：地址栏收放时浮层跟随可视高度，底部操作不被推出视口 */
  height: 100vh;
  height: 100dvh;
  width: min(520px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  display: flex;
  flex-direction: column;
  animation: slideIn .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(15px + var(--safe-top)) calc(20px + var(--safe-right)) 15px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.drawer-head h2 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head button {
  border: none; background: transparent; font-size: 22px; line-height: 1;
  color: var(--muted); border-radius: 6px; width: 34px; height: 34px; flex: none;
}
.drawer-head button:hover { background: var(--surface-2); }
.drawer-body {
  padding: 18px 20px calc(40px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field .desc { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.field input[type='text'],
.field input[type='email'],
.field input[type='number'],
.field input[type='password'],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field textarea { resize: vertical; line-height: 1.6; }
.field .row { display: flex; gap: 10px; }
.field .row > * { flex: 1; min-width: 0; }

.check-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 7px;
  font-size: 13px;
  cursor: pointer;
}
.check-row:hover { border-color: var(--accent); background: var(--surface-2); }
.check-row input { margin: 0; flex: none; }
.check-row .grow { flex: 1; min-width: 0; }
.check-row .tag { font-size: 11px; color: var(--muted); }

.mod-group { margin-bottom: 20px; }
.mod-group h4 {
  margin: 0 0 9px;
  font-size: 11.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.mod-card {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: .15s;
}
.mod-card:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-1px); }
.mod-card .mi { font-size: 18px; line-height: 1.3; flex: none; }
.mod-card b { display: block; font-size: 13.5px; }
.mod-card span { font-size: 12px; color: var(--muted); line-height: 1.6; }

.panel-actions { display: flex; gap: 9px; margin-top: 18px; }
.panel-actions .btn { flex: 1; text-align: center; }

/* 折叠菜单（复用抽屉渲染） */
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  transition: .15s;
}
.menu-item:hover { border-color: var(--accent); background: var(--surface-2); }
.menu-item span { font-size: 11.5px; font-weight: 400; color: var(--muted); }

.sublist { margin-top: 12px; }
.sub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 7px;
  font-size: 13px;
}
.sub-item .email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.badge.pending { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}
.toast {
  background: #1f2328;
  color: #fff;
  padding: 9px 17px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease-out;
  max-width: 80vw;
  text-align: center;
}
.toast.error { background: #b91c1c; }
.toast.ok { background: #15803d; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 空态 ---------- */
.empty-board {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ============================================================
   响应式
   档位：≥1025 桌面 / 601–1024 平板 / ≤600 手机
   格子列数与跨列数由 JS 按窗口宽度收敛后写入 --cols / --span，
   这里只负责留白、字号与触控目标等视觉层。
   ============================================================ */
@media (max-width: 1024px) {
  .topbar { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
  .board { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
  .edit-bar { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
  .tabbar { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
  .grid { gap: 12px; }
}

@media (max-width: 600px) {
  body { font-size: 13.5px; }

  .topbar {
    padding: calc(9px + var(--safe-top)) max(12px, var(--safe-right)) 9px max(12px, var(--safe-left));
    gap: 8px;
    flex-wrap: nowrap;
  }
  .brand { gap: 9px; flex: 1 1 auto; }
  .logo { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
  .brand h1 { font-size: 15px; }
  .brand p { display: none; }
  .topbar-actions { gap: 6px; flex-wrap: nowrap; flex: none; }
  .today-label { display: none; }

  /* 窄屏只留当前主题那一个图标：点它弹出选择面板（见 app.js 的 openPackPicker）。
     顶栏在窄屏是 nowrap，两个主题各占一个按钮会挤掉「订阅」这类主操作。 */
  .pack-switch { padding: 1px; }
  .pack-btn { padding: 5px 8px; }
  .pack-btn .pk-name { display: none; }
  /* 只收起「内容主题」的未选中项；语言切换必须两个都留着，否则窄屏没法切回另一种语言 */
  .pack-switch:not(.lang-switch) .pack-btn:not(.active) { display: none; }
  .lang-switch .pack-btn { padding: 5px 7px; }

  /* 次操作收进「⋯」，主操作外露 */
  .secondary-action { display: none; }
  .more-btn { display: grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0 11px; font-size: 19px; }
  .btn { padding: 8px 11px; font-size: 13px; min-height: 40px; }
  .btn.small { min-height: 32px; padding: 5px 9px; font-size: 12px; }
  .lbl-wide { display: none; }
  .lbl-narrow { display: inline; }

  .board { padding: 14px max(12px, var(--safe-right)) calc(48px + var(--safe-bottom)) max(12px, var(--safe-left)); gap: 10px; }

  /* 标签命中区 44×44；文案截断不撑破标签栏 */
  .tabbar { padding: 3px max(12px, var(--safe-right)) 0 max(12px, var(--safe-left)); gap: 2px; }
  .tab { min-height: var(--tap); padding: 0 12px; font-size: 13.5px; border-radius: 8px 8px 0 0; }
  .tab .tab-label { max-width: 16ch; }

  .edit-bar { padding: 8px max(12px, var(--safe-right)) 8px max(12px, var(--safe-left)); gap: 8px; font-size: 12px; }
  .edit-bar .hint { width: 100%; margin-right: 0; line-height: 1.5; }

  .section-head { gap: 8px; }
  .section-head h2 { letter-spacing: 1.6px; }
  .section-title-input { width: 100%; }
  .section-tools { width: 100%; gap: 6px; }
  .section-tools .btn { padding: 6px 10px; font-size: 12px; min-height: 32px; }

  .grid { gap: 10px; }

  .widget-head { padding: 10px 10px 8px; gap: 6px; }
  .widget-head h3 { font-size: 13px; }
  .widget-head .w-uptime { display: none; }
  .drag-handle { font-size: 15px; padding: 0 6px; }

  /* 触控目标：命中区 44×44，图标视觉尺寸基本不变 */
  .widget-tools { gap: 0; }
  .widget-tools button { width: var(--tap); height: var(--tap); font-size: 15px; border-radius: 9px; }

  /* 编辑态按钮变多（刷新/配置/前移/后移/宽度/移除），6×44px 挤不进一行标题栏，
     让工具条独占一行、靠右排列，既不缩小命中区也不会被卡片裁掉 */
  .widget.edit-mode .widget-head { flex-wrap: wrap; row-gap: 2px; }
  .widget.edit-mode .widget-tools { flex: 1 0 100%; justify-content: flex-end; }

  .item { padding: 4px 12px 8px; }
  .item-title { padding: 8px 0 2px; align-items: center; }
  .item-title .rank { min-width: 16px; }
  .item-desc { margin: 2px 0 0 16px; }
  .item-meta { margin: 4px 0 0 16px; }
  .notice { padding: 13px 12px; }
  .notice .btn { min-height: 34px; }

  /* iOS 聚焦输入框不放大：计算字号 ≥16px */
  .field input[type='text'],
  .field input[type='email'],
  .field input[type='number'],
  .field input[type='password'],
  .field select,
  .field textarea { font-size: 16px; padding: 9px 11px; }
  .field label { font-size: 13px; }
  .check-row { padding: 12px 12px; font-size: 14px; }
  .check-row input { width: 20px; height: 20px; }

  /* 抽屉铺满可视宽度 */
  .drawer { width: 100%; border-left: none; }
  .drawer-head { padding: calc(13px + var(--safe-top)) 15px 13px; }
  .drawer-head h2 { font-size: 16px; }
  .drawer-head button { width: var(--tap); height: var(--tap); font-size: 24px; }
  .drawer-body { padding: 16px 15px calc(32px + var(--safe-bottom)); }

  .panel-actions { flex-wrap: wrap; }
  .panel-actions .btn { min-height: var(--tap); flex: 1 1 45%; }

  .mod-card { padding: 13px 13px; }
  .mod-card b { font-size: 14px; }
  .menu-item { min-height: var(--tap); }

  .sub-item { flex-wrap: wrap; padding: 11px 12px; }
  .sub-item .btn { min-height: 34px; }

  .empty-board { padding: 56px 16px; }
  .toast { max-width: 88vw; }
}

/* 横屏手机（高度很矮）时，避免顶栏 + 编辑栏吃掉过多视口 */
@media (max-height: 460px) and (max-width: 900px) {
  .topbar { padding-top: calc(6px + var(--safe-top)); padding-bottom: 6px; }
}
