:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e4e6eb;
  --text: #1c1e21;
  --text-muted: #65676b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --tab-bg: #eef0f3;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #212226;
    --border: #34353a;
    --text: #f0f0f2;
    --text-muted: #9a9ba1;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --tab-bg: #2a2b30;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

/* Twemoji: 이모지를 이미지로 통일 표시 (모든 기기에서 동일하게 보임) */
img.emoji {
  height: 1em;
  width: 1em;
  margin: 0 0.03em 0 0.05em;
  vertical-align: -0.15em;
  pointer-events: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 22px;
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
}

.logo-emoji { font-size: 34px; }
.logo-text { color: var(--text); }
.logo-text strong { color: var(--accent); }

.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* Search */
.search-section {
  margin: 28px 0 18px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px 4px 18px;
  transition: border-color 0.15s ease;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-icon {
  font-size: 18px;
  margin-right: 10px;
  opacity: 0.6;
}

#searchInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 12px 4px;
  min-width: 0;
}

#searchInput::placeholder { color: var(--text-muted); }

.clear-btn {
  border: none;
  background: var(--tab-bg);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.clear-btn.show { display: flex; }
.clear-btn:hover { background: var(--border); }

/* Section title */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 12px;
}

.section-title h2 {
  font-size: 17px;
  margin: 0;
  color: var(--text);
}

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

.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
}
.link-btn:hover { text-decoration: underline; }

/* Category tabs */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 14px;
  scrollbar-width: thin;
}

.category-tabs::-webkit-scrollbar { height: 6px; }
.category-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tab {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--tab-bg);
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.tab:hover { background: var(--border); }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.recent-grid {
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
}

.emoji-cell {
  position: relative;
}

.emoji-btn {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow);
}

.fav-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.55;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  z-index: 2;
  transition: opacity 0.12s ease, transform 0.12s ease, color 0.12s ease;
}

.emoji-cell:hover .fav-toggle,
.fav-toggle:hover,
.fav-toggle.active {
  opacity: 1;
  transform: scale(1.08);
}

.fav-toggle.active {
  color: #f5a623;
}

.emoji-btn:hover {
  background: var(--tab-bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.emoji-btn:active {
  transform: translateY(0) scale(0.94);
}

.emoji-btn.copied {
  background: var(--accent);
}

.emoji-btn .name-tooltip {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 5;
}

.emoji-btn:hover .name-tooltip {
  opacity: 1;
}

.no-result {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

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

@media (max-width: 480px) {
  .logo { font-size: 22px; }
  .logo-emoji { font-size: 28px; }
  .emoji-btn { font-size: 24px; }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
}
