:root {
  --bg-primary: #0a0a14;
  --bg-secondary: #12122a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --surface-active: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.06);
  --text-primary: #f0f0f5;
  --text-secondary: rgba(255, 255, 255, 0.5);
  --text-tertiary: rgba(255, 255, 255, 0.3);
  --accent: #ff6b6b;
  --accent-hover: #ff5252;
  --accent-glow: rgba(255, 107, 107, 0.3);
  --gold: #ffd93d;
  --green: #51cf66;
  --toast-bg: rgba(81, 207, 102, 0.15);
  --toast-border: rgba(81, 207, 102, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255, 107, 107, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 217, 61, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(107, 107, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--toast-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--toast-border);
  color: var(--green);
  padding: 12px 28px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
}

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

/* Header */
.header {
  text-align: center;
  padding: 40px 0 32px;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f0f0f5 0%, rgba(240, 240, 245, 0.6) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.header p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
}

/* Search */
.search-wrapper {
  max-width: 560px;
  margin: 0 auto 28px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 1.1rem;
  pointer-events: none;
  transition: color 0.3s;
}

.search-wrapper:focus-within .search-icon {
  color: var(--text-secondary);
}

.search-input {
  width: 100%;
  padding: 16px 48px 16px 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all 0.3s ease;
}

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

.search-input:focus {
  border-color: rgba(255, 255, 255, 0.15);
  background: var(--surface-hover);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.03), 0 8px 32px rgba(0, 0, 0, 0.2);
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  opacity: 0;
  pointer-events: none;
}

.search-input:not(:placeholder-shown) ~ .clear-btn {
  opacity: 1;
  pointer-events: auto;
}

.clear-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

/* Categories */
.category-bar {
  display: flex;
  gap: 8px;
  padding: 4px 0 32px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.category-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.category-btn.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.category-btn span {
  font-size: 0.85rem;
}

/* Emoji Grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  margin-bottom: 40px;
}

.emoji-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  animation: fadeIn 0.3s ease backwards;
  aspect-ratio: 1;
}

.emoji-item:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.emoji-item:active {
  transform: scale(0.92);
}

.emoji-char {
  font-size: 2rem;
  line-height: 1;
  transition: transform 0.2s;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiOne Color', sans-serif;
  font-variant-emoji: emoji;
}

.emoji-item:hover .emoji-char {
  transform: scale(1.15);
}

.emoji-name {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  word-break: break-word;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  gap: 12px;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.4;
}

/* Recent Section */
.recent-section {
  margin-top: 8px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.recent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.recent-header span {
  font-size: 1rem;
}

.recent-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-item {
  font-size: 1.8rem;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Android Emoji', 'EmojiOne Color', sans-serif;
}

.recent-item:hover {
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.recent-item:active {
  transform: scale(0.9);
}

.recent-empty {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* Footer */
.footer {
  margin-top: 48px;
  padding: 40px 0 20px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.footer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.footer-about p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.85rem;
}

.footer-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

.footer-meta {
  grid-column: 1 / -1;
  text-align: center;
  padding-top: 24px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.heart {
  color: #ff6b6b;
  display: inline-block;
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Footer Bottom Bar */
.footer-bottom {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.footer-link {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s;
}

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

.footer-divider {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.footer-email {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-copy {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.emoji-item:nth-child(1) { animation-delay: 0s; }
.emoji-item:nth-child(2) { animation-delay: 0.01s; }
.emoji-item:nth-child(3) { animation-delay: 0.02s; }
.emoji-item:nth-child(4) { animation-delay: 0.03s; }
.emoji-item:nth-child(5) { animation-delay: 0.04s; }
.emoji-item:nth-child(6) { animation-delay: 0.05s; }
.emoji-item:nth-child(7) { animation-delay: 0.06s; }
.emoji-item:nth-child(8) { animation-delay: 0.07s; }
.emoji-item:nth-child(9) { animation-delay: 0.08s; }
.emoji-item:nth-child(10) { animation-delay: 0.09s; }
.emoji-item:nth-child(11) { animation-delay: 0.10s; }
.emoji-item:nth-child(12) { animation-delay: 0.11s; }
.emoji-item:nth-child(13) { animation-delay: 0.12s; }
.emoji-item:nth-child(14) { animation-delay: 0.13s; }
.emoji-item:nth-child(15) { animation-delay: 0.14s; }
.emoji-item:nth-child(16) { animation-delay: 0.15s; }

/* Responsive */
@media (max-width: 1024px) {
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (max-width: 768px) {
  .app {
    padding: 16px 12px 40px;
  }

  .header {
    padding: 24px 0 20px;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .header p {
    font-size: 0.9rem;
  }

  .search-wrapper {
    margin-bottom: 20px;
  }

  .search-input {
    padding: 14px 44px 14px 44px;
    font-size: 0.95rem;
  }

  .category-bar {
    padding-bottom: 20px;
    gap: 6px;
  }

  .category-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .emoji-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .emoji-char {
    font-size: 1.6rem;
  }

  .emoji-name {
    font-size: 0.55rem;
  }

  .toast {
    font-size: 0.85rem;
    padding: 10px 20px;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-meta {
    padding-top: 16px;
  }
}

@media (max-width: 480px) {
  .emoji-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .emoji-item {
    padding: 10px 2px;
  }

  .header h1 {
    font-size: 1.5rem;
  }
}
