:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --card-bg: #ffffff;
  --text: #1f2329;
  --text-secondary: #8a919c;
  --primary: #3b6ef0;
  --border: #eceef1;
  --hover-bg: #e8ecf3;
  --input-focus-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 10px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --card-bg: #1e2126;
  --text: #e6e8eb;
  --text-secondary: #9aa1ac;
  --primary: #5b85ff;
  --border: #2c3037;
  --hover-bg: #2c3037;
  --input-focus-bg: #14161a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.45);
}

html {
  transition: background 0.25s, color 0.25s;
}

body,
.site-header,
.site-footer,
.card {
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 60px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.logo span {
  color: var(--primary);
}

.search-box {
  flex: 1;
  max-width: 420px;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--bg);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  background: var(--input-focus-bg);
  color: var(--text);
}

.search-box input {
  color: var(--text);
}

/* Theme toggle */
.theme-toggle {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  border-color: var(--primary);
  transform: rotate(15deg);
}

/* Layout */
.layout {
  display: flex;
  gap: 24px;
  padding-top: 24px;
  padding-bottom: 40px;
  align-items: flex-start;
}

.sidebar {
  width: 160px;
  flex-shrink: 0;
  position: sticky;
  top: 84px;
}

.category-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-nav a {
  display: block;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.category-nav a:hover {
  background: var(--hover-bg);
}

.category-nav a.active {
  background: var(--primary);
  color: #fff;
}

.content {
  flex: 1;
  min-width: 0;
}

/* Sections & cards */
.category-section {
  margin-bottom: 32px;
}

.category-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid var(--primary);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  min-width: 0;
}

.card-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading,
.empty-tip {
  color: var(--text-secondary);
  padding: 40px 0;
  text-align: center;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  background: var(--card-bg);
}

/* Responsive */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
  }

  .category-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
