/* 通用组件：按钮 / 表单 / 卡片 / 弹窗 / 标签 / 提示 */

/* ── 按钮 ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: 99px;
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), opacity var(--dur-fast);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-input-hover); }
.btn-quiet { color: var(--text-2); padding: 0 10px; }
.btn-quiet:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 20%, transparent); }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 99px; }
.btn-sm { height: 28px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  display: inline-grid; place-items: center;
  color: var(--text-2);
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }

/* ── 表单 ───────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field-hint { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.field-hint a { color: var(--accent); }

.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:hover, .textarea:hover, .select:hover { background: var(--bg-input-hover); }
.input:focus, .textarea:focus, .select:focus {
  background: var(--bg-elevated);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.textarea { line-height: 1.6; resize: vertical; min-height: 84px; }
.input-sm { padding: 6px 10px; font-size: 13px; }
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%238a8a8f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; min-width: 0; }

.search-box { position: relative; display: flex; align-items: center; min-width: 180px; }
.search-box .icon { position: absolute; left: 10px; color: var(--text-3); width: 15px; height: 15px; }
.search-box .input { padding-left: 32px; height: 32px; padding-top: 0; padding-bottom: 0; border-radius: 99px; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 99px; background: var(--bg-input-hover);
  position: relative; transition: background var(--dur) var(--ease); flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* ── 卡片 ───────────────────────────── */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
}
.card-pad-sm { padding: 14px; }
.card-hover { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); cursor: pointer; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { flex: 1; }
.card-flat { background: var(--bg-input); box-shadow: none; }

.panel {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel-head h3 { font-size: 14px; flex: 1; }
.panel-body { padding: 16px; overflow: auto; min-height: 0; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); flex: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid-masonry { columns: 3 220px; column-gap: 16px; }
.grid-masonry > * { break-inside: avoid; margin-bottom: 16px; }

/* ── 标签 / 徽标 ───────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 10px;
  border-radius: 99px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-input); color: var(--text-2);
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.chip-btn { cursor: pointer; }
.chip-btn:hover { background: var(--bg-input-hover); color: var(--text); }
.chip.is-on { background: var(--accent-soft); color: var(--accent); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-input); color: var(--text-2);
}
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.badge-orange { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.badge-red { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.badge-purple { background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.badge-teal { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); flex: none; }
.dot-green { background: var(--green); }
.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }
.dot-pulse { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── 分段控件 ───────────────────────────── */
.segment {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--bg-input); border-radius: 9px;
}
.segment button {
  padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.segment button:hover { color: var(--text); }
.segment button.is-on { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-1); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  padding: 9px 14px; font-size: 13.5px; font-weight: 500; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.tabs button:hover { color: var(--text); }
.tabs button.is-on { color: var(--text); border-color: var(--accent); }

/* ── 弹窗 ───────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: fadeIn 0.2s var(--ease);
  overflow: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 900px);
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: modalIn 0.36s var(--ease-out);
  overflow: hidden;
}
.modal-wide { width: min(880px, 100%); }
.modal-full { width: min(1160px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 12px;
  flex: none;
}
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-head .modal-sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 2px; }
.modal-body { padding: 4px 20px 20px; overflow: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-sunken) 60%, transparent);
  flex: none;
}
.modal-foot .spread { margin-right: auto; }

.sheet {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 200;
  width: min(460px, 100%);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: sheetIn 0.36s var(--ease-out);
}
@keyframes sheetIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 提示条 ───────────────────────────── */
.toasts {
  position: fixed; z-index: 400; left: 50%; bottom: 28px;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-3);
  backdrop-filter: blur(12px);
  animation: toastIn 0.32s var(--ease-out);
  max-width: min(560px, 90vw);
}
.toast.is-out { animation: toastOut 0.24s var(--ease) forwards; }
.toast-err { background: color-mix(in srgb, var(--red) 92%, transparent); color: #fff; }
.toast-ok { background: color-mix(in srgb, #1c1c1e 92%, transparent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(0.97); } }

/* ── 空态 / 载入 / 骨架 ───────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 56px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty .empty-icon {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--bg-input); color: var(--text-3);
}
.empty .empty-icon svg { width: 24px; height: 24px; }
.empty h4 { color: var(--text); font-size: 15px; }
.empty p { font-size: 13px; max-width: 42ch; }

.spinner {
  width: 14px; height: 14px; flex: none;
  border: 1.8px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-input-hover) 37%, var(--bg-input) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.typing { display: inline-flex; gap: 3px; align-items: center; height: 16px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-3);
  animation: typing 1.2s var(--ease) infinite;
}
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px;
  border-radius: 5px; background: var(--bg-input); color: var(--text-3);
  border: 1px solid var(--line);
}

.tip {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 12.5px; line-height: 1.6;
}
.tip .icon { color: var(--accent); margin-top: 1px; }
.tip-warn { background: color-mix(in srgb, var(--orange) 12%, transparent); }
.tip-warn .icon { color: var(--orange); }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  transition: background var(--dur-fast); cursor: pointer;
}
.list-row:hover { background: var(--bg-hover); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .lr-sub { font-size: 11.5px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

.cover {
  aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(140deg, var(--bg-input), var(--bg-input-hover));
  display: grid; place-items: center; color: var(--text-4);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

.progress { height: 4px; border-radius: 99px; background: var(--bg-input); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s var(--ease); }
