/* ============================================================
   base.css — 设计令牌与共享组件（治愈系浅色）
   ============================================================ */

:root {
  /* 色彩：暖米色背景 + 鼠尾草绿主色 + 蜜桃色点缀 */
  --bg: hsl(36 44% 96%);
  --surface: hsl(38 50% 99%);
  --surface-2: hsl(35 32% 92%);
  --line: hsl(33 24% 86%);
  --text: hsl(28 16% 22%);
  --text-2: hsl(28 10% 44%);
  --primary: hsl(155 30% 38%);
  --primary-deep: hsl(155 34% 30%);
  --primary-soft: hsl(152 34% 90%);
  --accent: hsl(18 78% 70%);
  --accent-soft: hsl(20 72% 93%);
  --danger: hsl(4 60% 50%);
  --danger-soft: hsl(6 70% 95%);
  --overlay: hsl(28 22% 8% / 0.95);

  /* 间距（8px 网格） */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;

  /* 圆角 / 阴影 */
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow-1: 0 1px 2px hsl(28 20% 20% / 0.06);
  --shadow-2: 0 2px 8px hsl(28 20% 20% / 0.1);
  --shadow-3: 0 8px 24px hsl(28 20% 20% / 0.16);

  /* 字号 */
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Noto Sans CJK SC", "Microsoft YaHei",
    "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

img { max-width: 100%; }

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

input {
  font: inherit;
  color: inherit;
}

/* ---------- 图标 ---------- */

.icon {
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.28em;
  flex: none;
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-m);
  background: var(--primary);
  color: hsl(0 0% 100%);
  font-size: var(--fs-base);
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:active { background: var(--primary-deep); }

.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-ghost {
  background: var(--surface);
  color: var(--primary-deep);
  border: 1px solid var(--line);
}

.btn-ghost:active { background: var(--primary-soft); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid hsl(6 50% 86%);
}

.btn-danger:active { background: hsl(6 70% 91%); }

.btn-sm { min-height: 40px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--radius-s); }

/* 图标按钮（触控目标 44px） */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: inherit;
}

.icon-btn:active { background: hsl(28 20% 50% / 0.12); }

/* ---------- 筛选 chips ---------- */

.chip-row {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: var(--sp-2) var(--sp-4);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-sm);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip .chip-count { font-size: 0.72rem; opacity: 0.75; }

.chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: hsl(0 0% 100%);
}

/* 批量打标签时的"部分选中"态 */
.chip.part {
  background: var(--primary-soft);
  border: 1px dashed var(--primary);
  color: var(--primary-deep);
}

/* ---------- 底部弹层 sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: hsl(28 20% 12% / 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  box-shadow: var(--shadow-3);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(105%);
  transition: transform 0.25s ease;
}

.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
.sheet-open .sheet { transform: translateY(0); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
}

.sheet-head h2 { margin: 0; font-size: var(--fs-md); }

.sheet-body { overflow-y: auto; padding: 0 var(--sp-4) var(--sp-4); }

@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 480px; transform: translate(-50%, 105%); }
  .sheet-open .sheet { transform: translate(-50%, 0); }
}

/* ---------- 轻提示 toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translateX(-50%) translateY(8px);
  max-width: min(88vw, 420px);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-m);
  background: hsl(28 18% 20% / 0.92);
  color: hsl(36 40% 96%);
  font-size: var(--fs-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast.error { background: hsl(4 55% 38% / 0.95); }

/* ---------- 骨架占位 ---------- */

.skeleton {
  background: linear-gradient(100deg, var(--surface-2) 40%, hsl(35 40% 96%) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}

/* ---------- 空状态 / 错误提示卡 ---------- */

.notice {
  margin: var(--sp-8) auto;
  max-width: 420px;
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-2);
}

.notice .icon { width: 44px; height: 44px; stroke-width: 1.4; color: hsl(33 20% 74%); }

.notice h2 { margin: var(--sp-3) 0 var(--sp-1); font-size: var(--fs-md); color: var(--text); }

.notice p { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }

.notice code {
  display: inline-block;
  padding: 0 var(--sp-1);
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 0.78rem;
  word-break: break-all;
}
