* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #666;
  --accent: #4A90D9;
  --accent-hover: #357ABD;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 16px 16px 12px;
  text-align: center;
}

.header h1 {
  font-size: 22px;
  margin-bottom: 12px;
}

.search-bar {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.search-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Categories ---- */
.categories {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

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

/* ---- Gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 8px 80px;
}

.sticker-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
  cursor: pointer;
  transition: transform 0.15s;
}

.sticker-card:active {
  transform: scale(0.95);
}

.sticker-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-card .tags {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
}

.sticker-card .tag {
  display: inline-block;
  font-size: 10px;
  color: #fff;
  margin-right: 4px;
}

/* ---- Loading ---- */
.loading,
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Preview Modal ---- */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.preview-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.preview-container {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.preview-close:hover {
  background: rgba(255,255,255,0.3);
}

.preview-overlay img {
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.preview-info {
  color: #ccc;
  font-size: 13px;
  margin: 12px 0;
  text-align: center;
}

.preview-actions {
  display: flex;
  gap: 12px;
}

.pa-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.2s;
}

.pa-btn:hover {
  background: var(--accent-hover);
}

/* ---- Context Menu ---- */
.context-menu {
  position: fixed;
  z-index: 400;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  min-width: 160px;
  padding: 6px 0;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: opacity 0.15s, transform 0.15s;
}

.context-menu.show {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.cm-item {
  display: block;
  width: 100%;
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.cm-item:hover {
  background: #f0f0f0;
}
