/* base.css — 重置 / 壁纸层 / 通用控件 / 工具类 */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--c-text);
  background: var(--c-default-body);
}

body { user-select: none; }
input, textarea { user-select: text; font-family: inherit; }
button { font-family: inherit; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { width: 20px; height: 20px; display: block; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.92em; }

button, input, textarea { border: 0; outline: 0; background: none; color: inherit; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

/* ---------- 壁纸层 ---------- */
.wp-layer {
  position: fixed; inset: calc(var(--wallpaper-blur) * -2);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(var(--wallpaper-blur));
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease), filter var(--dur-base) var(--ease);
  z-index: 0;
  will-change: opacity;
}
.wp-layer.visible { opacity: 1; }
#wp-mask {
  position: fixed; inset: 0; z-index: 1;
  background: rgba(0, 0, 0, var(--mask-alpha));
  transition: background-color var(--dur-base) var(--ease);
}

#app { position: fixed; inset: 0; z-index: 2; zoom: var(--ui-scale); }

/* ---------- 通用按钮 ---------- */
.round-btn {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  display: grid; place-items: center;
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast);
}
.round-btn:hover { transform: scale(1.06); }
.round-btn:active { transform: scale(0.96); }
.round-btn.ghost { background: rgba(255, 255, 255, 0.16); color: #fff; }
.round-btn.ghost:hover { background: rgba(255, 255, 255, 0.28); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: grid; place-items: center; color: var(--c-text-muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.icon-btn:hover { background: var(--c-panel-soft); color: var(--c-text); }

.square-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  background: var(--c-accent); color: #fff;
  transition: filter var(--dur-fast);
}
.square-btn:hover { filter: brightness(1.06); }

.btn {
  height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--c-text);
  background: var(--c-panel-soft);
  transition: background var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--c-border); }
.btn.primary { background: var(--c-accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--c-text-secondary); }
.btn.ghost:hover { background: var(--c-panel-soft); }
.btn.danger { background: var(--c-danger); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--c-danger); }
.btn.danger-ghost:hover { background: var(--c-danger-weak); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-ico { width: 14px; height: 14px; }

.field {
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px;
  background: var(--c-panel); border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
}
.field:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-weak); }
.field .field-icon { width: 17px; height: 17px; color: var(--c-text-muted); flex: 0 0 auto; }
.field input { flex: 1; min-width: 0; height: 100%; font-size: 13px; }

/* ---------- 通用工具类 ---------- */
.hidden { display: none !important; }
.muted { color: var(--c-text-muted); }
.small { font-size: 12px; }
.empty-tip { color: var(--c-text-muted); font-size: 13px; text-align: center; padding: 40px 16px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; z-index: 3000;
  transform: translate(-50%, 8px);
  padding: 9px 18px; border-radius: var(--radius-pill);
  background: rgba(20, 24, 32, 0.86); color: #fff;
  font-size: 13px; max-width: min(70vw, 560px); text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base);
  backdrop-filter: blur(6px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.has-action { pointer-events: auto; }
.toast-action {
  margin-left: 10px; padding: 0; border: 0; background: none;
  color: #8ab8ff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.toast-action:hover { color: #b9d4ff; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(30, 36, 48, 0.16); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(30, 36, 48, 0.26); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 弹层通用 ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 1200;
  background: var(--c-overlay);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; z-index: 1210;
  left: 50%; top: 50%;
  width: min(460px, 92vw);
  border-radius: var(--radius-lg);
  background: var(--c-panel);
  box-shadow: 0 24px 64px rgba(15, 20, 30, 0.28);
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease-out);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: min(86vh, 760px);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px;
  flex: 0 0 auto;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.modal-head .head-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.modal-body { padding: 4px 20px 8px; overflow: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 20px 18px; flex: 0 0 auto;
}
.form-row { display: block; margin-bottom: 14px; }
.form-row > span { display: block; font-size: 12px; color: var(--c-text-muted); margin-bottom: 7px; }
.form-row input[type=text] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--c-panel);
}
.form-row input[type=text]:focus { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-weak); }
.form-error { min-height: 18px; color: var(--c-danger); font-size: 12px; }

/* ---------- 弹出菜单 ---------- */
.popover {
  position: fixed; z-index: 2000;
  min-width: 176px; padding: 6px;
  background: var(--c-menu-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  border: 1px solid rgba(20, 26, 36, 0.06);
  animation: pop-in var(--dur-fast) var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.popover > button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--c-text); text-align: left;
}
.popover > button:hover { background: var(--c-panel-soft); }
.popover > button.danger { color: var(--c-danger); }
.popover .pop-sep { height: 1px; margin: 5px 4px; background: var(--c-border); }
.popover .pop-title { padding: 6px 10px 4px; font-size: 11px; color: var(--c-text-muted); }

/* 启动动画 */
@keyframes card-zoom { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes card-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
