/* 共享主题与基础控件 */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-hover: #f1f5f9;
  --text: #172033;
  --muted: #5b6679;
  --faint: #7b8ba3;
  --border: #dfe6f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf2ff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --success: #059669;
  --glow-1: rgba(37, 99, 235, 0.06);
  --glow-2: rgba(96, 165, 250, 0.06);
  --shadow-sm: 0 1px 2px rgba(24, 42, 74, 0.04);
  --shadow-md: 0 14px 35px rgba(24, 42, 74, 0.1);
  --radius: 18px;
  --radius-sm: 11px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b101c;
  --surface: #121a2b;
  --surface-2: #172033;
  --surface-hover: #1c2740;
  --text: #e8eefc;
  --muted: #9aa9c4;
  --faint: #6f7f9c;
  --border: #22304a;
  --border-strong: #334563;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --accent-text: #0b101c;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #34d399;
  --glow-1: rgba(96, 165, 250, 0.12);
  --glow-2: rgba(37, 99, 235, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 16px 40px -16px rgba(0, 0, 0, 0.7);
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 控件 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

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

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

.icon-btn.ghost-border {
  border-color: var(--border);
  background: var(--surface);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  height: auto;
  min-height: 76px;
  padding: 10px 12px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.hint {
  font-size: 12px;
  color: var(--faint);
}

/* 站点图标（前台卡片与后台列表共用） */
.icon {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.icon img {
  position: absolute;
  inset: 0;
  width: 22px;
  height: 22px;
  margin: auto;
  object-fit: contain;
}

.icon-letter {
  color: var(--faint);
  font-size: 15px;
  font-weight: 650;
  text-transform: uppercase;
}

.icon-emoji {
  font-size: 19px;
  line-height: 1;
}

/* 提示条 */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in 0.2s ease both;
}

.toast.error {
  color: var(--danger);
  border-color: var(--danger);
}

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

.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;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
