/* 基础与变量 */
:root {
  --bg-page: #f5f6f8;
  --bg-card: #fff;
  --bg-sidebar: #fff;
  --bg-header: #fff;
  --border: #e8eaed;
  --text: #1f2937;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 10px;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
}

/* 顶栏 */
.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  line-height: 1;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.header-search {
  flex: 1;
  max-width: 560px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-page);
  transition: border-color .2s;
}

.header-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.header-actions {
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  transition: background .2s, border-color .2s;
}

.btn-download:hover {
  background: #e0e7ff;
  border-color: var(--accent);
  color: var(--accent);
}

/* 主体布局 */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* 侧栏 */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: background .2s;
}

.nav-item:hover {
  background: var(--bg-page);
}

.nav-item.active {
  background: #eff6ff;
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.nav-toggle {
  justify-content: space-between;
}

.nav-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .2s;
}

.nav-section.expanded .nav-arrow {
  transform: rotate(0deg);
}

.nav-section:not(.expanded) .nav-arrow {
  transform: rotate(-90deg);
}

.category-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--border);
  margin-left: 28px;
}

.nav-section:not(.expanded) .category-list {
  display: none;
}

.category-list li {
  margin: 0;
}

.category-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  transition: background .2s, color .2s;
}

.category-list a:hover {
  background: var(--bg-page);
}

.category-list a.active {
  background: #dbeafe;
  color: var(--accent);
  font-weight: 500;
}

/* 主内容区 */
.main {
  flex: 1;
  padding: 24px 32px 48px;
  min-width: 0;
}

.main-title {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.tool-card {
  display: block;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}

.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  border-color: #c7d2fe;
  transform: translateY(-2px);
}

.tool-card .icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: #f0f4ff;
  margin-bottom: 12px;
}

.tool-card .name {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.tool-card .description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0;
  font-size: 15px;
}

@media (max-width: 900px) {
  .header {
    flex-wrap: wrap;
  }
  .header-search {
    order: 3;
    max-width: none;
    width: 100%;
  }
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .category-list {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
  }
  .tool-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
