/* emojimix 静态版 — 样式 */

:root {
  --bg: #f5f3ea;
  --bg-card: #ffffff;
  --bg-soft: #ece9db;
  --ink: #33361f;
  --ink-soft: #878c72;
  --accent: #6e823a;
  --accent-ink: #ffffff;
  --accent-soft: #e7edd6;
  --ring: rgba(110, 130, 58, 0.4);
  --shadow: 0 12px 32px rgba(64, 74, 33, 0.14);
  --shadow-sm: 0 4px 14px rgba(64, 74, 33, 0.12);
  --radius: 24px;
  --font-ui: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #171a10;
  --bg-card: #22271a;
  --bg-soft: #2b3121;
  --ink: #eef0e0;
  --ink-soft: #a6ac8d;
  --accent: #a6c25c;
  --accent-ink: #1c200f;
  --accent-soft: #333c24;
  --ring: rgba(166, 194, 92, 0.45);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px 30px;
  transition: background-color 0.3s, color 0.3s;
}
body.modal-open { overflow: hidden; }
button { font-family: inherit; color: inherit; touch-action: manipulation; }
a { color: inherit; }

/* ---------- header ---------- */
header {
  position: relative;
  width: 100%;
  max-width: 980px;
  text-align: center;
  margin-bottom: 10px;
}
h1 {
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
h1 span { color: var(--accent); }
.header-actions {
  position: absolute;
  top: 4px;
  right: 0;
  display: flex;
  gap: 8px;
}
.ghost-btn {
  border: 2px solid transparent;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  line-height: 1;
  display: inline-grid;
  place-items: center;
}
.ghost-btn img { width: 20px; height: 20px; display: block; }
.ghost-btn:hover { border-color: var(--ring); }

main { width: 100%; max-width: 980px; }

/* ---------- mixer / sliders ---------- */
#mixer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 6px 0 24px;
}
.side-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: transform 0.15s, border-color 0.15s;
}
.icon-btn img { width: 22px; height: 22px; display: block; }
.icon-btn:hover { transform: scale(1.12); border: 2px solid var(--ring); }

.slider-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.slider-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  touch-action: pan-x pan-y;
}
.slider-viewport:active { cursor: grabbing; }
.slider-viewport::-webkit-scrollbar { display: none; }
.slider-strip {
  display: flex;
  gap: 6px;
  width: max-content;
  padding: 14px calc(50% - 34px);
}
.cell {
  flex: 0 0 68px;
  height: 68px;
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.18s, background-color 0.18s, box-shadow 0.18s;
}
.cell.current {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 3px var(--ring);
  transform: scale(1.14);
}
.cell img { width: 56px; height: 56px; object-fit: contain; pointer-events: none; }
.pick-cell img { width: 40px; height: 40px; object-fit: contain; pointer-events: none; }
#plus {
  font-size: 42px;
  font-weight: 900;
  color: var(--ink-soft);
  user-select: none;
}

/* ---------- result ---------- */
#result { text-align: center; }
#stage {
  position: relative;
  width: min(300px, 62vw);
  aspect-ratio: 1;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
#output {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(50, 60, 20, 0.25));
}
#output.pop { animation: pop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop {
  0% { transform: scale(0.45); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.spinner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid var(--ring);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#sad { text-align: center; }
.sad-img { width: 96px; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
#sad p { color: var(--ink-soft); font-weight: 700; margin-top: 8px; }

#mix-name {
  min-height: 1.7em;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 1.08rem;
  margin: 0 0 14px;
}
#mix-name img { width: 24px; height: 24px; vertical-align: -5px; }
#mix-name .plus { margin: 0 9px; font-weight: 900; }

#actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.act img { width: 20px; height: 20px; }
.act:hover { transform: translateY(-2px); border-color: var(--ring); }
.act:active { transform: translateY(0); }
.act.primary { background: var(--accent); color: var(--accent-ink); }

/* ---------- favourites ---------- */
#favourites { margin-top: 32px; }
#favourites h2 { font-size: 1.15rem; margin-bottom: 14px; }
#fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.fav-thumb {
  position: relative;
  background: var(--bg-card);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 8px;
  cursor: pointer;
  transition: transform 0.15s;
}
.fav-thumb:hover { transform: translateY(-3px); }
.fav-thumb img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.fav-del {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.fav-thumb:hover .fav-del { opacity: 1; }
@media (hover: none) {
  .fav-del { opacity: 1; } /* 触屏设备没有 hover，删除按钮常显 */
}

/* ---------- picker ---------- */
#picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 10, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
#picker-overlay[hidden] { display: none; }
#picker {
  width: min(680px, 100%);
  max-height: min(82vh, 660px);
  max-height: min(82dvh, 660px);
  background: var(--bg-card);
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rise 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes rise {
  from { transform: translateY(24px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  flex: 0 0 auto;
}
#picker-side-label {
  font-weight: 900;
  color: var(--accent);
  white-space: nowrap;
  font-size: 0.9rem;
}
#picker-search {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid var(--ring);
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px; /* 低于 16px 时 iOS 聚焦会自动放大页面 */
  outline: none;
}
#picker-search:focus { border-color: var(--accent); }
#picker-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  flex: 0 0 auto;
}
.chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: none;
  background: var(--bg-soft);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--accent-ink); }
#picker-grid {
  overflow-y: auto;
  padding: 4px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
}
.pick-cell {
  height: 58px;
  font-size: 34px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.12s, background-color 0.12s;
}
.pick-cell:hover { background: var(--accent-soft); transform: scale(1.18); }
#picker-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: var(--shadow);
  z-index: 99;
  opacity: 1;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* ---------- footer ---------- */
footer {
  margin-top: auto;
  padding-top: 34px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.9;
  max-width: 760px;
}
footer .hint { font-weight: 800; }

/* ---------- responsive ---------- */
@media (max-width: 700px) {
  body { padding: 16px 10px 24px; }
  #mixer {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .side-buttons { flex-direction: row; justify-content: center; }
  #plus { font-size: 30px; margin: -4px 0; }
  .slider-strip { padding: 10px calc(50% - 28px); }
  .cell { flex-basis: 56px; height: 56px; font-size: 32px; }
  .cell img { width: 46px; height: 46px; }
  .header-actions { position: static; justify-content: center; margin-top: 10px; }
  #stage { width: min(240px, 66vw); }
  .sad-img { width: 72px; }
  .act { padding: 9px 14px; font-size: 0.88rem; }
  .chip { padding: 8px 14px; }
  #picker-overlay { align-items: flex-start; padding-top: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
