/* ==========================================================================
   components.css — 通用组件（紧凑刻度）
   ========================================================================== */

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 13px; border-radius: var(--r1);
  border: 1px solid transparent; background: transparent;
  font-size: var(--fs-13); font-weight: 550; line-height: 1.5; white-space: nowrap;
  cursor: pointer; user-select: none; position: relative; overflow: hidden;
  transition: background-color .18s var(--ease), color .18s var(--ease),
              border-color .18s var(--ease), transform .22s var(--spring), box-shadow .2s var(--ease);
}
.btn::after {
  content: ''; position: absolute; inset: 0; background: currentColor;
  opacity: 0; transition: opacity .18s var(--ease); pointer-events: none;
}
.btn:hover::after { opacity: .05; }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--sh1); }
.btn-primary::after { background: #000; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn-outline { border-color: var(--accent-line); color: var(--accent); background: var(--surface); }
.btn-quiet { border-color: var(--line-2); color: var(--ink-2); background: var(--surface); }
.btn-quiet:hover:not(:disabled) { color: var(--ink); border-color: var(--line-3); background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); padding: 6px 9px; }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--line-2); background: var(--surface); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn-ink { background: var(--ink); color: var(--bg); }
.btn-ink:hover:not(:disabled) { opacity: .88; }

.btn-xs { padding: 3px 8px; font-size: var(--fs-11); border-radius: var(--r1); gap: 4px; }
.btn-sm { padding: 4px 10px; font-size: var(--fs-12); border-radius: var(--r1); gap: 5px; }
.btn-lg { padding: 9px 20px; font-size: var(--fs-14); border-radius: var(--r2); }
.btn-block { width: 100%; }
.btn .ic { opacity: .92; }

.icon-btn {
  width: 28px; height: 28px; border-radius: var(--r1);
  display: grid; place-items: center; color: var(--ink-2);
  border: 1px solid transparent; flex: none;
  transition: color .18s var(--ease), background-color .18s var(--ease),
              border-color .18s var(--ease), transform .22s var(--spring);
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }

.spin {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 1.8px solid currentColor; border-top-color: transparent;
  animation: spin .65s linear infinite; opacity: .85;
}

/* ---------------- 表单 ---------------- */
.field { position: relative; margin-bottom: var(--sp3); }
.field:last-child { margin-bottom: 0; }
.field > label, .label {
  display: block; margin-bottom: 5px;
  font-size: var(--fs-11); font-weight: 650; letter-spacing: .04em; color: var(--ink-2);
}
.field .hint { margin-top: 4px; font-size: var(--fs-11); color: var(--ink-3); line-height: 1.55; }

.input, .textarea, .select {
  width: 100%; padding: 7px 11px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  color: var(--ink); font-size: var(--fs-13); line-height: 1.55;
  outline: none; appearance: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background-color .18s var(--ease);
}
.textarea { resize: vertical; min-height: 68px; line-height: 1.7; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--line-3); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:disabled, .textarea:disabled { background: var(--surface-2); color: var(--ink-3); }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%238A8171' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  padding-right: 28px; cursor: pointer;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp4); }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 var(--sp4); }
@media (max-width: 760px) { .form-grid, .form-grid-3 { grid-template-columns: 1fr; } }

/* 复选 */
.check {
  display: inline-flex; align-items: center; gap: var(--sp2);
  font-size: var(--fs-13); color: var(--ink-2); cursor: pointer; user-select: none;
  transition: color .18s var(--ease);
}
.check:hover { color: var(--ink); }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 15px; height: 15px; border-radius: 4px; flex: none;
  border: 1.5px solid var(--line-3); background: var(--surface);
  display: grid; place-items: center;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), transform .22s var(--spring);
}
.check .box::after {
  content: ''; width: 8px; height: 4px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0); transition: transform .22s var(--spring);
  margin-top: -2px;
}
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-soft); }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 34px; height: 19px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line-2);
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}
.switch .track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 13px; height: 13px; border-radius: 50%; background: var(--surface);
  box-shadow: var(--sh1);
  transition: transform .22s var(--spring);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); background: #fff; }

/* 滑块 */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; border-radius: 3px;
  background: var(--line-2); outline: none; }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.22); cursor: pointer;
  transition: transform .18s var(--spring);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 2.5px solid var(--surface); cursor: pointer;
}
.range-row { display: flex; align-items: center; gap: var(--sp3); }
.range-val {
  font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 600;
  color: var(--accent); min-width: 38px; text-align: right; font-variant-numeric: tabular-nums;
}

/* 分段控件 */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r2);
}
.segmented button {
  padding: 4px 11px; border-radius: var(--r1);
  font-size: var(--fs-12); color: var(--ink-3); white-space: nowrap;
  transition: color .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.segmented button:hover { color: var(--ink-2); }
.segmented button.is-on {
  color: var(--ink); background: var(--surface); box-shadow: var(--sh1); font-weight: 600;
}

/* AI 触发按钮 */
.ai-btn {
  position: absolute; right: 6px; top: 25px; z-index: 3;
  width: 24px; height: 24px; border-radius: var(--r1);
  border: 1px solid var(--accent-line); background: var(--surface);
  color: var(--accent); display: none; place-items: center;
  box-shadow: var(--sh1);
  transition: background-color .18s var(--ease), transform .22s var(--spring), color .18s var(--ease);
}
.field:focus-within .ai-btn { display: grid; }
.field:has(.textarea) .ai-btn { top: 27px; }
.field.no-label .ai-btn { top: 6px; }
.field.no-label:has(.textarea) .ai-btn { top: 7px; }
.ai-btn:hover { background: var(--accent); color: #fff; transform: scale(1.07); }
.ai-btn:active { transform: scale(.94); }

/* ---------------- 卡片 ---------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  box-shadow: var(--sh1);
}
.card + .card { margin-top: var(--sp3); }
.card-hover:hover { border-color: var(--line-2); box-shadow: var(--sh2); }
.card-head {
  padding: var(--sp3) var(--sp4);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp3);
}
.card-head .grow { flex: 1; min-width: 0; }
.card-title {
  font-size: var(--fs-14); font-weight: 650; letter-spacing: .01em;
  display: flex; align-items: center; gap: 7px; line-height: 1.35;
}
.card-title .ic { color: var(--accent); }
.card-desc { font-size: var(--fs-11); color: var(--ink-3); margin-top: 2px; line-height: 1.55; }
.card-body { padding: var(--sp4); }
.card-foot {
  padding: var(--sp3) var(--sp4); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp2); flex-wrap: wrap;
}

.acc-num {
  display: inline-grid; place-items: center;
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  font-family: var(--font-mono); font-size: var(--fs-10); font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}

.block-label {
  display: flex; align-items: center; gap: var(--sp2);
  font-size: var(--fs-10); font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin: var(--sp4) 0 var(--sp2);
}
.block-label:first-child { margin-top: 0; }
.block-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.block-label .tag { text-transform: none; letter-spacing: 0; }

/* 提示条 */
.note {
  display: flex; gap: var(--sp2); align-items: flex-start;
  padding: var(--sp2) var(--sp3); border-radius: var(--r2);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--ink-2); line-height: 1.65;
}
.note .ic { color: var(--accent); margin-top: 2px; flex: none; }
.note.is-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }

/* ---------------- 标签 / 胶囊 ---------------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-11); font-weight: 550; letter-spacing: .01em;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap; line-height: 1.65;
}
.tag-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tag-jade   { background: var(--jade-soft); border-color: color-mix(in srgb, var(--jade) 30%, transparent); color: var(--jade); }
.tag-gold   { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 34%, transparent); color: var(--gold); }
.tag-ok     { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); color: var(--ok); }
.tag-warn   { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }
.tag-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--r-pill); cursor: pointer; user-select: none;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font-size: var(--fs-12); line-height: 1.55;
  transition: color .16s var(--ease), border-color .16s var(--ease),
              background-color .16s var(--ease), transform .2s var(--spring);
}
.chip::before {
  content: ''; width: 4px; height: 4px; border-radius: 50%; flex: none;
  background: var(--line-3); transition: background-color .16s var(--ease);
}
.chip:hover { color: var(--accent); border-color: var(--accent-line); }
.chip:hover::before { background: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.is-on::before { background: #fff; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-input .tag { padding: 3px 6px 3px 9px; font-size: var(--fs-11); }
.chip-input .tag button {
  display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  color: inherit; opacity: .6; transition: opacity .15s var(--ease), background-color .15s var(--ease);
}
.chip-input .tag button:hover { opacity: 1; background: var(--line); }
.chip-input input {
  flex: 1; min-width: 100px; border: none; background: transparent;
  font-size: var(--fs-12); padding: 4px 0; outline: none; color: var(--ink);
}
.chip-input input::placeholder { color: var(--ink-4); }

/* ---------------- 进度 ---------------- */
.bar { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 3px; background: var(--accent);
  transition: width .45s var(--ease);
}
.bar.is-ok > i { background: var(--ok); }
.bar.is-warn > i { background: var(--warn); }
.bar.is-thin { height: 2px; }

/* ---------------- 弹窗 ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in srgb, var(--ink) 40%, transparent);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 18px 24px; overflow-y: auto;
  animation: fade-in .16s var(--ease) both;
}
.dialog {
  position: relative; width: 100%; max-width: 600px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r4); box-shadow: var(--sh3);
  animation: pop-in .24s var(--ease-out) both;
}
.dialog-wide { max-width: 760px; }
.dialog-full { max-width: 1080px; }
.dialog-head { padding: var(--sp5) var(--sp5) 0; }
.dialog-title {
  font-family: var(--font-book); font-size: var(--fs-18); font-weight: 600;
  display: flex; align-items: center; gap: var(--sp2); line-height: 1.35;
}
.dialog-desc { font-size: var(--fs-12); color: var(--ink-3); margin-top: 4px; line-height: 1.6; }
.dialog-body { padding: var(--sp4) var(--sp5); }
.dialog-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp2);
  padding: var(--sp3) var(--sp5) var(--sp5); border-top: 1px solid var(--line); margin-top: var(--sp1);
}
.dialog-foot .grow { flex: 1; }
.x-btn {
  position: absolute; top: var(--sp3); right: var(--sp3);
  width: 26px; height: 26px; border-radius: var(--r1);
  display: grid; place-items: center; color: var(--ink-3); z-index: 2;
  transition: color .18s var(--ease), background-color .18s var(--ease), transform .25s var(--spring);
}
.x-btn:hover { color: var(--ink); background: var(--surface-2); transform: rotate(90deg); }

/* 抽屉 */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: color-mix(in srgb, var(--ink) 28%, transparent);
  backdrop-filter: blur(3px);
  animation: fade-in .16s var(--ease) both;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(440px, 92vw); background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--sh3);
  display: flex; flex-direction: column;
  animation: drawer-in .26s var(--ease-out) both;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; gap: var(--sp2);
  padding: var(--sp3) var(--sp4); border-bottom: 1px solid var(--line); flex: none;
}
.drawer-title { font-size: var(--fs-14); font-weight: 650; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp4); }

/* ---------------- Toast ---------------- */
.toasts {
  position: fixed; bottom: var(--sp6); left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; align-items: center; gap: var(--sp2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--r-pill);
  font-size: var(--fs-12); white-space: nowrap;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--sh3); border: 1px solid transparent;
  animation: pop-in .24s var(--ease-out) both;
}
.toast .ic { opacity: .85; }
.toast.is-ok { background: var(--ok); color: #fff; }
.toast.is-err { background: var(--danger); color: #fff; }
.toast.is-warn { background: var(--warn); color: #fff; }
.toast.is-out { animation: fade-in .2s var(--ease) reverse both; }

/* ---------------- 菜单 ---------------- */
.menu {
  position: fixed; z-index: 120; min-width: 168px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r2); box-shadow: var(--sh3);
  animation: pop-in .16s var(--ease-out) both;
}
.menu button {
  display: flex; align-items: center; gap: var(--sp2); width: 100%;
  padding: 6px 9px; border-radius: var(--r1); font-size: var(--fs-12); color: var(--ink-2);
  text-align: left; transition: background-color .14s var(--ease), color .14s var(--ease);
}
.menu button:hover { background: var(--surface-2); color: var(--ink); }
.menu button.is-danger { color: var(--danger); }
.menu button.is-danger:hover { background: var(--danger-soft); }
.menu hr { height: 1px; background: var(--line); border: none; margin: 4px 2px; }

/* ---------------- 骨架屏 ---------------- */
.skel {
  border-radius: var(--r1);
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel-card { height: 108px; border-radius: var(--r3); }

/* ---------------- 空状态 ---------------- */
.empty {
  text-align: center; padding: var(--sp8) var(--sp4);
  animation: fade-up .4s var(--ease-out) both;
}
.empty .glyph {
  width: 46px; height: 46px; margin: 0 auto var(--sp3); border-radius: var(--r3);
  display: grid; place-items: center;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--accent);
  box-shadow: var(--sh1);
}
.empty h2 { font-family: var(--font-book); font-size: var(--fs-20); font-weight: 600; }
.empty p { color: var(--ink-3); margin: var(--sp2) 0 var(--sp4); font-size: var(--fs-12); }
.empty .row { justify-content: center; }