/* ============================================================
   出行准备清单 - 主样式表
   旅行手账 / 精品文具风格
   ============================================================ */

/* ----- 1. CSS 变量 ----- */
:root {
  --bg: #f8f4ef;
  --surface: #fffcf9;
  --primary: #c8634a;
  --primary-deep: #b04f38;
  --primary-light: #faf0eb;
  --secondary: #3d7a7a;
  --secondary-light: #e8f2f0;
  --secondary-deep: #2f6363;
  --accent: #d4975a;
  --accent-light: #faf0df;
  --text: #2b211c;
  --text-secondary: #5f534a;
  --text-muted: #8c7e75;
  --border: #e8e0d8;
  --border-light: #f0ebe5;
  --danger: #d45a5a;
  --danger-light: #fdeaea;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(43, 33, 28, 0.06);
  --shadow-md: 0 4px 12px rgba(43, 33, 28, 0.07);
  --shadow-lg: 0 8px 24px rgba(43, 33, 28, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --header-height: 60px;
  --bottom-bar-height: 64px;
  --progress-height: 8px;
  --z-content: 1;
  --z-sticky: 10;
  --z-header: 20;
  --z-fab: 30;
  --z-overlay: 40;
  --z-dialog: 50;
  --z-toast: 60;
  --z-celebration: 70;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ----- 2. Reset & 基础 ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
  background: none;
}

ul, li { list-style: none; }
a { text-decoration: none; color: inherit; }

/* ----- 3. 应用容器 ----- */
#app {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--surface);
  overflow: hidden;
}

/* ----- 4. 页面切换 ----- */
.page {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.page.active {
  display: flex;
  animation: page-enter 0.35s var(--ease-smooth);
}

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

/* ----- 5. 顶栏 ----- */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-height);
  padding: 0 16px;
  background-color: var(--surface);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background-color: var(--border-light);
}

.app-header h1 {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 19px;
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

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

.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  font-size: 20px;
  color: var(--text-secondary);
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.btn-back:active {
  background-color: var(--border-light);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  font-size: 20px;
  color: var(--text-secondary);
  transition: background-color 0.2s;
}

.btn-icon:active {
  background-color: var(--border-light);
}

.header-detail-info {
  flex: 1;
  min-width: 0;
}

.header-detail-info h1 {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- 6. 页面内容 ----- */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  padding-bottom: 24px;
  -webkit-overflow-scrolling: touch;
}

/* ----- 7. 空状态 ----- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  min-height: 300px;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.empty-title {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ----- 8. 页面内边距调整 ----- */
#page-home .page-content {
  padding-bottom: 96px;
}

#page-detail .page-content {
  padding-bottom: calc(var(--bottom-bar-height) + 20px);
}

#page-templates .page-content,
#page-template-detail .page-content {
  padding-bottom: calc(var(--bottom-bar-height) + 20px);
}

/* ----- 9. 按钮系统 ----- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--white);
  background-color: var(--primary);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(200, 99, 74, 0.3);
  transition: transform 0.15s, box-shadow 0.2s;
  min-width: 80px;
  letter-spacing: 0.01em;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(200, 99, 74, 0.15);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 28px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--border-light);
  border-radius: var(--radius-full);
  transition: background-color 0.2s;
  min-width: 80px;
}

.btn-secondary:active {
  background-color: var(--border);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--white);
  background-color: var(--danger);
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(212, 90, 90, 0.25);
  transition: transform 0.15s, box-shadow 0.2s;
  min-width: 80px;
}

.btn-danger:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(212, 90, 90, 0.12);
}

/* ----- 10. 小按钮（卡片/批量操作） ----- */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--primary);
  background-color: var(--primary-light);
  border-radius: var(--radius-full);
  transition: background-color 0.15s, transform 0.12s;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn-sm:active {
  background-color: var(--border);
  transform: scale(0.96);
}

.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--danger);
  background-color: var(--danger-light);
  border-radius: var(--radius-full);
  transition: background-color 0.15s, transform 0.12s;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn-danger-sm:active {
  background-color: #fcd5d5;
  transform: scale(0.96);
}

/* ----- 11. FAB ----- */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-fab);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--white);
  font-size: 30px;
  font-weight: 400;
  font-family: 'DM Sans', sans-serif;
  box-shadow: 0 4px 16px rgba(200, 99, 74, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(200, 99, 74, 0.2);
}

/* ----- 12. 首页清单卡片 ----- */
.checklist-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 4px 0;
}

.card {
  position: relative;
  padding: 18px 16px 14px;
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
}

.card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-type {
  font-size: 28px;
  line-height: 1;
}

.card-status {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.status-preparing {
  background-color: var(--primary-light);
  color: var(--primary);
}

.status-traveled {
  background-color: var(--secondary-light);
  color: var(--secondary);
}

.card-title {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-progress-bar {
  flex: 1;
  height: 6px;
  background-color: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background-color: var(--secondary);
  transition: width 0.5s var(--ease-smooth);
}

.card-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

/* ----- 13. 进度条区域（详情页） ----- */
.progress-section {
  padding: 16px 16px 14px;
  background-color: var(--secondary-light);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.progress-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary-deep);
  margin-bottom: 8px;
}

.warning-text {
  font-size: 12px;
  color: var(--danger);
  font-weight: 500;
}

.progress-bar {
  width: 100%;
  height: var(--progress-height);
  background-color: rgba(61, 122, 122, 0.15);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background-color: var(--secondary);
  transition: width 0.6s var(--ease-smooth);
  position: relative;
}

.progress-fill.complete {
  background: linear-gradient(90deg, var(--secondary), #5a9e6f);
}

/* ----- 14. 分类折叠区 ----- */
.category {
  margin-bottom: 14px;
  background-color: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s;
}

.category-header:active {
  background-color: var(--border-light);
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.collapse-arrow {
  display: inline-block;
  transition: transform 0.25s var(--ease-smooth);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.collapse-arrow.expanded {
  transform: rotate(90deg);
}

.category-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
}

.category-title {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-progress {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.category-body {
  overflow: hidden;
  transition: max-height 0.3s var(--ease-smooth), opacity 0.2s;
}

.category.collapsed .category-body {
  max-height: 0 !important;
  opacity: 0;
}

.category.collapsed .empty-category {
  display: none;
}

/* ----- 15. 物品行 ----- */
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background-color: var(--surface);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
  cursor: default;
  user-select: none;
  margin: 2px 6px;
}

.item-row:active {
  background-color: var(--border-light);
}

/* 自定义复选框 - 圆形 + 弹跳 */
.checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.25s var(--ease-bounce);
  cursor: pointer;
  background-color: var(--surface);
}

.checkbox .checkmark {
  font-size: 13px;
  color: var(--white);
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s var(--ease-bounce);
}

.checkbox.checked {
  background-color: var(--secondary);
  border-color: var(--secondary);
  transform: scale(1.05);
}

.checkbox.checked .checkmark {
  opacity: 1;
  transform: scale(1);
}

/* 物品内容 */
.item-content {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-name.checked {
  color: var(--text-muted);
  text-decoration: line-through;
}

.item-qty {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

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

.item-note {
  font-size: 12px;
  color: var(--text-muted);
}

.badge-mandatory {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  background-color: var(--danger-light);
  border-radius: 4px;
}

.badge-location {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--secondary);
  background-color: var(--secondary-light);
  border-radius: 4px;
}

/* 拖拽手柄 */
.item-drag-handle {
  font-size: 14px;
  color: var(--border);
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
  letter-spacing: -2px;
}

.item-drag-handle:active {
  cursor: grabbing;
}

.item-row.dragging {
  opacity: 0.4;
  background-color: var(--border-light);
}

/* 空分类 */
.empty-category {
  padding: 20px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  margin: 6px;
  transition: border-color 0.2s, color 0.2s;
}

.empty-category:active {
  border-color: var(--primary);
  color: var(--primary);
}

/* ----- 16. 多选模式 ----- */
.item-row.multi-select {
  padding-left: 12px;
  cursor: pointer;
}

.select-checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--white);
  flex-shrink: 0;
  transition: all 0.15s var(--ease-bounce);
}

.select-checkbox.checked {
  background-color: var(--secondary);
  border-color: var(--secondary);
}

.item-row.multi-select.selected {
  background-color: var(--secondary-light);
}

/* ----- 17. 底部输入栏 ----- */
.add-item-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(43, 33, 28, 0.05);
}

.category-selector {
  position: relative;
  flex-shrink: 0;
}

.btn-category-select {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 42px;
  padding: 0 12px;
  background-color: var(--border-light);
  border-radius: var(--radius-full);
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background-color 0.2s;
  white-space: nowrap;
  max-width: 140px;
}

.btn-category-select:active {
  background-color: var(--border);
}

.btn-category-select .arrow {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.btn-category-select.active .arrow {
  transform: rotate(180deg);
}

#selected-category-label,
#template-selected-category-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: var(--z-dialog);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
}

.category-picker.show {
  display: block;
  animation: picker-slide-up 0.2s var(--ease-smooth);
}

@keyframes picker-slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s;
  white-space: nowrap;
}

.picker-item:active {
  background-color: var(--primary-light);
}

.picker-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.add-input-wrap {
  flex: 1;
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-input-wrap input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  background-color: var(--border-light);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  min-width: 0;
}

.add-input-wrap input::placeholder {
  color: var(--text-muted);
}

.add-input-wrap input:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(200, 99, 74, 0.08);
}

.btn-add-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  color: var(--white);
  background-color: var(--primary);
  border-radius: var(--radius-full);
  transition: transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.btn-add-item:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(200, 99, 74, 0.2);
}

/* ----- 18. 遮罩层 ----- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-overlay);
  background-color: rgba(43, 33, 28, 0.35);
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.overlay.hidden {
  display: none;
  opacity: 0;
}

/* ----- 19. 对话框 ----- */
.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-dialog);
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  overflow-y: auto;
  transition: opacity 0.25s ease;
}

.dialog.hidden {
  display: none;
  opacity: 0;
}

.dialog:not(.hidden) {
  animation: dialog-enter 0.3s var(--ease-bounce);
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.dialog-content {
  position: relative;
  background-color: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
  border-top: 3px solid var(--primary);
}

.dialog-content h2 {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

.dialog-actions .btn-primary,
.dialog-actions .btn-secondary,
.dialog-actions .btn-danger {
  flex: 1;
}

/* 菜单对话框 */
.dialog-menu {
  max-width: 240px;
}

.dialog-menu-items {
  background-color: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
  text-align: left;
  cursor: pointer;
}

.menu-item:active {
  background-color: var(--border-light);
}

/* ----- 20. 表单控件 ----- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 13px;
}

.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background-color: var(--border-light);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 3px rgba(200, 99, 74, 0.08);
}

.form-group select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background-color: var(--border-light);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s;
  appearance: auto;
}

.form-group select:focus {
  border-color: var(--primary);
}

/* checkbox 组 */
.checkbox-group {
  margin-bottom: 12px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-secondary);
  user-select: none;
  padding: 6px 0;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--secondary);
  cursor: pointer;
  flex-shrink: 0;
}

/* 类型选择器 */
.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--border-light);
  border-radius: var(--radius-full);
  transition: all 0.2s;
  border: 2px solid transparent;
}

.type-btn:active {
  transform: scale(0.96);
}

.type-btn.active {
  color: var(--primary);
  background-color: var(--primary-light);
  border-color: var(--primary);
  font-weight: 600;
}

/* 模板选择 */
.template-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-select .template-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  background-color: var(--border-light);
  border-radius: var(--radius-full);
  transition: all 0.2s;
  border: 2px solid transparent;
  cursor: pointer;
}

.template-select .template-option:active {
  transform: scale(0.96);
}

.template-select .template-option.active {
  color: var(--secondary);
  background-color: var(--secondary-light);
  border-color: var(--secondary);
  font-weight: 500;
}

/* ----- 21. 模板页面 ----- */
.template-section {
  margin-bottom: 24px;
}

.section-title {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-left: 4px;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background-color: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  margin-bottom: 10px;
}

.template-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.template-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.template-type {
  font-size: 24px;
}

.badge-builtin {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background-color: var(--accent-light);
  border-radius: var(--radius-full);
}

.template-name {
  font-family: 'Fraunces', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.template-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* 模板内物品 */
.template-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background-color: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s;
  margin: 2px 6px;
}

.template-item:active {
  background-color: var(--border-light);
}

.item-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-size: 14px;
  color: var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.15s;
  margin-left: auto;
}

.item-delete:active {
  color: var(--danger);
  background-color: var(--danger-light);
}

/* ----- 22. 批量操作栏 ----- */
.batch-actions-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fab);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(43, 33, 28, 0.06);
  align-items: center;
  gap: 8px;
}

.batch-count {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  flex-shrink: 0;
  margin-right: auto;
}

/* ----- 23. Toast ----- */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background-color: var(--text);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  max-width: calc(100% - 48px);
  text-align: center;
  pointer-events: none;
}

.toast.hidden {
  display: none;
}

.toast:not(.hidden) {
  animation: toast-in 0.35s var(--ease-smooth);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ----- 24. 庆祝动画 ----- */
.celebration {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-celebration);
  font-size: 80px;
  pointer-events: none;
  user-select: none;
}

.celebration.hidden {
  display: none;
}

.celebration:not(.hidden) {
  animation: celebration-pop 0.8s var(--ease-bounce) forwards;
}

@keyframes celebration-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-15deg);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
  }
  50% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1) rotate(-3deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.8) rotate(0deg);
  }
}

.celebration::before,
.celebration::after {
  content: '✨';
  position: absolute;
  font-size: 30px;
  opacity: 0;
}

.celebration::before {
  top: -30px;
  left: -40px;
  animation: confetti-1 0.8s var(--ease-bounce) forwards;
}

.celebration::after {
  top: -20px;
  right: -40px;
  animation: confetti-2 0.8s var(--ease-bounce) forwards 0.1s;
}

@keyframes confetti-1 {
  0% { opacity: 0; transform: translate(0, 0) scale(0) rotate(0deg); }
  20% { opacity: 1; transform: translate(-20px, -30px) scale(1) rotate(-20deg); }
  100% { opacity: 0; transform: translate(-60px, -80px) scale(0.5) rotate(-60deg); }
}

@keyframes confetti-2 {
  0% { opacity: 0; transform: translate(0, 0) scale(0) rotate(0deg); }
  20% { opacity: 1; transform: translate(20px, -25px) scale(1) rotate(20deg); }
  100% { opacity: 0; transform: translate(60px, -75px) scale(0.5) rotate(60deg); }
}

/* ----- 25. 滚动条 ----- */
.page-content::-webkit-scrollbar {
  width: 4px;
}

.page-content::-webkit-scrollbar-track {
  background: transparent;
}

.page-content::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

/* ----- 26. 分类管理对话框 ----- */
.cm-list {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.cm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-light);
}

.cm-item:last-child {
  border-bottom: none;
}

.cm-icon {
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.15s;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary-light);
  border-radius: var(--radius-sm);
}

.cm-icon:active {
  transform: scale(0.9);
}

.cm-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.cm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
  cursor: pointer;
}

.cm-btn:active {
  background-color: var(--border-light);
}

.cm-btn-danger:active {
  background-color: var(--danger-light);
}

.cm-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.cm-add-row input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  background-color: var(--border-light);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 15px;
  color: var(--text);
  transition: border-color 0.2s;
}

.cm-add-row input:focus {
  border-color: var(--primary);
  outline: none;
}

.cm-add-row input::placeholder {
  color: var(--text-muted);
}

/* 图标选择器 */
.ci-picker {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-celebration);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  width: calc(100% - 48px);
  max-width: 360px;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ci-picker.hidden {
  display: none !important;
}

.ci-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s, transform 0.12s;
}

.ci-option:active {
  background-color: var(--primary-light);
  transform: scale(1.15);
}

/* ----- 27. 工具类 ----- */
.hidden {
  display: none !important;
}

/* ----- 28. 桌面适配 ----- */
@media (min-width: 768px) {
  body {
    background-color: var(--bg);
    padding: 20px 0;
  }

  #app {
    max-width: min(90vw, 680px);
    border-radius: var(--radius-lg);
    min-height: calc(100vh - 40px);
    min-height: calc(100dvh - 40px);
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    box-shadow: var(--shadow-lg);
  }

  .checklist-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dialog { max-width: 420px; }
  .dialog-menu { max-width: 260px; }

  .add-item-bar {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  .fab {
    bottom: 32px;
    right: 32px;
  }

  .btn-category-select { max-width: 160px; }
  .page-content::-webkit-scrollbar { width: 6px; }
}

@media (min-width: 1024px) {
  body {
    padding: 32px 0;
  }

  #app {
    max-width: min(80vw, 820px);
    min-height: calc(100vh - 64px);
    min-height: calc(100dvh - 64px);
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
  }

  .checklist-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  body { font-size: 16px; }
}

/* ----- 29. 暗色模式 ----- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #24211e;
    --text: #f0ece8;
    --text-secondary: #c4bbb3;
    --text-muted: #8c8075;
    --border: #3a3531;
    --border-light: #2d2926;
    --primary-light: #3a2a24;
    --secondary-light: #1e2f2f;
    --accent-light: #3a3022;
    --danger-light: #3a2222;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  body {
    background-color: #12110f;
  }

  #app {
    box-shadow: none;
  }

  .app-header {
    border-bottom-color: var(--border);
  }

  .progress-section {
    border-bottom-color: var(--border);
  }

  .btn-category-select,
  .add-input-wrap input,
  .form-group input[type="text"],
  .form-group input[type="number"],
  .form-group select {
    background-color: var(--border-light);
  }

  .add-input-wrap input:focus,
  .form-group input[type="text"]:focus,
  .form-group input[type="number"]:focus {
    background-color: var(--surface);
  }

  .toast {
    background-color: var(--text);
    color: var(--bg);
  }

  .overlay {
    background-color: rgba(0, 0, 0, 0.5);
  }

  .btn-secondary {
    background-color: var(--border-light);
    color: var(--text-secondary);
  }

  .btn-secondary:active {
    background-color: var(--border);
  }

  .type-btn,
  .template-select .template-option {
    background-color: var(--border-light);
  }
}