/* ============================================================
   Dabber Emoji — forge UI
   Family tokens shared with create.dabber.life, plus a chunky
   display face and emoji-forge atmosphere.
   ============================================================ */

:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel-2: #1e242d;
  --border: #2a313c;
  --text: #e7eaf0;
  --muted: #8b94a3;
  --accent: #8ab4ff;
  --accent-2: #ffb47a;
  --grad: linear-gradient(135deg, #a17bff 0%, #ff8ad4 100%);
  --danger: #ff6b6b;
  --ok: #6dd388;
  --disp: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- atmosphere: gradient mesh + grain ---------- */
.atmo {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42rem 30rem at 85% -8%,  rgba(161,123,255,.13), transparent 60%),
    radial-gradient(36rem 26rem at -10% 22%, rgba(138,180,255,.10), transparent 60%),
    radial-gradient(40rem 30rem at 70% 115%, rgba(255,138,212,.09), transparent 60%);
}
.atmo::after {
  content: ""; position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 1.1rem;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  animation: drop-in .45s cubic-bezier(.2,.9,.3,1.2) both;
}
.brand { display: flex; align-items: baseline; gap: .55rem; }
.brand-mark {
  font-size: 22px; line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(255,138,212,.45));
  animation: mark-bob 4s ease-in-out infinite;
  align-self: center;
}
.brand-name {
  font-family: var(--disp); font-weight: 800; font-size: 19px; letter-spacing: .2px;
}
.brand-name em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: .18rem .55rem;
}
.head-status {
  margin-left: auto; display: flex; align-items: center; gap: .45rem;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.head-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); transition: background .3s;
}
.head-status.ok .dot   { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.head-status.bad .dot  { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.head-status.ok .label { color: var(--ok); }
.head-status.bad .label{ color: var(--danger); }

/* ---------- layout ---------- */
main {
  flex: 1;
  width: min(1180px, 100%); margin: 0 auto; padding: 1.4rem 1.1rem 3rem;
  display: grid; grid-template-columns: 410px 1fr; gap: 1.1rem;
  align-items: start;
}
.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.05rem;
}
.forge-pane  { animation: rise-in .5s .08s cubic-bezier(.2,.9,.3,1) both; }
.results-pane{
  animation: rise-in .5s .16s cubic-bezier(.2,.9,.3,1) both;
  min-height: 480px; display: flex; flex-direction: column; justify-content: center;
}
.studio, .gallery { grid-column: 1 / -1; }

/* ---------- mode tabs ---------- */
.mode-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 1rem;
}
.mode-tab {
  font-family: var(--disp); font-weight: 700; font-size: 13px;
  background: transparent; color: var(--muted); border: 0; border-radius: 8px;
  padding: .5rem .25rem; cursor: pointer; transition: all .18s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

/* ---------- fields ---------- */
.field-label {
  font-family: var(--disp); font-weight: 700; font-size: 12.5px;
  letter-spacing: .4px; text-transform: uppercase; color: var(--muted);
  margin: .9rem 0 .45rem; display: block;
}
textarea {
  width: 100%; resize: vertical;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .75rem; font: 14px/1.5 inherit; font-family: inherit;
  min-height: 64px; transition: border-color .2s, box-shadow .2s;
}
textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138,180,255,.15);
}
textarea::placeholder { color: #525b69; }

/* ---------- style chips ---------- */
.style-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); padding: .42rem .8rem .42rem .6rem;
  font: inherit; font-size: 13px; cursor: pointer;
  transition: transform .15s, border-color .2s, color .2s, box-shadow .2s;
}
.chip .c-ico { font-size: 15px; }
.chip:hover { transform: translateY(-1px); color: var(--text); border-color: #3a4350; }
.chip.active {
  color: var(--text); border-color: transparent;
  background:
    linear-gradient(var(--panel-2), var(--panel-2)) padding-box,
    var(--grad) border-box;
  box-shadow: 0 2px 14px rgba(161,123,255,.22);
}

/* ---------- steppers / segmented ---------- */
.forge-row { display: flex; align-items: center; gap: .7rem; margin-top: 1rem; flex-wrap: wrap; }
.stepper {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: .25rem .35rem;
}
.step-btn {
  width: 26px; height: 26px; border-radius: 7px; border: 0; cursor: pointer;
  background: var(--panel-2); color: var(--text); font-size: 15px; line-height: 1;
  transition: background .15s, transform .1s;
}
.step-btn:hover { background: #2a3340; }
.step-btn:active { transform: scale(.92); }
.step-val { font-family: var(--mono); font-weight: 700; font-size: 14px; min-width: 14px; text-align: center; }
.step-cap { font-size: 12px; color: var(--muted); margin-right: .2rem; }

.seg {
  display: inline-flex; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px;
}
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12.5px; padding: .35rem .7rem;
  border-radius: 7px; cursor: pointer; transition: all .15s;
}
.seg-btn.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.seg.mini .seg-btn { padding: .2rem .55rem; font-size: 11px; }

/* ---------- go button ---------- */
.go-btn {
  position: relative; overflow: hidden;
  width: 100%; margin-top: 1.1rem;
  background: var(--grad); border: 0; border-radius: 12px;
  color: #14060f; cursor: pointer;
  font-family: var(--disp); font-weight: 800; font-size: 15.5px; letter-spacing: .3px;
  padding: .85rem 1rem;
  transition: transform .15s, box-shadow .2s, filter .2s;
  box-shadow: 0 4px 22px rgba(161,123,255,.3);
}
.go-btn::after {
  content: ""; position: absolute; top: 0; left: -80%;
  width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.45), transparent);
  transform: skewX(-20deg); transition: left .45s ease;
}
.go-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(255,138,212,.4); }
.go-btn:hover::after { left: 130%; }
.go-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; transform: none; }
.go-btn.busy { animation: busy-pulse 1.6s ease-in-out infinite; }

/* ---------- dropzone ---------- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border); border-radius: 12px;
  background: var(--bg);
  min-height: 132px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .2s, background .2s;
  overflow: hidden;
}
.dropzone.tall { min-height: 260px; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #11151c; }
.dz-inner { text-align: center; padding: 1rem; }
.dz-icon { font-size: 30px; margin-bottom: .35rem; }
.dz-text { font-size: 13.5px; }
.dz-sub { font-size: 11.5px; color: var(--muted); margin-top: .2rem; }
.dz-sub.err { color: var(--danger); font-weight: 600; }
.dz-preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #11151c; padding: 6px;
}
.convert-blurb { color: var(--muted); font-size: 13px; margin: .2rem 0 .9rem; line-height: 1.55; }

/* ---------- switches / sliders ---------- */
.switch-row {
  display: flex; align-items: center; gap: .6rem;
  margin-top: .85rem; cursor: pointer; font-size: 13.5px; user-select: none;
}
.switch-row small { display: block; color: var(--muted); font-size: 11.5px; }
.switch-row input { display: none; }
.switch {
  flex: none; width: 36px; height: 20px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  position: relative; transition: background .2s, border-color .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: all .2s cubic-bezier(.2,.9,.3,1.3);
}
.switch-row input:checked + .switch { background: rgba(161,123,255,.35); border-color: #a17bff; }
.switch-row input:checked + .switch::after { left: 18px; background: #fff; }

.slider-row {
  display: flex; align-items: center; gap: .7rem;
  margin-top: .95rem; font-size: 13.5px;
}
.slider-row b { font-family: var(--mono); font-size: 12px; color: var(--accent); min-width: 34px; text-align: right; }
input[type="range"] {
  flex: 1; appearance: none; height: 4px; border-radius: 4px;
  background: var(--panel-2); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--grad); border: 2px solid #0e1014;
  box-shadow: 0 0 10px rgba(161,123,255,.5); cursor: pointer;
}

/* ---------- results ---------- */
.results-empty { text-align: center; color: var(--muted); }
.empty-face { font-size: 56px; filter: grayscale(.4); animation: mark-bob 5s ease-in-out infinite; }
.empty-text { font-family: var(--disp); font-weight: 700; font-size: 17px; color: var(--text); margin-top: .6rem; }
.empty-sub { font-size: 12.5px; margin-top: .25rem; }

.progress { text-align: center; padding: 2rem 1rem; }
.progress-emoji { font-size: 44px; animation: forge-spin 1.2s ease-in-out infinite; }
.progress-verb { font-family: var(--disp); font-weight: 700; font-size: 16px; margin-top: .7rem; }
.progress-bar {
  height: 6px; border-radius: 6px; overflow: hidden;
  background: var(--panel-2); margin: .9rem auto 0; max-width: 320px;
}
.progress-bar span {
  display: block; height: 100%; width: 40%;
  background: var(--grad); border-radius: 6px;
  animation: bar-slide 1.3s ease-in-out infinite;
}
.progress-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: .6rem; }

.cand-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .8rem;
}
.cand {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; aspect-ratio: 1;
  transition: transform .18s, border-color .2s, box-shadow .2s;
  animation: cand-pop .4s cubic-bezier(.2,.9,.3,1.25) both;
}
.cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand:hover { transform: translateY(-3px) scale(1.012); border-color: #3a4350; box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.cand.selected {
  border-color: transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    var(--grad) border-box;
  border: 2px solid transparent;
  box-shadow: 0 6px 26px rgba(255,138,212,.35);
}
.cand .pick {
  position: absolute; inset: auto 8px 8px auto;
  background: var(--grad); color: #14060f;
  font-family: var(--disp); font-weight: 800; font-size: 11px;
  border-radius: 999px; padding: .25rem .6rem; opacity: 0;
  transform: translateY(4px); transition: all .18s;
}
.cand:hover .pick, .cand.selected .pick { opacity: 1; transform: none; }
.cand.selected .pick::before { content: "✓ "; }
.results-err {
  text-align: center; color: var(--danger); font-size: 13.5px;
  padding: 1rem; border: 1px solid rgba(255,107,107,.3);
  background: rgba(255,107,107,.06); border-radius: 10px;
}

/* ---------- studio ---------- */
.studio { animation: rise-in .45s both; }
.studio-title {
  font-family: var(--disp); font-weight: 800; font-size: 20px;
  margin: .4rem 0 .9rem; display: flex; align-items: center; gap: .8rem;
}
.studio-title::before, .studio-title::after {
  content: ""; height: 1px; background: var(--border); flex: 1;
}
.studio-cols {
  display: grid; grid-template-columns: 1fr 1.25fr 1fr; gap: 1.1rem; align-items: start;
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1rem;
}

.checker {
  position: relative;
  border-radius: 12px; border: 1px solid var(--border);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background:
    conic-gradient(#191e26 25%, #11151c 0 50%, #191e26 0 75%, #11151c 0) 0 0/22px 22px;
  overflow: hidden;
}
.checker img { width: 82%; height: 82%; object-fit: contain; image-rendering: auto; }
.finish-spin {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(14,16,20,.55); backdrop-filter: blur(2px);
}
.finish-spin::after {
  content: ""; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: #ff8ad4;
  animation: spin .8s linear infinite;
}

.name-row {
  display: flex; align-items: center; gap: .15rem; margin-top: 1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: .45rem .6rem;
}
.name-row .colon { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.name-row input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
  color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: 13px;
}
.copy-btn {
  border: 0; background: var(--panel-2); color: var(--muted);
  border-radius: 6px; padding: .25rem .5rem; cursor: pointer; transition: all .15s;
}
.copy-btn:hover { color: var(--text); background: #2a3340; }

/* ---------- discord mock ---------- */
.discord-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: .6rem;
}
.discord-mock {
  border-radius: 10px; padding: .9rem .95rem;
  background: #313338; color: #dbdee1;
  font: 14px/1.4 "gg sans", "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column; gap: .85rem;
  border: 1px solid #26282c;
  transition: background .25s, color .25s;
}
.discord-mock.light { background: #ffffff; color: #313338; border-color: #e3e5e8; }
.dm-msg { display: flex; gap: .65rem; }
.dm-avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad); color: #14060f;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--disp); font-weight: 800; font-size: 15px;
}
.dm-avatar.a2 { background: linear-gradient(135deg, #8ab4ff, #6dd388); }
.dm-meta { display: flex; align-items: baseline; gap: .45rem; }
.dm-meta b { font-size: 14px; color: #f2f3f5; }
.discord-mock.light .dm-meta b { color: #060607; }
.dm-meta time { font-size: 11px; color: #80848e; }
.dm-text { margin-top: .15rem; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.dm-inline { width: 22px; height: 22px; object-fit: contain; }   /* Discord inline = 22px */
.dm-jumbo img { width: 48px; height: 48px; object-fit: contain; margin-top: .2rem; } /* jumbo = 48px */
.dm-reactions { display: flex; gap: .3rem; margin-top: .4rem; }
.dm-react {
  display: inline-flex; align-items: center; gap: .35rem;
  background: #2b2d31; border: 1px solid transparent; border-radius: 8px;
  padding: .15rem .5rem; font-size: 13px; color: #b5bac1; cursor: default;
}
.dm-react.reacted { background: #3c45a533; border-color: #5865f2; color: #dee0fc; }
.discord-mock.light .dm-react { background: #f2f3f5; color: #4e5058; }
.discord-mock.light .dm-react.reacted { background: #e0e3ff; border-color: #5865f2; color: #303adb; }
.dm-react-img { width: 16px; height: 16px; object-fit: contain; }  /* reaction = 16px */
.discord-cap { font-size: 11px; color: var(--muted); margin-top: .55rem; line-height: 1.45; }

/* ---------- export ---------- */
.export-head {
  font-family: var(--disp); font-weight: 700; font-size: 12.5px;
  letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin-bottom: .7rem;
}
.export-btn {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  background: var(--bg); border: 1px solid var(--border); border-radius: 11px;
  color: var(--text); padding: .6rem .75rem; margin-bottom: .55rem;
  font: inherit; cursor: pointer; text-align: left;
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.export-btn:hover { transform: translateY(-1px); border-color: #3a4350; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.export-btn.primary {
  border-color: transparent;
  background:
    linear-gradient(var(--panel-2), var(--panel-2)) padding-box,
    var(--grad) border-box;
}
.export-btn .x-ico { font-size: 18px; }
.export-btn .x-main { flex: 1; font-weight: 600; font-size: 13.5px; }
.export-btn .x-main small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; margin-top: .1rem; }
.export-btn .x-go { font-family: var(--mono); color: var(--accent); }
.export-btn.busy .x-go { animation: spin 1s linear infinite; display: inline-block; }
.export-fine { font-size: 11px; color: var(--muted); margin: .3rem 0 .75rem; }

.ghost-btn {
  background: transparent; border: 1px dashed var(--border); border-radius: 9px;
  color: var(--muted); font: inherit; font-size: 12.5px;
  padding: .45rem .7rem; cursor: pointer; transition: all .18s;
}
.ghost-btn:hover { color: var(--text); border-color: #3a4350; }

/* ---------- gallery ---------- */
.gallery-head {
  display: flex; align-items: center; gap: .7rem;
  font-family: var(--disp); font-weight: 700; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: .55rem;
}
.gallery-strip { display: flex; gap: .55rem; overflow-x: auto; padding-bottom: .4rem; }
.gallery-strip::-webkit-scrollbar { height: 6px; }
.gallery-strip::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 6px; }
.g-item {
  flex: none; width: 74px; height: 74px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg);
  transition: transform .15s, border-color .2s;
}
.g-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.g-item img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- footer / toasts ---------- */
.app-footer {
  display: flex; justify-content: center; gap: .6rem; align-items: center;
  padding: 1rem; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border);
}
.app-footer a { color: var(--accent); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
.app-footer i { font-style: normal; opacity: .4; }

.toasts { position: fixed; top: 64px; right: 14px; z-index: 100; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  color: var(--text); font-size: 13px; border-radius: 10px;
  padding: .6rem .85rem; max-width: 300px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toast-in .25s cubic-bezier(.2,.9,.3,1.2) both;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok  { border-left-color: var(--ok); }

.hidden { display: none !important; }

/* ---------- keyframes ---------- */
@keyframes drop-in  { from { transform: translateY(-14px); opacity: 0; } }
@keyframes rise-in  { from { transform: translateY(14px);  opacity: 0; } }
@keyframes cand-pop { from { transform: scale(.85);        opacity: 0; } }
@keyframes toast-in { from { transform: translateX(20px);  opacity: 0; } }
@keyframes mark-bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-4px) rotate(3deg); } }
@keyframes busy-pulse { 0%,100% { box-shadow: 0 4px 22px rgba(161,123,255,.3); } 50% { box-shadow: 0 4px 34px rgba(255,138,212,.55); } }
@keyframes forge-spin { 0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.12); } }
@keyframes bar-slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .studio-cols { grid-template-columns: 1fr 1fr; }
  .export-card { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .results-pane { min-height: 300px; }
}
@media (max-width: 560px) {
  main { padding: .9rem .6rem 2rem; }
  .pane, .card { padding: .8rem; }
  .studio-cols { grid-template-columns: 1fr; }
  .brand-tag { display: none; }
  textarea, input { font-size: 16px; } /* prevent iOS zoom */
  .cand-grid { grid-template-columns: repeat(2, 1fr); }
}
