:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --muted-surface: #f0f3ef;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #232724;
  --muted: #667069;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --shadow: 0 8px 28px rgba(35, 39, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100% - 20px, 1120px);
  margin: 0 auto;
  padding: 16px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.copy-button,
.tag-button,
.random-button,
.wide-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.copy-button {
  min-width: 150px;
  min-height: 40px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.copy-button:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.copy-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.search-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.search-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.search-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 240px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--muted-surface);
  padding: 2px;
}

.mode-button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.mode-button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#searchInput {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.quick-tags {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.quick-tags::-webkit-scrollbar {
  display: none;
}

.tag-button {
  flex: 0 0 auto;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 13px;
}

.result-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}

.pane-title-line {
  display: flex;
  align-items: baseline;
  flex: 0 0 auto;
  gap: 8px;
  white-space: nowrap;
}

.pane-title-line h2 {
  font-size: 15px;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hit-tags {
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.hit-tags::-webkit-scrollbar {
  display: none;
}

.hit-tags-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 30px;
}

.hit-tag-button {
  flex: 0 0 auto;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 10px;
  cursor: pointer;
  font-size: 12px;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.random-button {
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
}

.random-button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.emoji-card {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 6px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.emoji-card:active,
.emoji-card:hover {
  border-color: var(--line-strong);
  background: #fafafa;
}

.emoji-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.skin-indicator {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffcc4d 0 18%, #f7d7c4 18% 34%, #f2c28e 34% 50%, #d5a57a 50% 66%, #a57a5a 66% 82%, #6b4423 82% 100%);
  opacity: 0.62;
}

.emoji-char {
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
}

.emoji-name {
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
  font-size: 12px;
  font-weight: 400;
}

.empty-list {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.6;
  padding: 18px 4px;
}

.selected-inline {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  margin-top: 10px;
  padding: 10px;
}

.selected-summary {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.selected-emoji {
  font-size: 42px;
  line-height: 1;
}

.selected-title {
  min-width: 0;
}

.selected-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 800;
}

.selected-en {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  margin-top: 4px;
}

.skin-tone-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.skin-tone-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.skin-tone-dot::before {
  content: "";
  width: 15px;
  height: 15px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  transition: transform 120ms ease;
}

.skin-tone-dot:hover::before,
.skin-tone-dot:focus-visible::before {
  transform: scale(1.15);
}

.skin-tone-dot[aria-current="true"]::after {
  position: absolute;
  bottom: 0;
  left: 6px;
  right: 6px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}

.skin-tone-default::before {
  background: #ffcc4d;
}

.skin-tone-light::before {
  background: #f7d7c4;
}

.skin-tone-medium-light::before {
  background: #f2c28e;
}

.skin-tone-medium::before {
  background: #d5a57a;
}

.skin-tone-medium-dark::before {
  background: #a57a5a;
}

.skin-tone-dark::before {
  background: #6b4423;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.merged-chips {
  padding-top: 2px;
}

.chip {
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
}

.chip-button {
  cursor: pointer;
}

.chip-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip-meaning {
  background: #e6f3ef;
}

.chip-usage {
  background: #fff1d6;
}

.chip-impression {
  background: #edf0ff;
}

.chip-class {
  background: #f1ece4;
  color: #5d5346;
}

.wide-button {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100% - 32px, 1120px);
    padding-top: 24px;
  }

  .emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .emoji-card {
    min-height: 106px;
  }

  .emoji-char {
    font-size: 46px;
  }

  .selected-summary {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .selected-emoji {
    font-size: 50px;
  }

  .selected-inline {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
  }

  .selected-summary {
    margin-bottom: 0;
  }
}

@media (max-width: 420px) {
  .search-row {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .search-mode {
    width: 100%;
  }

  .pane-heading {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .hit-tags {
    grid-column: 1 / -1;
    order: 3;
  }
}
