/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --sidebar-w: 272px;
  --content-max: 680px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-hover: 0 4px 16px rgba(99,102,241,.13), 0 1px 3px rgba(0,0,0,.06);
}

body.dark {
  --bg: #0c0e14;
  --bg-subtle: #151822;
  --bg-card: #181c26;
  --border: #252a37;
  --border-subtle: #1e2330;
  --text: #f1f5f9;
  --text-muted: #8892a4;
  --text-faint: #4a5568;
  --accent-light: #1e1b4b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-hover: 0 4px 16px rgba(99,102,241,.2);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-subtle);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Centered page frame ── */
.page-frame {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Layout shell ── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-header {
  padding: 22px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.logo-badge {
  font-size: 10px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 20px;
  margin-left: 2px;
}

.sidebar-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  transition: border-color .15s, box-shadow .15s;
  cursor: text;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

.search-icon {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}

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

.search-kbd {
  font-size: 10px;
  color: var(--text-faint);
  background: var(--border-subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.search-scope {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.scope-pill {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .15s, background .15s, border-color .15s;
}

.scope-pill:hover { color: var(--text); border-color: var(--text-faint); }

.scope-pill.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px 8px;
  overflow-y: auto;
}

.nav-section { margin-bottom: 4px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 10px 5px;
  display: block;
}

.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .1s, color .1s;
  cursor: pointer;
  gap: 8px;
  line-height: 1.3;
}

.category-link-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-link:hover {
  background: var(--border-subtle);
  color: var(--text);
}

.category-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

.cat-count {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  line-height: 18px;
}

.category-link.active .cat-count {
  background: rgba(99,102,241,.12);
  border-color: rgba(99,102,241,.2);
  color: var(--accent);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 14px;
  line-height: 1;
  transition: background .12s, border-color .12s;
  color: var(--text-muted);
}

.theme-toggle:hover {
  background: var(--bg);
  border-color: var(--accent);
}

.updated-at {
  font-size: 11px;
  color: var(--text-faint);
  flex: 1;
  text-align: right;
}

/* ── Main wrapper ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.main-inner {
  width: 100%;
  max-width: calc(var(--content-max) + 80px);
  padding: 48px 40px 100px;
}

/* ── Hero section ── */
.hero {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 14px;
}

.hero-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 16px;
}

.hero-tag {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
}

.hero-tag:hover {
  background: var(--accent-light);
  border-color: rgba(99,102,241,.25);
  color: var(--accent);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-faint); }
.cat-hero { padding-top: 4px; }

.hero h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.hero-sub {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 560px;
}

/* ── Type tabs ── */
.type-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 4px;
  width: fit-content;
}

.type-tab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: background .12s, color .12s;
}

.type-tab:hover { color: var(--text); }

.type-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-count {
  font-size: 13px;
  color: var(--text-muted);
}

.result-count strong {
  color: var(--text);
  font-weight: 600;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.sort-control select {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  padding: 5px 10px;
  outline: none;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .12s;
}

.sort-control select:focus { border-color: var(--accent); }

/* ── Category header (shown when category selected) ── */
.category-header {
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.category-header h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.category-header p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .12s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.card:hover {
  border-color: rgba(99,102,241,.4);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-name-wrap { flex: 1; min-width: 0; }

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
  display: block;
}

.card-name:hover { color: var(--accent); }

.card-category-chip {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-stars {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
}

.star-icon {
  color: #f59e0b;
  font-size: 11px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  flex: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: lowercase;
  transition: background .1s, color .1s;
}

.tag:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: rgba(99,102,241,.2);
  cursor: pointer;
}

.card-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  opacity: .8;
  transition: opacity .12s;
}

.card-link:hover { opacity: 1; }

/* ── Load more ── */
.load-more-wrap {
  margin-top: 32px;
  text-align: center;
}

.btn-load-more {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 28px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}

.btn-load-more:hover {
  background: var(--accent-light);
  border-color: rgba(99,102,241,.3);
  color: var(--accent);
}

/* ── Empty state ── */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  color: var(--text-faint);
}

.empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.empty-sub { font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .main-inner { padding: 28px 16px 60px; }
  .card-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 22px; }
}

/* ── Tool detail page ── */
.tool-header {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.tool-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.tool-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: 6px;
}

.tool-category-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.tool-category-link:hover { text-decoration: underline; }

.tool-stars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  flex-shrink: 0;
  text-align: center;
}

.tool-stars .star-icon { font-size: 18px; color: #f59e0b; }
.tool-stars-num { font-size: 18px; font-weight: 700; line-height: 1; }
.tool-stars-label { font-size: 11px; color: var(--text-faint); }

.tool-description {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 16px;
  max-width: 600px;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tool-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .12s;
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 8px;
  text-decoration: none;
  transition: border-color .12s, color .12s;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12.5px;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Meta card */
.tool-meta-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 32px;
  overflow: hidden;
}

.tool-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.tool-meta-row:last-child { border-bottom: none; }

.tool-meta-label {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 500;
  flex-shrink: 0;
}

.tool-meta-value {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  text-align: right;
  word-break: break-all;
}

a.tool-meta-value { color: var(--accent); }
a.tool-meta-value:hover { text-decoration: underline; }

/* Related */
.related-section { margin-top: 8px; }

.related-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.related-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  transition: border-color .14s, box-shadow .14s, transform .1s;
}

.related-card:hover {
  border-color: rgba(99,102,241,.4);
  box-shadow: 0 3px 10px rgba(99,102,241,.1);
  transform: translateY(-1px);
}

.related-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.related-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-stars {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.related-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
