/* 拾页 · 全站样式（app.css）
   ─────────────────────────────────────────────────────────────
   视觉基调继承自《拾页原型》（暖白纸感 #F6F5F1 + 松墨绿 #2F6150 + 宋体人文标题），
   同时完整落实：
   · 深浅双主题全链路对比度 ≥ 4.5:1（WCAG AA）
   · 关系式弹性布局（320px ~ 2560px 连续缩放零错位，≥900px 自动展开常驻分类侧栏）
   · 弹层遮罩禁 100dvh + 上下延展伪元素防半透明键盘露白缝
   · 全站按钮禁选字（user-select:none）+ 触屏弹性按压反馈 + hover 媒体查询隔离 */

:root {
  --bg: #F6F5F1;
  --bg-glass: rgba(246, 245, 241, 0.84);
  --surface: #FFFFFF;
  --surface-2: #EFECE5;
  --drawer-bg: #FBFAF7;
  --text: #1E201D;
  --text-2: #50554D;
  --text-3: #646960;
  --line: #E4E2DA;
  --line2: #D6D3C8;
  --accent: #2F6150;
  --accent-text: #244C3F;
  --accent-soft: #E3EEE8;
  --accent-ink: #1C3D32;
  --danger: #A6291E;
  --danger-soft: #F5E3DC;
  --star-fg: #7C5106;
  --star-soft: #F6EBD5;
  --move-fg: #1F3F6B;
  --move-soft: #E2EAF6;
  --scrim: rgba(20, 22, 19, 0.44);
  --shadow-sm: 0 1px 2px rgba(24, 28, 24, 0.04), 0 4px 14px rgba(24, 28, 24, 0.05);
  --shadow-lg: 0 8px 28px rgba(24, 28, 24, 0.11), 0 2px 6px rgba(24, 28, 24, 0.05);
  --card-hl: inset 0 0 0 1px var(--line);

  /* 五色图标底板（浅色，字色对比度均 ≥ 6.0:1） */
  --tile-blue-bg: #E2EAF6;  --tile-blue-fg: #1F3F6B;
  --tile-rust-bg: #F5E3DC;  --tile-rust-fg: #7A2E1A;
  --tile-amber-bg: #F6EBD5; --tile-amber-fg: #5F400A;
  --tile-plum-bg: #EFE4EF;  --tile-plum-fg: #573358;
  --tile-green-bg: #E3EEE8; --tile-green-fg: #244C3F;

  /* 左滑操作淡色按钮 */
  --lsw-star-bg: #F6EBD5; --lsw-star-fg: #5F400A;
  --lsw-move-bg: #E2EAF6; --lsw-move-fg: #1F3F6B;
  --lsw-del-bg: #F5E3DC;  --lsw-del-fg: #7A2E1A;

  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong", Georgia, serif;
  --kb: 0px;
  --sheet-kb: 0px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171917;
    --bg-glass: rgba(23, 25, 23, 0.84);
    --surface: #212421;
    --surface-2: #2B2F2B;
    --drawer-bg: #1C1F1C;
    --text: #F0F2ED;
    --text-2: #BFC4BB;
    --text-3: #99A094;
    --line: rgba(255, 255, 255, 0.09);
    --line2: rgba(255, 255, 255, 0.15);
    --accent: #2E6A56;
    --accent-text: #86C8AF;
    --accent-soft: rgba(74, 156, 126, 0.20);
    --accent-ink: #BCE8D6;
    --danger: #F28B82;
    --danger-soft: rgba(242, 139, 130, 0.16);
    --star-fg: #F5C978;
    --star-soft: rgba(245, 201, 120, 0.16);
    --move-fg: #99C0F5;
    --move-soft: rgba(153, 192, 245, 0.16);
    --scrim: rgba(6, 8, 7, 0.62);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.45);
    --card-hl: inset 0 0 0 1px rgba(255, 255, 255, 0.07);

    --tile-blue-bg: rgba(96, 148, 228, 0.20);  --tile-blue-fg: #A8CAFA;
    --tile-rust-bg: rgba(226, 118, 94, 0.20);  --tile-rust-fg: #F7B4A4;
    --tile-amber-bg: rgba(224, 174, 82, 0.20); --tile-amber-fg: #F7D48E;
    --tile-plum-bg: rgba(186, 130, 194, 0.20); --tile-plum-fg: #E5BCE9;
    --tile-green-bg: rgba(78, 162, 130, 0.22); --tile-green-fg: #9EDEC5;

    --lsw-star-bg: rgba(224, 174, 82, 0.22); --lsw-star-fg: #F7D48E;
    --lsw-move-bg: rgba(96, 148, 228, 0.22); --lsw-move-fg: #A8CAFA;
    --lsw-del-bg: rgba(226, 118, 94, 0.22);  --lsw-del-fg: #F7B4A4;
  }
}

:root[data-theme="dark"] {
  --bg: #171917;
  --bg-glass: rgba(23, 25, 23, 0.84);
  --surface: #212421;
  --surface-2: #2B2F2B;
  --drawer-bg: #1C1F1C;
  --text: #F0F2ED;
  --text-2: #BFC4BB;
  --text-3: #99A094;
  --line: rgba(255, 255, 255, 0.09);
  --line2: rgba(255, 255, 255, 0.15);
  --accent: #2E6A56;
  --accent-text: #86C8AF;
  --accent-soft: rgba(74, 156, 126, 0.20);
  --accent-ink: #BCE8D6;
  --danger: #F28B82;
  --danger-soft: rgba(242, 139, 130, 0.16);
  --star-fg: #F5C978;
  --star-soft: rgba(245, 201, 120, 0.16);
  --move-fg: #99C0F5;
  --move-soft: rgba(153, 192, 245, 0.16);
  --scrim: rgba(6, 8, 7, 0.62);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, 0.45);
  --card-hl: inset 0 0 0 1px rgba(255, 255, 255, 0.07);

  --tile-blue-bg: rgba(96, 148, 228, 0.20);  --tile-blue-fg: #A8CAFA;
  --tile-rust-bg: rgba(226, 118, 94, 0.20);  --tile-rust-fg: #F7B4A4;
  --tile-amber-bg: rgba(224, 174, 82, 0.20); --tile-amber-fg: #F7D48E;
  --tile-plum-bg: rgba(186, 130, 194, 0.20); --tile-plum-fg: #E5BCE9;
  --tile-green-bg: rgba(78, 162, 130, 0.22); --tile-green-fg: #9EDEC5;

  --lsw-star-bg: rgba(224, 174, 82, 0.22); --lsw-star-fg: #F7D48E;
  --lsw-move-bg: rgba(96, 148, 228, 0.22); --lsw-move-fg: #A8CAFA;
  --lsw-del-bg: rgba(226, 118, 94, 0.22);  --lsw-del-fg: #F7B4A4;
}

::selection {
  background: rgba(47, 97, 80, 0.28);
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

h1, h2, h3, p {
  margin: 0;
}

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

/* 铁律 3：全站按钮与可点击控件默认禁选字、去点击蓝框、零 300ms 延迟 */
button,
.primary-link,
.chip,
.nav-item,
.icon-btn,
.lsw-btn {
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1), background-color 0.16s ease, opacity 0.16s ease;
}

input,
textarea,
.selectable {
  user-select: text;
  -webkit-user-select: text;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

button:active:not(:disabled),
.primary-link:active {
  transform: scale(0.968);
}

.icon-btn:active:not(:disabled),
.round:active:not(:disabled) {
  transform: scale(0.91);
}

/* ────── 整体壳层（窄屏单栏 / ≥900px 双栏常驻分类导航） ────── */
.app-shell {
  min-height: 100vh;
  display: block;
}

.side-rail {
  display: none;
}

.main-col {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  position: relative;
}

@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: 268px minmax(0, 1fr);
    align-items: start;
  }
  .side-rail {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--drawer-bg);
    border-right: 1px solid var(--line);
    padding: 18px 14px 20px;
    gap: 2px;
  }
  .only-mobile-drawer {
    display: none !important;
  }
}

/* ────── 固定顶部导航栏（feedback_fixed_nav_bar） ────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(52px + env(safe-area-inset-top, 0px));
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.18s ease;
}

.top-bar.scrolled {
  border-bottom-color: var(--line);
}

.bar-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bar-title-wrap.align-left {
  align-items: flex-start;
  padding-left: 4px;
}

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
  position: relative;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-2);
  }
}

.sync-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-text);
}

.sync-dot.bad {
  background: var(--danger);
}

/* ────── 主体内容区 ────── */
.page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 20px calc(156px + env(safe-area-inset-bottom, 0px));
}

.page-body.no-composer {
  padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 359px) {
  .page-body {
    padding-left: 14px;
    padding-right: 14px;
  }
}

.hero {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(24px, 6.8vw, 29px);
  line-height: 1.38;
  margin-top: 6px;
  letter-spacing: -0.01em;
}

.view-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(23px, 6.4vw, 27px);
  line-height: 1.32;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

/* ────── 待整理横幅 ────── */
.inbox-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 14px 16px;
  box-shadow: inset 0 0 0 1px rgba(47, 97, 80, 0.12);
}

.inbox-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inbox-title {
  font-size: 15px;
  font-weight: 600;
}

.inbox-sub {
  font-size: 13px;
  opacity: 0.88;
}

/* ────── 胶囊条（横向与自动折行两种） ────── */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 2px 0;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips.wrap {
  flex-wrap: wrap;
  overflow-x: visible;
}

.chip {
  min-height: 44px;
  flex-shrink: 0;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--card-hl);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 359px) {
  .chip {
    padding: 0 13px;
    font-size: 13.5px;
  }
}

@media (hover: hover) {
  .chip:hover:not(.on) {
    background: var(--surface-2);
  }
}

.chip.on {
  background: var(--accent);
  box-shadow: none;
  color: #FFFFFF;
}

.chip.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px dashed var(--line2);
  border: 1px dashed var(--line2);
  color: var(--text-2);
}

.ai-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.chip:not(.on) .ai-badge {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ────── 彩色首字方块 ────── */
.tile {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.tile-blue  { background: var(--tile-blue-bg);  color: var(--tile-blue-fg); }
.tile-rust  { background: var(--tile-rust-bg);  color: var(--tile-rust-fg); }
.tile-amber { background: var(--tile-amber-bg); color: var(--tile-amber-fg); }
.tile-plum  { background: var(--tile-plum-bg);  color: var(--tile-plum-fg); }
.tile-green { background: var(--tile-green-bg); color: var(--tile-green-fg); }

/* ────── 首页列表行与卡片列表 ────── */
.recent-list {
  display: flex;
  flex-direction: column;
  position: relative;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  text-align: left;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.name {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  overflow-wrap: anywhere;
}

.one {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 铁律 5：复合元信息分段不折孤字，分隔点用相邻伪元素避免换行后行尾孤立残留圆点 */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0;
  row-gap: 2px;
  font-size: 12.5px;
  color: var(--text-3);
}

.meta-seg {
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-seg + .meta-seg::before {
  content: "·";
  margin: 0 5px;
  opacity: 0.6;
}

.meta-star {
  color: var(--star-fg);
  font-weight: 600;
}

.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.bcard {
  background: var(--surface);
  box-shadow: var(--card-hl), var(--shadow-sm);
  border-radius: 18px;
  overflow: hidden;
}

.bcard-top {
  display: flex;
  align-items: center;
}

.bcard-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 0 14px 14px;
}

.bcard-more {
  width: 48px;
  min-height: 58px;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}

.bcard-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}

.bcard-actions button {
  min-height: 46px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
}

.act-star { background: var(--star-soft);   color: var(--star-fg); }
.act-move { background: var(--move-soft);   color: var(--move-fg); }
.act-edit { background: var(--accent-soft); color: var(--accent-ink); }
.act-del  { background: var(--danger-soft); color: var(--danger); }

.summary-snip {
  font-size: 13.5px;
  line-height: 1.48;
  color: var(--accent-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ────── 左滑露出按钮样式（SwipeActions） ────── */
.lsw-item {
  position: relative;
  touch-action: pan-y pinch-zoom;
}

.lsw-anim {
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
}

.lsw-acts {
  position: absolute;
  display: flex;
  gap: 6px;
  pointer-events: none;
  z-index: 0;
}

.lsw-item {
  z-index: 1;
}

.lsw-acts.is-open {
  pointer-events: auto;
}

.lsw-btn {
  width: clamp(64px, 18vw, 76px);
  height: 100%;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.lsw-ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lsw-star { background: var(--lsw-star-bg); color: var(--lsw-star-fg); }
.lsw-move { background: var(--lsw-move-bg); color: var(--lsw-move-fg); }
.lsw-del  { background: var(--lsw-del-bg);  color: var(--lsw-del-fg); }

/* ────── 详情页与生词卡片 ────── */
.detail-url {
  font-size: 13px;
  color: var(--text-3);
  overflow-wrap: anywhere;
  margin-top: 4px;
}

.primary-btn,
.primary-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border-radius: 25px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  padding: 0 20px;
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.outline-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  border-radius: 24px;
  box-shadow: inset 0 0 0 1px var(--accent-text);
  color: var(--accent-text);
  font-size: 15px;
  font-weight: 500;
  padding: 0 18px;
}

.outline-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: none;
}

.detail-block {
  background: var(--surface);
  box-shadow: var(--card-hl), var(--shadow-sm);
  border-radius: 18px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-text {
  font-size: 16px;
  line-height: 1.62;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 9px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 10px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.word-card {
  background: var(--surface);
  box-shadow: var(--card-hl), var(--shadow-sm);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.word-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.word-term {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.word-ipa {
  font-size: 13.5px;
  color: var(--text-3);
}

.word-zh {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--text);
}

.word-pic {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.5;
}

/* ────── 底部拇指悬浮输入舱（Composer） ────── */
.composer-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px) + var(--kb, 0px));
  z-index: 18;
  pointer-events: none;
  padding: 0 12px;
  transition: bottom 0.16s ease-out;
}

@media (min-width: 900px) {
  .composer-dock {
    left: 268px;
  }
}

.composer {
  pointer-events: auto;
  max-width: 740px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--card-hl), var(--shadow-lg);
  border-radius: 26px;
  padding: 8px 10px;
  transition: box-shadow 0.16s ease;
}

.composer:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--accent-text), var(--shadow-lg);
}

.composer-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  padding: 0 10px;
}

.composer input::placeholder {
  color: var(--text-3);
}

.clear-q {
  width: 36px;
  height: 36px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}

.tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.round {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.round.add {
  box-shadow: inset 0 0 0 1px var(--line2);
  color: var(--text);
}

.round.send {
  background: var(--accent);
  color: #FFFFFF;
}

.tool-pill {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

@media (hover: hover) {
  .tool-pill:hover,
  .round.add:hover {
    background: var(--surface-2);
  }
}

/* ────── 分类侧栏与抽屉共用导航项 ────── */
.drawer-logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 10px;
}

.drawer-logo {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border-radius: 12px;
  padding: 0 12px;
  width: 100%;
  text-align: left;
  font-size: 15.5px;
  color: var(--text);
}

.nav-item small {
  font-size: 13px;
  color: var(--text-3);
  flex-shrink: 0;
}

.nav-item.sel {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.nav-item.sel small {
  color: var(--accent-ink);
}

.nav-item.child {
  padding-left: 28px;
  font-size: 14.5px;
  min-height: 44px;
}

@media (hover: hover) {
  .nav-item:hover:not(.sel) {
    background: var(--surface-2);
  }
}

.nav-section-lbl {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  padding: 14px 12px 4px;
}

.new-cat-btn {
  min-height: 48px;
  width: 100%;
  border: 1px dashed var(--line2);
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ────── 弹层与遮罩（铁律 1 & 2：严禁 100dvh，遮罩上下延展 100vh 防半透明键盘断层） ────── */
.mask {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  background: var(--scrim);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.2s ease-out;
}

.mask::before,
.mask::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 100vh;
  background: var(--scrim);
  pointer-events: none;
}

.mask::before { bottom: 100%; }
.mask::after  { top: 100%; }

.mask.center-modal {
  align-items: center;
  padding: 20px;
  z-index: 80;
}

.mask.drawer-mask {
  justify-content: flex-start;
  align-items: stretch;
  z-index: 45;
}

.drawer-panel {
  width: 316px;
  max-width: 84%;
  height: 100%;
  background: var(--drawer-bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-lg);
  animation: slide-right 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer-panel > * {
  flex-shrink: 0;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 88%;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 640px) {
  .mask:not(.drawer-mask) {
    align-items: center;
    padding: 24px;
  }
  .sheet {
    border-radius: 24px;
    max-height: 86%;
  }
}

.mask.center-modal .sheet {
  max-width: 400px;
  border-radius: 22px;
  animation: pop-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sheet-head {
  flex-shrink: 0;
  padding: 10px 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line2);
  align-self: center;
}

@media (min-width: 640px) {
  .handle {
    display: none;
  }
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px calc(18px + env(safe-area-inset-bottom, 0px) + var(--sheet-kb, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-body > * {
  flex-shrink: 0;
}

.sheet-foot {
  flex-shrink: 0;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line2);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}

.field textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus {
  box-shadow: inset 0 0 0 2px var(--accent-text);
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row > button {
  flex: 1;
  min-width: 0;
}

.sec-btn {
  min-height: 48px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line2);
  padding: 0 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.danger-btn {
  min-height: 48px;
  border-radius: 24px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* AI 解析加载态卡片 */
.ai-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* 设置分组卡片 */
.set-group {
  background: var(--surface);
  box-shadow: var(--card-hl);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.set-row:last-child {
  border-bottom: 0;
}

.seg-ctrl {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.seg-ctrl button {
  flex: 1;
  min-height: 40px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}

.seg-ctrl button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ────── Toast 提示条（带 max-content 防窄屏挤成三行） ────── */
.toast {
  position: fixed;
  left: 50%;
  top: calc(62px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(440px, calc(100vw - 28px));
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--text);
  color: var(--bg);
  border-radius: 16px;
  padding: 6px 8px 6px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 95;
  animation: enter-up 0.2s ease-out;
}

.toast-msg {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast button {
  min-height: 40px;
  min-width: 52px;
  padding: 0 10px;
  border-radius: 10px;
  color: #8FE0BE;
  font-weight: 700;
}

:root[data-theme="dark"] .toast button {
  color: #245B47;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast button {
    color: #245B47;
  }
}

/* ────── 下拉刷新指示器（组件_下拉刷新 v2.1） ────── */
#ptr-indicator {
  position: fixed;
  top: calc(-44px + env(safe-area-inset-top, 0px));
  left: 50%;
  margin-left: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--card-hl), var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-text);
  opacity: 0;
  pointer-events: none;
  z-index: 90;
}

#ptr-indicator.ptr-animate {
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#ptr-indicator svg {
  width: 20px;
  height: 20px;
}

#ptr-indicator .ptr-arrow {
  transition: transform 0.2s ease;
}

#ptr-indicator.ptr-ready .ptr-arrow {
  transform: rotate(180deg);
}

#ptr-indicator .ptr-spinner {
  display: none;
}

#ptr-indicator.ptr-loading .ptr-arrow {
  display: none;
}

#ptr-indicator.ptr-loading .ptr-spinner {
  display: block;
  animation: spin 0.8s linear infinite;
}

#ptr-tip {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(16px);
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  background: var(--text);
  color: var(--bg);
  border-radius: 14px;
  padding: 10px 16px;
  font-size: 14px;
  z-index: 96;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#ptr-tip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ────── 动效关键帧与无障碍降级 ────── */
.enter {
  animation: enter-up 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
}

@keyframes slide-right {
  from { transform: translateX(-100%); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.95); }
}

@keyframes enter-up {
  from { opacity: 0; transform: translateY(6px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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