/* 东西放哪了 —— 界面样式
   移动端优先；深色模式跟随系统；不依赖任何外部资源。 */

/* ------------------------------------------------------------------ 变量 */

:root {
  color-scheme: light dark;

  --bg: #f4f4f1;
  --surface: #ffffff;
  --sheet: #ffffff;
  --field: #eeeeea;
  --ink: #1c1c1e;
  --ink-2: #5e5e64;
  --ink-3: #9a9aa0;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .16);

  --accent: #2a6a4a;
  --accent-fill: #2f6f4f;
  --on-accent: #ffffff;
  --accent-soft: rgba(47, 111, 79, .12);
  --accent-ring: rgba(47, 111, 79, .28);

  --danger: #b3261e;
  --danger-soft: rgba(179, 38, 30, .1);
  --warn: #7a4d00;
  --warn-soft: rgba(214, 150, 20, .18);

  --pressed: rgba(0, 0, 0, .05);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-float: 0 6px 20px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .08);
  --thumb-bg: hsl(var(--h, 152) 42% 91%);
  --thumb-ink: hsl(var(--h, 152) 45% 28%);

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 18px;
  --gutter: 16px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: 150ms;
  --mid: 220ms;
  --slow: 280ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101211;
    --surface: #1b1e1c;
    --sheet: #1e2220;
    --field: #2a2e2c;
    --ink: #f1f2ef;
    --ink-2: #a9aeaa;
    --ink-3: #6f7471;
    --line: rgba(255, 255, 255, .09);
    --line-strong: rgba(255, 255, 255, .2);

    --accent: #6fd0a3;
    --accent-fill: #62c79a;
    --on-accent: #06150d;
    --accent-soft: rgba(98, 199, 154, .16);
    --accent-ring: rgba(98, 199, 154, .34);

    --danger: #ff8f85;
    --danger-soft: rgba(255, 143, 133, .14);
    --warn: #f3c56a;
    --warn-soft: rgba(243, 197, 106, .15);

    --pressed: rgba(255, 255, 255, .07);
    --shadow-card: none;
    --shadow-float: 0 8px 24px rgba(0, 0, 0, .5);
    --thumb-bg: hsl(var(--h, 152) 24% 22%);
    --thumb-ink: hsl(var(--h, 152) 50% 80%);
  }
}

/* ------------------------------------------------------------------ 基础 */

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

[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans",
    "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 弹层开着的时候底下的页面不跟着滚 */
html.sheet-open { overflow: hidden; }

h1, h2, p, menu, ul { margin: 0; padding: 0; }
ul { list-style: none; }

button, input, select {
  font: inherit;
  color: inherit;
}
button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mono {
  font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.dim { color: var(--ink-2); font-weight: 400; }

/* ------------------------------------------------------------------ 布局 */

.app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) var(--gutter) 4px;
}
.masthead h1 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
}
.masthead-count {
  font-size: 14px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 8px var(--gutter) 10px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--mid) ease;
}
.topbar.stuck {
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom-color: var(--line);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
  }
}

main { padding: 6px var(--gutter) 0; }

/* ---------------------------------------------------------------- 搜索框 */

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.searchbar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 48px;
  padding-left: 12px;
  border-radius: var(--r-m);
  background: var(--field);
  border: 1.5px solid transparent;
  color: var(--ink-2);
  cursor: text;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}
.searchbar:focus-within {
  background: var(--surface);
  border-color: var(--accent-fill);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.searchbar > .icon { transition: color var(--fast) ease; }
.searchbar:focus-within > .icon { color: var(--accent); }

.searchbar input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.searchbar input::placeholder { color: var(--ink-2); opacity: 1; }
.searchbar input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0 2px 0 6px;
  border-radius: 50%;
  cursor: pointer;
  /* 圆底叉号；中性灰在明暗两套配色下都看得清 */
  background: #8e8e93 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='m6 6 6 6m0-6-6 6' stroke='%23fff' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center / 18px no-repeat;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--r-m);
  color: var(--ink-2);
  transition: background-color var(--fast) ease, transform var(--fast) var(--ease), color var(--fast) ease;
}
.icon-btn:active { transform: scale(.92); background: var(--pressed); }
.icon-btn.bare { width: 44px; height: 44px; margin-right: 1px; border-radius: 12px; }
.icon-btn.tinted { background: var(--accent-soft); color: var(--accent); }
.icon-btn.tinted:active { background: var(--accent-ring); }

/* 正在听的时候麦克风轻轻呼吸 */
.icon-btn.listening { color: var(--accent); animation: breathe 1.2s ease-in-out infinite; }

/* ---------------------------------------------------------------- 标签页 */

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
  padding: 3px;
  border-radius: 13px;
  background: var(--field);
}
.tab-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px var(--line);
  transform: translateX(calc(var(--tab-i, 0) * 100%));
  transition: transform var(--slow) var(--ease);
}
.tab {
  position: relative;
  min-height: 44px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-2);
  transition: color var(--mid) ease, transform var(--fast) var(--ease);
}
.tab.active { color: var(--ink); font-weight: 600; }
.tab:active { transform: scale(.97); }
@media (prefers-color-scheme: dark) {
  .tab-pill { background: #3a3f3c; box-shadow: none; }
}

/* ---------------------------------------------------------------- 提示条 */

.status {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--r-s);
  background: var(--field);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  animation: rise var(--mid) var(--ease) both;
}
.status.good { background: var(--accent-soft); color: var(--accent); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--danger-soft); color: var(--danger); }
.sheet .status { margin: 4px 0 0; }

/* ------------------------------------------------------------------ 视图 */

.view { animation: fade var(--mid) ease both; }

.filters { padding-top: 4px; }
.filter-row { display: flex; align-items: center; gap: 10px; }
.filter-label {
  flex: none;
  font-size: 14px;
  color: var(--ink-2);
}
.chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  margin-right: calc(var(--gutter) * -1);
  padding: 4px var(--gutter) 4px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative;
  flex: none;
  height: 38px;
  padding: 0 15px;
  border-radius: 19px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-size: 15px;
  white-space: nowrap;
  transition: background-color var(--fast) ease, color var(--fast) ease, transform var(--fast) var(--ease);
}
/* 看起来 38px 高，可点区域撑到 44px */
.chip::before { content: ""; position: absolute; inset: -3px 0; }
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] {
  background: var(--accent-fill);
  box-shadow: none;
  color: var(--on-accent);
  font-weight: 600;
}

/* ------------------------------------------------------------------ 列表 */

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 4px 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.group-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.group-thumb {
  align-self: center;
  width: 28px;
  height: 28px;
  flex: none;
  margin: -4px -2px -4px 0;
  border-radius: 8px;
  object-fit: cover;
  background: var(--field);
}
.group-count {
  flex: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.card {
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--line);
  overflow: hidden;
}
#placeList .card + .card { margin-top: 14px; }
#placeList, #codeList { margin-top: 10px; }

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 10px 10px 12px;
  text-align: left;
  transition: background-color var(--fast) ease;
}
.row:active { background: var(--pressed); }
.row:focus-visible { outline-offset: -3px; border-radius: var(--r-l); }
@media (hover: hover) {
  .row:hover { background: var(--pressed); }
}
/* 行与行之间的细线，从文字左边起，不贯穿缩略图 */
li + li > .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--rule-inset, 72px);
  height: 1px;
  background: var(--line);
}

.thumb {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 12px;
  object-fit: cover;
  background: var(--field);
}
.thumb-wrap { position: relative; flex: none; display: grid; }
/* 有照片的条目：角上一个小小的类别标识 */
.thumb-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  font-size: 12px;
  line-height: 1;
}
.thumb-badge.dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--thumb-ink);
}
.thumb-empty {
  display: grid;
  place-items: center;
  background: var(--thumb-bg);
  color: var(--thumb-ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.row-name {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.row-notes {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.row-count {
  flex: none;
  font-size: 14px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.row-chevron { flex: none; display: grid; color: var(--ink-3); }
.row-chevron .icon { width: 18px; height: 18px; }

mark {
  padding: 1px 2px;
  margin: 0 -2px;
  border-radius: 5px;
  background: var(--accent-soft);
  box-shadow: inset 0 -2px 0 var(--accent-ring);
  color: var(--accent);
}

/* 位置树：每行前面一个 40px 的格子，放照片 / 图钉 / 小圆点 */
.row.place { min-height: 60px; --rule-inset: 64px; }
.row.place .row-name { font-weight: 500; }
.row.place.depth-1 .row-name { font-weight: 600; }
.row.place.depth-2 { padding-left: 28px; --rule-inset: 80px; }
.row.place.depth-3 { padding-left: 44px; --rule-inset: 96px; }
.place-icon, .place-dot, .place-thumb {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 11px;
}
.place-thumb { object-fit: cover; background: var(--field); }
.place-icon {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.place-icon .icon { width: 20px; height: 20px; }
.place-dot { display: grid; place-items: center; }
.place-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-3);
}
#codeList .row { --rule-inset: 12px; }

/* 进场动画：第一次逐条错位，之后只做一次很短的淡入 */
.list[data-anim="stagger"] .row,
.list[data-anim="stagger"] .group-head,
#placeList .row,
#codeList .row {
  animation: rise var(--slow) var(--ease) both;
  animation-delay: calc(min(var(--i, 0), 12) * 26ms);
}
.list[data-anim="quick"] .group { animation: fade var(--fast) ease both; }

/* ------------------------------------------------------------ 空状态与提示 */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 56px 16px 24px;
  text-align: center;
  animation: rise var(--slow) var(--ease) both;
}
.empty-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  stroke-width: 1.3;
  color: var(--ink-3);
}
.empty-title { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; }
.empty-hint { font-size: 15px; color: var(--ink-2); }
.empty .btn { margin-top: 14px; max-width: 100%; }

.hint {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
}
.hint.center { text-align: center; }
.hint.note:empty { display: none; }
.hint.note {
  padding: 10px 14px;
  border-radius: var(--r-s);
  background: var(--field);
}
#codeHint { margin-top: 10px; }

/* ---------------------------------------------------------------- 骨架屏 */

.skeleton { animation: pulse 1.4s ease-in-out infinite; }
.sk-line, .sk-thumb, .sk-text i {
  display: block;
  border-radius: 6px;
  background: var(--field);
}
.sk-head { width: 96px; height: 14px; margin: 24px 4px 12px; }
.sk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 10px 12px;
}
.sk-row + .sk-row { box-shadow: inset 0 1px 0 var(--line); }
.sk-thumb { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.sk-text { flex: 1; display: grid; gap: 8px; }
.sk-text i { height: 14px; width: 58%; }
.sk-text i + i { height: 11px; width: 34%; }
.sk-row:nth-child(2) .sk-text i:first-child { width: 42%; }
.sk-row:nth-child(3) .sk-text i:first-child { width: 66%; }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 50px;
  padding: 0 20px;
  border-radius: var(--r-m);
  background: var(--field);
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  transition: transform var(--fast) var(--ease), filter var(--fast) ease, background-color var(--fast) ease, opacity var(--fast) ease;
}
.btn:active { transform: scale(.97); filter: brightness(.94); }
.btn.primary { background: var(--accent-fill); color: var(--on-accent); font-weight: 600; }
.btn.tinted { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn.text { background: none; color: var(--accent); font-size: 16px; min-height: 44px; }
.btn.text:active { background: var(--pressed); }
.btn.danger { color: var(--danger); }
.btn.dashed {
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  color: var(--ink-2);
  margin-top: 14px;
}
.btn.dashed:active { background: var(--pressed); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; pointer-events: none; }

.fab {
  position: fixed;
  z-index: 20;
  right: max(var(--gutter), calc(50vw - 360px + var(--gutter)));
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 28px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  transition: transform var(--fast) var(--ease), filter var(--fast) ease;
  animation: fab-in var(--slow) var(--ease) 120ms both;
}
.fab:active { transform: scale(.95); filter: brightness(.94); }
.fab:focus-visible { outline-offset: 3px; }
.fab .icon { stroke-width: 2.2; }

.foot {
  display: flex;
  justify-content: center;
  padding: 28px var(--gutter) 0;
}
.foot-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-s);
  color: var(--accent);
  font-size: 15px;
  text-decoration: none;
}
.foot-link:active { background: var(--pressed); }
.foot-link .icon { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ 弹层 */
/* 手机上贴底滑出，宽屏上居中。五个弹层共用这一套。 */

dialog.sheet {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top));
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
  overflow: hidden;
}
dialog.sheet[open] {
  display: flex;
  animation: sheet-up var(--slow) var(--ease) both;
}
dialog.sheet.closing { animation: sheet-down var(--mid) cubic-bezier(.4, 0, 1, 1) both; }

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, .4);
  animation: fade 220ms ease both;
}
dialog.sheet.closing::backdrop { animation: fade-out 220ms ease both; }

.sheet-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}
/* 顶上的小横条，提示这是一张可以收起的卡片 */
.sheet-body::before {
  content: "";
  flex: none;
  align-self: center;
  width: 36px;
  height: 5px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--line-strong);
}
.sheet-title {
  flex: none;
  padding: 12px 20px 10px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
/* 标题行：右边放一个低调的删除按钮，打开就看得到，但不抢「保存」 */
.sheet-head { flex: none; display: flex; align-items: flex-start; }
.sheet-head .sheet-title { flex: 1; min-width: 0; }
.sheet-delete { margin: 4px 10px 0 0; color: var(--ink-2); }
.sheet-delete:active { background: var(--danger-soft); color: var(--danger); }
@media (hover: hover) {
  .sheet-delete:hover { background: var(--danger-soft); color: var(--danger); }
}
/* 弹层打开时焦点落在标题上（不落在删除按钮上），标题本身不画焦点框 */
.sheet-title:focus { outline: none; }
.sheet-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 20px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-foot {
  flex: none;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--sheet);
}
.sheet-foot { position: relative; }
/* 下面还有内容时，按钮栏上方一道渐隐，提示可以往下滚 */
.sheet-foot::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 36px;
  margin-bottom: 1px;
  background: linear-gradient(to top, var(--sheet), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--mid) ease;
}
.more-below .sheet-foot::before { opacity: 1; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .btn.primary { flex: 1.6; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }

.field input:not([type="file"]),
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: var(--r-m);
  background: var(--field);
  color: var(--ink);
  font-size: 17px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}
.field input::placeholder { color: var(--ink-2); opacity: 1; }
.field input:not([type="file"]):focus,
.field select:focus {
  background-color: var(--sheet);
  border-color: var(--accent-fill);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.field input[readonly] { color: var(--ink-2); }
.field input.mono { font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace; }
.field select {
  padding-right: 40px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}

.photo-pick {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  border-radius: var(--r-m);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: background-color var(--fast) ease;
}
.photo-pick:active { background: var(--pressed); }
.photo-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-pick input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
/* 已经有预览时把选图按钮收起来；不支持 :has 的旧浏览器两个都显示，照样能用 */
.photo-box:not([hidden]) + .photo-pick { display: none; }
.photo-box { position: relative; }

/* 就地新建分类 */
.newcat {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: var(--r-m);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  animation: rise var(--mid) var(--ease) both;
}
.newcat-inputs { display: grid; grid-template-columns: 64px 1fr; gap: 8px; }
.field .newcat-icon { padding: 0; text-align: center; }
.newcat-actions { display: flex; justify-content: flex-end; gap: 8px; }
.newcat-actions .btn { min-height: 44px; padding: 0 16px; font-size: 16px; }

/* 分类管理 */
.filter-action { flex: none; min-height: 44px; padding: 0 6px; font-size: 15px; }
#catFilter { margin-right: 0; padding-right: 2px; }
.card.flat { flex: none; box-shadow: 0 0 0 1px var(--line); }
.cat-item { position: relative; display: flex; align-items: center; padding-right: 6px; }
.cat-item + .cat-item::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 64px;
  height: 1px;
  background: var(--line);
}
.cat-item > .row::before { display: none; }
.row.cat { flex: 1; min-width: 0; min-height: 60px; }
.cat-move { width: 44px; height: 44px; border-radius: 12px; }
.cat-move .icon { width: 18px; height: 18px; }
.cat-move.up .icon { transform: rotate(-90deg); }
.cat-move.down .icon { transform: rotate(90deg); }
.cat-move:disabled { opacity: .3; pointer-events: none; }

/* 弹层里的二次确认 */
.confirm {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r-m);
  background: var(--danger-soft);
  animation: rise var(--mid) var(--ease) both;
}
.confirm-text { font-size: 16px; line-height: 1.5; color: var(--ink); }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; min-height: 46px; font-size: 16px; }
.confirm-actions .btn:first-child { background: var(--sheet); }
.btn.danger-fill { background: var(--danger); color: var(--sheet); font-weight: 600; }
.cat-thumb { width: 40px; height: 40px; border-radius: 11px; font-size: 20px; }
.cat-fields { display: grid; grid-template-columns: 72px 1fr; gap: 10px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.photo-box img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--r-m);
  background: var(--field);
}
.photo-box .icon-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
}

/* 扫码 */
dialog.sheet.full { height: calc(100dvh - 24px - env(safe-area-inset-top)); }
.camera-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  border-radius: var(--r-l);
  background: #000;
  overflow: hidden;
}
.camera-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(78%, 320px);
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .38), inset 0 0 0 2px rgba(255, 255, 255, .9);
}
.reticle::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  border-radius: 1px;
  background: #7ee0b2;
  animation: scanline 1.8s ease-in-out infinite;
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }

  .masthead { padding-top: 36px; }
  .masthead h1 { font-size: 32px; }

  dialog.sheet {
    width: 480px;
    max-height: min(720px, calc(100dvh - 64px));
    margin: auto;
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  }
  dialog.sheet.full { height: min(640px, calc(100dvh - 64px)); }
  dialog.sheet[open] { animation-name: pop-in; }
  dialog.sheet.closing { animation-name: pop-out; }
  .sheet-body::before { display: none; }
  .sheet-title { padding-top: 22px; }
  .sheet-delete { margin-top: 14px; }
  .sheet-foot { padding-bottom: 18px; }
}

/* ------------------------------------------------------------------ 动画 */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}
@keyframes fade {
  from { opacity: 0; }
}
@keyframes fade-out {
  to { opacity: 0; }
}
@keyframes pulse {
  50% { opacity: .5; }
}
@keyframes breathe {
  50% { transform: scale(1.12); }
}
@keyframes fab-in {
  from { opacity: 0; transform: translateY(12px) scale(.94); }
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
}
@keyframes sheet-down {
  to { transform: translateY(100%); }
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
}
@keyframes pop-out {
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}
@keyframes scanline {
  0%, 100% { transform: translateY(-34px); opacity: .5; }
  50% { transform: translateY(34px); opacity: 1; }
}

/* 系统设了「减少动态效果」：位移和循环动画都停掉，只保留瞬间切换 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
