/* ============================================================
   番茄小站 · 设计系统 v2  「Graphite Aurora」
   ── 石墨底 + 番茄朱红渐变 + 玻璃质感 + 弹性动效
   深色为默认（质感优先），浅色为「瓷白 + 柔光」同样精致
   ============================================================ */

/* ---------- 设计令牌 v3「Paper Tomato」（浅色为默认） ---------- */
:root {
  /* 主色阶：番茄红 */
  --p-50: #fff4f1;
  --p-100: #ffe4dc;
  --p-200: #ffc7b7;
  --p-300: #ffa48c;
  --p-400: #f97c5c;
  --p-500: #e5482c;
  --p-600: #cc3a20;
  --p-700: #a82d18;
  --p-800: #7f2413;
  --p-900: #5c1a0e;

  /* 强调（兼容旧命名） */
  --accent: #e5482c;
  --accent-2: #cc3a20;
  --accent-3: #a82d18;
  --accent-text: #a82d18;
  --grad-accent: linear-gradient(180deg, #e5482c 0%, #d23e23 100%);
  --grad-accent-soft: linear-gradient(180deg, #fff4f1 0%, #fff4f1 100%);
  --accent-soft: rgba(229, 72, 44, 0.08);
  --accent-soft-2: rgba(229, 72, 44, 0.14);
  --accent-ring: rgba(229, 72, 44, 0.32);
  --accent-glow: transparent;

  /* 中性：暖砂 */
  --bg: #fcfaf8;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-solid: #ffffff;
  --surface-soft: #f7f4f1;
  --surface-hover: #f0ebe6;
  --surface-sunken: rgba(27, 24, 21, 0.04);
  --border: #e4ddd6;
  --border-strong: #cfc6bd;
  --hairline: #ffffff;

  --text: #1b1815;
  --text-2: #453e37;
  --muted: #7e746a;
  --muted-2: #a79c90;

  /* 语义色：只表状态 */
  --danger: #b3261e;
  --danger-soft: #fbedec;
  --danger-line: #f3cfcc;
  --warn: #c77a0a;
  --warn-soft: #fdf3e3;
  --warn-line: #f5e3c2;
  --ok: #0f9d6e;
  --ok-soft: #e9f7f1;
  --ok-line: #cdeade;
  --info: #3c6fd1;
  --info-soft: #eef3fe;
  --info-line: #d5e1f9;

  /* 旧的工具色板：统一收敛到品牌色 / 语义色，避免彩色噪音 */
  --purple: #a82d18;
  --purple-soft: #fff4f1;
  --teal: #0f9d6e;
  --teal-soft: #e9f7f1;
  --rose: #b3261e;
  --rose-soft: #fbedec;
  --cyan: #3c6fd1;
  --cyan-soft: #eef3fe;
  --amber: #c77a0a;
  --amber-soft: #fdf3e3;
  --blue: #3c6fd1;
  --blue-soft: #eef3fe;

  /* 氛围光晕：v3 全部关闭 */
  --glow-1: transparent;
  --glow-2: transparent;
  --glow-3: transparent;

  /* 圆角：只有三档语义 */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  /* 单选 / 多选标签统一尺寸 */
  --tag-w: 124px;
  --tag-h: 36px;

  /* 阴影：只有两级 */
  --sh-1: 0 1px 2px rgba(27, 24, 21, 0.04), 0 4px 12px -4px rgba(27, 24, 21, 0.06);
  --sh-2: 0 2px 6px rgba(27, 24, 21, 0.05), 0 12px 28px -8px rgba(27, 24, 21, 0.1);
  --sh-3: 0 24px 60px rgba(27, 24, 21, 0.16), 0 8px 20px rgba(27, 24, 21, 0.06);
  --sh-drag: 0 20px 48px rgba(27, 24, 21, 0.18);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);

  /* 动效 */
  --dur-1: 150ms;
  --dur-2: 200ms;
  --dur-3: 280ms;
  --ease: cubic-bezier(0.16, 0.84, 0.44, 1);
  --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);

  /* 登录页输入面 */
  --au-bg: #ffffff;
  --au-bg-hover: #ffffff;
  --au-bg-focus: #ffffff;
  --au-sheen: none;
  --au-edge: transparent;

  --sidebar-w: 264px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI",
    "Hiragino Sans GB", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Pro Display", "Segoe UI", "PingFang SC", system-ui, sans-serif;
}

/* ---------- 深色：石墨暖调（可选，默认不启用） ---------- */
[data-theme="dark"] {
  --p-50: #2c1c18;
  --p-100: #3e251e;
  --p-200: #63342a;
  --p-300: #8a4030;
  --p-400: #c74e33;
  --p-500: #e5482c;
  --p-600: #cc3a20;
  --p-700: #ffb3a0;
  --p-800: #ffc9ba;
  --p-900: #ffdcd2;

  --accent: #f2603f;
  --accent-2: #cc3a20;
  --accent-3: #a82d18;
  --accent-text: #ffb3a0;
  --grad-accent: linear-gradient(180deg, #e5482c 0%, #d23e23 100%);
  --grad-accent-soft: linear-gradient(180deg, #2c1c18 0%, #2c1c18 100%);
  --accent-soft: rgba(242, 96, 63, 0.14);
  --accent-soft-2: rgba(242, 96, 63, 0.2);
  --accent-ring: rgba(242, 96, 63, 0.42);
  --accent-glow: transparent;

  --bg: #131211;
  --surface: #1b1917;
  --surface-2: #1b1917;
  --surface-solid: #1b1917;
  --surface-soft: #232120;
  --surface-hover: #2a2725;
  --surface-sunken: rgba(0, 0, 0, 0.28);
  --border: #332e2a;
  --border-strong: #4a433d;
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #f6f3f0;
  --text-2: #cfc7be;
  --muted: #9c9288;
  --muted-2: #776e65;

  --danger: #ff8177;
  --danger-soft: rgba(255, 90, 80, 0.14);
  --danger-line: rgba(255, 90, 80, 0.32);
  --warn: #e9a23b;
  --warn-soft: rgba(233, 162, 59, 0.14);
  --warn-line: rgba(233, 162, 59, 0.3);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
  --ok-line: rgba(52, 211, 153, 0.28);
  --info: #7fa8f5;
  --info-soft: rgba(127, 168, 245, 0.14);
  --info-line: rgba(127, 168, 245, 0.28);

  --purple: #ffb3a0;
  --purple-soft: #2c1c18;
  --teal: #34d399;
  --teal-soft: rgba(52, 211, 153, 0.13);
  --rose: #ff8177;
  --rose-soft: rgba(255, 90, 80, 0.14);
  --cyan: #7fa8f5;
  --cyan-soft: rgba(127, 168, 245, 0.14);
  --amber: #e9a23b;
  --amber-soft: rgba(233, 162, 59, 0.14);
  --blue: #7fa8f5;
  --blue-soft: rgba(127, 168, 245, 0.14);

  --glow-1: transparent;
  --glow-2: transparent;
  --glow-3: transparent;

  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 2px 6px rgba(0, 0, 0, 0.4), 0 12px 28px -8px rgba(0, 0, 0, 0.5);
  --sh-3: 0 24px 60px rgba(0, 0, 0, 0.6), 0 8px 20px rgba(0, 0, 0, 0.4);
  --sh-drag: 0 20px 48px rgba(0, 0, 0, 0.6);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --au-bg: #1b1917;
  --au-bg-hover: #232120;
  --au-bg-focus: #1b1917;
  --au-sheen: none;
  --au-edge: transparent;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
  letter-spacing: 0.005em;
}

/* v3：关闭氛围光晕层（浅色下会变成一片粉色浮雾，是「没做完」的主要观感来源） */
body::before {
  display: none;
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* 顶部一层底色渐隐：光晕原本从左上角 (10% -4%) 就开始，装成 PWA 后状态栏透明，
     最上面那一条会整片发红。这里让顶部先保持纯背景色，往下一段再慢慢透出光晕，
     既保住氛围，又让状态栏和页面连成一片。 */
  background: linear-gradient(180deg, var(--bg) 0, color-mix(in srgb, var(--bg) 72%, transparent) 88px,
      transparent 220px),
    radial-gradient(58% 46% at 10% -4%, var(--glow-1), transparent 68%),
    radial-gradient(48% 42% at 94% 4%, var(--glow-2), transparent 70%),
    radial-gradient(46% 40% at 46% 104%, var(--glow-3), transparent 72%);
}

/* 细颗粒质感（v3 关闭：浅色纸感底上会显脏） */
body::after {
  display: none;
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: radial-gradient(rgba(255, 255, 255, 0.8) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

/* 移动端点击反馈默认是「矩形色块」，会把胶囊标签的高亮撑成方框；
   统一关掉系统高亮，改由各组件自己的圆角 :active 态承担点击反馈 */
*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
}

/* 键盘焦点环：只描边，不覆写圆角（覆写会把胶囊标签的圆角压成方框） */
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: padding-box;
}

/* ---------- 通用文字 ---------- */
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  margin: 34px 0 16px;
}
.section-title:first-child {
  margin-top: 4px;
}
.section-title .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong), transparent);
}

.stat-mini {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.5;
}
/* 自动算出的结论性提示（如储备药量）需要比普通说明更醒目 */
.hint-accent {
  color: var(--accent-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.grow {
  flex: 1;
}
.spacer {
  flex: 1;
}
.meta {
  font-size: 12px;
  color: var(--muted);
}
.sub {
  font-size: 12.5px;
  color: var(--muted);
}
.name {
  font-weight: 600;
}
.wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
    background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease), filter var(--dur-1) var(--ease);
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.975);
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 100% at 50% 0%, rgba(255, 255, 255, 0.22), transparent 60%);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
  pointer-events: none;
}
.btn:hover::after {
  opacity: 1;
}
.btn .ico svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 8px 22px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.07) saturate(1.05);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), 0 14px 30px var(--accent-glow);
}

.btn-soft {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
  backdrop-filter: blur(8px);
}
.btn-soft:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: linear-gradient(135deg, #ff6b6b, #dc2626);
  color: #fff;
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.26);
}
.btn-danger:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: var(--r-xs);
}
.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  flex: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
/* btn 与 icon-btn 同时使用时不撑破 */
.btn.icon-btn {
  padding: 0;
  width: 32px;
}
.btn-sm.icon-btn {
  width: 30px;
  height: 30px;
}

.ico {
  display: inline-grid;
  place-items: center;
  flex: none;
}
.ico svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.input,
.field input,
.field select,
.field textarea,
select.input,
textarea.input {
  height: 40px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  width: 100%;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
    background var(--dur-1) var(--ease);
  font-variant-numeric: tabular-nums;
}
.input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted-2);
}
.input:hover,
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-strong);
}
.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-ring);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
textarea.input {
  height: auto;
  min-height: 84px;
  padding: 10px 13px;
  line-height: 1.6;
  resize: vertical;
}

/* ---------- 自绘选择器：触发按钮与 .input 完全同高同圆角 ---------- */
.sel-wrap {
  position: relative;
  width: 100%;
}
.sel-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 11px 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
    background var(--dur-1) var(--ease);
}
.sel-btn:hover {
  border-color: var(--border-strong);
}
.sel-btn:focus-visible,
.sel-btn.is-open {
  outline: none;
  border-color: var(--p-500);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--p-100);
}
.sel-btn .sel-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.sel-btn .sel-text.is-empty {
  color: var(--muted-2);
}
.sel-caret {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--muted);
  transition: transform var(--dur-2) var(--ease);
}
.sel-caret svg {
  width: 100%;
  height: 100%;
}
.sel-btn.is-open .sel-caret {
  transform: rotate(180deg);
  color: var(--accent-text);
}
.sel-lead {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--muted);
}
.sel-lead svg {
  width: 100%;
  height: 100%;
}

/* ---------- 浮层（下拉列表 / 日历）---------- */
.pop-layer {
  position: fixed;
  /* 抽屉 250 / 确认框 300，浮层必须在其之上，否则会被面板盖住点不到 */
  z-index: 340;
  /* 兜底：面板里若有 width:100% 的子元素，fixed 容器会被撑到整屏宽、右边溢出屏幕 */
  max-width: calc(100vw - 24px);
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--sh-3), var(--sh-inset);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(0.985);
  transition: opacity var(--dur-1) var(--ease), transform var(--dur-2) var(--ease-spring),
    visibility var(--dur-1) var(--ease);
}
.pop-layer[data-side="up"] {
  transform: translateY(4px) scale(0.985);
}
.pop-layer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.pop-list {
  display: grid;
  gap: 1px;
  /* --pop-max 由 openPopover 在视口放不下时写入：列表自己滚，浮层就不会越出屏幕 */
  max-height: var(--pop-max, min(46vh, 320px));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pop-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.pop-opt:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.pop-opt .opt-tx {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.pop-opt .opt-tick {
  flex: none;
  font-size: 11px;
  color: var(--accent-text);
  opacity: 0;
}
.pop-opt.is-active {
  background: var(--grad-accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.pop-opt.is-active .opt-tick {
  opacity: 1;
}
.pop-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- 日历 ---------- */
.pop-cal {
  padding: 10px;
}
/* 浮层是 fixed 定位、宽度由内容撑（日历那条没走 matchWidth），
   这里若写 width:100% 会相对视口解析成整屏宽，所以给一个明确的面板宽度 */
.cal {
  width: 268px;
}
.cal-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
}
.cal-title {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.cal-nav {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.cal-nav:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.cal-ico {
  width: 15px;
  height: 15px;
  display: block;
}
.cal-ico svg {
  width: 100%;
  height: 100%;
}
.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-week span {
  text-align: center;
  font-size: 11px;
  color: var(--muted-2);
  padding: 2px 0 6px;
}
.cal-day {
  height: 32px;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.cal-day:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.cal-day.is-out {
  color: var(--muted-2);
  opacity: 0.55;
}
.cal-day.is-today {
  box-shadow: inset 0 0 0 1px var(--accent-ring);
  color: var(--accent-text);
  font-weight: 700;
}
.cal-day.is-active {
  background: var(--grad-accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.cal-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.cal-quick {
  height: 26px;
  padding: 0 9px;
  border-radius: var(--r-xs);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.cal-quick:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ---------- 可输入组合框（如生产厂家）---------- */
.combo {
  position: relative;
  width: 100%;
}
.combo .input {
  padding-right: 38px;
}
.combo-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.combo-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.combo-btn.is-open {
  color: var(--accent-text);
}
.combo-btn.is-open .sel-caret {
  transform: rotate(180deg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 18px;
}
.form-grid .span-2 {
  grid-column: span 2;
}
@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
}

/* ---------- 开关（自动更新等二选一） ---------- */
.switch-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
/* 分段开关：外框和「追更状态 / 更新星期」的标签同高同宽，滑块滑到哪半边就是哪个值 */
.seg-switch {
  position: relative;
  align-self: flex-start;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--tag-w);
  height: var(--tag-h);
  padding: 3px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  box-shadow: var(--sh-1);
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.seg-switch:focus-visible {
  border-color: var(--accent-ring, var(--border-strong));
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.seg-thumb {
  position: absolute;
  top: 3px;
  /* 6px = 容器 3px 内边距 + 半格留白，让滑块在两格里都是居中对称的 */
  left: 6px;
  width: calc(var(--tag-w) - 6px);
  height: calc(var(--tag-h) - 8px);
  border-radius: var(--r-full);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  transition: transform var(--dur-2) var(--ease), background var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
/* 开启：滑块挪到左边那格并换成品牌渐变；关闭：停在右边那格、保持中性 */
.seg-switch.is-on .seg-thumb {
  transform: translateX(0);
  background: var(--grad-accent);
  border-color: transparent;
  box-shadow: 0 2px 10px var(--accent-soft);
}
.seg-switch:not(.is-on) .seg-thumb {
  transform: translateX(var(--tag-w));
}
.seg-opt {
  position: relative;
  z-index: 1;
  height: 100%;
  border: 0;
  background: none;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), font-weight var(--dur-1) var(--ease);
}
.seg-opt.is-active {
  font-weight: 600;
}
.seg-switch.is-on .seg-opt.is-active {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}
.seg-switch:not(.is-on) .seg-opt.is-active {
  color: var(--text);
}
.seg-switch.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.seg-switch.is-disabled .seg-opt {
  cursor: not-allowed;
}

.form-error {
  font-size: 12.5px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  padding: 8px 12px;
  animation: shake 380ms var(--ease);
}
.form-note {
  font-size: 12.5px;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: var(--r-xs);
  padding: 8px 12px;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* 步进器：与输入框 / 下拉共用同一「控件槽」（灰底 + 1px 描边 + 10px 圆角 + 聚焦变白），
   两侧 ± 是浮在槽上的白色方形按钮，让「可点」这件事一眼可见 */
.stepper {
  display: inline-flex;
  align-items: center;
  /* 2px：按钮之间只留一条缝，两个键看起来同属一个控件而不是三个零件 */
  gap: 2px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease);
  width: 100%;
}
.stepper:hover {
  border-color: var(--border-strong);
}
/* 聚焦态与普通输入框完全同步：主色边框 + 3px 光环。
   以前步进器自己一套（只换边框色），和同一行的文本框并排时像两种控件 */
.stepper:focus-within {
  border-color: var(--p-500);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--p-100);
}
/* 整行字段里的步进器不跟着拉满：667px 宽的槽会让中间的 1 位数字显得孤立，
   收到和半宽字段（约 325px）相近的体量，全站步进器大小才一致 */
.field .stepper {
  max-width: 360px;
}
/* ± 按键：不再各自描一圈边框。槽本身就是那个输入框，按钮只是嵌在里面的两个键，
   各自带框会变成「框里套框」，四组圆角互相打架，越看越碎 */
.stepper button {
  /* 32px：40px 的槽里上下各留 3px 内边距刚好装下，比原来的 28px 更好按 */
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text-2);
  box-shadow: 0 1px 2px rgba(27, 24, 21, 0.07);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.stepper button:hover:not(:disabled) {
  background: var(--p-50);
  color: var(--p-700);
  box-shadow: 0 1px 2px rgba(27, 24, 21, 0.11);
}
.stepper button:active:not(:disabled) {
  background: var(--p-100);
  /* 按下缩一点，配合数值跳变，手感上像真按到了 */
  transform: scale(0.9);
}
/* 到 min / max 就置灰：按钮留在原位，不像「隐藏」那样会让输入框宽度跳一下 */
.stepper button:disabled {
  opacity: 0.34;
  cursor: not-allowed;
  box-shadow: none;
}
.step-ico {
  display: block;
  width: 15px;
  height: 15px;
}
.step-ico svg {
  width: 100%;
  height: 100%;
  display: block;
  /* 加粗到 2.2：15px 下 1.7 的描边偏虚，撑不住中间那个 650 字重的数字 */
  stroke-width: 2.2;
}
.stepper input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
}
.stepper input:focus {
  outline: none;
}
.stepper .suffix {
  font-size: 12px;
  color: var(--muted);
  /* 单位紧贴数字右侧，和 + 按钮之间留出足够间隙，不会被看成「mg+」 */
  padding: 0 7px 0 0;
  flex: none;
}

/* 行内组合（步进器 + 单位文案）用 flex，选项组用固定列宽网格 */
.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
/* 选项组：固定列宽，保证所有单选/多选标签大小完全一致 */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--tag-w));
  gap: 8px;
  justify-content: start;
}
/* 窗口变窄时整体收窄标签，仍保持同一尺寸 */
@media (max-width: 1200px) {
  :root {
    --tag-w: 112px;
  }
  .option {
    font-size: 12.5px;
  }
}
/* 行内步进器不能撑满整行，否则「每 X 天 X 次，每次 X 粒」会被压成竖排 */
.option-row > .stepper {
  width: auto;
  /* 库存等输入框要能完整显示两位及以上数字 / 小数，同时又不能宽到把「盒 + 粒」挤到第二行 */
  flex: 0 0 150px;
  min-width: 124px;
}
/* 一行里并排好几个步进器时，把宽度让给中间的数字 */
.option-row > .stepper input {
  min-width: 56px;
}
/* 库存这类「多个步进器 + 单位」的组合：整组换行，单位不会掉到单独一行 */
.stock-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.stock-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.stock-item > .stepper {
  /* 收窄外观但把宽度让给输入框（± 按钮 32px），保证「12」这类两位数完整可见，
     且「12 盒 + 0 粒」在常规抽屉宽度下能排成一行 */
  flex: 0 0 130px;
  min-width: 110px;
}
.stock-plus {
  color: var(--muted);
  font-size: 12.5px;
  flex: none;
}
.option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: var(--tag-w);
  height: var(--tag-h);
  padding: 0 20px 0 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--dur-1) var(--ease);
}
.option:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.option.is-active {
  background: var(--grad-accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-soft);
  font-weight: 600;
}
.option:active {
  transform: translateY(0) scale(0.96);
}
.option .option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 不能用 line-height:1 —— 会裁掉 g / y 这类下伸笔画（如 mg:mg、mg、g） */
  line-height: 1.3;
}
.option .pick-mark {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 11px;
  font-size: 11px;
  line-height: 1;
  text-align: center;
  color: var(--accent-text);
}
/* 编辑模式：不可删项（内置平台）淡出，避免误以为能选 */
.option-grid.is-editing .option.is-locked {
  opacity: 0.45;
}
/* 编辑模式下被选为「待删」的项：整块变红 + 打勾，不放右上角角标 */
.option-grid.is-editing .option.is-marked {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}
.option.is-marked {
  border-color: var(--danger);
  color: var(--danger);
}
.option.is-marked .pick-mark {
  color: var(--danger);
}
/* 批量删除操作条 */
.plat-del-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  background: var(--surface-soft);
}
.plat-del-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: auto;
}
/* 已移除内置平台的恢复行 */
.plat-hidden-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.plat-hidden-row .chip.is-restore {
  cursor: pointer;
  color: var(--muted);
  border-style: dashed;
}
.plat-hidden-row .chip.is-restore:hover {
  color: var(--accent-text);
  border-color: var(--accent-ring);
}
/* 字段标题里的小文字按钮（如「编辑」） */
.link-btn {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover {
  text-decoration: underline;
}
.link-btn.is-on {
  color: var(--danger);
}
.plat-logo {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-hover);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.plat-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.plat-logo.is-text {
  background: var(--surface-sunken);
  color: var(--text-2);
  box-shadow: none;
}

/* 筛选栏内放滑动高亮块：容器要当定位参照，且不能裁掉块的柔光 */
.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  /* 筛选栏是独立的方框，必须与上下内容留出呼吸空间 */
  margin: 18px 0;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--sh-1);
}
/**
 * 滑动高亮块：整组筛选只有一个元素，切换时只改 transform / 宽高。
 * 宽度与位移都是可过渡的属性，所以块会从上一个标签「滑」到下一个，
 * 连点时浏览器从当前插值位置继续，不会跳回起点。
 */
.chip-slider {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: var(--r-full);
  background: var(--grad-accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: transform 420ms var(--ease-spring), width 320ms var(--ease),
    height 320ms var(--ease), opacity 200ms var(--ease);
}
/* 首次落位 / 尺寸变化直接到位，不要从上一处滑过来 */
.chip-slider.is-static {
  transition: none;
}
.chip {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--dur-1) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover {
  color: var(--text);
  background: var(--surface-hover);
}
/* 筛选栏内搜索框：与筛选按钮同一行，单层胶囊（输入框自身不再带边框，
   避免出现「胶囊里套一个方框」的双层轮廓） */
.filters > .searchbox {
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--tag-h);
  padding: 0 9px 0 13px;
  /* 追番页 6 个筛选按钮后剩余空间有限：搜索框自适应吃掉剩余宽度；
     flex-basis 148px 保证 1280 宽窗口下仍能与筛选按钮同行，宽屏下最多长到 320px */
  flex: 1 1 148px;
  min-width: 148px;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-soft);
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease);
}
.filters > .searchbox:hover {
  border-color: var(--border-strong);
}
.filters > .searchbox:focus-within {
  border-color: var(--p-500);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--p-100);
}
.searchbox-ic {
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
  transition: color var(--dur-1) var(--ease);
}
.filters > .searchbox:focus-within .searchbox-ic {
  color: var(--p-600);
}
.searchbox-ic .ico,
.searchbox-ic svg {
  width: 15px;
  height: 15px;
  display: block;
}
.searchbox input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
.searchbox input::placeholder {
  color: var(--muted-2);
}
.searchbox input:focus {
  border: 0;
  box-shadow: none;
  background: transparent;
}
.searchbox-clear {
  display: none;
  width: 17px;
  height: 17px;
  border-radius: var(--r-full);
  border: 0;
  background: var(--border);
  color: var(--surface-solid);
  font-size: 12px;
  line-height: 1;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: background var(--dur-1) var(--ease);
}
.searchbox-clear.is-show {
  display: grid;
}
.searchbox-clear:hover {
  background: var(--border-strong);
}

/* 窄屏下搜索框独占一整行：手指点得到，占位文字也不会被截断 */
@media (max-width: 640px) {
  .filters > .searchbox {
    flex: 1 1 100%;
    max-width: none;
    height: 40px;
    margin-left: 0;
  }
  /* 触屏上 ± 要够大：整条槽加高到 46、按键放到 38，接近 44 的推荐触达尺寸 */
  .stepper {
    height: 46px;
  }
  .stepper button {
    width: 38px;
    height: 38px;
  }
}
/* 筛选也是单选标签，与表单里的选项保持同一尺寸；空间不够时整体等比收窄，仍留在一行 */
.filters > .chip {
  width: var(--tag-w);
  height: var(--tag-h);
  justify-content: center;
  flex: 0 1 var(--tag-w);
  min-width: 78px;
  /* 压在滑动高亮块上面：块负责背景，文字自己不能有底色，否则会盖住块 */
  position: relative;
  z-index: 1;
  /* app.css 有一条 `.chip{font-size:11px!important;font-weight:550!important;padding:2px 8px!important}`
     （本意是给小徽章用的），把所有筛选标签也压成了 11px 的徽章尺寸。
     这里特异性更高、同样带 !important，才能把它顶回筛选标签该有的字号 */
  font-size: 13px !important;
  font-weight: 600 !important;
  padding: 0 14px !important;
}
.chip.is-active {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
/* 筛选栏里的选中态不再自己涂色，交给那块会滑动的背景；
   只保留文字变白，这样切换时文字位置与尺寸完全不动 */
.filters > .chip.is-active,
.filters > .chip.is-active:hover {
  background: transparent;
  box-shadow: none;
  color: #fff;
}
/* 点击 / 触摸反馈走组件自身的圆角，避免系统矩形高亮把胶囊撑成方框 */
.chip:active {
  transform: scale(0.96);
}
.chip,
.option,
.tag,
.nav-item,
.auth-tab,
.plat-chip,
.hr-chip {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.chip-count {
  opacity: 0.75;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-hover);
  color: var(--text-2);
  white-space: nowrap;
}
.tag-neutral {
  background: var(--surface-hover);
  color: var(--muted);
}
.tag-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.tag-low {
  background: var(--danger-soft);
  color: var(--danger);
}
.tag-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag-info {
  background: var(--info-soft);
  color: var(--info);
}
.tag-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tiny-badge {
  /* 定高胶囊：用 flex 居中，别靠 line-height 撑。
     高度和内边距由 app.css 覆写（带 !important），一旦只写 line-height:18px，
     border-box 下可用内容区只剩 12px，字就会偏下、看起来没居中。 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 0 7px;
  height: 18px;
  line-height: 1;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  background: var(--grad-accent);
  color: #fff;
  vertical-align: 1px;
}

/* ---------- 登录 / 注册 / 找回密码：整页无框设计 ---------- */
.auth-view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  /* 顶部多留出状态栏高度：PWA 独立窗口下 iOS 状态栏透明，不避让会被压住 */
  padding: calc(clamp(20px, 4vw, 56px) + env(safe-area-inset-top)) clamp(20px, 4vw, 56px)
    calc(clamp(20px, 4vw, 56px) + env(safe-area-inset-bottom));
  z-index: 5;
  overflow: auto;
}
/* 状态栏底色：
   装成 PWA 独立窗口后，安卓 / iOS 的状态栏都是透明的，会把**页面顶部那一块内容**
   原样透上来。登录页顶部的红色光晕（--glow-1 在 22% / 20% 处）正好落在那条上，
   于是看起来就是「顶部一片红、跟页面不搭」。这里补一条纯背景色的顶衬，盖住光晕，
   状态栏区域就等于页面背景，视觉上连成一片。浏览器里 inset 为 0，不占任何空间。 */
.auth-view::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  z-index: 1;
  pointer-events: none;
}
.auth-bg {
  position: fixed;
  inset: 0;
  /* 光晕中心整体下移，别贴着状态栏那一条；顶部再加一层底色渐隐（同 body::before） */
  background: linear-gradient(180deg, var(--bg) 0, color-mix(in srgb, var(--bg) 72%, transparent) 88px,
      transparent 220px),
    radial-gradient(70% 52% at 22% 24%, var(--glow-1), transparent 66%),
    radial-gradient(55% 48% at 84% 30%, var(--glow-2), transparent 68%),
    radial-gradient(60% 50% at 50% 100%, var(--glow-3), transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  from {
    transform: scale(1) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.12) translate3d(-2%, 1.5%, 0);
  }
}

/* 单列窄栏：没有卡片边框、没有阴影、没有左右分栏，层次全靠留白与字号 */
.auth-stage {
  position: relative;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  /* 品牌落款与标题挨得紧一点：标识只是开场白，中间空一大段会把两者拆成两块 */
  gap: 12px;
  animation: authStageIn 620ms var(--ease-spring) both;
}
/* 卡片壳上提到 .auth-stage：品牌区是 .auth-stage 的直接子元素、在 .auth-card 外面，
   而 app.css 用 !important 把白底 / 边框 / 圆角 / 阴影都画在了 .auth-card 上，
   于是番茄图标和站名被甩到卡片外的灰底上（Windows 账号页的标识是在面板内的）。
   这里带 #auth-view 把壳搬到 .auth-stage，再把 .auth-card 自己的壳脱掉 */
#auth-view .auth-stage {
  padding: 28px 28px 24px !important;
  gap: 12px !important;
  background: var(--surface-solid) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  box-shadow: var(--sh-2) !important;
}
#auth-view .auth-card {
  width: 100% !important;
  max-width: none !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
@keyframes authStageIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 顶部品牌标识 */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.auth-brand .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}
/* 参照 Windows 账号页顶部的「Microsoft」：标识只是个落款，不是主角。
   字号和字重都压住，视线才会顺势往下走到标题，而不是停在这行。
   app.css 把它钉成 16px / 650，必须带 #auth-view + !important 才生效 */
#auth-view .auth-brand-name {
  font-size: 13.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  color: var(--text-2) !important;
}
/* app.css 给 .auth-brand 加了 margin-bottom:28px!important，再叠上 .auth-stage 的 gap，
   品牌到标题会空出 40px，标题就像被推离了标识。这里清零，
   让「番茄小站」和标题连成一组，间距只由 .auth-stage 的 gap 决定 */
#auth-view .auth-brand {
  gap: 10px !important;
  margin-bottom: 0 !important;
}

/* 每次只显示一屏，切换时整屏淡入上浮 */
.auth-card {
  display: flex;
  flex-direction: column;
}
.auth-card.is-enter {
  animation: authCardIn 420ms var(--ease) both;
}
@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
/* 登录页标题：32px / Semibold。比 Windows 的「创建帐户」再大一点——
   它是这一屏唯一的视觉重心，字号压不住的话整页会显得散。
   必须带 #auth-view + !important：app.css 把 .auth-title 钉成了
   21px / 700 / -0.02em，h2 也被它设成 17px / 650，不加就会被压成小号粗体 */
#auth-view .auth-title {
  margin-bottom: 22px !important;
  font-size: 32px !important;
  font-weight: 600 !important;
  letter-spacing: -0.015em !important;
  line-height: 1.22 !important;
  color: var(--text) !important;
}

/* 注册屏第一行：头像 + 昵称。头像做成圆片，底沿与输入框底线齐平，
   这样一行看起来仍是一个字段，而不是两个不相干的东西 */
.au-reg-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.au-field-grow {
  flex: 1;
  min-width: 0;
}
.au-avatar {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background-color: var(--au-bg);
  background-image: var(--au-sheen);
  box-shadow: inset 0 1px 0 var(--au-edge);
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease),
    background-color var(--dur-2) var(--ease);
}
.au-avatar:hover {
  border-color: var(--accent);
  background-color: var(--au-bg-hover);
}
.au-avatar:active {
  transform: scale(0.96);
}
.au-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.au-avatar img[hidden] {
  display: none;
}
/* 右下角「＋」小圆点：告诉用户这位头像可以点 */
.au-avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--grad-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.au-reg-hint {
  margin: -6px 0 -2px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted-2);
}

/* 输入框：回到下划线式，但垫一层有层次的背景面
   上面两角是圆的、底部只留一条直线，聚焦时强调色线从左往右长出来——
   比全封闭的方框轻盈，比纯线条更容易看清「可以点这里输入」。
   高度依旧交给 padding 撑，不写死：高度一写死文字就被顶到面中央，贴不住底线。 */
.au-field {
  position: relative;
  display: grid;
  gap: 2px;
}
.au-label {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--muted);
  /* 只给拉丁字母留一点呼吸，中文被拉散会显得松散 */
  letter-spacing: 0.02em;
  transition: color var(--dur-2) var(--ease);
}
/* app.css 把 .au-label 钉成了 12.5px / 600 / --text-2，字段标签于是比预览大一号、
   粗一档、颜色还更深。这里带 #auth-view 压回去——标签是提示不是正文，
   应该是 11.5px / 500 / 灰色，跟 Windows 账号页那种轻提示一个重量 */
#auth-view .au-field .au-label {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: var(--muted) !important;
  letter-spacing: 0.02em !important;
}
.au-field:hover .au-label {
  color: var(--text-2);
}
/* 登录 / 注册 / 找回密码的输入框：下划线式，不要方框。
   app.css 里 .au-field input 带着 !important（40px 高、10px 圆角、1px 边框、
   白底），必须同级别盖回去——这里的选择器带 #auth-view，特异性更高，配 !important 稳赢。
   三件事：① 除底边外全部去掉边框，圆角归零，背景透明，只留一条底线定边界
   ② 左侧留 40px 放字段图标 ③ 聚焦 = 主色底线（由 .au-inp::after 从左展开），
   不再套 3px 光环——方框时代靠光环强调焦点，线式把线本身点亮就够了。 */
#auth-view .au-field input {
  display: block !important;
  width: 100% !important;
  height: 44px !important;
  /* 左 40px 让位给字段图标，右侧 13px 是正常留白 */
  padding: 0 13px 0 40px !important;
  /* 底线不画在 input 身上：input 左侧有 40px 内距让位给字段图标，
     线画在它自己身上会和画在包裹层上的聚焦线错开一截（看起来一长一短）。
     现在静态线和聚焦线都画在 .au-inp 上，宽度和位置天然一致 */
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--text) !important;
  font-size: 14.5px !important;
  line-height: 1.4 !important;
  letter-spacing: 0.005em;
  caret-color: var(--accent);
  box-shadow: none !important;
  transition: border-bottom-color var(--dur-1) var(--ease),
    background-color var(--dur-1) var(--ease) !important;
}
/* 密码框右侧要给「显示 / 隐藏」留出位置（.has-eye 由 JS 注入时打上，
   不用 :has() 是为了老一点的浏览器也能拿到） */
#auth-view .au-inp.has-eye input {
  padding-right: 44px !important;
}
/* 出错：底线转红，视线回到输入框时还看得出是哪一格出的问题 */
#auth-view .au-field.is-err .au-inp::before {
  background: var(--danger);
}
#auth-view .au-field.is-err input:focus {
  box-shadow: none !important;
}
#auth-view .au-field input::placeholder {
  /* 亮色下用更淡的 --muted-2：占位文字要像「提示」，不能看着像已经填好的内容 */
  color: var(--muted-2) !important;
  font-size: 14px;
  font-weight: 400 !important;
  letter-spacing: 0;
}
/* 深色下 --muted-2 只有 #776e65，压在深底上糊成一团，换回 --muted */
[data-theme="dark"] #auth-view .au-field input::placeholder {
  color: var(--muted) !important;
}
/* 密码：圆点拉一点字距，否则一坨挤在一起 */
.au-field input[type='password'] {
  letter-spacing: 0.1em;
}
/* hover / focus 的底线都交给 .au-inp 的伪元素处理：
   hover → .au-field:hover .au-inp::before 变深，focus → ::after 长出主色线 */
#auth-view .au-field input:focus {
  outline: none;
  box-shadow: none !important;
}
/* 聚焦线：画在包裹层 .au-inp 上，宽度恒等于输入框
   —— 画在 .au-field 上会拉满整行（手机号 + 获取验证码那种并排格子就长出一截）；
   画在 input 自身则做不了展开动画。放包裹层两头都占：宽度贴合、还能做动画。
   静止收起（scaleX(0)），聚焦时从左往右长出，出错转红。 */
.au-inp {
  position: relative;
  display: block;
  /* 去掉行内基线留出的一丝空隙，线才正好压在 input 的底边上 */
  line-height: 0;
}
/* 静态底线：与聚焦线画在同一个盒子上，两条线必然同起点、同长度 */
.au-inp::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border);
  /* ::before 渲染在内容之前，不加 z-index 会被 input 的 autofill 白底盖掉 */
  z-index: 1;
  pointer-events: none;
}
.au-field:hover .au-inp::before {
  background: var(--border-strong);
}
.au-inp::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--p-500);
  z-index: 1;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 260ms var(--ease), background-color var(--dur-1) var(--ease);
  pointer-events: none;
}
.au-field:focus-within .au-inp::after {
  transform: scaleX(1);
}
.au-field.is-err .au-inp::after {
  background: var(--danger);
}
/* 深色下 --border（#332e2a）压在卡片上几乎看不见，底线换深一档 */
[data-theme="dark"] #auth-view .au-inp::before {
  background: var(--border-strong);
}
/* 字段图标：贴在输入框左内侧，聚焦转主色、出错转红 —— 与底线同步变色，
   等于给每一格都配了一个「这是什么」的静默说明 */
.au-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  transition: color var(--dur-1) var(--ease);
}
.au-ico svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.8;
}
.au-field:hover .au-ico {
  color: var(--text-2);
}
.au-field:focus-within .au-ico {
  color: var(--p-600);
}
.au-field.is-err .au-ico {
  color: var(--danger);
}
/* 密码显隐：常驻输入框右内侧，点一下切明文，看完不用再点回输入框 */
.au-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  color: var(--muted-2);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.au-eye:hover {
  background: var(--surface-soft);
  color: var(--text);
}
.au-eye.is-on {
  color: var(--p-600);
}
.au-eye-ic svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}
/* input 脱离 .au-field 的 grid 拉伸后不再自动撑满，这里补回来 */
.au-inp input {
  width: 100%;
}
/* 聚焦线已统一到前面「登录 / 注册输入框」那一节的 .au-inp::after（left/right:0，
   与静态底线同长）。这里原先还有一份 left/right:12px 的旧版本——那是给圆角输入框
   内缩用的，会把聚焦线截短 24px、和静态底线对不齐，已删除，勿再补回 */
/* 手机号 + 获取验证码并排：让输入框吃掉剩余宽度，底线跟着它 */
.otp-row .au-inp {
  flex: 1;
  min-width: 0;
}
.au-field:focus-within .au-label {
  color: var(--accent-text);
}
/* 已经填过的字段标签提亮一档：一眼能看出哪格还空着。
   排除聚焦态，否则 :has() 的优先级会盖掉上面的强调色 */
.au-field:has(input:not(:placeholder-shown)):not(:focus-within) .au-label {
  color: var(--text-2);
}
/* 浏览器自动填充会给输入框刷上不透明的淡蓝底，深色下非常刺眼。
   background-color 的长过渡是唯一能压住它的办法（inset 阴影会被背景盖回去） */
.au-field input:-webkit-autofill,
.au-field input:-webkit-autofill:hover,
.au-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent);
  transition: background-color 100000s ease-out 0s,
    border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
/* 登录页：自动填充刷的淡蓝紫底，background-color 压不住（Chrome 的 UA 样式更横），
   只能用一层 inset 阴影把它盖掉。卡片本身是纯色的，盖完后看着就等于没底色——
   这层底是整个页面看着「不像干净的下划线输入框」的元凶 */
#auth-view .au-field input:-webkit-autofill,
#auth-view .au-field input:-webkit-autofill:hover,
#auth-view .au-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--accent);
  box-shadow: 0 0 0 1000px var(--surface-solid) inset !important;
  transition: background-color 100000s ease-out 0s;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
/* 主按钮不再撑满整行：Windows 的「下一步」是跟着内容走的一颗按钮，靠右收尾、
   有最小宽度。宽度必须带 #auth-view 才压得住 app.css 的 .btn-block{width:100%!important} */
#auth-view .auth-form .btn-block {
  width: auto !important;
  align-self: flex-end;
  min-width: 132px;
  height: 44px;
  margin-top: 4px;
  padding: 0 24px;
  border-radius: 10px;
  font-size: 15px;
}
/* 错误 / 提示不再用色块，保持整页的干净；负边距让它贴住上方输入框而不是漂在中间 */
.auth-form .form-error,
.auth-form .form-note {
  margin-top: -14px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12.5px;
  line-height: 1.5;
  animation: none;
}

/* 文字入口排在按钮上方：Windows 账号页把「改用电话号码 / 获取新邮箱」这类入口
   放在输入框下面、提交按钮上面，一路往下读再右下角收尾。
   现在 .auth-links 已移进 form 内，纵向间距交给 form 的 gap，这里不再额外加 margin。
   app.css 用 !important 钉死了 margin-top / gap，这里带 #auth-view 盖回去 */
#auth-view .auth-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px !important;
  margin-top: 0 !important;
}
/* app.css 把 .link-btn 钉成了 550 字重 + --p-700（比主色深一档），
   这几条入口于是比预览粗、颜色也重。链接是辅助入口不是按钮，
   常规字重（400）+ 主色就够了，跟 Windows 账号页那几行链接一个重量 */
#auth-view .auth-links .link-btn {
  margin-left: 0;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--accent-text) !important;
  text-align: left;
}
/* 竖排之后不再需要中间那颗分隔点 */
#auth-view .auth-links .au-dot {
  display: none;
}
.au-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted-2);
}

/* 云服务登录入口：Windows 风格的登录页不该在底部再挂一排实心按钮，
   弱化成几行小字链接——功能一个不少，视觉上让位给标题和输入框 */
.auth-cloud {
  margin-top: 18px;
}
.ac-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  color: var(--muted-2);
  font-size: 11.5px;
  white-space: nowrap;
}
/* 左右分隔线去掉：它把页面横切成两截，打断「一屏往下走」的顺畅感 */
.ac-line::before,
.ac-line::after {
  display: none;
}
.ac-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
/* app.css 的 .btn-soft 带着底色和边框的 !important，这里带 #auth-view 才压得住 */
#auth-view .ac-row .btn {
  flex: none;
  height: auto;
  min-width: 0;
  padding: 0 !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  color: var(--accent-text) !important;
  font-size: 12.5px;
  font-weight: 500;
}
#auth-view .ac-row .btn:hover {
  background: none !important;
  text-decoration: underline;
}
/* 整屏左对齐之后，这行提示也跟着靠左，别再单独居中 */
.ac-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted-2);
}
.ac-hint.is-warn {
  color: var(--danger);
}

/* 验证码一行：输入框 + 发送按钮 */
.otp-row {
  display: flex;
  gap: 8px;
}
.otp-row .input {
  flex: 1;
  min-width: 0;
}
#auth-view .otp-row .btn {
  flex: none;
  white-space: nowrap;
  /* 输入框加高到 44 后按钮必须跟上，否则「手机号 + 获取验证码」这一行会一高一矮。
     必须 !important：app.css 的 .btn-sm 也是 !important，同权重下它后加载会赢 */
  height: 44px !important;
}
.au-err {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--danger);
}

/* 站点标识：直接复用 /assets/favicon.svg，保证浏览器标签页与页内图标完全一致 */
.logo-mark {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 16px;
  display: block;
  object-fit: contain;
  background: var(--grad-accent);
  box-shadow: 0 8px 22px var(--accent-glow), var(--sh-inset);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 应用骨架 ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* 侧边栏 */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-solid);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  position: relative;
}
[data-theme="dark"] .sidebar {
  background: rgba(12, 13, 16, 0.72);
}
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--border-strong) 30%, var(--border-strong) 70%, transparent);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 18px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 4px;
  border-radius: var(--r-md);
  transition: background var(--dur-1) var(--ease);
}
.brand:hover {
  background: var(--surface-hover);
}
.brand .logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
}
.brand-text {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-close {
  display: none;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* 一级菜单：整行可点，点击后子菜单在下方就地展开 / 收起 */
button.nav-title {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
button.nav-title:hover {
  background: var(--surface-hover);
  color: var(--text-2);
}
button.nav-title .tx {
  flex: 1;
  min-width: 0;
}
button.nav-title .caret-ic {
  width: 13px;
  height: 13px;
  flex: none;
  transition: transform var(--dur-2) var(--ease);
}
.nav-group.is-open > button.nav-title .caret-ic {
  transform: rotate(90deg);
}
/* 展开态：标题文字与折叠箭头一起高亮，一眼看出当前打开的是哪一组 */
.nav-group.is-open > button.nav-title {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.nav-group.is-open > button.nav-title:hover {
  color: var(--accent-text);
  background: var(--accent-soft-2);
}
.nav-group.is-open > button.nav-title .caret-ic {
  color: var(--accent-text);
}
button.nav-title .group-count {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.nav-group.is-open > button.nav-title .group-count {
  color: var(--accent-text);
  background: var(--surface);
}
/* 折叠容器：高度动画带动后续栏目一起移动 */
.nav-collapse {
  position: relative;
  overflow: hidden;
}
.nav-group:not(.is-open) > .nav-collapse {
  height: 0;
}
/* 滑动高亮块：位置与尺寸跟随选中项连续移动，文字不受影响 */
.nav-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: var(--r-md);
  background: var(--grad-accent-soft);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: transform 340ms var(--ease-spring), width 300ms var(--ease), height 300ms var(--ease),
    opacity 200ms var(--ease);
}
.nav-indicator::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--grad-accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
/* 首次定位 / 窗口尺寸变化时直接落位，避免从上一位置莫名滑过来 */
.nav-indicator.is-static {
  transition: none;
}
.nav-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* 展开时子项轻微错峰：整体上移微小距离后归位，层次更清楚 */
@keyframes navSubIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.nav-group.is-anim .nav-item {
  animation: navSubIn 240ms var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 26ms);
}
/* 两段导航共用的滑动高亮块：与追番页筛选按钮同一支弹性曲线（渐变底色 + 发光 + 滑动）。
   选中态以前只把文字染成主色，切换时毫无动作；现在这块底色会滑过去，跟筛选栏一个手感 */
.nav-slider {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: var(--r-md);
  background: var(--grad-accent);
  box-shadow: 0 4px 14px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: transform 420ms var(--ease-spring), width 320ms var(--ease),
    height 320ms var(--ease), opacity 200ms var(--ease);
}
/* 首次落位 / 窗口缩放后直接到位，不要从左上角滑过来 */
.nav-slider.is-static {
  transition: none;
}
/* 滑块在底下、文字浮在上面：选中项转白，与筛选按钮的选中态一致。
   加 .has-slider 前缀是为了滑块还没挂载时（工具表未返回）不把文字刷成白底白字。
   这里必须用 !important：app.css 里 .nav-item.is-active 同样带 !important，
   它铺的是 --p-50 实底，不掀掉这块底色，滑块就永远被盖在下面看不见 */
.nav-list.has-slider .nav-item.is-active,
.nav-list.has-slider .nav-item.is-active:hover {
  background: transparent !important;
  color: #fff !important;
}
.nav-list.has-slider .nav-item.is-active .ico {
  color: #fff !important;
}
.nav-list.has-slider .nav-item.is-active .nav-count {
  background: rgba(255, 255, 255, 0.26) !important;
  color: #fff !important;
}
/* 点击反馈：一圈从落点铺开的柔光，动画结束由 JS 摘掉 */
@keyframes navInk {
  from {
    opacity: 0.32;
    transform: scale(0.25);
  }
  to {
    opacity: 0;
    transform: scale(1);
  }
}
.nav-ink {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--p-400) 0%, var(--p-500) 62%, rgba(229, 72, 44, 0) 72%);
  pointer-events: none;
  z-index: 0;
  animation: navInk 520ms var(--ease) forwards;
}
.nav-item {
  position: relative;
  /* 点击涟漪要被裁在圆角内，否则会溢出成一个方框 */
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  /* 可拖拽排序：用抓取手势提示这一行能被拖动 */
  cursor: grab;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease);
  user-select: none;
}
.nav-item .ico svg {
  width: 17px;
  height: 17px;
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
/* 按下轻微下压，跟筛选按钮同款反馈。排除 .floating：拖拽中那行的 transform
   归拖拽逻辑用，这里再叠一个 scale 会把卡片按歪 */
.nav-item:not(.floating):active {
  transform: scale(0.975);
}
/* 选中态背景交给统一的滑动高亮块，这里只负责文字与图标，保证文字稳定不被遮住 */
.nav-item.is-active,
.nav-item.is-active:hover {
  background: transparent;
  color: var(--accent-text);
  font-weight: 700;
}
.nav-item.is-active .ico {
  color: var(--accent-text);
}
.nav-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 一级分组项「我的工具」：外观与首页 / 工具箱完全一致，只是右侧多一枚折叠箭头。
   类名不能用 .nav-group —— 旧版折叠导航留了一套 .nav-group{flex-direction:column}
   （配 button.nav-title / .nav-collapse），撞上去会把这一行竖过来 */
.nav-item.nav-fold {
  cursor: pointer;
}
.nav-caret {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--muted-2);
  transition: transform 260ms var(--ease), color var(--dur-1) var(--ease);
}
.nav-caret svg {
  width: 15px;
  height: 15px;
  /* 缩到 15px 后 1.7 的描边偏细会发虚，加粗到 2.2 才和文字笔画一个重量 */
  stroke-width: 2.2;
}
.nav-item.nav-fold:hover .nav-caret {
  color: var(--text);
}
/* 折叠时箭头转平，与子列表收起同一条曲线 */
.nav-item.nav-fold.is-collapsed .nav-caret {
  transform: rotate(-90deg);
}
/* 子项被选中时，分组项也要亮起来：浅主色底 + 主色字，一眼看出当前在「我的工具」里 */
.nav-item.nav-fold.is-parent,
.nav-item.nav-fold.is-parent:hover {
  color: var(--accent-text);
  font-weight: 700;
  background: var(--accent-soft);
}
.nav-item.nav-fold.is-parent .ico {
  color: var(--accent-text);
}
/* 子列表：折叠靠 max-height 收起（子项最多 6 个 × 38px，340px 足够）。
   不用 display:none —— 那样展开没有过渡，子项上的拖拽绑定也会丢 */
.nav-subs {
  max-height: 340px;
  overflow: hidden;
  transition: max-height 280ms var(--ease), opacity 200ms var(--ease);
}
.nav-subs.is-collapsed {
  max-height: 0;
  opacity: 0;
}
.nav-list.nav-tools {
  /* 与一级项共用同一块滑动高亮：层级压平，别再开一层叠上下文把滑块盖住 */
  z-index: auto;
  margin: 2px 0;
  padding-left: 11px;
}
/* 一条细竖线点出层级：这些子项属于上面那个分组 */
.nav-list.nav-tools::before {
  content: '';
  position: absolute;
  left: 1px;
  top: 5px;
  bottom: 5px;
  width: 1px;
  background: var(--border);
}
.nav-item.nav-sub {
  height: 38px;
  font-size: 13px;
}
.nav-item.nav-sub .ico svg {
  width: 16px;
  height: 16px;
}
.nav-action {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 15px;
  color: var(--muted-2);
  opacity: 0;
  transition: all var(--dur-1) var(--ease);
  flex: none;
}
.nav-item:hover .nav-action {
  opacity: 1;
}
.nav-action:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-empty {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--muted-2);
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}
/* 左下角「头像 + 昵称 + 邮箱」：整块可点，直达个人中心 */
.user-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.user-card:hover {
  background: var(--surface-hover);
}
.avatar {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--grad-accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar.has-img {
  background: var(--surface-soft);
}
.user-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.user-name {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-mail {
  display: block;
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-go {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--muted-2);
  transition: transform var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.user-card:hover .user-go {
  color: var(--accent-text);
  transform: translateX(2px);
}
.user-ops {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
}
.sidebar-mask {
  display: none;
}

/* ---------- 主题切换：浅色 / 深色 / 跟随系统 ---------- */
.theme-wrap {
  position: relative;
  flex: none;
}
.theme-menu {
  position: absolute;
  /* 主题按钮在左下角，菜单必须朝右展开：朝左会顶出侧边栏边界被裁掉。
     菜单 156px + 左侧 12px 内边距，268px 的侧边栏完全装得下。 */
  left: -6px;
  right: auto;
  bottom: calc(100% + 8px);
  z-index: 60;
  min-width: 156px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  display: grid;
  gap: 2px;
  border-radius: var(--r-md);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--sh-3), var(--sh-inset);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.96);
  transform-origin: bottom left;
  transition: opacity var(--dur-1) var(--ease), transform var(--dur-2) var(--ease-spring),
    visibility var(--dur-1) var(--ease);
}
.theme-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.theme-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.theme-opt:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.theme-opt:active {
  transform: scale(0.98);
}
.theme-ic {
  width: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.theme-tx {
  flex: 1;
}
.theme-tick {
  font-size: 12px;
  color: var(--accent-text);
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease);
}
.theme-opt.is-active {
  background: var(--grad-accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.theme-opt.is-active .theme-ic {
  color: var(--accent-text);
}
.theme-opt.is-active .theme-tick {
  opacity: 1;
}

/* 主区 */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 34px;
  transition: padding var(--dur-2) var(--ease), background var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
  border-bottom: 1px solid transparent;
}
.topbar.is-scrolled {
  padding: 12px 34px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom-color: var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.menu-btn {
  display: none;
}
.topbar-title {
  flex: 1;
  min-width: 0;
}
.topbar-title h2 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

/* 页面容器 */
.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 34px 60px;
}
.page-inner {
  max-width: 1320px;
  margin: 0 auto;
  /* 用 backwards 而非 both：both 会让动画结束后 transform 一直保持为矩阵值，
     从而给 position:fixed 的拖拽元素造出包含块，导致拖拽定位偏移 */
  animation: pageIn 460ms var(--ease) backwards;
}
@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 卡片进场（网格子项错峰） */
.tool-grid > *,
.anime-grid > *,
.med-grid > *,
.result-grid > *,
.icon-grid > *,
.stats > * {
  /* 同 pageIn：不用 both，避免动画结束后 transform 被钉住、盖掉拖拽的内联 transform */
  animation: rise 520ms var(--ease) backwards;
}
.tool-grid > *:nth-child(1),
.anime-grid > *:nth-child(1),
.med-grid > *:nth-child(1),
.result-grid > *:nth-child(1),
.icon-grid > *:nth-child(1),
.stats > *:nth-child(1) {
  animation-delay: 40ms;
}
.tool-grid > *:nth-child(2),
.anime-grid > *:nth-child(2),
.med-grid > *:nth-child(2),
.result-grid > *:nth-child(2),
.icon-grid > *:nth-child(2),
.stats > *:nth-child(2) {
  animation-delay: 80ms;
}
.tool-grid > *:nth-child(3),
.anime-grid > *:nth-child(3),
.med-grid > *:nth-child(3),
.result-grid > *:nth-child(3),
.icon-grid > *:nth-child(3),
.stats > *:nth-child(3) {
  animation-delay: 120ms;
}
.tool-grid > *:nth-child(4),
.anime-grid > *:nth-child(4),
.med-grid > *:nth-child(4),
.result-grid > *:nth-child(4),
.icon-grid > *:nth-child(4),
.stats > *:nth-child(4) {
  animation-delay: 160ms;
}
.tool-grid > *:nth-child(n + 5),
.anime-grid > *:nth-child(n + 5),
.med-grid > *:nth-child(n + 5),
.result-grid > *:nth-child(n + 5),
.icon-grid > *:nth-child(n + 5),
.stats > *:nth-child(n + 5) {
  animation-delay: 200ms;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 首页 ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: linear-gradient(120deg, var(--grad-accent-soft), transparent 70%), var(--surface);
  box-shadow: var(--sh-1);
  padding: 30px 34px;
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft-2), transparent 68%);
  pointer-events: none;
}
.hero-text {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.hero-eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 8px;
}
.hero-title {
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.28;
}
/* 逐行遮罩入场：.title-line 只负责裁切（高度不变），.line-in 才是被移动的那层 */
.hero-title .title-line {
  display: block;
  overflow: hidden;
}
.hero-title .line-in {
  display: block;
  transform: translateY(105%);
  animation: titleLineUp 860ms var(--ease-spring) both;
}
.hero-title .title-line:nth-child(2) .line-in {
  animation-delay: 150ms;
}
@keyframes titleLineUp {
  from {
    transform: translateY(105%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hero-title .line-in {
    animation: none;
    transform: none;
    opacity: 1;
  }
}
.hero-title em {
  font-style: normal;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  font-size: 13.5px;
  color: var(--text-2);
  margin-top: 8px;
}
.hero-actions {
  display: flex;
  gap: 10px;
  flex: none;
  position: relative;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(228px, 1fr));
  gap: 16px;
}
.stat {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline), transparent);
  opacity: 0.6;
}
.stat:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
/* 可点击跳转：手型光标 + 右侧箭头，hover 时箭头右移给出暗示 */
.stat[data-stat] {
  cursor: pointer;
}
.stat-go {
  margin-left: auto;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  transition: transform var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.stat-go svg {
  width: 20px;
  height: 20px;
}
.stat[data-stat]:hover .stat-go,
.stat[data-stat]:focus-visible .stat-go {
  transform: translateX(3px);
  color: var(--accent-text);
}
.stat[data-stat]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* 触屏没有 hover：点按位移会在手指离开后残留，这里只保留箭头变色 */
@media (hover: none) {
  .stat[data-stat]:hover {
    transform: none;
  }
}
.stat-icon {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: var(--sh-inset);
}
.stat-icon .ico svg {
  width: 22px;
  height: 22px;
}
.stat-body {
  min-width: 0;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.stat-value {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.stat-unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 3px;
}
.stat-foot {
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 2px;
}
.stat-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.ring-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.pct-ring {
  position: relative;
  width: 76px;
  height: 76px;
  flex: none;
}
.pct-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.ring-b,
.ring-f {
  fill: none;
  stroke-width: 5;
}
.ring-b {
  stroke: var(--surface-sunken);
}
.ring-f {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  animation: ringDraw 1000ms var(--ease) both;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
@keyframes ringDraw {
  from {
    stroke-dashoffset: var(--circ);
  }
  to {
    stroke-dashoffset: var(--target);
  }
}
.ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  font-family: var(--font-num);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* 工具卡 */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 16px;
}
.tool-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline), transparent);
  opacity: 0.55;
}
.tool-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.tool-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  box-shadow: var(--sh-inset);
  transition: transform var(--dur-2) var(--ease-spring);
}
.tool-icon .ico svg {
  width: 22px;
  height: 22px;
}
.tool-card:hover .tool-icon {
  transform: scale(1.08) rotate(-4deg);
}
.tool-card h4 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* 「全部工具」里已添加的工具标一个角标，避免和未添加项混淆 */
.tool-added {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: var(--r-full);
  color: var(--accent-text);
  background: var(--grad-accent-soft);
  border: 1px solid var(--accent-ring);
}
.tool-card.is-added {
  border-color: var(--accent-ring);
}
.tool-card p {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  min-height: 38px;
}
.tool-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
}

.drag-hint {
  font-size: 12px;
  color: var(--muted-2);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.drag-hint::before {
  content: "";
  width: 14px;
  height: 8px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--muted-2) 0 2px, transparent 2px 4px);
  opacity: 0.7;
}

/* ---------- 追番 ---------- */
.anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 20px;
  /* 同一行的卡片必须等高、顶边对齐 */
  align-items: stretch;
}
.anime-card {
  position: relative;
  /* 整卡可点开编辑（见 ui.js bindCardActivate）；操作按钮仍有各自行为 */
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
  /* 卡片宽度决定操作区能放几个按钮：用容器查询按「卡片自身宽度」切换，
     而不是按视口——同一屏里 4 列和 2 列的卡片宽度差一倍，媒体查询管不了 */
  container-type: inline-size;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.anime-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.anime-cover {
  position: relative;
  aspect-ratio: 3 / 5;
  background: var(--surface-sunken);
  overflow: hidden;
}
.anime-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 620ms var(--ease), filter var(--dur-2) var(--ease);
}
.anime-card:hover .anime-cover img {
  transform: scale(1.06);
}
.anime-cover::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.62));
  pointer-events: none;
}
.anime-cover .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted-2);
  background: repeating-linear-gradient(
    135deg,
    var(--surface-soft) 0 8px,
    transparent 8px 16px
  );
}
.badge {
  position: absolute;
  z-index: 2;
  left: 10px;
  top: 10px;
  height: 22px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.badge-watching {
  background: linear-gradient(135deg, #ff9152, #f0492f);
}
.badge-finished {
  background: linear-gradient(135deg, #34d399, #0f9d63);
}
.badge-paused {
  background: linear-gradient(135deg, #fbbf24, #b45309);
}
.badge-plan {
  background: linear-gradient(135deg, #7dd3fc, #0284c7);
}
.badge-dropped {
  background: linear-gradient(135deg, #94a3b8, #475569);
}

.anime-card-body {
  padding: 13px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  /* 吃掉网格拉伸出来的多余高度，保证各卡片底部按钮在同一水平线 */
  flex: 1;
}
.anime-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.epic {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.epic b {
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 800;
}
.anime-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--muted-2);
  /* 待看徽标与文字混排，固定行高保证各卡片这一行一样高 */
  height: 20px;
  line-height: 20px;
}
/* 空副行（已完结且无待看、想看而未填上线日）：只占位，不显示内容。
   高度必须保留（20px，继承自 .anime-sub）——它撑住的是整行的位置，
   省掉这一行会让下方平台标签在网格里与相邻卡片错位 */
.anime-sub.is-empty {
  visibility: hidden;
}
/* 更新日文字可以省略号截断，但绝不能把后面的「待看 X」一起裁掉 */
.anime-sub-txt {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.anime-sub .tiny-badge {
  flex: none;
  margin-left: 0;
}
/* 「已看完」用成功色，与橙色的「待看 N」区分开：
   前者是完成态，后者是待办态。app.css 只覆写了 tiny-badge 的
   padding/font/radius，没碰 background/color，所以这里生效 */
.anime-sub .tiny-badge.is-done {
  background: var(--ok-soft);
  color: var(--ok);
}
/* 三色集数进度条：已看 / 待看 / 未更新 */
.epic-bar {
  display: flex;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--border);
}
.epic-bar i {
  display: block;
  height: 100%;
  transition: width var(--dur-3) var(--ease);
}
.epic-bar .seg-watched {
  background: var(--grad-accent);
}
.epic-bar .seg-pending {
  background: linear-gradient(90deg, #ffd06a, #f2972a);
}
.epic-bar .seg-rest {
  background: var(--border);
}
.epic-bar.is-empty {
  opacity: 0.55;
}
/* 卡片上的「自动更新」开关：不满足条件时留空行占位，保证各卡片等高 */
.auto-row {
  display: flex;
  align-items: center;
  min-height: 22px;
}
.auto-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px 0 7px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.auto-chip .auto-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.auto-chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
  color: var(--accent-text);
}
.auto-chip.is-on .auto-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auto-chip:hover {
  border-color: var(--border-strong);
}
.auto-chip.is-busy {
  opacity: 0.55;
  pointer-events: none;
}
/* 开了开关但没填「更新日」：没有触发依据，做淡处理（悬停提示里写明原因） */
.auto-chip.is-idle {
  border-style: dashed;
}

/* 平台：Logo + 名称 */
.platform-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  align-items: center;
  /* 固定最小高度：没有平台或平台多时高度保持一致，卡片不会被内容顶高 */
  min-height: 25px;
  overflow: hidden;
}
.plat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 7px 2px 3px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 11px;
  line-height: 1.2;
  color: var(--text-2);
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.plat-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.plat-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.platform-row .plat-logo {
  width: 19px;
  height: 19px;
  border-radius: 5px;
  font-size: 9px;
}
.plat-item.plat-more {
  padding: 2px 8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card-actions {
  display: flex;
  gap: 6px;
  /* 贴底：卡片被拉高时按钮始终落在同一水平线 */
  margin-top: auto;
  padding-top: 4px;
}

/* ---------- 动漫卡片操作条 ----------
   与药品卡片的操作区同一套语言：一颗颗分立的描边按钮，而不是一条被竖线切开的
   工具条。统一 32px 高 / 9px 圆角 / 1px 边框 / 15px 图标 / 0.16s 过渡，
   只靠语义色分层——主操作（开始追番 / 重新追番）静态就是主色，
   常规操作（已看 / 更新 / 编辑）悬停才转主色，删除悬停转红。 */
.act-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.act-bar > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-solid);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
    background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease);
}
/* 分立按钮不再需要格子之间的竖线 */
.act-bar > * + *::before {
  content: none;
}
.act-bar > *:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.act-bar > *:active {
  transform: translateY(0) scale(0.96);
  box-shadow: var(--sh-1);
}
.act-bar > *:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.act-bar .ico svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
}

/* 常规主操作：已看 / 更新 —— 静态中性，悬停才点出主色 */
.act-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background: var(--accent-soft);
}
/* 开始追番 / 重新追番：卡片上真正的主操作，静态就带主色，免得和编辑 / 删除混成一片 */
.act-btn.is-go {
  color: var(--accent);
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
  background: var(--accent-soft);
}
.act-btn.is-go:hover {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

/* 编辑 / 删除：正方形图标按钮，与前一个按钮同高同圆角 */
.act-ico {
  width: 32px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.act-ico:hover {
  background: var(--surface-soft);
}
.act-ico:hover {
  color: var(--accent);
  border-color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background: var(--accent-soft);
}
.act-ico.is-danger:hover {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}
/* 已完结：没有主操作，编辑 / 删除补上文字标签，宽度随内容 */
.act-ico.is-wide {
  width: auto;
}

/* ---------- 四种状态各自的排布 ----------
   卡片可用宽度 = 卡片宽 - 左右内距 28px：桌面最小 196px → 168px，窄屏 148px → 120px。
   一行放得下是硬约束，按钮数量又不同（4 / 2 / 3 / 3），所以分配方式必须分开算：
   少的平分整行还能带文字，多的只能等分成纯图标格。 */

/* ① 追更中：已看 / 更新 / 编辑 / 删除 —— 四个最多，等分成四格，
   平分后每格只够放一个图标，文字留给够宽的卡片（见下面的容器查询） */
.act-bar.st-watching {
  gap: 6px;
}
.act-bar.st-watching > * {
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
}
.act-bar.st-watching .act-btn .txt {
  display: none;
}

/* ② 已完结：编辑 / 删除 —— 只有两个，平分整行，图标 + 文字都放得下 */
.act-bar.st-finished > .act-ico.is-wide {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  padding: 0 8px;
}

/* ③④ 想看 / 弃番：主操作（开始追番 / 重新追番）+ 编辑 + 删除。
   这两个主操作必须带文字——光靠图标说不清「开始」和「重新」的区别——
   所以主操作吃掉剩余宽度，间距和内距都让一档出来给文字 */
.act-bar.st-plan,
.act-bar.st-dropped {
  gap: 6px;
}
.act-bar.st-plan .act-btn.is-go,
.act-bar.st-dropped .act-btn.is-go {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 8px;
}
.act-bar.st-plan .act-btn.is-go .txt,
.act-bar.st-dropped .act-btn.is-go .txt {
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 短文案默认不出场，只有极窄卡片才顶替完整文案 */
.act-bar .act-btn .txt-s {
  display: none;
}

/* 卡片够宽时（≥ 250px）：追更中的「已看 / 更新」把文字放回来，
   主操作分 2 份、图标格 1 份，字才不会被挤掉 */
@container (min-width: 250px) {
  .act-bar.st-watching > * {
    padding: 0 10px;
  }
  .act-bar.st-watching .act-btn {
    flex: 2 1 0;
  }
  .act-bar.st-watching .act-btn .txt {
    display: inline;
  }
}

/* 卡片不够宽（≤ 220px）：三按钮的主操作也只留图标。
   220px 是算出来的临界值——卡片 220 → 可用 192px，主操作只分到 112px，
   而「开始追番」连图标带字要 91px，再窄就只能截断了，不如直接收成图标格。
   只有两个按钮的已完结卡反而空间富余，文字照常显示 */
@container (max-width: 220px) {
  .act-bar {
    gap: 5px;
  }
  .act-bar > * {
    height: 30px;
    font-size: 11.5px;
  }
  .act-ico {
    width: 30px;
  }
  .act-bar.st-watching > * {
    padding: 0;
  }
  .act-bar.st-plan,
  .act-bar.st-dropped {
    gap: 4px;
  }
  .act-bar.st-plan .act-btn.is-go,
  .act-bar.st-dropped .act-btn.is-go {
    padding: 0 6px;
  }
  .act-bar.st-finished > .act-ico.is-wide {
    padding: 0 6px;
  }
}
/* 极窄卡片（≤ 200px）：「开始追番 / 重新追番」换短文案，图标格再收一档——
   这是它们还能保持一行带字的极限，再窄就真的只能留图标了 */
@container (max-width: 200px) {
  .act-bar .act-btn.is-go .txt {
    display: none;
  }
  .act-bar .act-btn.is-go .txt-s {
    display: inline;
  }
  .act-ico {
    width: 28px;
  }
}

/* 进度条 */
.bar {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  overflow: hidden;
  position: relative;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-accent);
  position: relative;
  overflow: hidden;
  transition: width 700ms var(--ease);
}
.bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%);
  animation: sheen 2.6s var(--ease) infinite;
}
@keyframes sheen {
  0% {
    transform: translateX(-100%);
  }
  60%,
  100% {
    transform: translateX(220%);
  }
}

/* ---------- 药品 ---------- */
.med-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.med-card {
  position: relative;
  /* 整卡可点开编辑（见 ui.js bindCardActivate）；封面/入库等按钮仍有各自行为 */
  cursor: pointer;
  overflow: hidden;
  display: flex;
  gap: 16px;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.med-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline), transparent);
  opacity: 0.55;
}
.med-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.med-cover {
  width: 100px;
  height: 100px;
  flex: none;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-sunken);
  display: grid;
  place-items: center;
  color: var(--muted-2);
  font-size: 11.5px;
  border: 1px solid var(--border);
}
.med-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 620ms var(--ease);
}
.med-card:hover .med-cover img {
  transform: scale(1.06);
}
/* 封面即上传入口：有图时 hover 出角标，无图时角标常显（触屏没有 hover） */
.med-cover {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  position: relative;
  display: block;
}
.med-cover-tip {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: rgba(24, 21, 19, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 180ms var(--ease), background 180ms var(--ease);
}
.med-cover-tip .ico svg {
  width: 13px;
  height: 13px;
}
.med-cover:hover .med-cover-tip {
  opacity: 1;
}
.med-cover:not(.has-img) .med-cover-tip {
  opacity: 1;
  background: var(--surface-solid);
  color: var(--muted);
  border: 1px solid var(--border);
}
/* 无封面占位：药丸图形 + 药品名首字，和追番「首字 + 暂无封面」同一套语言 */
.med-ph {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: linear-gradient(155deg, var(--p-50), var(--surface-soft));
  color: var(--p-700);
}
.med-ph .ph-ic {
  display: grid;
  place-items: center;
  opacity: 0.9;
}
.med-ph .ph-ic .ico svg {
  width: 30px;
  height: 30px;
  stroke-width: 1.5;
}
.med-ph .ph-tx {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (hover: none) {
  .med-cover-tip {
    opacity: 1;
  }
}
.med-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.med-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
.med-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  /* 名称独占一行，标签（库存 / 医保）折到下一行，避免名称被两个标签挤成省略号 */
  flex: 1 0 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.med-line {
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.med-line .k {
  color: var(--muted-2);
  flex: none;
  min-width: 40px;
  font-size: 11.5px;
}
.med-line .v {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* 「吃完」这类长文本允许换行，保证完整日期不被截断 */
.med-line .v.wrap {
  white-space: normal;
  overflow: visible;
  line-height: 1.5;
}
.med-bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  overflow: hidden;
  margin-top: 2px;
}
.med-bar i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-accent);
  transition: width 760ms var(--ease);
  position: relative;
  overflow: hidden;
}
.med-bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: translateX(-100%);
  animation: sheen 2.8s var(--ease) infinite;
}
.med-bar i.low {
  background: linear-gradient(135deg, #ff6b6b, #dc2626);
}
/* 续航刻度说明：第一行「续航 X / Y 天」，第二行「储备 N 个月 · 需备 …」。
   两行是定死的（原来是 flex-wrap，宽屏会把它们挤到同一行，读起来像一句绕口令），
   所以改成竖排；内部每个 <span> 自己还能在极窄屏里再折一次。 */
.med-scale {
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.med-scale .dot {
  color: var(--border-strong);
  /* 竖排后「·」不再是 flex 子项，原来的 gap 间距没了，得自己补回来 */
  margin: 0 3px;
}
/* 每日自动结算说明条 */
.settle-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 9px 14px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.settle-note .sn-ic {
  display: inline-flex;
  flex: 0 0 auto;
  color: var(--accent-text);
}
.settle-note .sn-ic .ico svg {
  width: 15px;
  height: 15px;
}
.settle-note .sn-text {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.med-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ---------- 药品卡片操作区：入库 / 编辑 / 删除 ----------
   app.css 后加载且大量使用 !important（关掉了阴影、位移、高光，并把 .btn-sm
   钉成 32px 高），导致「入库」与两个图标按钮高矮不一、交互全无。
   这里用更高特异性（.med-foot .btn = 0,2,0）配合 !important 压回去，
   让三种按钮共用一套尺寸、圆角、边框与反馈语言，只靠语义色区分。 */
.med-foot .btn {
  height: 32px !important;
  padding: 0 12px !important;
  gap: 6px !important;
  border-radius: 9px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em !important;
  line-height: 1 !important;
  flex: none;
  border: 1px solid var(--border) !important;
  background: var(--surface-solid) !important;
  color: var(--text-2) !important;
  box-shadow: var(--sh-1) !important;
  transform: none !important;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
    background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease) !important;
}
/* 通用按钮的径向高光在这组小按钮上发脏，关掉 */
.med-foot .btn::after {
  content: none !important;
}
.med-foot .btn .ico svg {
  width: 15px !important;
  height: 15px !important;
}
.med-foot .btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: var(--sh-2) !important;
}
.med-foot .btn:active {
  transform: translateY(0) scale(0.96) !important;
  box-shadow: var(--sh-1) !important;
}
.med-foot .btn:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
}

/* 入库：卡片上的主操作，静态就带品牌色，才不会和编辑/删除混成一片 */
.med-foot .btn[data-act='stock'] {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  border-color: color-mix(in srgb, var(--accent) 34%, transparent) !important;
  background: var(--accent-soft) !important;
}
.med-foot .btn[data-act='stock']:hover {
  color: #fff !important;
  border-color: var(--accent) !important;
  background: var(--accent) !important;
}

/* 编辑 / 删除：正方形图标按钮，与入库同高同圆角 */
.med-foot .btn.icon-btn {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  color: var(--muted) !important;
  background: transparent !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}
.med-foot .btn.icon-btn:hover {
  background: var(--surface-soft) !important;
  box-shadow: var(--sh-1) !important;
}
.med-foot .btn.icon-btn[data-act='edit']:hover {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  border-color: color-mix(in srgb, var(--accent) 38%, transparent) !important;
  background: var(--accent-soft) !important;
}
.med-foot .btn.icon-btn[data-act='del']:hover {
  color: var(--danger) !important;
  border-color: var(--danger-line) !important;
  background: var(--danger-soft) !important;
}

/* 预警值：窄卡片上「预警 30 天」一行放不下会挤到按钮，拆成两行右对齐 */
.med-foot .med-warn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1.25;
  text-align: right;
}
.med-warn .mw-k {
  font-size: 10.5px;
  color: var(--muted-2);
}
.med-warn .mw-v {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* 窄卡片时操作区不挤成一团：允许换行，预警值自然落到下一行 */
@media (max-width: 380px) {
  .med-foot {
    flex-wrap: wrap;
  }
}

/* ---------- 排班 ---------- */
.panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
  overflow: hidden;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.panel-head h3 {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.finder {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  gap: 12px;
}
.finder .spacer {
  flex: 1;
}
/* 人数 / 日期 / 临时加班 / 智能排班必须成行：宽度不够时整组换行，绝不裁掉按钮 */
.finder.nowrap {
  flex-wrap: nowrap;
  min-width: 0;
}
.finder.nowrap > .fitem,
.finder.nowrap > .btn-row {
  flex: 0 0 auto;
}
.finder.nowrap > .spacer {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 920px) {
  .finder.nowrap {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .finder.nowrap > .spacer {
    display: none;
  }
  /* 人数 / 日期在窄屏各占一整行：原来靠固定 132px 挤在一行里，
     一旦父容器不够宽（手机），.fitem 是 flex:0 0 auto 不会收缩，
     整个控件就被顶出面板边界——看起来就是「＋ 跑到输入框外面」。
     改成占满一行 + 宽度跟随容器，从根上避免溢出。 */
  .finder.nowrap > .fitem {
    flex: 1 1 100%;
    min-width: 0;
  }
  /* 步进器宽度按断点给死（见下方 .fitem .stepper 说明），这里不再重复定义：
     本块位置在基础规则之前，写在这里反而会被后面的同特异性规则覆盖掉。 */
}
/* 面板正文：面板内的列表 / 提示 / 预览都要有左右留白，不能贴着边框 */
.panel-body {
  padding: 16px 20px;
}
.panel-body.pb-tight {
  padding-top: 0;
}
.panel-body > *:last-child {
  margin-bottom: 0;
}
/* 面板头部需要容纳筛选控件时允许换行，避免挤压文字 */
.panel-head.wrap {
  flex-wrap: wrap;
  row-gap: 10px;
}
/* 行内「标签 + 控件」组合：统一基线，步进器给固定宽度而不是撑满 */
.fitem {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}
.flabel {
  font-size: 12.5px;
  color: var(--muted);
  flex: none;
  white-space: nowrap;
}
.fhint {
  font-size: 12.5px;
  color: var(--muted-2);
  flex: none;
}
/* 人数步进器：容器宽度必须按「按钮实际尺寸」给足，且要跟着断点走。
   根因：≤640px 的触屏规则（本文件上方 @media (max-width:640px)）会把 ± 按钮
   放大到 38px，而这里原先只按桌面 32px 算了一个 132px 的固定宽——
   38×2 + 数字区 52 + 间隙 4 = 132，已经超过 132px 容器扣掉 1px×2 边框和
   3px×2 内距后的 124px 内容区；两个按钮又是 flex:none 压不下，
   超出的部分在 overflow:visible 下就顶出边框——正是「＋ 号跑到输入框外面去了」。
   桌面端按钮小、余量够，所以只有手机端复现。 */
.fitem .stepper {
  /* 132px：按钮 32×2 + 数字区 52 + 间隙 4 = 120，≤ 内容区 124，桌面余 4px */
  width: 132px;
  flex: 0 0 132px;
  overflow: visible;
}
/* 触屏断点下按钮变成 38px，容器必须同步加宽，否则「＋」又会顶出去 */
@media (max-width: 640px) {
  .fitem .stepper {
    /* 148px：按钮 38×2 + 数字区 52 + 间隙 4 = 132，≤ 内容区 140，余 8px */
    width: 148px;
    flex: 0 0 148px;
  }
}
/* 按钮尺寸与圆角统一走 .stepper button，这里只留数字区的最小宽度（与桌面一致） */
.fitem .stepper input {
  min-width: 52px;
}
.fdate {
  /* 要放得下 yyyy-mm-dd 全写，否则会显示成 2026-10… */
  width: 150px;
  flex: none;
}
.panel-head .fdate {
  width: 148px;
}
/* 行尾按钮组：整体不参与伸缩，窗口变窄时整组换行，不会单独掉一个按钮 */
.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
/* 班次标签与下方说明之间的呼吸位 */
.preview-box {
  margin-top: 16px;
}

/* ---------- 工时统计：柱状图 + Tooltip + 下钻折线图 ---------- */
.hours-chart {
  position: relative;
}
/* 下钻时收起总览，只留下钻区 */
.hours-chart.is-drill .chart-head,
.hours-chart.is-drill .chart-plot,
/* 只收「柱状图那一层的」空态说明：下钻区里还有它自己的一句，
   两者共用 .chart-empty 样式，靠子选择器区分，别把下面那句也一起藏了 */
.hours-chart.is-drill > .chart-empty {
  display: none;
}
.chart-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chart-title {
  font-size: 13px;
  font-weight: 700;
}
.chart-sub {
  font-size: 11.5px;
  color: var(--muted);
}
.chart-plot {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.chart-axis {
  position: relative;
  flex: none;
  width: 34px;
  /* 与 .bar-track 同高：刻度线要对在槽的顶/中/底 */
  height: 150px;
}
.chart-axis .ax {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.chart-bars {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  /* 柱子有宽度上限后，富余空间靠均匀分布消化，柱子不会全挤在左边 */
  justify-content: space-around;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

/* 横向滚动：两侧渐隐提示「还有内容」。
   用 mask 而非渐变遮片，就不必猜容器底色（面板是半透明 + 背景模糊的）。 */
.chart-bars.fade-l,
.chart-scroll.fade-l {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 28px, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 28px, #000 100%);
}
.chart-bars.fade-r,
.chart-scroll.fade-r {
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent 100%);
}
.chart-bars.fade-l.fade-r,
.chart-scroll.fade-l.fade-r {
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 28px,
    #000 calc(100% - 28px),
    transparent 100%
  );
  mask-image: linear-gradient(
    90deg,
    transparent 0,
    #000 28px,
    #000 calc(100% - 28px),
    transparent 100%
  );
}
.chart-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  padding-bottom: 4px;
}
/* 折线图的纵轴单独一列，不随画布滚动、也不会被渐隐吃掉 */
.line-plot {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.line-axis {
  position: relative;
  flex: none;
  width: 28px;
  height: 230px;
}
.line-axis .lay {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-size: 10.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.chart-hint {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.bar-col {
  /* 列宽由内容决定 = max(灰槽 24px, 姓名宽度)，下限 34px 保住点击热区。
     之前写死 34px，名字一过三个字就被 ellipsis 吃掉（「张三丰」只剩「张三…」），
     现在长名字会自己把列撑开，人多了照样横向滚动而不是互相挤。 */
  flex: 0 0 auto;
  min-width: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.bar-track {
  position: relative;
  /* 灰槽宽度 = 实心柱宽度。列内居中，剩下的两侧空白只当列间距，
     这样灰底不再比柱身宽出一圈 */
  width: 24px;
  height: 150px;
  border-radius: 8px;
  background: var(--surface-sunken);
  overflow: hidden;
  transition: background var(--dur-2) var(--ease);
}
.bar-col:hover .bar-track,
.bar-col:focus-visible .bar-track {
  background: var(--surface-hover);
}
.bar-fill {
  position: absolute;
  /* 撑满灰槽：实心柱与灰色背景同宽，长出来的部分就是「完成了多少」 */
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  border-radius: 8px 8px 3px 3px;
  background: var(--grad-accent);
  box-shadow: 0 6px 18px var(--accent-glow);
  transition: height 760ms var(--ease-spring), filter var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
  transition-delay: var(--d, 0ms), 0ms, 0ms;
}
.hours-chart.is-grow .bar-fill {
  height: var(--h, 0%);
}
.bar-col:hover .bar-fill,
.bar-col:focus-visible .bar-fill {
  filter: brightness(1.12) saturate(1.05);
  box-shadow: 0 8px 22px var(--accent-glow);
}
.bar-name {
  display: block;
  /* 宽度跟着文字走（不再占满整列），名字多长就给多长的地；
     只有长到离谱（超过 8 个字）才在 96px 处打省略号 */
  width: auto;
  max-width: 96px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-2);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-col:hover .bar-name {
  color: var(--text);
}

/* Tooltip：悬停才显示具体数值与补充说明 */
.chart-tip {
  position: absolute;
  z-index: 6;
  min-width: 132px;
  max-width: 240px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--sh-2);
  display: grid;
  gap: 4px;
  pointer-events: none;
  animation: tipIn 160ms var(--ease) both;
}
.chart-tip b {
  font-size: 12.5px;
}
.tip-main {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}
.tip-sub {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.45;
}
.tip-hint {
  font-size: 11px;
  color: var(--muted-2);
}
@keyframes tipIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 下钻：每日工时折线图 */
.chart-drill {
  animation: drillIn 320ms var(--ease) both;
}
.drill-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.drill-head b {
  font-size: 14px;
}
/* 下钻头部的档位标签：总计工时 / 本月工时 / 本周工时 */
.drill-scope {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 9px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
/* 无记录时的空白图说明：坐标轴照画，只补一句「还没有排班记录」 */
.chart-empty {
  margin: 10px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted-2);
}
/* 总计 / 本月 / 本周 三档切换 + 总览 / 祥览 视图切换 + 人员切换，共用一套外观。
   position:relative 是必须的：滑动高亮块绝对定位在这个容器里 */
.drill-range {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
}
.drill-range[hidden] {
  /* [hidden] 自带的 display:none 会被上面的 display:inline-flex 盖掉，得自己声明 */
  display: none;
}
.range-chip {
  position: relative;
  /* 压在滑动高亮块上面：块 z-index:0，文字靠 z-index 抬起来 */
  z-index: 1;
  height: 24px;
  padding: 0 11px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.range-chip:hover {
  color: var(--text);
}
/* 选中态不再自己涂背景：底色交给那块会滑过去的高亮，
   文字位置与尺寸因此完全不动，只有底下那块在平移 / 改宽 */
.range-chip.is-active,
.range-chip.is-active:hover {
  background: transparent;
  box-shadow: none;
  color: #fff;
}
.line-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.line-chart .gl {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.line-chart .gt {
  font-size: 10.5px;
  fill: var(--muted-2);
  text-anchor: end;
  dominant-baseline: middle;
}
.line-chart .xt {
  font-size: 10.5px;
  fill: var(--muted-2);
  text-anchor: middle;
}
/* 日期下面那行周几：比日期再淡一号，凑近看才知道是工作日还是周末 */
.line-chart .xw {
  font-size: 9.5px;
  fill: var(--muted);
  text-anchor: middle;
  opacity: 0.72;
}
/* 祥览模式的人员切换行：人多就换行（窄屏下两行），所以圆角用 r-lg 而不是胶囊——
   一旦换行，999px 的圆角会把整个两行的框画成一个怪异的操场形 */
.person-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  margin-bottom: 12px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
}
.line-chart .area {
  fill: url(#lineArea);
  opacity: 0;
  animation: areaIn 700ms var(--ease) 300ms forwards;
}
.line-chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 2400);
  stroke-dashoffset: var(--len, 2400);
  animation: drawLine 1000ms var(--ease) forwards;
}
/* 数据点：小实心圆 + 一圈背景色描边，看起来是「落在折线上」的点，
   而不是压在基线上的一颗灰棋子。零值日不画点，整条基线因此干净了 */
.line-chart .dot {
  fill: var(--accent);
  stroke: var(--surface-solid);
  stroke-width: 1.6;
  stroke-linejoin: round;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: dotFade 340ms var(--ease) both;
  animation-delay: var(--d, 0ms);
  transition: transform 150ms var(--ease), filter 150ms var(--ease);
}
.line-chart .dot.is-hot {
  transform: scale(1.55);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}
/* 悬停当天的竖向参考线，比把整条折线加粗更克制 */
.line-chart .hot-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms var(--ease);
}
.line-chart .hot-line.is-on {
  opacity: 0.45;
}
.line-chart .hit {
  fill: transparent;
  cursor: crosshair;
}
.drill-hint {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted-2);
}
@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes areaIn {
  to {
    opacity: 1;
  }
}
@keyframes dotFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes dotIn {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes drillIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .bar-fill,
  .line-chart .line,
  .line-chart .area,
  .line-chart .dot,
  .chart-drill {
    animation: none;
  }
  .bar-fill {
    height: var(--h, 0%);
  }
  .line-chart .line {
    stroke-dashoffset: 0;
  }
  .line-chart .area,
  .line-chart .dot {
    opacity: 1;
  }
}

.person-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 8px 0 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--dur-1) var(--ease);
}
.person-tag:hover {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.person-tag .rm {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 10px;
  color: var(--muted-2);
  transition: all var(--dur-1) var(--ease);
}
.person-tag .rm:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
/* 请假：一段（可跨多天）一条，天数用徽标区分 */
.leave-tag {
  border-color: color-mix(in srgb, var(--warn, #f2972a) 40%, var(--border));
  background: color-mix(in srgb, var(--warn, #f2972a) 10%, var(--surface-soft));
}
.leave-tag .leave-days {
  display: inline-block;
  margin-left: 7px;
  padding: 0 7px;
  height: 18px;
  line-height: 18px;
  border-radius: var(--r-full);
  background: var(--grad-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* 请假抽屉里的天数摘要 */
.leave-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--border);
  background: var(--surface-sunken);
  font-size: 12.5px;
  color: var(--muted-2);
}
.leave-summary.is-on {
  border-style: solid;
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.leave-summary.is-on b {
  font-size: 15px;
  font-weight: 800;
}
.leave-summary .leave-dates {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.leave-summary.is-on .leave-dates {
  color: var(--accent-text);
  opacity: 0.8;
}

.shift-table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 16px;
}
.shift-block {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.shift-block:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-2);
}
/* 预览里撞车的班次：这一天这个班次已经排过，不允许再保存一次 */
.shift-block.is-conflict {
  border-color: color-mix(in srgb, var(--danger, #e04b3a) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger, #e04b3a) 22%, transparent) inset;
}
.conflict-tag {
  flex: none;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--danger, #e04b3a);
  background: color-mix(in srgb, var(--danger, #e04b3a) 14%, transparent);
}
.conflict-hint {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--danger, #e04b3a);
  background: color-mix(in srgb, var(--danger, #e04b3a) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #e04b3a) 26%, transparent);
  border-radius: var(--r-md, 10px);
  padding: 9px 12px;
}
.shift-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(120deg, var(--grad-accent-soft), transparent 80%);
}
.shift-head h4 {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}
.shift-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.assign {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  transition: all var(--dur-1) var(--ease);
}
[data-theme="light"] .assign {
  background: var(--surface-soft);
}
.assign:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.assign .who {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assign .hours {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.assign .ops {
  display: flex;
  gap: 3px;
  flex: none;
  opacity: 0.8;
}
.assign .ops .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.workstat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.workstat .assign {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
/* 工时统计：按人排列的等宽列，数值不再被面板底边切掉 */
.week-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 16px 14px;
}
.week-stats .who {
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-stats .hours {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.week-stats .stat-unit {
  font-size: 11px;
  margin-left: 1px;
}

.history-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  flex-wrap: wrap;
}
/* 排班记录：左边一条「日期 + 标签 + 合计」信息栏，右边班次块铺满剩余宽度。
   之前是上下单列，宽屏下只排出两个班次块，右侧空出一大片，像没加载完。 */
.history-item {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 4px 20px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur-1) var(--ease);
}
.history-item:last-child {
  border-bottom: 0;
}
.history-item:hover {
  background: var(--surface-hover);
}
.history-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}
.history-rail-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-date {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
/* 删除按钮平时压暗，整行悬停才亮起来：不必每行都挂一个醒目的红叉 */
.history-rail-top .icon-btn {
  margin-left: auto;
  opacity: 0.4;
  transition: opacity var(--dur-1) var(--ease);
}
.history-item:hover .history-rail-top .icon-btn,
.history-rail-top .icon-btn:focus-visible {
  opacity: 1;
}
.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.history-sum {
  font-size: 11.5px;
  color: var(--muted);
}
/* auto-fit 让已有的班次块把整行分掉，两个班次就各占一半，右边不再留白 */
.history-item .shift-table {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
/* 人员行补一个小号工时，右侧不至于只是一串图标 */
.assign-h {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 820px) {
  .history-item {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .history-rail {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
  }
  .history-rail-top .icon-btn {
    margin-left: 0;
  }
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}
.preset {
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  text-align: left;
  transition: all var(--dur-1) var(--ease);
}
.preset:hover {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.preset.is-active {
  border-color: var(--accent-ring);
  background: var(--grad-accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 封面 / 图标 / 结果网格 ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 18px;
}
/* 只有一条结果时：横版大卡，封面在左、信息与操作在右 */
.result-grid.single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 760px;
}
.result-grid.single .result-card {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  align-items: stretch;
}
.result-grid.single .result-thumb {
  aspect-ratio: auto;
  height: 100%;
  min-height: 196px;
}
.result-grid.single .result-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 20px 22px;
}
.result-grid.single .result-title {
  font-size: 15px;
  -webkit-line-clamp: 3;
}
.result-grid.single .result-foot {
  margin-top: 14px;
}
@media (max-width: 720px) {
  .result-grid.single .result-card {
    grid-template-columns: 1fr;
  }
  .result-grid.single .result-thumb {
    aspect-ratio: 16 / 9;
    min-height: 0;
  }
  .result-grid.single .result-body {
    padding: 14px 15px;
  }
}
.result-card {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease);
}
.result-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.result-thumb {
  aspect-ratio: 16 / 10;
  background: var(--surface-sunken);
  overflow: hidden;
  position: relative;
}
.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 620ms var(--ease);
}
.result-card:hover .result-thumb img {
  transform: scale(1.06);
}
.result-body {
  padding: 12px 13px;
}
.result-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-sub {
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 封面原图分辨率，图片加载完成后回填 */
.result-dims {
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.result-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px;
}
.icon-card {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.icon-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.icon-card.selected {
  border-color: var(--accent-ring);
  background: var(--grad-accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.icon-thumb {
  width: 62px;
  height: 62px;
  border-radius: 17px;
  overflow: hidden;
  background: var(--surface-sunken);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28), var(--sh-inset);
  transition: transform var(--dur-2) var(--ease-spring);
}
.icon-card:hover .icon-thumb {
  transform: scale(1.07) translateY(-2px);
}
.icon-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.icon-name {
  font-size: 12.5px;
  font-weight: 600;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.icon-sub {
  font-size: 11px;
  color: var(--muted-2);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-check {
  position: absolute;
  right: 9px;
  top: 9px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.6);
  transition: all var(--dur-2) var(--ease-spring);
  box-shadow: 0 3px 10px var(--accent-glow);
}
.icon-card.selected .icon-check {
  opacity: 1;
  transform: scale(1);
}

/* 封面选择器 */
.cover-picker {
  position: relative;
  width: 100%;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-sunken);
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--dur-2) var(--ease);
}
.cover-picker:hover {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}
.cover-picker.ratio-3-5 {
  aspect-ratio: 3 / 5;
  max-width: 220px;
}
.cover-picker.ratio-1-1 {
  aspect-ratio: 1 / 1;
  max-width: 180px;
}
/* file input：1px + 全透明，保留盒模型。用 display:none / hidden 会让部分移动浏览器
   不再把 label 的点击转发给它（点了没反应），所以只能这样藏。
   注意：不放在 .cover-picker 里，也不做负偏移——它是 label 的兄弟节点，
   兜底时加 .is-visible 就能正常显示在下方，不会被父级的 overflow/aspect-ratio 裁掉。 */
.cover-file {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
/* 兜底通道：自动唤不起系统选择器时，把原生控件真正显示出来给用户直接点 */
.cover-file.is-visible {
  position: static;
  width: auto;
  height: auto;
  max-width: 100%;
  margin-top: 8px;
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
  font-size: 13px;
}

/* 兜底提示：只在独立窗口唤不起文件选择器时才出现 */
.cover-tip {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* label 里的内容层：撑满选择器，预览图才能铺满整块 */
.cover-picker .cover-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.cover-picker img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted-2);
  font-size: 12px;
  padding: 14px;
  text-align: center;
}
.cover-empty .big {
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
}
.cover-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.dropzone {
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-sunken);
  padding: 34px;
  text-align: center;
  color: var(--muted);
  transition: all var(--dur-2) var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 300px;
}
.dropzone .empty-icon {
  margin: 0 0 8px;
}
.dropzone h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.dropzone p {
  font-size: 12.5px;
  color: var(--muted-2);
  margin: 0;
}
.dropzone:hover {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--text);
}

/* 搜索区 */
.search {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.findcard {
  display: flex;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  align-items: center;
}
/* 列表外壳：内部各自维护网格（anime-grid / med-grid），此处不参与排版 */
.grid-list {
  display: block;
}

/* ---------- 编辑器 ---------- */
.editor {
  display: grid;
  grid-template-columns: 1fr 296px;
  gap: 18px;
  align-items: start;
}
.editor-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* 上下对照：上面原图、下面处理结果 */
.editor-stage {
  min-width: 0;
}
.compare-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.compare-pane {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.cp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cp-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 700;
}
.cp-tag.is-original {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}
.cp-meta {
  font-size: 11.5px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.cp-body {
  display: grid;
  place-items: center;
  padding: 14px;
  min-height: 120px;
  background-image: linear-gradient(45deg, var(--surface-sunken) 25%, transparent 25%),
    linear-gradient(-45deg, var(--surface-sunken) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-sunken) 75%),
    linear-gradient(-45deg, transparent 75%, var(--surface-sunken) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.cp-body canvas {
  max-width: 100%;
  /* 两块画布 + 结果栏尽量落在同一屏内，方便直接上下对照 */
  max-height: clamp(150px, calc((100vh - 430px) / 2), 34vh);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
}
/* 结果栏：处理状态 / 输出尺寸 / 格式 / 预计大小 */
.result-bar {
  display: flex;
  align-items: center;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.rb-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-wrap: nowrap;
}
.rb-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.result-bar .rb-cell:first-child {
  flex: 1 1 170px;
}
.result-bar .rb-cell:not(:first-child) {
  flex: 0 0 auto;
  min-width: 68px;
}
.rb-k {
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.rb-v {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .result-bar {
    gap: 10px 14px;
    padding: 12px 14px;
  }
  .rb-actions {
    margin-left: 0;
    width: 100%;
  }
  .rb-actions .btn {
    flex: 1 1 0;
  }
}
.stage {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  box-shadow: var(--sh-1);
}
.stage canvas,
.stage img {
  max-width: 100%;
  max-height: 58vh;
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
}
.side-panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(10px);
}
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.slider-head span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 500;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-hover);
  box-shadow: inset 0 0 0 1px var(--border);
  outline: none;
  margin: 8px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--grad-accent);
  box-shadow: 0 2px 8px var(--accent-glow), 0 0 0 3px var(--bg);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.14);
}

/* ---------- 空态 / 错误态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  border-radius: var(--r-lg);
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}
.empty-icon {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--grad-accent-soft);
  color: var(--accent-text);
  margin-bottom: 2px;
}
.empty-icon .ico svg {
  width: 26px;
  height: 26px;
}
.error-state {
  padding: 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

/* ---------- 骨架屏 ---------- */
.skel {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    var(--surface-hover) 45%,
    rgba(255, 255, 255, 0.08) 50%,
    var(--surface-hover) 55%,
    transparent
  );
  animation: shimmer 1.35s infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}
.skel-card {
  height: 152px;
  border-radius: var(--r-lg);
}
.skel-line {
  height: 12px;
  margin-bottom: 9px;
}
.skel-text {
  width: 52%;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}
.toast {
  position: relative;
  padding: 12px 20px 12px 26px;
  border-radius: var(--r-md);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--sh-3);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  backdrop-filter: blur(20px) saturate(150%);
  animation: toastIn 460ms var(--ease-spring) both;
  max-width: min(78vw, 460px);
}
[data-theme="dark"] .toast {
  background: rgba(22, 24, 28, 0.92);
}
/* 状态圆点：绝对定位在 left:12px、宽 5px，也就是占住 12~17px 这一段。
   ⚠️ 因此 .toast 的左内边距必须 > 17px（style.css 里给的是 26px）。
   注意 app.css 会用 !important 覆盖 .toast 的 padding —— 它排在后面，
   改那条时必须同步留出 ≥24px 的左边距，否则文字会压在圆点上。
   圆点用 top:50%+translateY(-50%) 是为了在「单行」时正好垂直居中
   （行高固定 22px，9px 上内边距 + 11px = 20px，与 50% 完全吻合）。 */
.toast::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.toast.ok::before {
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}
.toast.err::before {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}
.toast.warn::before {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  animation: fade 260ms var(--ease) both;
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal {
  position: relative;
  width: min(412px, 100%);
  padding: 28px;
  border-radius: var(--r-xl);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--sh-3);
  animation: modalIn 420ms var(--ease-spring) both;
}
[data-theme="dark"] .modal {
  background: rgba(22, 24, 28, 0.96);
}
.modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline), transparent);
  opacity: 0.5;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}
.modal p {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.65;
  /* 安装指引这类多段文案靠 \n 分段，要保留换行 */
  white-space: pre-line;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---------- 抽屉 ---------- */
.drawer-root {
  position: fixed;
  inset: 0;
  z-index: 250;
}
.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
  animation: fade 260ms var(--ease) both;
}
.drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(60vw, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  box-shadow: -30px 0 70px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(20px) saturate(150%);
  animation: drawerIn 380ms var(--ease) both;
}
[data-theme="dark"] .drawer {
  background: rgba(17, 18, 22, 0.96);
}
@keyframes drawerIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: none;
  }
}
.drawer.closing {
  animation: drawerOut 200ms var(--ease) both;
}
@keyframes drawerOut {
  from {
    transform: none;
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0.6;
  }
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.drawer-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-ring), transparent 55%);
  opacity: 0.7;
}
.drawer-head h3 {
  flex: 1;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 26px;
}
.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}
/* 拖拽把手：默认不显示，只有窄屏 sheet 形态才出现 */
.drawer-grip {
  display: none;
}

/* ---------- 移动端底部面板（Bottom Sheet）----------
   窄屏下面板从右侧改为从底部升起：整宽、顶部圆角、把手可下滑关闭。
   断点取 900px，与底部 Tab 一致，PWA 独立窗口同样命中。
   表单类抽屉（新增追番 / 新增药品）走这个形态：手机上侧边抽屉只有 60vw 宽，
   表单控件被压得很窄，底部面板反而能铺满整行。 */
@media (max-width: 900px) {
  .drawer.is-sheet {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: 92vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 64px rgba(0, 0, 0, 0.5);
    animation: sheetIn 340ms var(--ease) both;
    /* 顶部圆角要能把内容裁掉，否则正文的方角会盖在圆角上 */
    overflow: hidden;
  }
  .drawer.is-sheet .drawer-body {
    /* 允许内部滚动，但滚到头时不把整页带着滚 */
    overscroll-behavior: contain;
  }
  .drawer.is-sheet.closing {
    animation: sheetOut 220ms var(--ease) both;
  }
  @keyframes sheetIn {
    from {
      transform: translateY(100%);
    }
    to {
      transform: none;
    }
  }
  @keyframes sheetOut {
    from {
      transform: none;
      opacity: 1;
    }
    to {
      transform: translateY(100%);
      opacity: 0.7;
    }
  }
  .drawer.is-sheet .drawer-grip {
    display: block;
    flex: none;
    width: 40px;
    height: 4px;
    margin: 4px auto 0;
    border-radius: 999px;
    background: var(--border-strong);
    /* 把手是唯一的拖拽区，给它足够的触摸面积（padding 只放大热区，不影响视觉宽度） */
    padding: 12px 44px;
    box-sizing: content-box;
    background-clip: content-box;
    /* 只禁掉把手自身的手势，正文区域仍可正常滚动 */
    touch-action: none;
  }
  .drawer.is-sheet .drawer-head {
    padding: 10px 18px 14px;
  }
  .drawer.is-sheet .drawer-body {
    padding: 16px 18px;
  }
  .drawer.is-sheet .drawer-foot {
    padding: 12px 18px;
    /* 刘海屏 / PWA 底部安全区：按钮不能被系统手势条压住 */
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  /* 底部面板上两个按钮平铺，拇指够得到，也不会挤在一行 */
  .drawer.is-sheet .drawer-foot .btn {
    flex: 1 1 0;
    justify-content: center;
    min-height: 44px;
  }
  .drawer.is-sheet .drawer-foot .spacer {
    display: none;
  }
}

/* ---------- 自定义平台 ---------- */
.custom-plat {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}
.custom-plat .hint {
  display: block;
  margin-top: 8px;
  line-height: 1.5;
}
.custom-plat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-plat-form .input {
  flex: 1;
  min-width: 0;
  height: 34px;
}
.plat-logo-pick {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--muted-2);
  cursor: pointer;
  flex: none;
  transition: all var(--dur-1) var(--ease);
}
.plat-logo-pick:hover {
  border-color: var(--accent-ring);
  color: var(--accent-text);
}
.plat-logo-pick.has-img {
  border-style: solid;
}

/* ---------- 拖拽 ---------- */
.sort-placeholder {
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--accent-ring);
  background: var(--accent-soft);
  transition: none;
}
.floating {
  position: fixed !important;
  z-index: 400;
  pointer-events: none;
  box-shadow: var(--sh-drag);
  transform-origin: center;
  border-color: var(--accent-ring) !important;
  transition: box-shadow 180ms var(--ease);
  /* 毛玻璃在跟随指针移动的元素上会每帧重采样背景，既卡顿又会出现内容残影 */
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  contain: paint;
  /* 卡片入场动画 rise 是 fill:both，动画结束后会一直把 transform 钉成 none，
     优先级高于内联样式，导致拖拽时卡片不跟手——这里必须彻底关掉 */
  animation: none !important;
}
/* 拖拽中：其它元素不做 hover 位移，保证让位动画干净 */
body.is-dragging {
  cursor: grabbing;
}
body.is-dragging .tool-card:hover,
body.is-dragging .nav-item:hover,
body.is-dragging .stat:hover {
  transform: none;
}
/* 只给让位的卡片加 will-change；被拖元素自己靠 fixed + transform 合成 */
.is-sorting > *:not(.floating) {
  will-change: transform;
}
[data-key].floating.tool-card,
[data-key].floating.nav-item {
  cursor: grabbing;
}
/* 侧边栏菜单本身是透明底，浮起来后必须补一层实底，否则拖动时像「隐形」 */
[data-key].floating.nav-item {
  background: var(--surface-solid);
  border: 1px solid var(--accent-ring);
  border-radius: var(--r-md);
  color: var(--text);
}
/* 占位块与菜单项保持同一圆角 */
#nav-mine > .sort-placeholder,
#nav-all > .sort-placeholder {
  border-radius: var(--r-md);
}

/* ---------- 工具页：介绍卡 + 统一高度搜索栏 ---------- */
.tool-hero {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  padding: 20px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  position: relative;
  overflow: hidden;
}
.tool-hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -90px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 68%);
  pointer-events: none;
}
.tool-hero .hero-ic {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent);
}
.tool-hero .hero-ic svg {
  width: 21px;
  height: 21px;
}
.tool-hero .hero-main {
  min-width: 0;
}
.tool-hero h3 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tool-hero p {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  margin-top: 5px;
  max-width: 64ch;
}
.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}
.hero-chip {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

/* 搜索栏：输入框 / 下拉 / 按钮统一 48px，靠 stretch 保证基线对齐 */
.searchbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.sb-field {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 8px 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.sb-field:hover {
  border-color: var(--border-strong);
}
.sb-field:focus-within {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.sb-field .sb-ic {
  display: grid;
  place-items: center;
  color: var(--muted-2);
  flex: none;
}
.sb-field .sb-ic svg {
  width: 16px;
  height: 16px;
}
.sb-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
}
.sb-field input::placeholder {
  color: var(--muted-2);
}
.sb-field input:focus {
  outline: none;
}
.sb-clear {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: none;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
}
.sb-clear.is-show {
  display: grid;
}
.sb-clear:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.searchbar .sb-select {
  height: 48px;
  flex: none;
  width: 118px;
  border-radius: 14px;
  padding: 0 32px 0 13px;
  background-position: calc(100% - 17px) 21px, calc(100% - 12px) 21px;
}
.searchbar .sb-btn {
  height: 48px;
  flex: none;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 14px;
}
.searchbar .sb-btn svg {
  width: 16px;
  height: 16px;
}
.searchbar .sb-btn[disabled] {
  opacity: 0.7;
  cursor: progress;
}

/* 历史搜索 */
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
}
.hr-label {
  flex: none;
  font-size: 12px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}
.hr-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 1 auto;
  min-width: 0;
}
.hr-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 220px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.hr-chip > * {
  pointer-events: none;
}
.hr-chip span.hr-x {
  pointer-events: auto;
}
.hr-chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.hr-chip .hr-x {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  color: var(--muted-2);
}
.hr-chip .hr-x:hover {
  background: var(--surface-sunken);
  color: var(--text);
}
.hr-clear {
  flex: none;
  font-size: 12px;
  color: var(--muted-2);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px 2px;
}
.hr-clear:hover {
  color: var(--text);
}

/* 多选操作条 */
.select-bar {
  margin-top: 14px;
  padding: 9px 12px 9px 14px;
  gap: 10px;
  border-radius: 14px;
  border: 1px solid var(--accent-ring);
  background: var(--accent-soft);
}
.select-bar[hidden] {
  display: none;
}
.sel-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
}

/* 引导卡：结果为空时的三步说明 */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.guide-card {
  padding: 16px 16px 15px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.guide-card .guide-n {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 800;
  margin-bottom: 10px;
}
.guide-card h4 {
  font-size: 13px;
  font-weight: 700;
}
.guide-card p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  margin-top: 5px;
}

@media (max-width: 640px) {
  .searchbar {
    gap: 8px;
  }
  .sb-field {
    flex: 1 1 100%;
  }
  .searchbar .sb-select {
    flex: 1 1 0;
    width: auto;
  }
  .searchbar .sb-btn {
    flex: 1 1 100%;
  }
  .tool-hero {
    padding: 16px;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .editor {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 290px;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 320ms var(--ease);
    box-shadow: var(--sh-3);
  }
  .sidebar.open {
    transform: none;
  }
  .sidebar-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease);
  }
  .sidebar-mask.show {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-close {
    display: inline-grid;
  }
  .menu-btn {
    display: inline-grid;
  }
  .topbar {
    /* 装成 PWA 后 iOS 状态栏是透明的（black-translucent），内容要自己往下让一段，
       否则标题会被时间 / 电量压住；env() 在浏览器里是 0，不影响普通网页 */
    padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  }
  .topbar.is-scrolled {
    padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  }
  .page {
    padding: 4px 18px 48px;
  }
  .drawer {
    width: 100vw;
    border-radius: 0;
  }
  .hero {
    padding: 24px 22px;
  }
  .hero-title {
    font-size: 22px;
  }
}

@media (max-width: 720px) {
  /* 移动端顶栏只保留主操作，避免标题被挤成竖排 */
  .topbar-actions .btn-ghost {
    display: none;
  }
  .topbar-actions .btn:not(.btn-primary) {
    padding: 0 10px;
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  /* 移动端统计卡统一整行，信息层级更清晰 */
  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stat {
    padding: 13px 15px;
    gap: 12px;
    align-items: center;
  }
  .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }
  .stat-icon .ico svg {
    width: 18px;
    height: 18px;
  }
  .stat-label {
    font-size: 11.5px;
  }
  .stat-value {
    font-size: 21px;
  }
  .stat-foot {
    font-size: 11px;
  }
  .stats .stat:has(.ring-wrap) {
    grid-column: auto;
  }
  .ring-wrap {
    width: 100%;
    justify-content: flex-start;
  }
  .anime-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 14px;
  }
  /* 窄屏：字号收一号给按钮腾地方。
     真正的排布（几个按钮怎么分、文字留不留）交给 .act-bar 上的容器查询——
     它按卡片自身宽度判断，比按视口准：同一屏里 4 列和 2 列的卡片差一倍宽 */
  .act-bar {
    gap: 6px;
    padding-top: 10px;
  }
  .act-bar > * {
    font-size: 11.5px;
    gap: 4px;
  }
  .act-bar .ico svg {
    width: 14px;
    height: 14px;
  }
  .med-grid {
    grid-template-columns: 1fr;
  }
  .auth-stage {
    gap: 22px;
  }
  /* 选择器要带 #auth-view：主规则用的就是 #auth-view .auth-title，
     这里降级写成 .auth-title 会因特异性更低而不生效 */
  #auth-view .auth-title {
    font-size: 26px !important;
    margin-bottom: 20px !important;
  }
  .topbar-title h2 {
    font-size: 18px;
  }
  .topbar-title p {
    font-size: 11.5px;
  }
  .toast-wrap {
    bottom: 20px;
  }
}

/* ---------- 指针柔光（跟随鼠标的高光层） ---------- */
.tool-card::after,
.stat::after,
.med-card::after,
.result-card::after,
.icon-card::after,
.shift-block::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
  background: radial-gradient(
    260px circle at var(--mx, 50%) var(--my, 0%),
    var(--accent-soft),
    transparent 62%
  );
}
.tool-card:hover::after,
.stat:hover::after,
.med-card:hover::after,
.result-card:hover::after,
.icon-card:hover::after,
.shift-block:hover::after {
  opacity: 0.9;
}
/* 卡片内容需压在柔光层之上 */
.tool-card > *,
.stat > *,
.med-card > *,
.result-card > *,
.icon-card > *,
.shift-block > * {
  position: relative;
  z-index: 2;
}

/* ---------- 主题润色 ---------- */
[data-theme="light"] .hero {
  background: radial-gradient(60% 120% at 4% 0%, rgba(255, 122, 69, 0.2), transparent 62%),
    radial-gradient(40% 100% at 96% 100%, rgba(224, 52, 42, 0.1), transparent 60%), var(--surface);
  border-color: rgba(224, 52, 42, 0.16);
  box-shadow: 0 1px 2px rgba(224, 52, 42, 0.05), 0 14px 34px rgba(224, 52, 42, 0.07);
}
[data-theme="light"] .sidebar {
  background: #fff;
  box-shadow: 1px 0 0 var(--border), 12px 0 40px rgba(16, 18, 27, 0.03);
}
[data-theme="light"] .badge {
  box-shadow: 0 2px 8px rgba(16, 18, 27, 0.18);
}
[data-theme="dark"] .auth-bg {
  opacity: 1;
}
[data-theme="dark"] .tool-card,
[data-theme="dark"] .anime-card,
[data-theme="dark"] .med-card,
[data-theme="dark"] .stat,
[data-theme="dark"] .result-card,
[data-theme="dark"] .icon-card,
[data-theme="dark"] .shift-block {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.055);
}
[data-theme="dark"] .tool-card:hover,
[data-theme="dark"] .anime-card:hover,
[data-theme="dark"] .med-card:hover,
[data-theme="dark"] .stat:hover,
[data-theme="dark"] .result-card:hover,
[data-theme="dark"] .icon-card:hover,
[data-theme="dark"] .shift-block:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 18px 44px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

@media (max-width: 900px) {
  .hero-actions {
    width: 100%;
  }
  .hero-actions .btn {
    flex: 1;
  }
}

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

/* ---------- 个人中心 ---------- */
.profile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.profile-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
}
.ph-avatar {
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 22px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 8px 22px var(--accent-glow);
}
.ph-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ph-main {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ph-id {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.ph-id h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.ph-account {
  font-size: 12.5px;
  color: var(--muted);
}
.ph-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ph-chip {
  height: 26px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
  color: var(--text-2);
}
.ph-theme {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}
.ph-theme-label {
  font-size: 11.5px;
  color: var(--muted-2);
}
.ph-theme-opts {
  display: flex;
  gap: 6px;
}
.pf-theme-btn {
  height: 32px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--dur-1) var(--ease);
}
.pf-theme-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.pf-theme-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-text);
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.profile-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: all var(--dur-2) var(--ease);
}
.profile-tab:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.profile-tab.is-active {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}
.profile-tab .tab-ic {
  font-size: 18px;
  line-height: 1;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.profile-tab.is-active .tab-ic {
  color: var(--accent-text);
}
.profile-tab .tab-svg svg {
  width: 18px;
  height: 18px;
}
.profile-tab .tab-tx {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.profile-tab .tab-tx b {
  font-size: 13.5px;
  font-weight: 700;
}
.profile-tab .tab-tx i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-tab.is-active .tab-tx b {
  color: var(--accent-text);
}

.profile-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pf-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 20px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  backdrop-filter: blur(10px);
}

/* ---------- 安装引导条（登录页 + 个人中心共用一套观感） ---------- */
.auth-install,
.pf-install {
  width: 100%;
}
.auth-install-btn,
.pf-install-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.auth-install-btn:hover,
.pf-install-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent-ring);
  transform: translateY(-1px);
}
.ai-ic,
.pi-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-soft);
  font-size: 18px;
}
.ai-tx,
.pi-tx {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ai-tx b,
.pi-tx b {
  font-size: 13.5px;
  font-weight: 700;
}
.ai-tx i,
.pi-tx i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
}
.ai-go,
.pi-go {
  flex: none;
  color: var(--muted);
  font-size: 17px;
}
.pf-head h3 {
  font-size: 15px;
  font-weight: 700;
}
.pf-head p {
  font-size: 12px;
  color: var(--muted-2);
  margin-top: 4px;
}

/* 头像编辑 */
.avatar-edit {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.avatar-big {
  position: relative;
  width: 92px;
  height: 92px;
  flex: none;
  border-radius: 24px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 2px dashed var(--border-strong);
  background: var(--surface-sunken);
  color: #fff;
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease);
}
.avatar-big:hover {
  border-color: var(--accent-ring);
}
.avatar-big img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-big .avatar-hover {
  position: absolute;
  inset: auto 0 0 0;
  height: 26px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.avatar-big:hover .avatar-hover {
  opacity: 1;
}
.avatar-tx {
  font-weight: 800;
}
.avatar-ops {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.avatar-btns {
  display: flex;
  gap: 8px;
}

/* 只读信息 */
.pf-readonly {
  display: flex;
  flex-direction: column;
  padding: 4px 14px;
  border-radius: 14px;
  background: var(--surface-sunken);
}
.ro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}
.ro-row:last-child {
  border-bottom: 0;
}
.ro-label {
  width: 72px;
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
}
.ro-value {
  font-size: 13px;
  font-weight: 600;
}
.ro-row .hint {
  margin-left: auto;
}

.pf-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.pf-actions .hint {
  margin-right: auto;
}

/* 密码强度：三段固定宽度的小条，空态也看得见 */
.pw-strength {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 20px;
}
.pw-strength i {
  width: 46px;
  flex: none;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.pw-strength i.is-on {
  box-shadow: none;
}
.pw-strength i.is-on:nth-child(1) {
  background: var(--rose, #f0492f);
}
.pw-strength i.is-on:nth-child(2) {
  background: var(--amber, #f2972a);
}
.pw-strength i.is-on:nth-child(3) {
  background: var(--teal, #0f9d63);
}
.pw-text {
  font-size: 12px;
  color: var(--muted-2);
  min-width: 48px;
  margin-left: 3px;
}
.pw-text.lv1 {
  color: var(--rose, #f0492f);
}
.pw-text.lv2 {
  color: var(--amber, #f2972a);
}
.pw-text.lv3 {
  color: var(--teal, #0f9d63);
}

.pf-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pf-tips li {
  position: relative;
  padding-left: 15px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.pf-tips li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* 邮箱 */
.mail-now {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-sunken);
  flex-wrap: wrap;
}
.mail-now .mail-ic {
  font-size: 16px;
  display: grid;
  place-items: center;
  color: var(--accent-text);
}
.mail-now .mail-svg svg {
  width: 18px;
  height: 18px;
}
.mail-now b {
  font-size: 14px;
}
.mail-now .hint {
  margin-left: auto;
}
.code-row {
  display: flex;
  gap: 8px;
}
.code-row .input {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .profile-tabs {
    grid-template-columns: 1fr;
  }
  .ph-theme {
    width: 100%;
  }
}

/* ==========================================================
   全站底部 · ICP 备案信息
   应用内是 .main 的最后一个 flex 子元素（常驻可见，且不遮挡内容）；
   登录页 .auth-view 是 fixed 满屏容器，改用绝对定位贴底。
   ========================================================== */
.site-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 16px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted-2);
  text-align: center;
  user-select: none;
}
.site-foot .beian {
  color: inherit;
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 4px;
  transition: color var(--dur-1) var(--ease);
}
.site-foot .beian:hover,
.site-foot .beian:focus-visible {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* 登录 / 注册页：容器是 fixed 满屏，这里贴屏幕底边 */
.site-foot.is-fixed {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: none;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

@media (max-width: 640px) {
  .site-foot {
    font-size: 11.5px;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  }
}

/* ---------- 触屏 / 移动端：去掉滚动时的闪烁与跳动 ----------
   1) 触屏没有真正的「悬停」：手指按住或划过的卡片会一直挂着 :hover，
      抬起位移被保留下来，滚动时看着像在闪。这里只在支持悬停的设备上启用抬起效果。
   2) 卡片普遍带 backdrop-filter，而首页的滚动容器是 #page（overflow-y:auto），
      毛玻璃在滚动过程中要逐帧重新采样背景，中低端手机会明显掉帧、闪一下。
      移动端改为不模糊（背景本来就是纯色 + 固定光晕，观感几乎无差别）。 */
@media (hover: none) {
  .stat:hover,
  .tool-card:hover,
  .tool-card:hover .tool-icon,
  .anime-card:hover,
  .anime-card:hover .anime-cover img,
  .med-card:hover,
  .med-card:hover .med-cover img,
  .result-card:hover,
  .result-card:hover .result-thumb img,
  .icon-card:hover,
  .icon-card:hover .icon-thumb,
  .shift-block:hover,
  .user-card:hover,
  .user-card:hover .user-go {
    transform: none !important;
  }
}

@media (max-width: 720px) {
  .stat,
  .tool-card,
  .anime-card,
  .med-card,
  .result-card,
  .icon-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* 拖拽结束后的残留动画在触屏上更容易被看成「跳一下」，移动端直接不排 */
  .tool-card {
    -webkit-touch-callout: none;
  }
}

/* ==========================================================================
   v4 外壳：导航收敛（4 项 + 工具箱）、移动端底部 Tab、工具箱页
   新增类名统一带 tb- / tab- / nav-label 前缀，避免和历史类名撞车
   （踩过的坑：.ring 撞 Tailwind 工具类、.ph 撞手机框，都是同名不同义）
   ========================================================================== */
.sidebar-nav {
  gap: 4px;
  padding-top: 8px;
}
/* 「工具箱」组标题：本身是入口，点一下进工具箱页 */
.nav-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 18px 0 4px;
  padding: 0 10px;
  height: 24px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  cursor: pointer;
  border-radius: 6px;
  transition: color var(--dur-1) var(--ease);
}
.nav-label::after {
  content: "›";
  margin-left: auto;
  font-size: 14px;
  font-weight: 400;
  opacity: 0.6;
}
.nav-label:hover,
.nav-label.is-active {
  color: var(--p-700);
}
.nav-list.nav-tools .nav-item {
  color: var(--text-2);
}

/* 顶栏「+」：位置固定，只换文案 */
.new-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.new-btn .ico svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.1;
}

/* ---------------- 移动端底部 Tab ---------------- */
.tabbar {
  display: none;
}
@media (max-width: 900px) {
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    /* 项数不固定：首页 + 已添加工具（最多 3 个）+ 工具箱，几项就均分几份，
       写死 repeat(5) 会在工具少于 3 个时留一段空白 */
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -1px 10px rgba(27, 24, 21, 0.05);
  }
  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    padding: 0;
    /* 点击涟漪的定位参照 */
    position: relative;
    overflow: hidden;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color var(--dur-1) var(--ease);
    -webkit-tap-highlight-color: transparent;
  }
  .tab-item .ico {
    display: grid;
    place-items: center;
  }
  .tab-item .ico svg {
    width: 21px;
    height: 21px;
    stroke-width: 1.8;
  }
  .tab-item.is-active {
    color: var(--p-600);
  }
  .tab-item:active {
    transform: scale(0.94);
  }
  /* 底部条会盖住内容，给滚动区留出等高的尾巴 */
  .page-inner {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------------- 工具箱页 ---------------- */
.tb-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.tb-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-solid);
  box-shadow: var(--sh-1);
  text-align: left;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    transform var(--dur-1) var(--ease);
}
.tb-tile:hover {
  border-color: var(--p-200);
  background: var(--p-50);
  transform: translateY(-1px);
}
.tb-tile:active {
  transform: none;
}
.tb-tile-ic {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--p-50);
  color: var(--p-600);
}
.tb-tile-ic .ico svg {
  width: 20px;
  height: 20px;
}
.tb-tile b {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--text);
}
.tb-tile-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.tb-list {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-solid);
  overflow: hidden;
}
.tb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  cursor: grab;
}
.tb-list#tb-rest .tb-row {
  cursor: default;
}
.tb-row:last-child {
  border-bottom: 0;
}
.tb-row-ic {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  background: var(--surface-sunken);
  color: var(--muted);
}
.tb-row-ic .ico svg {
  width: 17px;
  height: 17px;
}
.tb-row-tx {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.tb-row-tx b {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.tb-row-tx i {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tb-row-op {
  flex: none;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  transition: all var(--dur-1) var(--ease);
}
.tb-row-op.is-add {
  border-color: var(--p-200);
  background: var(--p-50);
  color: var(--p-700);
}
.tb-row-op.is-add:hover {
  background: var(--p-100);
}
.tb-row-op.is-remove:hover {
  border-color: var(--danger-soft, #e7c9c4);
  color: var(--danger);
}
.tb-empty {
  padding: 20px 14px;
  font-size: 12.5px;
  color: var(--muted-2);
  text-align: center;
}
.tb-empty .btn {
  margin-top: 12px;
}
/* 主导航固定项：一直在侧栏，不参与增删，只给个能点进去的入口 */
.tb-fixed {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tb-fixed-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.tb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  transition: background 160ms var(--ease), border-color 160ms var(--ease),
    color 160ms var(--ease);
}
.tb-chip .ico svg {
  width: 15px;
  height: 15px;
}
.tb-chip:hover {
  background: var(--surface-solid);
  border-color: var(--border-strong);
  color: var(--text);
}
@media (max-width: 720px) {
  .tb-tiles {
    grid-template-columns: 1fr;
  }
  .tb-tile {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px;
  }
  .tb-tile-ic {
    margin-bottom: 0;
  }
  .tb-tile b {
    flex: 1;
    min-width: 0;
  }
  .tb-tile-desc {
    flex-basis: 100%;
    padding-left: 52px;
  }
}

/* ==========================================================================
   v4 · 今天（时间轴清单）
   一条轴 + 每行一个固定位置的主操作；
   完成态用「绿 + 划线 + 图标去色」三重信号，不靠颜色单打独斗
   ========================================================================== */
.td-hero {
  margin-bottom: 20px;
}
.td-h1 {
  font-size: 26px;
  line-height: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}
.td-sub {
  margin-top: 6px;
  font-size: 13px;
  line-height: 20px;
  color: var(--muted);
}

.td-group {
  margin-bottom: 18px;
}
.td-cap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}
.td-cap .ln {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.td-cap-note {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.td-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-solid);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.td-panel.is-ghost {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.td-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.td-row:last-child {
  border-bottom: 0;
}
.td-panel.is-ghost .td-row {
  border-bottom: 0;
}
.td-row.is-ghost {
  opacity: 0.72;
}

.td-ic {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.td-ic .ico svg {
  width: 17px;
  height: 17px;
}
.td-ic-med,
.td-ic-anime {
  background: var(--p-50);
  color: var(--p-600);
}
.td-ic-schedule,
.td-ic-ghost {
  background: var(--surface-soft);
  color: var(--muted);
}

.td-time {
  width: 46px;
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.td-tx {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.td-tx b {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--dur-1) var(--ease);
}
.td-tx i {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
  height: 30px;
  min-width: 66px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: var(--p-600);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease);
}
.td-act:hover {
  background: var(--p-700);
}
.td-act .ico svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.6;
}
.td-act:disabled {
  opacity: 0.6;
  cursor: default;
}
/* 已完成：从实心红转成绿色描边，形态变化本身就是反馈 */
.td-row.is-done .td-act {
  background: transparent;
  border-color: var(--ok-line);
  color: var(--ok);
}
.td-row.is-done .td-act:hover {
  background: var(--ok-soft);
}
.td-row.is-done .td-tx b {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--muted-2);
}
.td-row.is-done .td-ic {
  background: var(--ok-soft);
  color: var(--ok);
}
.td-act.is-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted-2);
  font-weight: 600;
  min-width: 0;
}

.td-empty {
  padding: 44px 20px;
}
.td-empty-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.td-skel {
  height: 58px;
  margin-bottom: 10px;
  border-radius: var(--r-md);
  background: var(--surface-soft);
  animation: tdPulse 1.4s ease-in-out infinite;
}
@keyframes tdPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@media (max-width: 560px) {
  .td-h1 {
    font-size: 23px;
    line-height: 31px;
  }
  .td-row {
    gap: 9px;
    padding: 10px 12px;
  }
  .td-ic {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }
  .td-time {
    width: 40px;
    font-size: 11.5px;
  }
  .td-tx i {
    font-size: 11.5px;
  }
  .td-act {
    height: 28px;
    min-width: 0;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* ==========================================================================
   v4 · 追番
   统计条替代四张统计卡；「待看 N」移到封面右上角标
   ========================================================================== */
.an-sum {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 38px;
  padding: 0 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-solid);
  box-shadow: var(--sh-1);
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
}
.an-sum-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.an-sum-item b {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.an-sum-item.is-loading {
  color: var(--muted-2);
}
.an-sum-sep {
  flex: none;
  width: 1px;
  height: 12px;
  background: var(--border);
}
.an-sum-prog {
  margin-left: auto;
  font-weight: 600;
  color: var(--p-700);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 封面右上角「待看 N」：不再和星期文字挤同一行 */
.an-pend {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-full);
  background: var(--p-600);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 3px rgba(27, 24, 21, 0.22);
}

@media (max-width: 640px) {
  .an-sum {
    gap: 10px;
    padding: 0 12px;
    height: 36px;
  }
  /* 窄屏先让「已看集」下场，留下更新 / 待看 / 进度三件最要紧的 */
  .an-sum-hide-sm {
    display: none !important;
  }
  .an-sum-prog {
    font-size: 12px;
  }
}

/* ==========================================================================
   v4 · 吃药：库存横幅 + 今日清单（复用 td-* 时间轴样式）
   ========================================================================== */
.md-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-solid);
  box-shadow: var(--sh-1);
}
.md-banner.is-low {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}
.md-banner-ic {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--warn);
  color: #fff;
}
.md-banner.is-ok .md-banner-ic {
  background: var(--ok-soft);
  color: var(--ok);
}
.md-banner-ic .ico svg {
  width: 16px;
  height: 16px;
}
.md-banner-tx {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.md-banner-tx b {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-banner.is-low .md-banner-tx b {
  color: #8a5606;
}
.md-banner-tx i {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-banner-go {
  flex: none;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--warn-line);
  background: #fff;
  color: var(--warn);
  font-size: 12.5px;
  font-weight: 700;
  transition: background var(--dur-1) var(--ease);
}
.md-banner-go:hover {
  background: #fffaf2;
}

/* 今日清单里的库存列：一眼看出「还够不够」，不用切到全部药品 */
.md-stock {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.md-stock.is-low {
  color: var(--warn);
}

@media (max-width: 620px) {
  .md-banner {
    padding: 10px 12px;
    gap: 10px;
  }
  /* 窄屏让位给药名和「吃了」按钮，库存去「全部药品」里看 */
  .md-stock {
    display: none;
  }
}

/* ==========================================================================
   v4 · 排班月历
   前缀用 mc-（month calendar）：.cal 已被日期选择浮层占用，不能再撞
   ========================================================================== */
.mc-layout {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 16px;
  align-items: start;
}
.mc-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.mc-week span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-2);
}
.mc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.mc-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 58px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.mc-day.is-empty {
  cursor: default;
}
.mc-day.is-work {
  background: var(--p-50);
  color: var(--p-700);
}
.mc-day.is-work:hover {
  border-color: var(--p-200);
}
.mc-day:hover {
  background: var(--surface-soft);
}
.mc-day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--p-500);
}
.mc-day.is-pick,
.mc-day.is-pick:hover {
  background: var(--p-600);
  border-color: var(--p-600);
  color: #fff;
}
.mc-day.is-skel {
  background: var(--surface-soft);
  cursor: default;
}
.mc-mark {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--p-500);
}
.mc-day.is-pick .mc-mark {
  background: #fff;
}

.mc-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
}
.mc-lg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.mc-lg-hint {
  margin-left: auto;
  color: var(--muted-2);
}
.mc-dot {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
}
.mc-dot.is-work {
  background: var(--p-50);
  border: 1px solid var(--p-200);
}
.mc-dot.is-today {
  background: var(--p-600);
}

.mc-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mc-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.mc-card.is-empty {
  background: var(--surface-soft);
}
.mc-card-cap {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}
.mc-shift + .mc-shift {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.mc-shift b {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
}
.mc-people {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mc-people li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}
.mc-av {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background: var(--p-50);
  color: var(--p-700);
  font-size: 9.5px;
  font-weight: 700;
}
.mc-pn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-card-foot {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted-2);
}
.mc-empty-tx {
  font-size: 12px;
  color: var(--muted);
}

.mc-bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  margin-bottom: 8px;
}
.mc-bar-name {
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-bar-val {
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mc-bar {
  grid-column: 1 / -1;
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-soft);
  overflow: hidden;
}
.mc-bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--p-500);
}

@media (max-width: 860px) {
  .mc-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .mc-day {
    height: 42px;
    font-size: 12px;
  }
  .mc-lg-hint {
    display: none;
  }
}

/* ============================================================
   v4 · 工具箱统一两栏骨架（封面 / 图标 / 修图）
   左栏 = 输入 + 主按钮 + 历史；右栏 = 结果预览 + 下载
   ============================================================ */
.tw {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.tw-side {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.tw-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tw-side-ic {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--p-50);
  color: var(--p-600);
}
.tw-side-ic svg {
  width: 18px;
  height: 18px;
}
.tw-title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.tw-desc {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  margin: -3px 0 0;
}

/* 表单域 */
.tw-field {
  display: block;
}
.tw-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.tw-input {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 6px 0 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease);
  cursor: text;
}
.tw-input:hover {
  border-color: var(--border-strong);
}
.tw-input:focus-within {
  border-color: var(--accent-ring);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tw-input-ic {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}
.tw-input-ic svg {
  width: 15px;
  height: 15px;
}
.tw-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.tw-input input::placeholder {
  color: var(--muted-2);
}
.tw-input input:focus {
  outline: none;
}
.tw-clear {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: none;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
}
.tw-clear.is-show {
  display: grid;
}
.tw-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* 左栏内的原生下拉：与 tw-input 等高 */
.tw-side .input,
.tw-side select.input {
  height: 42px;
  border-radius: var(--r-md);
  background-color: var(--surface-sunken);
}
.tw-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tw-side .btn-block,
.tw-side .btn.btn-primary,
/* 同一组里的按钮必须等高：主按钮 42、次要按钮 38，并排会差 4px，看着像没对齐
   （封面下载页的「获取封面 + 粘贴」就是这样） */
.tw-side .tw-grid2 .btn {
  height: 42px;
  border-radius: var(--r-md);
  font-size: 13.5px;
}

/* 左栏底部：编号小贴士 */
.tw-tips {
  list-style: none;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: twt;
}
.tw-tips li {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted-2);
}
.tw-tips li::before {
  counter-increment: twt;
  content: counter(twt);
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}
.tw-tips b {
  color: var(--text-2);
  font-weight: 600;
}
.tw-tips b::after {
  content: '，';
}

/* 右栏：结果 / 预览 */
.tw-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tw-placeholder {
  min-height: 372px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 32px 20px;
  text-align: center;
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-sunken);
}
.tw-ph-ic {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 6px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  color: var(--muted-2);
}
.tw-ph-ic svg {
  width: 22px;
  height: 22px;
}
.tw-placeholder h4 {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text-2);
}
.tw-placeholder p {
  font-size: 12px;
  color: var(--muted-2);
}

/* 右栏顶部：多选操作条 */
.tw-selbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.tw-selbar[hidden] {
  display: none;
}
.tw-selbar .sel-badge {
  flex: none;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--p-50);
  color: var(--p-700);
  font-size: 11.5px;
  font-weight: 700;
}
.tw-selbar .stat-mini {
  font-size: 11.5px;
  color: var(--muted-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 修图：右栏舞台 */
.tw-stage {
  min-width: 0;
}
.tw-stage .dropzone {
  min-height: 372px;
}

@media (max-width: 980px) {
  .tw {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .tw-placeholder {
    min-height: 240px;
  }
  .tw-stage .dropzone {
    min-height: 240px;
  }
}
@media (max-width: 560px) {
  .tw-side {
    padding: 14px;
    gap: 11px;
  }
  .tw-selbar .stat-mini {
    display: none;
  }
}

/* 左栏下拉：app.css 的 Tailwind 兼容层用 !important 重置了 select 背景，
   会把自绘箭头一起清掉，这里用更高优先级 + !important 补回来 */
.tw-side select.input {
  height: 42px;
  border-radius: var(--r-md);
  padding: 0 30px 0 12px !important;
  background-color: var(--surface-sunken) !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) !important;
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px !important;
  background-size: 5px 5px, 5px 5px !important;
  background-repeat: no-repeat !important;
}
.tw-side select.input:hover {
  border-color: var(--border-strong) !important;
}
.tw-side select.input:focus {
  border-color: var(--accent-ring) !important;
  background-color: var(--surface-solid) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

/* 月历头部：窄屏时标题不许换行，「N 天有班」让位 */
#cal-panel .panel-head h3,
#cal-panel .panel-head #cal-sub > span:first-child {
  white-space: nowrap;
}
#cal-panel .panel-head #cal-sub {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.mc-sub-more {
  white-space: nowrap;
}
@media (max-width: 620px) {
  .mc-sub-more {
    display: none;
  }
  #cal-panel .panel-head {
    gap: 6px;
  }
  #cal-panel .panel-head h3 {
    font-size: 14px;
  }
}

/* 工具箱：大按钮兼任「我的工具」清单 —— 拖拽排序 + 右上角移除 */
.tb-tile {
  position: relative;
  cursor: pointer;
}
.tb-tile:focus-visible {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tb-tile-x {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  color: var(--muted-2);
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
    color var(--dur-1) var(--ease);
}
.tb-tile:hover .tb-tile-x,
.tb-tile:focus-within .tb-tile-x {
  opacity: 1;
}
.tb-tile-x:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
/* 触屏没有 hover，✕ 常驻，否则用户永远发现不了可以移除 */
@media (hover: none) {
  .tb-tile-x {
    opacity: 1;
  }
}
.tb-tiles .tb-empty {
  grid-column: 1 / -1;
}
.tb-list:empty {
  display: none;
}

