/* MemeOverlay — dark, loud, fast. */
@font-face { font-family: 'Anton'; src: url('../assets/fonts/anton.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Bangers'; src: url('../assets/fonts/bangers.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Archivo Black'; src: url('../assets/fonts/archivo-black.woff2') format('woff2'); font-display: swap; }
:root {
  --bg: #0b0b10;
  --panel: #15151d;
  --panel-2: #1c1c27;
  --line: #2a2a38;
  --text: #f2f2f7;
  --muted: #9aa0b4;
  --accent: #c8ff00;
  --accent-ink: #10130a;
  --pink: #ff3d8b;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(255, 61, 139, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 10% -10%, rgba(200, 255, 0, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; font-size: 0.85em;
}

/* header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(11, 11, 16, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 20px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); font-weight: 800; }
.site-header nav { display: flex; gap: clamp(12px, 3vw, 28px); }
.site-header nav a { color: var(--muted); font-weight: 600; font-size: 15px; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }

/* hero */
.hero { text-align: center; padding: clamp(36px, 7vw, 72px) 20px 8px; }
.hero h1 {
  font-size: clamp(38px, 7vw, 76px);
  font-weight: 900; letter-spacing: -0.02em;
}
.hero .zap {
  color: var(--accent-ink);
  background: var(--accent);
  padding: 0 0.18em;
  border-radius: 0.15em;
  display: inline-block;
  transform: rotate(-2deg);
  box-shadow: 6px 6px 0 var(--pink);
}
.hero p { max-width: 620px; margin: 18px auto 0; color: var(--muted); font-size: clamp(16px, 2vw, 19px); }

/* editor layout */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 22px;
  padding: clamp(20px, 4vw, 40px);
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; }
}

.stage-col { position: sticky; top: 72px; }
@media (max-width: 980px) { .stage-col { position: static; } }

.stage-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-conic-gradient(#181822 0% 25%, #12121a 0% 50%) 0 0 / 26px 26px;
}
.stage-wrap.drag { outline: 3px dashed var(--accent); outline-offset: -3px; }
#stage { display: block; max-width: 100%; max-height: 76vh; height: auto; }
#stage.active { cursor: grab; }

.dropzone {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 24px;
  background: rgba(11, 11, 16, 0.55);
}
.dropzone.hidden { display: none; }
.dz-title { font-size: clamp(20px, 3vw, 28px); font-weight: 800; margin: 0; }
.dz-sub { color: var(--muted); margin: 0 0 14px; }
.dz-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.stage-hint { color: var(--muted); font-size: 13px; margin: 10px 4px 0; }

/* panel */
.panel { display: flex; flex-direction: column; gap: 14px; }
.panel-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-block h3 {
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 13px;
}
.hidden { display: none !important; }

/* buttons */
.btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #242433; border-color: #3a3a4e; }
.btn:active { transform: scale(0.97); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.accent:hover { background: #d9ff4d; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 10px; font-size: 13px; }
.btn.big { padding: 14px 18px; font-size: 16px; flex: 1; }
.btn.danger { color: #ff7a7a; border-color: #52222a; }
.btn.danger:hover { background: #2a1418; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #3a3a4e; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* tray */
#traySearch, #selText {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 14px;
}
#traySearch:focus, #selText:focus { outline: 2px solid var(--accent); border-color: transparent; }
.tray-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px; margin-top: 12px; max-height: 320px; overflow-y: auto;
  scrollbar-width: thin; padding-right: 2px;
}
.tray-item {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 10px; padding: 8px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600;
  transition: border-color 0.15s ease, transform 0.06s ease;
}
.tray-item:hover { border-color: var(--accent); color: var(--text); }
.tray-item:active { transform: scale(0.95); }
.tray-item img { width: 100%; height: 52px; object-fit: contain; pointer-events: none; }
.tray-item span { text-align: center; line-height: 1.2; }
.tray-empty { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

.export-block .fineprint { margin: 10px 0 0; }
.fineprint { color: var(--muted); font-size: 12.5px; }

/* library teaser */
.library-teaser { text-align: center; padding: clamp(30px, 6vw, 60px) 20px; max-width: 1100px; margin: 0 auto; }
.library-teaser h2, .how h2 { font-size: clamp(26px, 4vw, 40px); font-weight: 900; }
.library-teaser > p { color: var(--muted); max-width: 560px; margin: 0 auto 24px; }
.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.lib-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; font-size: 13px;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.lib-card:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.lib-card img { width: 100%; height: 64px; object-fit: contain; }

/* how */
.how { padding: 0 20px clamp(40px, 7vw, 80px); max-width: 1100px; margin: 0 auto; text-align: center; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 24px; }
.how-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 18px; text-align: left;
}
.how-card span {
  display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center;
  background: var(--pink); color: #fff; font-weight: 800; border-radius: 9px; margin-bottom: 10px;
}
.how-card h3 { font-size: 18px; }
.how-card p { color: var(--muted); font-size: 14.5px; margin: 0; }

/* footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 20px 40px; text-align: center; color: var(--muted); font-size: 14px;
}
.site-footer p { margin: 4px 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100; max-width: min(90vw, 480px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* library pages */
.page { max-width: 1100px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) 20px; }
.page h1 { font-size: clamp(28px, 5vw, 46px); font-weight: 900; }
.page .lead { color: var(--muted); max-width: 640px; font-size: 17px; }
.overlay-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px;
  align-items: center; margin: 26px 0;
}
@media (max-width: 760px) { .overlay-hero { grid-template-columns: 1fr; } }
.overlay-preview {
  background: repeating-conic-gradient(#181822 0% 25%, #12121a 0% 50%) 0 0 / 26px 26px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; display: flex; align-items: center; justify-content: center; min-height: 260px;
}
.overlay-preview img { max-width: 100%; max-height: 300px; }
.overlay-actions { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.overlay-actions .btn { width: auto; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; padding: 3px 10px; border-radius: 999px; }
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.related h2 { font-size: 22px; margin-top: 40px; }

/* v2: templates, stickers, emoji, text styling, coins */
.chip.tmpl { border-color: #3a3a4e; color: var(--text); }
.chip.tmpl:hover { border-color: var(--pink); }
.ticker-row { display: flex; gap: 8px; margin-top: 10px; }
.ticker-row input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; }
.ticker-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.sticker-grid { max-height: 150px; margin-top: 10px; }
.tray-item.sticker { position: relative; }
.sticker-x { position: absolute; top: 2px; right: 5px; font-style: normal; color: var(--muted); font-size: 15px; padding: 2px 5px; border-radius: 6px; }
.sticker-x:hover { color: #ff7a7a; background: #2a1418; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; max-height: 150px; overflow-y: auto; scrollbar-width: thin; }
.emoji-item { appearance: none; border: 1px solid transparent; background: transparent; font-size: 22px; line-height: 1; padding: 5px 0; border-radius: 8px; cursor: pointer; }
.emoji-item:hover { background: var(--panel-2); border-color: var(--line); }
.emoji-item:active { transform: scale(0.9); }
.style-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.swatches { display: flex; gap: 5px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatch:hover { border-color: var(--accent); transform: scale(1.1); }
.font-sel { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; }
.alpha-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; margin: 10px 0; }
.alpha-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.coins { text-align: center; padding: clamp(30px, 6vw, 60px) 20px; max-width: 1100px; margin: 0 auto; }
.coins h2 { font-size: clamp(26px, 4vw, 40px); font-weight: 900; }
.coins-lead { color: var(--muted); max-width: 640px; margin: 0 auto 24px; font-size: 17px; }
.coins .how-card span { background: var(--panel-2); font-size: 20px; width: 40px; height: 40px; border-radius: 11px; }
.coins > .fineprint { max-width: 640px; margin: 20px auto 0; }
.format-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* icon system — no emoji in UI chrome */
.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; margin-right: 7px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic .f { fill: currentColor; stroke: none; }
.ic.big { width: 22px; height: 22px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; }
.btn .ic { margin-right: 7px; }
.btn.ghost .ic, .btn.sm .ic { width: 14px; height: 14px; }

/* tabs */
.tab-bar { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; }
.tab-bar button {
  flex: 1; appearance: none; border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 700; padding: 8px 4px; border-radius: 9px; cursor: pointer;
}
.tab-bar button:hover { color: var(--text); }
.tab-bar button.on { background: var(--accent); color: var(--accent-ink); }
.tab-page { display: none; }
.tab-page.on { display: block; }
.mini-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 4px; }
.tray-grid.tall { max-height: 430px; }
.emoji-grid.tall { max-height: 300px; }
#selTools h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 10px; }

/* gallery */
.gallery { text-align: center; padding: clamp(30px, 6vw, 64px) 20px 10px; max-width: 1100px; margin: 0 auto; }
.gallery h2 { font-size: clamp(26px, 4vw, 40px); font-weight: 900; }
.gallery-lead { color: var(--muted); margin: 0 auto 26px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.gallery-grid figure { margin: 0; }
.gallery-grid img {
  width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line);
  transition: transform 0.15s ease, border-color 0.15s ease; display: block;
}
.gallery-grid figure:nth-child(odd) img { transform: rotate(-1.2deg); }
.gallery-grid figure:nth-child(even) img { transform: rotate(1.2deg); }
.gallery-grid figure:hover img { transform: rotate(0) scale(1.03); border-color: var(--accent); }
.gallery-grid figcaption { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 8px; }
.icard { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; background: var(--panel-2); color: var(--accent); margin-bottom: 10px; }
.adj-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.adj-rows .alpha-row { margin: 4px 0; white-space: nowrap; }
.adj-rows .btn { align-self: flex-start; margin-top: 4px; }
#animSel { flex: 1; }
