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

:root,
[data-theme="light"] {
  --bg: #f0f0f0;
  --text: #111111;
  --border-color: #d8d8dd;
  --btn-bg: rgba(255,255,255,0.7);
  --search-bg: rgba(255,255,255,0.8);
  --action-hover-bg: #e4e4e4;
  --toggle-bg: rgba(0,0,0,0.08);
  --toggle-active-bg: #ffffff;
  --toggle-active-shadow: 0 1px 3px rgba(0,0,0,0.12);
  --blur-bg: rgba(240,240,240,0.82);
}

[data-theme="dark"] {
  --bg: #1D1D1D;
  --text: #eeeeee;
  --border-color: #2C2C2C;
  --btn-bg: rgba(255,255,255,0.06);
  --search-bg: rgba(255,255,255,0.06);
  --action-hover-bg: #252525;
  --toggle-bg: rgba(255,255,255,0.07);
  --toggle-active-bg: rgba(255,255,255,0.12);
  --toggle-active-shadow: none;
  --blur-bg: rgba(29,29,29,0.82);
}

body {
  font-family: 'Inconsolata', monospace;
  font-size: 14px;
  color: #8E8E93;
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-font-smoothing: antialiased;
}

body::-webkit-scrollbar {
  display: none;
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 64px;
  background: var(--blur-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.logo {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.tagline {
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Theme toggle ── */

.theme-toggle {
  display: flex;
  align-items: center;
  background: var(--toggle-bg);
  border-radius: 8px;
  padding: 3px;
  gap: 1px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #8E8E93;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.toggle-btn.active {
  background: var(--toggle-active-bg);
  color: #8E8E93;
  box-shadow: var(--toggle-active-shadow);
}

/* ── Main ── */

.main {
  padding: 64px 28px 80px;
  width: 100%;
}

/* ── Search (in main) ── */

.search-wrap {
  display: flex;
  justify-content: center;
  padding: 48px 0 36px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--search-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 16px;
  width: 540px;
  max-width: 100%;
  height: 52px;
  transition: border-color 0.15s;
}

.search-box:focus-within {
  border-color: #8E8E93;
}

.search-icon {
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  min-width: 0;
}

#searchInput::placeholder {
  color: #8E8E93;
}

.search-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #8E8E93;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s;
}

.search-clear-btn:hover {
  background: var(--action-hover-bg);
}

/* ── Grid ── */

.logo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 200px);
  justify-content: center;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Card ── */

.card {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  cursor: default;
  position: relative;
  height: 180px;
  z-index: 1;
  transition: border-color 0.15s;
}

.card:hover,
.card:focus-within {
  z-index: 2;
}

.card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  text-decoration: none;
  color: inherit;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .card-body,
.card:focus-within .card-body {
  transform: translateY(-8px);
}

.card-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 22px 10px;
}

.card-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  border-radius: 20px;
}

.card-name {
  text-align: center;
  font-size: 14px;
  padding: 0 10px 4px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  border-top: 1px solid var(--border-color);
  background: var(--bg);
  border-radius: 0 0 11px 11px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
  transform: translateY(0);
}

.card-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: none;
  background: transparent;
  color: #8E8E93;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.card-btn:hover {
  background: var(--action-hover-bg);
  color: #8E8E93;
}

.card-btn:first-child {
  border-radius: 0 0 0 11px;
}

.card-btn:last-child {
  border-radius: 0 0 11px 0;
}

.card-btn + .card-btn {
  border-left: 1px solid var(--border-color);
}

/* ── Global tooltip ── */

.tooltip {
  position: fixed;
  background: var(--bg);
  color: #8E8E93;
  font-size: 14px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tooltip::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--bg);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.tooltip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Empty state ── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 0;
  gap: 24px;
}

.ascii-anim {
  font-family: 'Inconsolata', monospace;
  font-size: 15px;
  color: #8E8E93;
  line-height: 1.8;
  white-space: pre;
  opacity: 0.55;
  letter-spacing: 0.02em;
}

.empty-label {
  font-size: 14px;
  color: #8E8E93;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

/* ── Footer ── */

.footer {
  display: flex;
  align-items: center;
  padding: 0 28px;
  height: 52px;
  border-top: 1px solid var(--border-color);
  font-size: 14px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--blur-bg);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  z-index: 100;
}

.footer a {
  color: inherit;
  text-decoration: none;
}

.footer a:hover {
  color: var(--text);
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */

@media (max-width: 600px) {
  .header {
    padding: 0 16px;
  }

  .tagline {
    display: none;
  }

  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .search-wrap {
    padding: 32px 0 24px;
  }

  .logo-grid {
    grid-template-columns: repeat(auto-fit, 140px);
    gap: 10px;
  }

  .card {
    height: 140px;
  }

  .card-logo img {
    width: 56px;
    height: 56px;
  }

  .footer {
    padding: 0 16px;
  }
}
