:root {
  color-scheme: light dark;

  /* 双值写法：第一行是旧浏览器兜底，第二行 light-dark() 随配色方案自动切换 */
  --bg: #f5f7fb;
  --bg: light-dark(#f5f7fb, #0f172a);
  --surface: #ffffff;
  --surface: light-dark(#ffffff, #111c33);
  --text: #1f2937;
  --text: light-dark(#1f2937, #e5e7eb);
  --text-muted: #6b7280;
  --text-muted: light-dark(#6b7280, #94a3b8);
  --border: #e5e7eb;
  --border: light-dark(#e5e7eb, #1f2a44);
  --primary: #2563eb;
  --primary: light-dark(#2563eb, #60a5fa);
  --primary-soft: #dbeafe;
  --primary-soft: light-dark(#dbeafe, rgba(96, 165, 250, 0.16));
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow: light-dark(0 8px 24px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(0, 0, 0, 0.25));
  --shadow-hover: 0 12px 32px rgba(15, 23, 42, 0.14);
  --shadow-hover: light-dark(
    0 12px 32px rgba(15, 23, 42, 0.14),
    0 12px 32px rgba(0, 0, 0, 0.35)
  );
  --radius: 16px;
}

/* 强制浅色 / 深色：只影响 light-dark() 取值，不改变量定义 */
:root[data-theme="light"] {
  color-scheme: only light;
}

:root[data-theme="dark"] {
  color-scheme: only dark;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 32px 0 24px;
  text-align: center;
}

.header-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

/* 主题切换按钮：三态（跟随电脑 / 浅色 / 深色），右上角固定位置 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.theme-toggle .icon {
  display: none;
  width: 19px;
  height: 19px;
}

/* 无 JS 或未设置时默认显示「跟随电脑」图标 */
.theme-toggle .icon-system {
  display: block;
}

:root[data-theme="light"] .theme-toggle .icon-system,
:root[data-theme="dark"] .theme-toggle .icon-system {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-light,
:root[data-theme="dark"] .theme-toggle .icon-dark {
  display: block;
}

.site-header h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.2;
}

.site-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* 用 flex + 居中，卡片数量不足一行时整组居中，右侧不会留空白 */
.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  padding-bottom: 40px;
}

.card {
  flex: 1 1 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 22px 18px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.card-disabled {
  opacity: 0.65;
}

.card-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-icon-fallback {
  color: var(--primary);
  font-weight: 700;
  font-size: 18px;
}

.card-title {
  margin: 0;
  max-width: 100%;
  font-size: 16px;
  line-height: 1.35;
  word-break: break-word;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.status-normal {
  background: #dcfce7;
  background: light-dark(#dcfce7, rgba(34, 197, 94, 0.16));
  color: #166534;
  color: light-dark(#166534, #86efac);
}

.status-maintenance {
  background: #fef3c7;
  background: light-dark(#fef3c7, rgba(245, 158, 11, 0.16));
  color: #92400e;
  color: light-dark(#92400e, #fcd34d);
}

.status-disabled {
  background: #f3f4f6;
  background: light-dark(#f3f4f6, rgba(148, 163, 184, 0.16));
  color: #4b5563;
  color: light-dark(#4b5563, #cbd5e1);
}

.empty-state {
  padding: 48px 0;
  text-align: center;
  color: var(--text-muted);
}

.site-footer {
  padding: 24px 0 40px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 520px) {
  .site-header {
    padding-top: 32px;
  }

  .card {
    flex: 1 1 100%;
    max-width: none;
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .theme-toggle {
    transition: none;
  }
}
