/* Meme Generator: picker page (scoped to .mg-main) + editor on the shared Media Engine skeleton (.mg-studio). */

/* ---------- Picker ---------- */
.mg-main { width: 100%; max-width: 1180px; margin: 0 auto; align-self: center; padding: 56px 16px 90px; color: #e4e4e7; font-family: Inter, system-ui, sans-serif; box-sizing: border-box; }
.mg-main *, .mg-main *::before, .mg-main *::after { box-sizing: border-box; }
.mg-main svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mg-hero { text-align: center; max-width: 640px; margin: 0 auto 38px; }
.mg-kick { margin: 0 0 14px; color: #a1a1aa; font-size: 12px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.mg-main h1 { margin: 0; color: #fff; font: 800 clamp(38px, 7vw, 64px)/1.02 Outfit, Inter, sans-serif; letter-spacing: -.02em; }
.mg-main h1 em { font-style: normal; background: linear-gradient(90deg, #facc15, #fb7185 55%, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mg-lead { margin: 18px auto 0; max-width: 480px; color: #a1a1aa; font-size: 16px; line-height: 1.6; }
.mg-search { display: flex; align-items: center; gap: 10px; max-width: 460px; height: 50px; margin: 28px auto 0; padding: 0 18px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; background: rgba(255,255,255,.05); color: #71717a; }
.mg-search:focus-within { border-color: rgba(255,255,255,.3); }
.mg-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: #fff; font: 500 15px Inter, system-ui, sans-serif; outline: none; }
.mg-search input::placeholder { color: #71717a; }

.mg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 26px 18px; }
.mg-card { display: flex; flex-direction: column; gap: 10px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: center; cursor: pointer; }
.mg-card[hidden] { display: none; }
.mg-thumb { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: 16px; background: rgba(255,255,255,.04); transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s; }
.mg-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mg-card:hover .mg-thumb, .mg-card:focus-visible .mg-thumb { transform: translateY(-3px); box-shadow: 0 18px 40px -18px rgba(0,0,0,.9), 0 0 0 2px rgba(255,255,255,.7); }
.mg-card:focus-visible { outline: none; }
.mg-name { color: #d4d4d8; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.mg-own .mg-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; border: 1.5px dashed rgba(255,255,255,.22); background: none; color: #e4e4e7; }
.mg-own .mg-thumb svg { width: 30px; height: 30px; }
.mg-own .mg-thumb b { font-size: 14px; font-weight: 700; }
.mg-none { margin: 30px 0 0; color: #a1a1aa; text-align: center; }
@media (max-width: 560px) {
  .mg-main { padding-top: 36px; }
  .mg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .mg-name { font-size: 12.5px; }
}

/* ---------- Editor ---------- */
.mg-studio .mx-tabs { grid-template-columns: repeat(2, 1fr); }
.mg-studio .mx-tool { width: 100%; }
.mg-studio .mx-acts { margin-left: auto; }
.mg-studio { --rail-open: 190px; }
.mg-back { margin-right: -2px; }
.mg-board { position: relative; flex: none; box-shadow: 0 30px 80px -30px rgba(0,0,0,.9); touch-action: none; user-select: none; -webkit-user-select: none; }
.mg-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mg-boxes { position: absolute; inset: 0; }
.mg-box { position: absolute; border: 1.5px dashed transparent; border-radius: 4px; cursor: text; transition: border-color .15s, background .15s; }
.mg-box.pic { cursor: move; border-color: transparent; box-shadow: none; }
@media (hover: hover) { .mg-box:hover { border-color: rgba(255,255,255,.7); } }
.mg-box.on { border: 2px solid #a78bfa; background: rgba(167,139,250,.08); }
.mg-box.empty { display: grid; place-items: center; border-color: rgba(255,255,255,.5); background: rgba(0,0,0,.25); }
.mg-box.empty span { color: rgba(255,255,255,.8); font: 700 12px Inter, system-ui, sans-serif; pointer-events: none; }
.mg-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border: 2px solid #fff; border-radius: 50%; background: #a78bfa; cursor: nwse-resize; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.mg-handle::before { content: ""; position: absolute; inset: -10px; }
.mg-edit { position: absolute; z-index: 5; margin: 0; padding: 0 3%; border: 2px solid #a78bfa; border-radius: 4px; background: rgba(0,0,0,.35); resize: none; overflow: hidden; outline: none; caret-color: #a78bfa; box-sizing: border-box; }

.mg-list { display: grid; gap: 8px; }
.mg-li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.03); cursor: text; transition: border-color .15s; }
.mg-li.on { border-color: rgba(167,139,250,.6); }
.mg-li-n { display: grid; place-items: center; flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; background: rgba(255,255,255,.08); color: #a1a1aa; font: 800 11px Inter, system-ui, sans-serif; }
.mg-li textarea { flex: 1; min-width: 0; min-height: 26px; padding: 3px 0; border: 0; background: none; color: #f4f4f5; font: 500 14px/1.4 Inter, system-ui, sans-serif; resize: none; outline: none; overflow: hidden; }
.mg-tip, .mg-pickfirst { margin: 14px 0 0; color: #71717a; font-size: 12.5px; line-height: 1.5; }
.mg-pickfirst { padding: 24px 18px; text-align: center; }

.mg-fonts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.mg-fonts button { height: 40px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; background: rgba(255,255,255,.03); color: #e4e4e7; font-size: 17px; cursor: pointer; }
.mg-fonts button:hover { background: rgba(255,255,255,.07); }
.mg-fonts button[aria-checked="true"] { border-color: #a78bfa; background: rgba(167,139,250,.14); color: #fff; }
.mg-studio #mg-auto[aria-pressed="true"] { border-color: transparent; background: #e7e7ea; color: #0b0b10; }
.mg-row { display: flex; align-items: center; gap: 4px; margin-top: 14px; }
.mg-row .mx-icon-btn[aria-pressed="true"] { background: rgba(167,139,250,.16); color: #ddd6fe; }
.mg-caps { margin-left: auto; letter-spacing: .06em; }
.mg-caps[aria-pressed="false"] { text-transform: lowercase; opacity: .7; }
.mg-sws { display: flex; flex-wrap: wrap; gap: 8px; }
.mg-sws button, .mg-cust { position: relative; width: 28px; height: 28px; padding: 0; border: 2px solid rgba(255,255,255,.15); border-radius: 50%; background: var(--sw); cursor: pointer; }
.mg-sws button[aria-pressed="true"] { box-shadow: 0 0 0 2px #08080c, 0 0 0 4px #a78bfa; }
.mg-cust { overflow: hidden; background: conic-gradient(#ef4444, #facc15, #22c55e, #3b82f6, #a855f7, #ef4444); }
.mg-cust input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.mg-gap { margin-top: 18px; }
.mg-del { width: 100%; justify-content: center; }

@media (max-width: 760px) {
  .mg-studio { grid-template-rows: auto minmax(0, 1fr) auto 36%; grid-template-areas: "id acts" "stage stage" "rail rail" "side side"; }
  .mg-studio .mx-title { display: block; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .mg-studio .mx-id { flex: 1 1 auto; min-width: 0; gap: 4px; padding-left: 6px; }
  .mg-studio .mx-sub { display: none; }
  .mg-studio .mx-rail, .mg-studio .mx-rail.open { justify-content: center; border-top: 1px solid var(--line); border-bottom: 0; }
  .mg-studio .mx-tool { width: 66px; }
  .mg-studio .mx-stage { padding: 10px; }
  #mg-dl { height: 36px; padding: 0 14px; }
  #mg-dl span { display: inline; }
  .mg-fonts { grid-template-columns: repeat(4, 1fr); }
  .mg-fonts button { font-size: 14px; }
}
@media (max-width: 760px) { #mg-dl .mg-dl-x { display: none; } }
@media (max-width: 400px) { .mg-studio .mx-title { max-width: 30vw; } }
