:root {
  color-scheme: light dark;
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-pressed: #ececf1;
  --border: #e3e3e9;
  --text: #16161d;
  --text-muted: #74747e;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --toast-bg: #16161d;
  --toast-text: #ffffff;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #1a1a21;
    --surface-pressed: #2a2a34;
    --border: #2a2a34;
    --text: #ececf1;
    --text-muted: #9a9aa6;
    --accent: #8a8af0;
    --accent-text: #0e0e12;
    --toast-bg: #ececf1;
    --toast-text: #16161d;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

button {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

/*
 * Kaomoji lean heavily on katakana, CJK punctuation, IPA extensions and
 * box-drawing glyphs. No single web-safe font covers them, so this spells
 * out an explicit fallback chain rather than bundling a CJK font.
 */
.kaomoji-font {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo,
    "MS Gothic", "Apple Color Emoji", sans-serif;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 16px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

.title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Category bar */

.category-bar {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.category-bar-content {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-bar-content::-webkit-scrollbar {
  display: none;
}

.category-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.category-chip:hover {
  background: var(--surface-pressed);
}

.category-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.category-chip.active:hover {
  background: var(--accent);
}

/* Scrollable content */

.scroll-area {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.section-header {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--bg);
}

.section-category {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.section-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kaomoji-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 20px;
}

.kaomoji-chip {
  position: relative;
  min-height: 48px;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  line-height: 30px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
  user-select: none;
}

.kaomoji-chip:hover {
  background: var(--surface-pressed);
}

.kaomoji-chip:active {
  background: var(--surface-pressed);
}

/* Toast */

.toast-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 90%;
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--toast-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease-in, transform 180ms ease-in;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 140ms ease-out, transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-kaomoji {
  font-size: 15px;
  line-height: 22px;
  color: var(--toast-text);
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--toast-text);
  white-space: nowrap;
}
