/* The Image tool (js/image.js): the pop-up over Home, the words (and the picture to change), the image, the Gallery,
   and the sheet that picks a picture from the Gallery. The theme's own tokens (light, dark, wine). */

/* ---------- the pop-up over Home ---------- */

/* Home stays in sight behind it, softly blurred; a tap anywhere outside the card closes it. */
.ip-scrim {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgb(8 6 10 / 38%); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: ip-fade 0.22s ease both;
}
.ip-scrim[hidden] { display: none; }
.ip-scrim.closing { animation: ip-fade 0.18s ease reverse both; }
.ip-card {
  width: 100%; max-width: 380px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgb(0 0 0 / 35%); padding: 22px 16px 16px; text-align: center; color: var(--ink);
  animation: ip-pop 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.12) both;
}
.ip-scrim.closing .ip-card { animation: ip-pop 0.18s ease reverse both; }
.ip-when { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }
.ip-ask { font: 600 1.6rem/1.15 var(--serif); margin: 0.45rem 0 1.15rem; }
.ip-rows { display: grid; gap: 8px; }
.ip-row {
  display: flex; align-items: center; gap: 13px; width: 100%; padding: 10px 12px 10px 10px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); text-align: left; transition: transform 0.12s ease, border-color 0.15s;
}
.ip-row:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.ip-row:active { transform: scale(0.98); }
.ip-row .tile { width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; flex: none; color: var(--ink); }
.ip-row .tile svg { width: 34px; height: 34px; overflow: visible; }
.ip-row b { font: 600 1.25rem/1.1 var(--serif); }
.ip-row .chev { margin-left: auto; width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.ip-card .acc, .imagine .acc { fill: var(--accent); }
@keyframes ip-fade { from { opacity: 0; } }
@keyframes ip-pop { from { opacity: 0; transform: translateY(10px) scale(0.94); } }

/* ---------- the screen ---------- */

.imagine { min-height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.im-bar {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; max-width: 760px; margin: 0 auto;
  padding: calc(0.8rem + var(--inset-top)) 16px 0.4rem;
}
.im-title { flex: 1; margin: 0; text-align: center; font: 600 1.6rem/1.1 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-gap { width: 40px; flex: none; }
.im-body { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 0.6rem 16px 1rem; }

/* ---------- the words, and the picture to change ---------- */

.im-compose { display: flex; flex-direction: column; gap: 12px; animation: im-in 0.3s ease both; }
.im-from { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.im-from button[hidden] { display: none; }
.im-from button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; aspect-ratio: 1 / 0.82;
  border-radius: 22px; border: 1.5px dashed var(--line); background: var(--surface); color: var(--ink); font: 600 1.15rem/1.1 var(--serif);
  transition: border-color 0.15s, transform 0.12s;
}
.im-from button:hover { border-color: var(--accent); }
.im-from button:active { transform: scale(0.97); }
.im-from .ic { width: 52px; height: 52px; border-radius: 16px; background: var(--accent-soft); display: grid; place-items: center; }
.im-from svg { width: 30px; height: 30px; overflow: visible; }
/* three choices (with the camera): narrower tiles, the words may take two lines */
.im-from:has(> #im-camera:not([hidden])) button { aspect-ratio: auto; min-height: 8.6rem; padding: 12px 6px; font-size: 1.05rem; text-align: center; }
.im-photo { position: relative; display: grid; place-items: center; border-radius: 20px; overflow: hidden; background: var(--surface-2); }
.im-photo img { display: block; max-width: 100%; max-height: 42vh; object-fit: contain; }
.im-swap {
  position: absolute; right: 10px; bottom: 10px; border: 0; border-radius: 999px; padding: 0.45rem 0.9rem;
  font-weight: 600; font-size: 0.85rem; color: #fff; background: rgb(0 0 0 / 55%); backdrop-filter: blur(8px);
}
.im-error { color: var(--danger); font-size: 0.88rem; margin: 0.2rem 2px 0; }
.im-error:empty { display: none; }
#im-prompt {
  width: 100%; min-height: 9rem; resize: none; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  color: var(--ink); padding: 1rem 1.05rem; font: inherit; font-size: 1.05rem; line-height: 1.5; outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
#im-prompt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#im-prompt::placeholder { color: var(--ink-3); }

/* the engine and Generate, at the bottom while the words are written */
.im-foot {
  position: sticky; bottom: 0; width: 100%; max-width: 760px; margin: 0 auto; display: grid; gap: 10px;
  padding: 10px 16px calc(14px + var(--inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.im-engine { margin: 0; }
.im-engine[hidden] { display: none; }
.im-go { padding: 0.95rem 1.3rem; font-size: 1.02rem; }
.im-go-row { display: flex; gap: 10px; }
.im-go-row .im-go { flex: 1; }
.im-erase { padding: 0.95rem 1.4rem; font-size: 1.02rem; }
.im-erase[hidden] { display: none; }

/* ---------- the image ---------- */

.im-result { display: flex; flex-direction: column; align-items: center; animation: im-in 0.3s ease both; }
.im-frame {
  position: relative; width: 100%; max-width: 560px; aspect-ratio: var(--ratio, 1); max-height: 62vh; border-radius: 22px;
  overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow);
}
.im-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* the image zooms: the frame clips, im-out-zoom moves (js/image.js zoomable) */
.im-frame { touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.im-frame.zoomed { touch-action: none; cursor: grab; }
.im-out-zoom { position: absolute; inset: 0; transform-origin: 0 0; }
/* under an edit: Edit more, Discard (thin, under the image) */
.im-minor { display: flex; justify-content: center; gap: 8px; margin-top: 0.8rem; }
.im-minor:empty { display: none; }
.im-minor .btn { padding: 0.3rem 0.8rem; font-size: 0.8rem; gap: 0.35rem; }
.im-minor .btn svg { width: 14px; height: 14px; }
.im-under { filter: blur(14px) saturate(0.8); opacity: 0.55; transform: scale(1.08); }
.im-under:not([src]), .im-out:not([src]) { display: none; }
.im-out { opacity: 0; transform: scale(1.015); transition: opacity 0.6s ease, transform 0.8s ease; }
.im-out.shown { opacity: 1; transform: none; }
.im-wait { position: absolute; inset: 0; }
.im-wait[hidden] { display: none; }
.im-shine {
  display: block; width: 100%; height: 100%;
  background: linear-gradient(110deg, transparent 30%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 70%);
  background-size: 250% 100%; background-repeat: no-repeat; animation: im-shine 2.2s ease-in-out infinite;
}
/* one band, not tiled: it starts and ends fully outside the box, so the loop never jumps in view (Faris 2026-10-21:
   "it moves smoothly, then cuts and repeats": the tiled copy was in view when it jumped back) */
@keyframes im-shine { from { background-position: 130% 0; } to { background-position: -30% 0; } }
.im-state { margin: 1rem 0 0; color: var(--ink-2); font-weight: 600; text-align: center; }
.im-state:empty { display: none; }
.im-state.bad { color: var(--danger); }
.im-said {
  margin: 0.6rem 0 0; max-width: 560px; color: var(--ink-3); text-align: center; font-size: 0.92rem; line-height: 1.45;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
/* one row: Save, Share, Edit this */
.im-acts { display: flex; flex-wrap: nowrap; justify-content: center; gap: 8px; margin-top: 1.2rem; max-width: 100%; }
.im-acts .btn { padding: 0.62rem 1rem; white-space: nowrap; min-width: 0; }
.im-acts .btn svg { width: 17px; height: 17px; }

/* ---------- the Gallery: the newest image big, then a row for each day ---------- */

.im-gallery { animation: im-in 0.3s ease both; padding-bottom: calc(1rem + var(--inset-bottom)); }
.im-hero { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2); }
.im-hero img { display: block; width: 100%; aspect-ratio: 4 / 4.2; object-fit: cover; }
.im-hero .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 44px 16px 14px; text-align: left; color: #fff;
  background: linear-gradient(to top, rgb(0 0 0 / 66%), transparent); font: 600 1.15rem/1.25 var(--serif);
}
.im-hero .cap span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.im-hero .cap small { display: block; font: 500 0.78rem var(--sans); opacity: 0.8; margin-top: 3px; }
.im-day { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); margin: 20px 2px 10px; }
.im-row {
  display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; scroll-snap-type: x proximity; scrollbar-width: none;
}
.im-row::-webkit-scrollbar { display: none; }
.im-tile {
  position: relative; flex: none; height: 150px; aspect-ratio: var(--ratio, 1); border: 0; padding: 0; border-radius: 16px; overflow: hidden;
  background: var(--surface-2); box-shadow: var(--shadow); scroll-snap-align: start; transition: transform 0.12s ease;
}
.im-tile:active { transform: scale(0.96); }
.im-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.im-tile .im-shine { position: absolute; inset: 0; }
.im-tile.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.im-none { text-align: center; color: var(--ink-3); padding: 18vh 0 2rem; }

/* ---------- From Ignis: the sheet ---------- */

.im-sheet-scrim { position: fixed; inset: 0; z-index: 30; background: rgb(8 6 10 / 45%); animation: ip-fade 0.2s ease both; }
.im-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 82vh; display: flex; flex-direction: column;
  border-radius: 26px 26px 0 0; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -16px 50px rgb(0 0 0 / 35%);
  padding: 10px 16px 0; animation: im-up 0.32s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.im-sheet-scrim[hidden], .im-sheet[hidden] { display: none; }
.im-sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; flex: none; }
.im-sheet h2 { margin: 0 0 12px; text-align: center; font: 600 1.4rem/1.2 var(--serif); }
.im-sheet-body { overflow-y: auto; margin: 0 -16px; padding: 0 16px calc(16px + var(--inset-bottom)); }
.im-sheet-body .im-day:first-child { margin-top: 4px; }
@keyframes im-up { from { transform: translateY(100%); } }

@keyframes im-in { from { opacity: 0; transform: translateY(8px); } }
/* a tile grows into its image (view transitions); the rest crossfades */
::view-transition-group(*) { animation-duration: 0.42s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.26s; }
::view-transition-old(im-card), ::view-transition-new(im-card) { height: 100%; object-fit: cover; }
@media (prefers-reduced-motion: reduce) {
  .ip-scrim, .ip-card, .im-sheet, .im-sheet-scrim, .im-compose, .im-result, .im-gallery { animation: none; }
  .im-shine { animation: none; opacity: 0.6; }
  .im-out { transition: none; }
}

/* Arabic, right to left: arrows point the other way, and what sits on one side moves to the other. */
[dir='rtl'] #im-back svg, [dir='rtl'] .ip-row .chev { transform: scaleX(-1); }
[dir='rtl'] .ip-row, [dir='rtl'] .im-hero .cap { text-align: right; }
[dir='rtl'] .im-swap { right: auto; left: 10px; }

/* ---------- the small menu (Save's two choices; holding an image: Edit this, Delete), the note, leaving ---------- */

.im-menu-scrim { position: fixed; inset: 0; z-index: 44; }
.im-menu {
  position: fixed; z-index: 45; min-width: 210px; padding: 6px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 18px 44px rgb(0 0 0 / 30%); animation: ip-pop 0.18s cubic-bezier(0.2, 0.9, 0.25, 1.1) both;
}
.im-mi {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 12px;
  background: none; color: var(--ink); font-weight: 600; font-size: 0.98rem; text-align: start;
}
.im-mi:hover { background: var(--surface-2); }
.im-mi svg { width: 20px; height: 20px; flex: none; color: var(--accent); overflow: visible; }
.im-mi:disabled { color: var(--ink-3); background: none; }
.im-mi:disabled svg { color: var(--ink-3); }
.im-mi.danger, .im-mi.danger svg { color: var(--danger); }
.im-toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--inset-bottom)); transform: translateX(-50%); z-index: 46;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-radius: 999px; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.9rem; box-shadow: 0 10px 30px rgb(0 0 0 / 30%);
  animation: im-in 0.22s ease both;
}
.im-toast[hidden] { display: none; }
.im-toast button { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 6px; }
.im-leave-acts { display: grid; gap: 8px; }
.im-leave-acts .btn { width: 100%; }

/* ---------- markers on the picture to change, zoom, and the small card next to a marker ---------- */

/* im-pins is the picture's own box (it clips); im-zoom inside it holds the picture and its markers and is what a pinch
   scales and a drag moves, so a marker's place (in % of the picture) stays put at any zoom. Markers keep their size. */
.im-pins { position: relative; display: block; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.im-pins.zoomed { touch-action: none; cursor: grab; }
.im-zoom { position: relative; transform-origin: 0 0; --z: 1; }
.im-zoom img { pointer-events: none; }
.im-pin {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; padding: 0; display: grid; place-items: center;
  border-radius: 50%; border: 2px solid #fff; background: #e0352b; color: #fff; font: 700 0.72rem/1 var(--sans);
  box-shadow: 0 2px 8px rgb(0 0 0 / 45%); cursor: pointer; scale: calc(1 / var(--z));
  animation: pin-in 0.26s cubic-bezier(0.2, 0.9, 0.25, 1.35) both;
}
.im-pin.open { box-shadow: 0 0 0 3px rgb(255 255 255 / 45%), 0 2px 8px rgb(0 0 0 / 45%); }
/* a marker not said Yes to yet: a small dot with a ring that breathes */
.im-pin.new { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.im-pin.new::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid #fff; animation: pin-ring 1.3s ease-out infinite; }
@keyframes pin-in { from { transform: scale(0.2); opacity: 0; } }
@keyframes pin-ring { from { transform: scale(0.5); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }

/* the card: slim, so it hides little of the picture */
.im-pin-scrim { position: fixed; inset: 0; z-index: 44; }
.im-pin-scrim[hidden], .im-pin-pop[hidden], .im-pin-ask[hidden], .im-pin-say[hidden], .im-pin-del[hidden] { display: none; }
.im-pin-pop {
  position: fixed; z-index: 45; left: 0; top: 0; max-width: calc(100vw - 24px); padding: 5px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgb(0 0 0 / 30%); color: var(--ink);
  animation: ip-pop 0.18s cubic-bezier(0.2, 0.9, 0.25, 1.1) both;
}
.im-pin-pop[data-side='above'] { transform-origin: 50% 100%; }
.im-pin-pop[data-side='below'] { transform-origin: 50% 0; }
.im-pin-pop .btn { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.im-pin-ask { display: flex; align-items: center; gap: 6px; padding-inline-start: 8px; }
.im-pin-ask b { font: 600 0.92rem/1.2 var(--serif); white-space: nowrap; margin-inline-end: 4px; }
.im-pin-acts { display: flex; gap: 5px; }
.im-pin-say { width: min(250px, calc(100vw - 36px)); }
.im-pin-head { display: flex; align-items: center; gap: 4px; margin: 1px 1px 5px 5px; }
.im-pin-head label { flex: 1; font: 600 0.82rem/1.2 var(--serif); }
.im-pin-del { flex: none; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--danger); }
.im-pin-del svg { width: 16px; height: 16px; }
.im-pin-row { display: flex; align-items: flex-end; gap: 5px; }
#im-pin-text {
  flex: 1; min-width: 0; resize: none; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
  padding: 0.32rem 0.5rem; font: inherit; font-size: 0.88rem; line-height: 1.35; outline: none; max-height: 7.5em;
}
#im-pin-text:focus { border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .im-pin, .im-pin-pop { animation: none; }
  .im-pin.new::after { animation: none; opacity: 0.6; }
}

/* ---------- the toolbox under the picture to change: Markers, Select ---------- */

.im-tools { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 12px 0 2px; }
.im-tools[hidden] { display: none; }
.im-tool-set { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.im-tool-set button {
  display: grid; place-items: center; width: 44px; height: 38px; border: 0; border-radius: 999px; background: none; color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.im-tool-set button[aria-checked='true'] { background: var(--accent); color: var(--accent-ink); }
.im-tool-set svg, .im-tool-mini svg { width: 21px; height: 21px; }
.im-tool-mini {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
}
.im-tool-mini[hidden] { display: none; }
.im-tool-mini:disabled { opacity: 0.4; }
.im-tool-mini[aria-checked='true'] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
.im-tool-state { margin: 4px 0 0; min-height: 1.1em; text-align: center; color: var(--ink-3); font-size: 0.8rem; }
.im-tool-state:empty { min-height: 0; margin: 0; }
/* the selection drawn over the picture (it zooms with it) */
.im-sel { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* the wand draws with one finger: the page does not scroll under it */
.im-pins.drawing { touch-action: none; cursor: crosshair; }

/* the picture is busy (the select tool getting ready, reading the picture, looking): a band of blue light sweeps over
   it, its edge glows, the picture dims a little; the words and the download bar sit on it */
.im-busy { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; z-index: 2; }
.im-busy[hidden] { display: none; }
.im-busy::before {
  content: ''; position: absolute; top: -50%; bottom: -50%; left: -60%; width: 60%; will-change: transform;
  background: linear-gradient(100deg, transparent, rgb(110 170 255 / 0%) 20%, rgb(120 180 255 / 65%) 50%, rgb(110 170 255 / 0%) 80%, transparent);
  mix-blend-mode: screen; animation: im-sweep 1.5s cubic-bezier(0.45, 0, 0.35, 1) infinite;
}
.im-busy::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgb(120 175 255 / 75%), inset 0 0 46px rgb(80 145 255 / 40%); animation: im-glow 1.5s ease-in-out infinite;
}
/* moved by transform only, so it keeps moving while the page is busy reading the picture */
@keyframes im-sweep { from { transform: translateX(0) skewX(-12deg); } to { transform: translateX(290%) skewX(-12deg); } }
@keyframes im-glow { 50% { opacity: 0.45; } }
.im-photo.busy img, .im-frame.busy .im-out { filter: saturate(0.7) brightness(0.9); transition: filter 0.3s; }
.im-busy-text {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 1; max-width: calc(100% - 24px);
  padding: 6px 13px; border-radius: 999px; background: rgb(12 22 44 / 70%); color: #fff; font-size: 0.8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.im-busy-text:empty { display: none; }
.im-busy-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: rgb(120 180 255); box-shadow: 0 0 10px rgb(120 180 255); transition: width 0.25s; z-index: 1; }
/* the call's AI is the one working (it looks at the picture, or its hands select): the call's green, as its ring
   (Faris: green for her, blue for the app's own work) */
.im-busy.ai::before { background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--live) 0%, transparent) 20%, color-mix(in srgb, var(--live) 65%, transparent) 50%, color-mix(in srgb, var(--live) 0%, transparent) 80%, transparent); }
.im-busy.ai::after { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--live) 75%, transparent), inset 0 0 46px color-mix(in srgb, var(--live) 40%, transparent); }
.im-busy.ai .im-busy-bar { background: var(--live); box-shadow: 0 0 10px var(--live); }
.im-busy.ai .im-busy-text { background: color-mix(in srgb, var(--live) 30%, rgb(10 30 18 / 75%)); }
@media (prefers-reduced-motion: reduce) {
  .im-busy::before { animation-duration: 3s; }
  .im-busy::after { animation: none; }
}

/* ---------- a laptop (a wide screen): the picture big on the left, the words and Generate on the right ---------- */

@media (min-width: 1000px) {
  .imagine:not([hidden]) {
    display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto 1fr;
    width: 100%; max-width: 1500px; margin: 0 auto;
  }
  .im-bar { grid-column: 1 / -1; max-width: none; padding-inline: 28px; }
  .im-body { grid-column: 1 / -1; grid-row: 2; max-width: none; padding: 0.6rem 28px 1.5rem; }
  /* Generate and the engine sit at the bottom of the right column, over the empty space under the words */
  .im-foot {
    grid-column: 2; grid-row: 2; align-self: end; position: sticky; bottom: 0; z-index: 3; max-width: none;
    padding: 0 28px 24px; background: none;
  }
  .im-compose { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 0 28px; align-items: start; }
  .im-compose > .im-source { grid-column: 1; }
  .im-compose > #im-prompt { grid-column: 2; grid-row: 1; min-height: 16rem; }
  /* a new image has no picture: the words take the left side */
  .im-compose:has(> .im-source[hidden]) > #im-prompt { grid-column: 1; min-height: 55vh; }
  /* Edit image before a picture: the choices alone, across */
  .im-compose:has(> #im-prompt[hidden]) > .im-source { grid-column: 1 / -1; justify-self: center; width: min(100%, 640px); margin-top: 8vh; }
  .im-photo img { max-height: calc(100vh - 200px); }
  .im-from button { aspect-ratio: 1 / 0.6; }
  /* the image: as tall as the screen allows */
  .im-frame { width: auto; max-width: 100%; height: min(calc(100vh - 270px), 1100px); max-height: none; }
  .im-said { max-width: 900px; }
  .im-gallery { max-width: 900px; margin: 0 auto; }
}
