/* ==========================================================================
   设计令牌 & 基础组件
   ========================================================================== */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --border: #e3e8ef;
  --border-strong: #d3dae6;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #8a94a6;
  --primary: #4f7cff;
  --primary-hover: #3f6ae8;
  --primary-soft: #eaf0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #12a594;
  --warning: #e8a33d;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

::selection {
  background: rgba(79, 124, 255, 0.18);
}

/* ------------------------------- 表单控件 -------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.input::placeholder,
.textarea::placeholder {
  color: #aab2c0;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #c2ccdc;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.15);
}

.textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.6;
}

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

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.12);
}

/* -------------------------------- 按钮 ----------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.06s, box-shadow 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #cf3b40;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* 加载态 */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------------------------------- 提示条 --------------------------------- */
.alert {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.45;
}

.alert.is-visible {
  display: flex;
}

.alert-error {
  background: var(--danger-soft);
  color: #a5282c;
  border: 1px solid #f7c9ca;
}

.alert-success {
  background: #e7f7f4;
  color: #0b7268;
  border: 1px solid #bde8e2;
}

/* -------------------------------- 模态框 --------------------------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
}

.modal-mask.is-open {
  display: flex;
  animation: fade-in 0.16s ease-out;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: pop-in 0.18s ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* -------------------------------- 轻提示 --------------------------------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}

.toast.is-error {
  background: #b3262b;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

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

.muted {
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
