:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --shell: 1180px;
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #111827;
  --surface-2: #182132;
  --text: #f8fafc;
  --muted: #9ca3af;
  --line: #273244;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: #12213b;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 50% -120px, rgba(37, 99, 235, 0.10), transparent 420px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
button, .emoji-card { -webkit-tap-highlight-color: transparent; }
.shell { width: min(calc(100% - 32px), var(--shell)); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed;
  left: 16px; top: 12px;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}
.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}
.header-actions { display: flex; gap: 8px; }
.icon-button {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); }

.hero {
  text-align: center;
  padding-block: 72px 32px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.9rem);
  line-height: 1;
  letter-spacing: -0.055em;
}
.hero-copy {
  max-width: 620px;
  margin: 18px auto 28px;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
}
.search-wrap {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}
.search-icon {
  position: absolute;
  left: 19px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.35rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--line);
  outline: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 0 58px 0 50px;
  box-shadow: var(--shadow);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow);
}
.search-input::placeholder { color: color-mix(in srgb, var(--muted) 78%, transparent); }
.search-shortcut {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 28px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}
.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
}
.search-clear:hover,
.search-clear:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.search-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.catalog-status {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.category-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 30px;
  padding: 2px 0 6px;
}
.category-scroller::-webkit-scrollbar { display: none; }
.category-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}
.category-tab[aria-selected="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: var(--accent-soft);
  font-weight: 700;
}

.utility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-block: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.utility-left {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.utility-left::-webkit-scrollbar { display: none; }
.utility-right { flex: 0 0 auto; }
.pill-button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  cursor: pointer;
}
.pill-button:hover, .pill-button.active { background: var(--surface-2); color: var(--text); }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}
.toggle input {
  appearance: none;
  width: 38px; height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
}
.toggle input::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  top: 3px; left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); }

.results-section { padding-block: 34px 54px; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section-heading h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.035em;
}
.result-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.emoji-card {
  position: relative;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.emoji-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
}
.emoji-copy-button {
  width: 100%;
  min-height: 102px;
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  place-items: center;
  padding: 14px 8px 10px;
  cursor: pointer;
}
.emoji-copy-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: -3px;
}
.emoji-glyph {
  font-size: 2.3rem;
  line-height: 1;
}
.emoji-name {
  width: 100%;
  margin-top: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}
.favorite-button {
  position: absolute;
  top: 5px; right: 5px;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #a1a1aa;
  opacity: 0;
  cursor: pointer;
}
.emoji-card:hover .favorite-button,
.favorite-button:focus,
.favorite-button.is-favorite { opacity: 1; }
.favorite-button.is-favorite { color: #f59e0b; }
.favorite-button:hover { background: var(--surface-2); }

.load-more-button {
  display: block;
  margin: 24px auto 0;
}
.load-more-button[hidden] { display: none; }

.empty-state {
  max-width: 480px;
  margin: 46px auto;
  text-align: center;
}
.empty-emoji { font-size: 3rem; }
.empty-state h3 { margin-bottom: 4px; }
.empty-state p { margin-top: 0; color: var(--muted); }
.primary-button, .secondary-button {
  min-height: 42px;
  border-radius: 11px;
  padding: 0 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 700;
}
.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary-button:hover { background: var(--accent-strong); }
.secondary-button { background: var(--surface); }
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.info-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-bottom: 58px;
}
.info-strip article {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 16px;
}
.info-strip article > span { font-size: 1.5rem; }
.info-strip strong, .info-strip small { display: block; }
.info-strip small { color: var(--muted); margin-top: 2px; }

.copy-tray {
  position: sticky;
  bottom: 0;
  z-index: 20;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: 0 -10px 30px rgba(17, 24, 39, 0.08);
}
.tray-content {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.tray-preview {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 1.65rem;
}
.tray-actions { display: flex; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 50;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--surface);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: opacity .18s ease, transform .18s ease;
  font-size: 0.9rem;
  font-weight: 700;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.copy-tray:not([hidden]) ~ .toast { bottom: 96px; }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.footer-inner {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.86rem;
}
.footer-inner p { margin: 0; }
.muted { color: var(--muted); }
.noscript {
  width: min(calc(100% - 32px), var(--shell));
  margin: 20px auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

@media (max-width: 700px) {
  .shell { width: min(calc(100% - 20px), var(--shell)); }
  .hero { padding-block: 52px 22px; }
  .hero h1 { font-size: clamp(2.3rem, 12vw, 3.6rem); }
  .search-input { min-height: 56px; }
  .search-shortcut { display: none; }
  .category-scroller { margin-top: 22px; }
  .utility-bar { align-items: flex-start; }
  .emoji-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .emoji-card { min-height: 88px; }
  .emoji-copy-button { min-height: 86px; padding-inline: 4px; }
  .emoji-glyph { font-size: 2rem; }
  .emoji-name { font-size: 0.64rem; }
  .favorite-button { opacity: 1; width: 25px; height: 25px; }
  .info-strip { grid-template-columns: 1fr; }
  .footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; padding-block: 20px; }
}

@media (max-width: 430px) {
  .utility-bar { flex-direction: column; align-items: stretch; }
  .utility-right { display: flex; justify-content: flex-end; }
  .emoji-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .emoji-card { min-height: 82px; }
  .emoji-copy-button { min-height: 80px; }
  .emoji-name { display: none; }
  .tray-content { min-height: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}