/* ============================================================
   components.css — 通用组件：按钮/卡片/标签/表单/弹层/骨架屏…
   ============================================================ */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 46px; padding: 0 20px; border-radius: var(--r-full);
  font-size: 15px; font-weight: 600; letter-spacing: .2px;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), filter var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--g-brand); color: #fff; box-shadow: var(--sh-brand); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-indigo { background: var(--g-indigo); color: #fff; box-shadow: 0 8px 22px -8px rgba(99,102,241,.6); }
.btn-ghost { background: #fff; color: var(--brand-800); border: 1px solid var(--border); }
.btn-soft { background: rgba(99,102,241,.1); color: var(--indigo-d); }
.btn-success { background: var(--g-success); color: #fff; box-shadow: 0 8px 22px -8px rgba(16,185,129,.55); }
.btn-wechat { background: #07c160; color: #fff; box-shadow: 0 8px 22px -8px rgba(7,193,96,.5); }
.btn-block { width: 100%; }
.btn-lg { height: 52px; font-size: 16px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-full); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card); border-radius: var(--r-xl); padding: 18px;
  box-shadow: var(--sh-sm); border: 1px solid var(--border-soft);
}
.card-premium { box-shadow: var(--sh-brand); }
.card-micro { background: linear-gradient(145deg,#fff 0%,#f8f9ff 100%); }
.section-title { display:flex; align-items:center; justify-content:space-between; margin: 4px 2px 12px; }
.section-title h3 { font-size: 17px; font-weight: 800; display:flex; align-items:center; gap:6px; }
.section-title .more { font-size: 13px; color: var(--text-3); font-weight: 500; display:flex; align-items:center; gap:2px; }
.section-title h3 .sec-ic { display:inline-flex; color: var(--brand-600); }

/* 知识磁贴网格（取代单调长卡片列表） */
.tile-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.tile { background:#fff; border:1px solid var(--border-soft); border-radius: var(--r-lg); padding:15px 14px; text-align:left; box-shadow: var(--sh-xs); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast); }
.tile:active { transform: scale(.97); box-shadow: var(--sh-sm); }
.tile .tl-ic { width:40px; height:40px; border-radius:12px; display:flex; align-items:center; justify-content:center; margin-bottom:10px; }
.tile .tl-t { font-size:15px; font-weight:700; letter-spacing:-.2px; }
.tile .tl-d { font-size:11.5px; color:var(--text-3); margin-top:3px; line-height:1.45; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }

/* 横幅半透明艺术图标 */
.banner-art { position:absolute; right:-6px; bottom:-16px; color:#fff; opacity:.13; pointer-events:none; }

/* 对话角色渐变首字头像（高优先级，避免被 .msg-avatar 覆盖） */
.msg-avatar.ai-av, .ds-avatar.ai-av { background: var(--g-brand); color:#fff; font-size:15px; font-weight:800; border:none; box-shadow: var(--sh-brand); }

/* 空态 SVG 尺寸 */
.empty .e-ico { display:flex; align-items:center; justify-content:center; color: var(--text-4); }
.empty .e-ico svg { width:52px; height:52px; stroke-width:1.4; }

/* ---------- 标签 / chip ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 9px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; line-height: 1.5;
}
.tag-indigo { background: #eef2ff; color: #4f46e5; }
.tag-green  { background: #ecfdf5; color: #059669; }
.tag-amber  { background: #fffbeb; color: #d97706; }
.tag-rose   { background: #fff1f2; color: #e11d48; }
.tag-gray   { background: var(--bg-mute); color: var(--text-3); }
.tag-purple { background: #f5f3ff; color: #7c3aed; }

.chip {
  padding: 7px 15px; border-radius: var(--r-full); font-size: 13px; font-weight: 600;
  background: #fff; color: var(--text-2); border: 1px solid var(--border);
  transition: all var(--t-fast) var(--ease); white-space: nowrap;
}
.chip.active { background: var(--g-brand); color: #fff; border-color: transparent; box-shadow: var(--sh-brand); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.badge-gold {
  display:inline-flex; align-items:center; gap:3px; padding: 3px 10px; border-radius: var(--r-full);
  background: var(--g-gold); color: #78350f; font-size: 12px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(245,158,11,.3);
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field-label { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text-2); font-weight:600; margin-bottom:8px; }
.field-label .req { color: var(--danger); }
.input, .textarea, .select {
  width: 100%; padding: 13px 15px; border: 1.5px solid var(--border);
  border-radius: var(--r-md); background: #fff; font-size: 15px; color: var(--text-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3.5px rgba(124,58,237,.12); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { resize: none; line-height: 1.6; min-height: 96px; }
.input-icon { position: relative; }
.input-icon .ico { position:absolute; left:14px; top:50%; transform:translateY(-50%); font-size:16px; opacity:.7; }
.input-icon .input { padding-left: 40px; }
.input-icon .eye { position:absolute; right:8px; top:50%; transform:translateY(-50%); width:34px; height:34px; display:flex; align-items:center; justify-content:center; color:var(--text-4); font-size:16px; }
.form-hint { font-size: 12px; color: var(--text-4); margin-top: 6px; }
.form-err { font-size: 12px; color: var(--danger); margin-top: 6px; }

.seg { display:flex; background: var(--bg-mute); border-radius: var(--r-full); padding: 3px; gap: 3px; }
.seg button { flex:1; height: 34px; border-radius: var(--r-full); font-size:13px; font-weight:600; color:var(--text-3); transition: all var(--t-fast) var(--ease); }
.seg button.active { background:#fff; color: var(--brand-800); box-shadow: var(--sh-xs); }

.checkbox { display:flex; align-items:flex-start; gap:9px; font-size:13px; color:var(--text-2); cursor:pointer; line-height:1.5; }
.checkbox .box { width:19px; height:19px; min-width:19px; border-radius:6px; border:1.5px solid var(--border); display:flex; align-items:center; justify-content:center; color:#fff; font-size:12px; transition: all var(--t-fast); margin-top:1px; }
.checkbox.on .box { background: var(--g-brand); border-color: transparent; }

.switch { width:46px; height:27px; border-radius:var(--r-full); background:#d7dbe4; position:relative; transition: background var(--t-fast); flex:none; }
.switch::after { content:''; position:absolute; top:3px; left:3px; width:21px; height:21px; border-radius:50%; background:#fff; box-shadow:var(--sh-xs); transition: transform var(--t-fast) var(--ease); }
.switch.on { background: var(--success); }
.switch.on::after { transform: translateX(19px); }

/* ---------- 列表行 ---------- */
.list { background:#fff; border-radius: var(--r-xl); overflow:hidden; border:1px solid var(--border-soft); box-shadow: var(--sh-sm); }
.list-row { display:flex; align-items:center; gap:13px; padding: 15px 16px; position:relative; transition: background var(--t-fast); }
.list-row:active { background: var(--bg-subtle); }
.list-row + .list-row::before { content:''; position:absolute; left:16px; right:0; top:0; height:1px; background: var(--border-soft); }
.list-row .li-ico { width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:17px; flex:none; }
.list-row .li-body { flex:1; min-width:0; }
.list-row .li-title { font-size:15px; font-weight:600; }
.list-row .li-sub { font-size:12.5px; color:var(--text-4); margin-top:1px; }
.list-row .li-arrow { color:#cbd5e1; font-size:18px; flex:none; }
.dot-badge { min-width:17px; height:17px; padding:0 5px; border-radius:var(--r-full); background:var(--danger); color:#fff; font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center; }

/* ---------- 头像 ---------- */
.avatar { border-radius: 50%; object-fit: cover; background: var(--bg-mute); display:flex; align-items:center; justify-content:center; font-weight:800; color:#fff; flex:none; overflow:hidden; }

/* ---------- 进度条 ---------- */
.bar { height: 8px; border-radius: var(--r-full); background: var(--bg-mute); overflow: hidden; }
.bar > i { display:block; height:100%; border-radius:var(--r-full); background: var(--g-brand); transition: width .7s var(--ease); }
.bar.thin { height: 5px; }
.bar.thick { height: 12px; }

/* ---------- 环形进度 ---------- */
.ring { position: relative; display:inline-flex; align-items:center; justify-content:center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-val { position:absolute; text-align:center; }

/* ---------- 骨架屏 ---------- */
.skeleton {
  background: linear-gradient(90deg,#eef0f4 25%,#e2e5ec 37%,#eef0f4 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm);
}
.sk-line { height: 13px; margin-bottom: 9px; border-radius: 6px; }
.sk-card { height: 96px; border-radius: var(--r-lg); margin-bottom: 12px; }

/* ---------- 空状态 ---------- */
.empty { text-align:center; padding: 52px 24px; color: var(--text-4); }
.empty .e-ico { font-size: 52px; margin-bottom: 12px; opacity: .8; }
.empty .e-title { font-size: 15px; font-weight: 600; color: var(--text-3); margin-bottom: 5px; }
.empty .e-desc { font-size: 13px; }

/* ---------- 加载点 ---------- */
.spinner { width: 20px; height: 20px; border-radius:50%; border: 2.5px solid rgba(255,255,255,.35); border-top-color:#fff; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(124,58,237,.2); border-top-color: var(--brand-500); }
.dots { display:inline-flex; gap:4px; align-items:center; }
.dots i { width:7px; height:7px; border-radius:50%; background: var(--text-4); animation: bounceDot 1.3s infinite ease-in-out; }
.dots i:nth-child(2){ animation-delay:.16s } .dots i:nth-child(3){ animation-delay:.32s }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; left:50%; top: 16%; transform: translateX(-50%); z-index: 9000; display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none; width: max-content; max-width: 82%; }
.toast {
  padding: 11px 18px; border-radius: var(--r-full); font-size: 14px; font-weight: 500;
  background: rgba(30,27,50,.92); color:#fff; box-shadow: var(--sh-lg); backdrop-filter: blur(8px);
  animation: popIn .28s var(--ease-pop) both; display:flex; align-items:center; gap:7px; text-align:center;
}
.toast.success { background: rgba(5,150,105,.95); }
.toast.error { background: rgba(220,38,38,.95); }
.toast.out { animation: fadeIn .2s reverse both; }

/* ---------- 遮罩 / Modal / Sheet ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,11,30,.5); backdrop-filter: blur(3px);
  z-index: 8000; display:flex; align-items:center; justify-content:center; padding: 24px;
  animation: fadeIn .22s ease both;
}
.overlay.out { animation: fadeIn .2s reverse both; }
.modal {
  width: 100%; max-width: 340px; background:#fff; border-radius: var(--r-2xl); padding: 24px;
  box-shadow: 0 30px 70px -20px rgba(0,0,0,.45); animation: popIn .3s var(--ease-pop) both; max-height: 86vh; overflow-y:auto;
}
.modal.out { animation: popIn .2s reverse both; }
.modal h3 { font-size: 18px; margin-bottom: 8px; text-align:center; }
.modal .m-body { font-size: 14px; color: var(--text-2); text-align:center; line-height:1.6; }
.modal .m-actions { display:flex; gap:10px; margin-top: 20px; }
.modal .m-actions .btn { flex:1; height:44px; }

.sheet-overlay { position: fixed; inset:0; background: rgba(15,11,30,.5); backdrop-filter: blur(3px); z-index:8000; animation: fadeIn .22s ease both; }
.sheet {
  position: fixed; left:50%; bottom:0; transform: translateX(-50%); width:100%; max-width: var(--app-max);
  background:#fff; border-radius: var(--r-2xl) var(--r-2xl) 0 0; z-index:8001; padding: 8px 0 calc(16px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(0,0,0,.2); animation: sheetUp .34s var(--ease) both; max-height: 84vh; display:flex; flex-direction:column;
}
.sheet.out { animation: sheetUp .26s reverse both; }
@keyframes sheetUp { from { transform: translate(-50%,100%);} to { transform: translate(-50%,0);} }
.sheet .grab { width:38px; height:4px; border-radius:var(--r-full); background:#e2e5ec; margin: 6px auto 12px; flex:none; }
.sheet .sheet-head { padding: 0 20px 12px; flex:none; }
.sheet .sheet-body { padding: 0 16px; overflow-y:auto; }

/* ---------- 分段选择大卡 ---------- */
.pick-card { border: 1.5px solid var(--border); border-radius: var(--r-lg); padding: 14px; transition: all var(--t-fast) var(--ease); background:#fff; }
.pick-card.active { border-color: var(--brand-500); background: linear-gradient(135deg, rgba(99,102,241,.07), rgba(168,85,247,.07)); box-shadow: 0 6px 18px -6px rgba(124,58,237,.3); }
