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

[hidden] {
  display: none !important;
}

:root {
  --wechat-green: #07C160;
  --wechat-green-dark: #06AD56;
  --wechat-green-light: #E8F8EF;
  --bg: #F7F8FA;
  --card-bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #E8E8E8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(12px);
  background: rgba(255,255,255,0.92);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 36px;
  line-height: 1;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 14px;
  background: var(--bg);
  transition: var(--transition);
  outline: none;
}

.search-box input:focus {
  border-color: var(--wechat-green);
  background: var(--card-bg);
  box-shadow: 0 0 0 3px var(--wechat-green-light);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
  pointer-events: none;
}

/* ===== Category Nav ===== */
.category-nav {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 73px;
  z-index: 99;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.tab.active {
  background: var(--wechat-green);
  color: #fff;
}

.tab .tab-emoji {
  font-size: 15px;
}

/* ===== Stats Bar ===== */
.stats-bar {
  padding: 20px 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Emoji Grid ===== */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  padding-bottom: 40px;
}

.emoji-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 10px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 150px;
}

.emoji-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--wechat-green);
}

.emoji-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.emoji-card .emoji-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
  min-height: 48px;
}

.emoji-card .emoji-cn {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

.emoji-card .detail-badge {
  font-size: 10px;
  color: var(--wechat-green);
  background: var(--wechat-green-light);
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  margin-top: auto;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1;
  color: var(--text-secondary);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-body {
  padding: 32px;
}

/* Modal content */
.detail-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-emoji {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 8px;
}

.detail-titles h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-titles .cn-name {
  font-size: 15px;
  color: var(--text-secondary);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.detail-section p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
}

.meanings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meanings-list li {
  font-size: 14px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--wechat-green);
  color: var(--text-primary);
}

.examples-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.example-item {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
}

.example-item .ex-chinese {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.example-item .ex-english {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 6px;
}

.example-item .ex-meaning {
  font-size: 13px;
  color: var(--wechat-green-dark);
  font-weight: 500;
}

.warning-box {
  background: #FFF7E6;
  border: 1px solid #FFE0A0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  color: #8A6D00;
  line-height: 1.6;
  display: flex;
  gap: 10px;
}

.warning-box .warn-icon {
  flex-shrink: 0;
  font-size: 18px;
}

.no-detail {
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
}

.site-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

.site-footer .footer-author {
  margin-top: 6px;
  font-size: 12px;
  color: var(--wechat-green);
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .brand {
    justify-content: center;
  }

  .brand-text h1 {
    font-size: 18px;
    text-align: center;
  }

  .tagline {
    text-align: center;
    font-size: 12px;
  }

  .search-box {
    max-width: 100%;
  }

  .category-nav {
    top: 117px;
  }

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

  .emoji-card {
    padding: 12px 6px 10px;
    min-height: 145px;
  }

  .emoji-card img {
    width: 44px;
    height: 44px;
  }

  .emoji-card .emoji-name {
    font-size: 11px;
    min-height: 44px;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-body {
    padding: 24px 20px;
  }

  .detail-header {
    gap: 14px;
  }

  .detail-emoji {
    width: 64px;
    height: 64px;
  }

  .detail-titles h2 {
    font-size: 19px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 14px;
  }

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

  .emoji-card {
    min-height: 150px;
  }

  .emoji-card img {
    width: 38px;
    height: 38px;
  }
}
