/* extinction.meme — meme-o-matic (the make-ur-own mini-game). Built by maker.js inside #meme-maker.
   Colours come from the site's tokens so it follows the discord kitten (light) / reddit mod (dark) themes.
   The only fixed colours are the text-style swatches, which preview what gets drawn on the image. */

@font-face { font-family: "Anton"; src: url(/fonts/Anton-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
/* from keltan's Rapid Meme Maker (google fonts: Bangers + Oswald OFL, Permanent Marker Apache 2.0; licences in /fonts) */
@font-face { font-family: "Bangers"; src: url(/fonts/Bangers-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Oswald"; src: url(/fonts/Oswald-700.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Permanent Marker"; src: url(/fonts/PermanentMarker-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }

.mm {
  position: relative; margin: 10px 0 34px; padding: 22px 20px 24px; color: var(--ink);
  background: var(--paper); border: 3px solid var(--line); border-radius: 26px; box-shadow: 7px 7px 0 var(--shade);
}
.mm *, .mm *::before, .mm *::after { box-sizing: border-box; }
.mm::before {
  content: ""; position: absolute; top: -14px; left: 34px; width: 110px; height: 28px;
  background: var(--butter); opacity: .85; border: 2px dashed var(--line); transform: rotate(-4deg); pointer-events: none;
}

/* ---------- head ---------- */
.mm-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; }
.mm-title { margin: 0; font-family: var(--hand); font-weight: 700; font-size: clamp(38px, 6vw, 54px); line-height: 1; color: var(--hot); transform: rotate(-1.5deg); }
.mm-badge {
  display: inline-block; padding: 2px 11px; font-weight: 700; font-size: 14px; color: var(--pastel-ink);
  background: var(--mint); border: 2px solid var(--line); border-radius: 999px; box-shadow: 2px 2px 0 var(--shade); transform: rotate(4deg);
}
.mm-sub { flex-basis: 100%; margin: 4px 0 0; font-size: 17px; color: var(--ink-soft); }

.mm-step-h { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-family: var(--hand); font-weight: 700; font-size: 27px; line-height: 1.05; }
.mm-num {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; font-family: var(--body); font-size: 16px;
  background: var(--hot); color: #fff; border: 2.5px solid var(--line); border-radius: 50%; box-shadow: 2px 2px 0 var(--shade);
}
.mm-count { font-family: var(--body); font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* ---------- 1. template picker: search + two-row strip that scrolls sideways ----------
   maker.js places the tiles itself (absolute, only the ones near the view): a column is 114px wide and a row 112px tall,
   100px / 100px at <= 520px. Change those numbers in geom() too if the tile size changes here. */
.mm-pick { margin-bottom: 6px; }
.mm-find { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.mm-search {
  flex: 1 1 220px; min-width: 0; padding: 8px 14px; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 999px; transition: box-shadow .12s, border-color .12s;
}
.mm-search::placeholder { color: var(--ink-soft); opacity: .75; }
.mm-search:focus { outline: none; border-color: var(--hot); box-shadow: 0 0 0 3px var(--pink); }
.mm-find-btns { display: flex; align-items: center; gap: 6px; }
.mm-find-btns .icon-btn:disabled { opacity: .35; cursor: default; transform: none; }
.mm-tpls {
  position: relative; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; padding: 8px 4px 12px;
  scrollbar-color: var(--hot) transparent; scrollbar-width: thin;
}
.mm-track { position: relative; min-height: 100px; }
.mm-nomatch { margin: 0 0 6px; font-family: var(--hand); font-weight: 700; font-size: 22px; line-height: 1.1; color: var(--ink-soft); }
.mm-tpl {
  position: absolute; top: 0; left: 0; display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 104px; height: 102px;
  padding: 5px 5px 6px; overflow: hidden;
  font: inherit; font-size: 12.5px; font-weight: 700; line-height: 1.1; text-align: center; color: var(--ink); cursor: pointer;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 12px; box-shadow: 2px 2px 0 var(--shade);
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), background .15s;
}
.mm-tpl img { flex: none; width: 100%; height: 66px; object-fit: cover; border-radius: 7px; background: var(--well); }
.mm-tpl span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-tpl:hover { transform: rotate(-2deg) translateY(-2px); }
.mm-tpl[aria-pressed="true"], .mm-upload.on { background: var(--hot); color: #fff; transform: rotate(-2.5deg) scale(1.04); box-shadow: 3px 3px 0 var(--shade); }
.mm-upload { justify-content: center; align-items: center; background: var(--butter); color: var(--pastel-ink); }
.mm-upload span { white-space: normal; }
.mm-upload small { font-size: 11px; font-weight: 700; opacity: .8; }
.mm-up-ico { font-size: 28px; line-height: 1.1; }
.mm-upload:focus-within { outline: 3px dashed var(--hot); outline-offset: 3px; }
.mm-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

/* ---------- workspace ---------- */
.mm-work { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); gap: 22px; align-items: start; margin-top: 8px; }
.mm-left { position: sticky; top: 86px; min-width: 0; }
.mm-panel { min-width: 0; }

.mm-stage {
  position: relative; display: grid; place-items: center; min-height: 220px; padding: 12px; overflow: hidden;
  border: 3px solid var(--line); border-radius: 18px; touch-action: none;
  background-color: var(--well);
  background-image: linear-gradient(45deg, var(--card) 25%, transparent 25%, transparent 75%, var(--card) 75%),
    linear-gradient(45deg, var(--card) 25%, transparent 25%, transparent 75%, var(--card) 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
}
.mm-canvas {
  display: block; max-width: 100%; max-height: 68vh; width: auto; height: auto; border-radius: 6px; box-shadow: 4px 4px 0 var(--shade);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.mm-canvas:focus { outline: none; }
.mm-canvas:focus-visible { outline: 3px dashed var(--hot); outline-offset: 4px; }
.mm-dragging .mm-canvas { cursor: grabbing; }
.mm-stage.loading .mm-canvas { opacity: .35; }
.mm-stage.loading::after {
  content: "loading… ✿"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-3deg);
  padding: 6px 16px; font-family: var(--hand); font-weight: 700; font-size: 28px; color: var(--pastel-ink);
  background: var(--butter); border: 2.5px solid var(--line); border-radius: 999px; box-shadow: 3px 3px 0 var(--shade);
}
.mm-stage.drop { outline: 4px dashed var(--hot); outline-offset: -8px; }
.mm-tip { margin: 8px 2px 0; font-family: var(--hand); font-weight: 700; font-size: 21px; line-height: 1.1; color: var(--ink-soft); text-align: center; }

/* meme-o-meter */
.mm-meter {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 10px; padding: 8px 14px 9px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 18px; box-shadow: 3px 3px 0 var(--shade);
}
.mm-meter-lbl { font-weight: 700; font-size: 14px; white-space: nowrap; }
.mm-meter-bar { flex: 1 1 80px; min-width: 60px; height: 16px; overflow: hidden; background: var(--paper); border: 2px solid var(--line); border-radius: 999px; }
.mm-meter-bar i {
  display: block; width: 0; height: 100%; border-radius: 999px;
  background: repeating-linear-gradient(-45deg, var(--hot) 0 8px, var(--pink) 8px 16px);
  transition: width .45s cubic-bezier(.3, 1.5, .5, 1);
}
.mm-meter-msg { flex-basis: 100%; min-width: 0; font-family: var(--hand); font-weight: 700; font-size: 24px; line-height: 1.1; color: var(--hot); }

/* ---------- panel cards ---------- */
.mm-card { margin-bottom: 14px; padding: 12px 14px 14px; background: var(--card); border: 2.5px solid var(--line); border-radius: 18px; box-shadow: 3px 3px 0 var(--shade); }
.mm-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mm-row .btn { flex: 1 1 auto; }

.mm-boxes { margin-bottom: 10px; }
.mm-boxrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mm-dot {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; font-weight: 700; font-size: 14px; line-height: 1;
  color: var(--pastel-ink); background: var(--butter); border: 2px solid var(--line); border-radius: 50%;
}
.mm-in, .mm-title-in {
  flex: 1 1 auto; min-width: 0; padding: 9px 12px; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 12px; transition: box-shadow .12s, border-color .12s;
}
.mm-in::placeholder, .mm-title-in::placeholder { color: var(--ink-soft); opacity: .75; }
.mm-in:focus, .mm-title-in:focus { outline: none; border-color: var(--hot); box-shadow: 0 0 0 3px var(--pink); }
.mm-boxrow.on .mm-in { border-color: var(--hot); }
.mm-boxrow.on .mm-dot { background: var(--hot); color: #fff; }
.mm-x { width: 32px; height: 32px; font-size: 14px; }
.mm-empty { margin: 0 0 10px; font-family: var(--hand); font-size: 21px; color: var(--ink-soft); }

/* tweak card */
.mm-tune-h { margin: 0 0 10px; font-family: var(--hand); font-weight: 700; font-size: 23px; line-height: 1.1; }
.mm-tune-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; transition: opacity .15s; }
.mm-tune-body.off { opacity: .45; }
.mm-size-row { display: flex; align-items: center; gap: 10px; width: 100%; font-weight: 700; font-size: 15px; }
.mm-size { flex: 1; min-width: 0; accent-color: var(--hot); height: 28px; }
.mm-size-out { min-width: 34px; text-align: right; font-size: 14px; color: var(--ink-soft); }
.mm-styles { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-styles .chip { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); }
.mm-styles .chip[aria-pressed="true"] { color: #fff; }
.mm-styles .chip:disabled, .mm-del:disabled { cursor: not-allowed; }
.mm-sw {
  display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 4px; border-radius: 6px; font-size: 15px; line-height: 1;
  background: #8a8a8a linear-gradient(135deg, #9b9b9b 25%, #7a7a7a 75%);
}
.mm-sw-classic { font-family: Anton, Impact, sans-serif; color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; }
.mm-sw-ink { font-family: Anton, Impact, sans-serif; color: #141414; background: #fff; border: 1px solid #c9c9c9; }
.mm-sw-kitten { font-family: var(--display); color: #ff3d9a; text-shadow: 1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff, 2px 2px 0 #2b1020; }
.mm-sw-label { font-family: var(--body); font-weight: 700; color: #2b1020; background: #fff27a; border: 1.5px solid #2b1020; }
.mm-caps { letter-spacing: .03em; }

/* line it up: multi-select, align / distribute, misalign + the eliezer pop-up */
.mm-selrow { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.mm-selrow .chip { color: var(--ink); }
.mm-selrow .chip[aria-pressed="true"] { color: #fff; }
.mm-alignrow { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.mm-algroup { display: flex; flex-wrap: nowrap; gap: 5px; }
.mm-al { width: 34px; height: 34px; color: var(--ink); }
.mm-al svg { display: block; width: 18px; height: 18px; }
.mm-mis, .mm-algroup, .mm-selrow { position: relative; z-index: 2; } /* eliezer pops up from behind these */
/* misalign is an easter egg, not a tool: a small grey-ish swirl tucked at the end of the row. it wakes up (colour, size) on hover / focus */
.mm-mis { width: 26px; height: 26px; margin-left: auto; font-size: 13px; opacity: .5; filter: grayscale(1); box-shadow: none; border-width: 2px; border-style: dashed; background: transparent; }
.mm-mis:hover, .mm-mis:focus-visible { opacity: 1; filter: none; background: var(--bubble); }
.mm-mis span { display: block; line-height: 1; }
.mm-align-info { margin: 10px 0 0; font-size: 14px; line-height: 1.35; color: var(--ink-soft); }
.mm-selecting .mm-canvas { cursor: copy; }
.mm-eli-clip { position: absolute; left: 0; right: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.mm-eli { position: absolute; bottom: 0; left: 0; transform: translateY(105%); }
.mm-eli.pop { animation: mm-eli-pop 1.7s cubic-bezier(.3, 1.3, .5, 1) both; }
.mm-eli.still { transform: none; }
.mm-eli-img { display: block; width: 100%; height: 100%; max-width: none; object-fit: contain; object-position: bottom; filter: drop-shadow(3px 3px 0 var(--shade)); }
.mm-eli-img.flip { transform: scaleX(-1); }
@keyframes mm-eli-pop {
  0% { transform: translateY(105%); }
  16% { transform: translateY(-4%) rotate(-1deg); }
  24%, 80% { transform: translateY(0) rotate(0); }
  100% { transform: translateY(105%); }
}

/* undo / redo + tools, right under the picture */
.mm-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; }
.mm-bargroup { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-hist:disabled, .mm-tool:disabled { opacity: .35; cursor: default; transform: none; background: var(--paper); }

/* stickers */
.mm-stks { display: flex; flex-wrap: wrap; gap: 8px; }
.mm-stk {
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0; font-size: 26px; line-height: 1; color: var(--hot);
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 13px; box-shadow: 2px 2px 0 var(--shade);
  transition: transform .15s cubic-bezier(.3, 1.8, .5, 1);
}
.mm-stk:hover { transform: rotate(-10deg) scale(1.12); }
.mm-stk:active { transform: scale(.9); }

/* send */
.mm-submit { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 2.5px dashed var(--line); }
.mm-title-in { flex: 1 1 200px; }
.mm-submit-btn { flex: 1 1 auto; }
.mm-fine { margin: 8px 0 0; font-size: 14.5px; line-height: 1.35; color: var(--ink-soft); }
.mm-reset { margin-top: 2px; }

/* little wiggle when something reacts */
.mm-wiggle { animation: mm-wiggle .45s ease-in-out; }
@keyframes mm-wiggle {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-3deg) scale(1.04); }
  60% { transform: rotate(2deg) scale(1.02); }
}

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .mm-work { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .mm-left { position: static; }
  .mm-canvas { max-height: 60vh; }
}
@media (max-width: 520px) {
  .mm { padding: 18px 12px 18px; border-radius: 22px; box-shadow: 5px 5px 0 var(--shade); }
  .mm::before { left: 20px; width: 80px; height: 22px; top: -11px; }
  .mm-sub { font-size: 16px; }
  .mm-search { flex-basis: 100%; }
  .mm-tpl { width: 92px; height: 92px; font-size: 12px; }
  .mm-tpl img { height: 58px; }
  .mm-stage { padding: 8px; min-height: 180px; border-radius: 14px; }
  .mm-card { padding: 11px 11px 12px; }
  .mm-step-h { font-size: 25px; }
  .mm-row .btn { padding-left: 10px; padding-right: 10px; }
}

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

/* ---------- mini mode: the profile-picture editor (window.XMMaker.openMini, built by maker.js) ----------
   A <dialog class="dlg mini-dlg"> with a pinned preview on top, a tab strip (look / words / stickers) and a pinned save row,
   so the picture and the save button are always on screen on a phone. Colours come from the site's tokens. */
dialog.dlg.mini-dlg { width: min(460px, calc(100vw - 20px)); padding: 0; overflow: hidden; }
dialog.dlg.mini-dlg[open] { display: flex; flex-direction: column; }
.mini-dlg *, .mini-dlg *::before, .mini-dlg *::after { box-sizing: border-box; }
.mini-dlg [hidden] { display: none !important; }
.mini-head { position: relative; flex: none; padding: 16px 56px 4px 18px; }
dialog.dlg.mini-dlg h2 { margin: 0; font-size: 34px; }
.mini-stagewrap { flex: none; padding: 0 16px; }
.mini-stage { position: relative; display: grid; place-items: center; padding: 8px; background: var(--well); border-radius: 16px; }
.mini-canvas {
  display: block; width: min(320px, 100%, 40vh); width: min(320px, 100%, 40dvh); min-width: 150px; height: auto; aspect-ratio: 1;
  border: 3px solid var(--line); border-radius: 8px; box-shadow: 4px 4px 0 var(--shade); background: var(--paper);
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.mini-stage.dragging .mini-canvas { cursor: grabbing; }
.mini-canvas:focus { outline: none; }
.mini-canvas:focus-visible { outline: 3px dashed var(--hot); outline-offset: 4px; }
.mini-loading {
  position: absolute; left: 50%; top: 50%; padding: 4px 14px; transform: translate(-50%, -50%) rotate(-3deg);
  font-family: var(--hand); font-weight: 700; font-size: 26px; color: var(--pastel-ink);
  background: var(--butter); border: 2.5px solid var(--line); border-radius: 999px; box-shadow: 3px 3px 0 var(--shade);
}
/* undo / redo sit in the two top corners of the preview, which the circle crops away anyway */
.mini-hist { position: absolute; top: 10px; z-index: 2; width: 32px; height: 32px; }
.mini-hist-l { left: 10px; }
.mini-hist-r { right: 10px; }
.mini-hist:disabled { opacity: .35; cursor: default; transform: none; }
.mini-tip { margin: 6px 0 0; font-family: var(--hand); font-weight: 700; font-size: 20px; line-height: 1.1; text-align: center; color: var(--ink-soft); }

.mini-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 16px 6px; }
.mini-tabs { position: sticky; top: 0; z-index: 1; display: flex; gap: 6px; margin: 0 0 8px; padding: 4px 0 4px; background: var(--paper); }
.mini-tab { flex: 1 1 0; min-width: 0; padding: 6px 4px; text-align: center; color: var(--ink); }
.mini-tab[aria-selected="true"] { background: var(--hot); color: #fff; }
/* the three panels share one grid cell, so the dialog is as tall as the tallest and nothing jumps when the tab changes */
.mini-panels { display: grid; }
.mini-panel { grid-area: 1 / 1; align-content: start; display: grid; gap: 10px; padding-bottom: 4px; }
.mini-dlg .mini-panel[hidden] { display: grid !important; visibility: hidden; }
.mini-row { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 36px; }
.mini-lbl { flex: none; min-width: 52px; font-weight: 700; font-size: 15px; }
.mini-range { flex: 1 1 auto; min-width: 0; height: 30px; accent-color: var(--hot); }
.mini-in {
  flex: 1 1 auto; min-width: 0; padding: 9px 12px; font: inherit; font-size: 17px; color: var(--ink);
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 12px;
}
.mini-in::placeholder { color: var(--ink-soft); opacity: .75; }
.mini-in:focus { outline: none; border-color: var(--hot); box-shadow: 0 0 0 3px var(--pink); }
.mini-sws, .mini-chipset { display: flex; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.mini-sw {
  flex: none; width: 34px; height: 34px; padding: 0; border: 2.5px solid var(--line); border-radius: 50%; box-shadow: 2px 2px 0 var(--shade);
}
.mini-sw[aria-pressed="true"] { outline: 3px solid var(--hot); outline-offset: 2px; }
.mini-bg .mini-sws { flex: 1 1 auto; flex-wrap: nowrap; justify-content: space-between; padding: 3px 4px; }
.mini-bg .mini-sw { width: 32px; height: 32px; }
.mini-chips .chip, .mini-chipset .chip { padding: 3px 9px; font-size: 14.5px; color: var(--ink); }
.mini-chips .chip[aria-pressed="true"], .mini-chipset .chip[aria-pressed="true"] { color: #fff; }
.mini-chips .chip:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.mini-hint { margin: 0; font-size: 14.5px; line-height: 1.35; color: var(--ink-soft); }
.mini-stks { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.mini-stk {
  display: grid; place-items: center; height: 44px; padding: 0; font-size: 24px; line-height: 1;
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 12px; box-shadow: 2px 2px 0 var(--shade);
}
.mini-stk:hover { background: var(--bubble); }
.mini-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.mini-act { flex-direction: column; gap: 0; min-height: 46px; padding: 4px 2px; font-size: 13.5px; line-height: 1.15; }
.mini-act-ico { font-size: 17px; line-height: 1.1; }
.mini-actions .btn:disabled { opacity: .4; }

.mini-foot { flex: none; padding: 8px 16px 14px; border-top: 2.5px dashed var(--line); background: var(--paper); }
.mini-err { margin: 0 0 6px; font-size: 14.5px; line-height: 1.3; }
.mini-err:empty { display: none; }
.mini-btns { display: flex; gap: 10px; }
.mini-btns .btn { flex: 1 1 auto; padding: 8px 14px; }
.mini-btns .btn.hot { flex: 2 1 auto; }

@media (max-width: 420px) {
  .mini-head { padding: 14px 52px 2px 14px; }
  .mini-stagewrap, .mini-main { padding-left: 12px; padding-right: 12px; }
  .mini-foot { padding-left: 12px; padding-right: 12px; }
  .mini-tab { font-size: 14px; }
}
@media (max-width: 360px) {
  .mini-tab { padding: 6px 2px; font-size: 13px; white-space: nowrap; }
}
/* a short screen (small phones): a smaller picture and no tip, so the controls have room */
@media (max-height: 640px) {
  .mini-canvas { width: min(320px, 100%, 36vh); width: min(320px, 100%, 36dvh); }
  .mini-tip { display: none; }
  .mini-head { padding-top: 10px; }
  dialog.dlg.mini-dlg h2 { font-size: 28px; }
}
/* a short, wide screen (a phone on its side): picture on the left, controls on the right */
@media (max-height: 520px) and (min-width: 600px) {
  dialog.dlg.mini-dlg { width: min(740px, calc(100vw - 20px)); }
  dialog.dlg.mini-dlg[open] { display: grid; grid-template-columns: minmax(0, 270px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .mini-head { grid-column: 1 / -1; padding-top: 8px; }
  dialog.dlg.mini-dlg h2 { font-size: 28px; }
  .mini-stagewrap { grid-column: 1; grid-row: 2 / 4; align-self: start; }
  .mini-canvas { width: min(250px, 100%, 62vh); width: min(250px, 100%, 62dvh); }
  .mini-tip { display: block; }
  .mini-main { grid-column: 2; grid-row: 2; }
  .mini-foot { grid-column: 2; grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.dlg.mini-dlg[open] { animation: none; }
  .mini-dlg, .mini-dlg * { animation: none !important; transition: none !important; }
}

/* ---------- tools under the picture: colour / pen options, crop bar, typing on the picture ---------- */
.mm-opts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; padding: 7px 12px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 14px; box-shadow: 2px 2px 0 var(--shade);
}
.mm-opt { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.mm-opt-pen { flex: 1 1 150px; min-width: 0; }
.mm-pen { flex: 1 1 60px; min-width: 60px; height: 24px; accent-color: var(--hot); }
.mm-pen-out { min-width: 22px; text-align: right; font-size: 13px; font-weight: 400; color: var(--ink-soft); }
.mm-color { flex: none; width: 38px; height: 30px; padding: 0; border: 2.5px solid var(--line); border-radius: 9px; background: var(--paper); cursor: pointer; }
.mm-check { cursor: pointer; }
.mm-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--hot); }
.mm-font, .mm-shape, .mm-strip {
  min-width: 0; padding: 4px 8px; font: inherit; font-size: 15px; color: var(--ink); background: var(--paper);
  border: 2.5px solid var(--line); border-radius: 10px;
}
.mm-font:focus-visible, .mm-shape:focus-visible, .mm-strip:focus-visible, .mm-ow:focus-visible, .mm-color:focus-visible { outline: 3px dashed var(--hot); outline-offset: 2px; }
.mm-ow { width: 58px; padding: 4px 6px; font: inherit; font-size: 15px; color: var(--ink); background: var(--paper); border: 2.5px solid var(--line); border-radius: 10px; }
.mm-textopts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.mm-orow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.mm-olbl { font-weight: 700; font-size: 14px; }
.mm-fmt, .mm-talign { min-width: 34px; padding: 3px 9px; color: var(--ink); }
.mm-fmt[aria-pressed="true"], .mm-talign[aria-pressed="true"] { color: #fff; }
.mm-talign-set { display: inline-flex; gap: 4px; }
.mm-sw-custom { font-family: Impact, Anton, sans-serif; color: #ff3d9a; text-shadow: 1px 1px 0 #2b1020, -1px 1px 0 #2b1020, 1px -1px 0 #2b1020, -1px -1px 0 #2b1020; background: #8a8a8a; }
.mm-ta { display: block; resize: none; overflow: hidden; line-height: 1.25; }
.mm-cropbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; }
.mm-cropnote { flex: 1 1 170px; font-family: var(--hand); font-weight: 700; font-size: 21px; line-height: 1.1; color: var(--ink-soft); }
.mm-live {
  position: absolute; z-index: 4; margin: 0; padding: 2px 8px; resize: none; overflow: hidden; line-height: 1.1; color: #fff;
  background: rgba(43, 16, 32, .62); border: 2px dashed var(--hot); border-radius: 6px; outline: none; text-shadow: 0 0 3px #000, 0 0 3px #000;
}
.mm-canvas[data-tool="text"] { cursor: text; }
.mm-canvas[data-tool="pen"], .mm-canvas[data-tool="eraser"], .mm-canvas[data-tool="line"], .mm-canvas[data-tool="rect"], .mm-canvas[data-tool="crop"] { cursor: crosshair; }
.mm-strip-prev { display: block; margin: 5px auto 0; max-width: 100%; image-rendering: pixelated; }
.mm-exportopts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; }
.mm-picrow { margin-top: 10px; }
.mm-addpic { position: relative; cursor: pointer; }
.mm-addpic:focus-within { outline: 3px dashed var(--hot); outline-offset: 3px; }

/* ---------- video: trim bar under the picture ---------- */
.mm-vid-src { position: absolute; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.mm-timeline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; padding: 8px 12px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 14px; box-shadow: 2px 2px 0 var(--shade);
}
.mm-play { width: 36px; height: 36px; font-size: 15px; }
.mm-time { flex: none; min-width: 78px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.mm-vtrack {
  position: relative; flex: 1 1 140px; min-width: 120px; height: 30px; margin: 0 8px; cursor: pointer; touch-action: none;
  background: var(--paper); border: 2.5px solid var(--line); border-radius: 10px;
}
.mm-vrange { position: absolute; top: 0; bottom: 0; pointer-events: none; background: color-mix(in srgb, var(--hot) 30%, transparent); border-left: 2px solid var(--hot); border-right: 2px solid var(--hot); }
.mm-vhead { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; pointer-events: none; background: var(--ink); border-radius: 2px; }
.mm-vhandle {
  position: absolute; top: -6px; bottom: -6px; width: 14px; margin-left: -7px; cursor: ew-resize; touch-action: none;
  background: var(--hot); border: 2px solid var(--line); border-radius: 6px; box-shadow: 1px 1px 0 var(--shade);
}
.mm-vhandle::after { content: ""; position: absolute; inset: -4px -12px; } /* a bigger thing to grab with a thumb */
.mm-vhandle:focus-visible { outline: 3px dashed var(--hot); outline-offset: 3px; }
.mm-timeline .btn.small { padding: 4px 10px; font-size: 14px; }
/* while a video is being saved nothing can be touched */
.mm-busy .mm-panel, .mm-busy .mm-bar, .mm-busy .mm-opts, .mm-busy .mm-timeline, .mm-busy .mm-pick, .mm-busy .mm-cropbar { pointer-events: none; opacity: .55; }
.mm-busy .mm-canvas { cursor: progress; }
