/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --bg-3: #181818;
  --bg-card: #131313;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.15);
  --text: #e8e8e8;
  --text-dim: #777;
  --text-dimmer: #444;
  --header-h: 72px;
  --sidebar-w: 240px;
  --radius: 8px;
  --radius-sm: 5px;
  --transition: 0.2s ease;
  --font: -apple-system, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;

  /* category neon colors */
  --c-foundation:  #ff2d78;
  --c-image:       #ff6b00;
  --c-coding:      #00ff88;
  --c-agents:      #00cfff;
  --c-search:      #ffe600;
  --c-voice:       #dd00ff;
  --c-enterprise:  #4477ff;
  --c-infra:       #ff3344;
  --c-local:       #00ffcc;
  --c-mcp-dev:     #aa44ff;
  --c-mcp-data:    #ff44aa;
  --c-mcp-plat:    #44aaff;
  --c-design:      #ff9944;
  --c-music:       #ff44ff;
  --c-science:     #44ff66;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

/* === SCANLINES === */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* === HEADER === */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(255,45,120,0.4) 20%,
    rgba(0,207,255,0.4) 50%,
    rgba(0,255,136,0.4) 80%,
    transparent
  );
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  padding: 0 20px 0 16px;
}

/* === TITLE === */
.title {
  font-size: clamp(18px, 2.5vw, 26px);
  font-weight: 900;
  letter-spacing: -0.5px;
  white-space: nowrap;
  line-height: 1.1;
}

.title-ai {
  color: #fff;
  letter-spacing: -1px;
}

.title-chaos {
  color: #ff2d78;
  text-shadow:
    0 0 10px rgba(255,45,120,0.8),
    0 0 30px rgba(255,45,120,0.4),
    0 0 60px rgba(255,45,120,0.2);
  margin: 0 4px;
  animation: titlePulse 3s ease-in-out infinite;
}

.title-year {
  color: #00cfff;
  font-size: 0.65em;
  text-shadow:
    0 0 8px rgba(0,207,255,0.8),
    0 0 20px rgba(0,207,255,0.4);
  vertical-align: middle;
  margin-left: 4px;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 10px rgba(255,45,120,0.8), 0 0 30px rgba(255,45,120,0.4), 0 0 60px rgba(255,45,120,0.2); }
  50% { text-shadow: 0 0 15px rgba(255,45,120,1), 0 0 40px rgba(255,45,120,0.6), 0 0 80px rgba(255,45,120,0.3); }
}

.subtitle {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  margin-top: 2px;
  text-transform: uppercase;
}

.header-title-group { flex-shrink: 0; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

/* === SEARCH === */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 440px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 16px;
  pointer-events: none;
  line-height: 1;
}

.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 36px 0 36px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--text-dimmer); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-input:focus {
  border-color: rgba(0,207,255,0.5);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px rgba(0,207,255,0.08), inset 0 0 20px rgba(0,207,255,0.03);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: center;
}

.search-clear.visible { opacity: 1; }
.search-clear:hover { color: var(--text); }

/* === STATS === */
.stats {
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.stats strong { color: var(--text); }

/* === LAYOUT === */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  z-index: 50;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-inner { padding: 14px 10px 80px; }

.sidebar-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dimmer);
  padding: 0 8px;
  margin-bottom: 8px;
}

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

.cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  position: relative;
}

.cat-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2px;
  border-radius: 2px;
  background: var(--cat-color, transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.cat-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.cat-btn:hover::before { opacity: 0.6; }

.cat-btn.active {
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-weight: 600;
}

.cat-btn.active::before { opacity: 1; }

.cat-emoji { font-size: 14px; flex-shrink: 0; line-height: 1; }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 10px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.cat-btn.active .cat-count {
  background: rgba(255,255,255,0.15);
  color: var(--text);
}

/* ALL button */
.cat-btn.cat-all {
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-radius: 0;
}

/* === CONTENT === */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding: 28px 24px 40px;
}

.content-inner {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* === CATEGORY SECTION === */
.cat-section {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cat-section.hidden {
  display: none;
}

.cat-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  cursor: pointer;
  user-select: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-2);
  transition: background var(--transition), border-color var(--transition);
}

.cat-section-header:hover { background: var(--bg-3); }

.cat-section-emoji { font-size: 20px; line-height: 1; }

.cat-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--section-color, #fff);
  text-shadow: 0 0 12px var(--section-color-faint, transparent);
  flex: 1;
}

.cat-section-en {
  font-size: 10px;
  color: var(--text-dimmer);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cat-section-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.cat-section.collapsed .cat-section-toggle {
  transform: rotate(-90deg);
}

.cat-section-count {
  font-size: 11px;
  color: var(--text-dimmer);
  flex-shrink: 0;
}

.cat-section-color-bar {
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--section-color, #fff);
  box-shadow: 0 0 8px var(--section-color, transparent);
  flex-shrink: 0;
}

/* === CARDS GRID === */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
}

.cat-section.collapsed .cards-grid {
  max-height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

/* === CARD === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--transition),
    background var(--transition),
    transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
    box-shadow var(--transition);
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--card-color, transparent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: radial-gradient(ellipse at 50% 0%, var(--card-glow, transparent) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}

.card:hover {
  border-color: var(--card-color, var(--border-hover));
  background: var(--bg-3);
  transform: translateY(-2px);
  box-shadow:
    0 4px 20px rgba(0,0,0,0.4),
    0 0 0 1px var(--card-color, transparent),
    0 0 20px var(--card-glow, transparent);
}

.card:hover::before { opacity: 1; }
.card:hover::after { opacity: 1; }

.card:focus-visible {
  outline: 2px solid var(--card-color, #fff);
  outline-offset: 2px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-favicon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  flex-shrink: 0;
  object-fit: contain;
  background: var(--bg-2);
}

.card-favicon-fallback {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  flex-shrink: 0;
  background: var(--card-color, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--bg);
  text-transform: uppercase;
}

.card-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
}

.card-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--card-color, var(--text-dim));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.6;
  transition: opacity var(--transition);
  margin-top: auto;
}

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

.card.hidden-by-search {
  display: none;
}

/* === NO RESULTS === */
.no-results {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.no-results-icon {
  font-size: 48px;
  margin-bottom: 16px;
  filter: grayscale(1);
  opacity: 0.4;
}

.no-results p { font-size: 14px; }

/* === FOOTER === */
.footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding: 16px 24px;
}

.footer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.footer-link {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-link:hover { color: #ff2d78; }

.footer-sep { color: var(--text-dimmer); }
.footer-note { color: var(--text-dimmer); }

/* === MOBILE MENU BTN === */
.mobile-menu-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  width: 48px;
  height: 48px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: background var(--transition);
}

.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 49;
  backdrop-filter: blur(2px);
}

/* === SEARCH HIGHLIGHT === */
.highlight {
  background: rgba(255,230,0,0.25);
  color: #ffe600;
  border-radius: 2px;
  padding: 0 1px;
}

/* === CATEGORY ANIMATIONS === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cat-section { animation: fadeInUp 0.4s ease both; }
.cat-section:nth-child(1)  { animation-delay: 0.05s; }
.cat-section:nth-child(2)  { animation-delay: 0.08s; }
.cat-section:nth-child(3)  { animation-delay: 0.11s; }
.cat-section:nth-child(4)  { animation-delay: 0.14s; }
.cat-section:nth-child(5)  { animation-delay: 0.17s; }
.cat-section:nth-child(6)  { animation-delay: 0.20s; }
.cat-section:nth-child(7)  { animation-delay: 0.23s; }
.cat-section:nth-child(8)  { animation-delay: 0.26s; }
.cat-section:nth-child(9)  { animation-delay: 0.29s; }
.cat-section:nth-child(10) { animation-delay: 0.32s; }
.cat-section:nth-child(11) { animation-delay: 0.35s; }
.cat-section:nth-child(12) { animation-delay: 0.38s; }
.cat-section:nth-child(13) { animation-delay: 0.41s; }
.cat-section:nth-child(14) { animation-delay: 0.44s; }
.cat-section:nth-child(15) { animation-delay: 0.47s; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  :root {
    --header-h: 60px;
    --sidebar-w: 260px;
  }

  .header-inner { padding: 0 14px; gap: 12px; }
  .subtitle { display: none; }
  .stats { display: none; }

  .search-wrapper { max-width: none; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  .mobile-menu-btn { display: flex; }

  .content {
    margin-left: 0;
    padding: 16px 14px 80px;
  }

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

  .footer { margin-left: 0; }
}

@media (max-width: 480px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .card { padding: 10px; }
  .card-desc { display: none; }
}

@media (max-width: 340px) {
  .cards-grid { grid-template-columns: 1fr; }
}

/* === NEON GLOW UTILITIES (set via JS inline style) === */
.neon-text {
  text-shadow:
    0 0 6px currentColor,
    0 0 20px currentColor;
}
