
/* Owner (2026-11-15): the past-generation rail belongs to the right of the card,
   with a 10px gutter — never wrapped below it. The rail column exists only while
   the rail is visible, so a card without history keeps the single-column width.
   Owner (2026-11-16): the card's width is intrinsic, never a percentage of the
   max-content column that sizes it. `width: min(100%, …)` resolved against its own
   column, so a delivered picture card collapsed to its 2px border next to the rail
   (measured live: cols "2px 300px"). */
.wnx-media {
  display: grid; grid-template-columns: minmax(0, max-content) minmax(220px, 300px);
  align-items: start; gap: 10px; width: 100%; margin-top: 8px;
}
.wnx-media:not(:has(> .wnx-media__history:not([hidden]))) { grid-template-columns: minmax(0, max-content); }
.wnx-media, .wnx-media * { box-sizing: border-box; }
.wnx-media [hidden] { display: none !important; }

.wnx-media__card {
  --mg-ar: 1; --mg-w: 360px; --mg-frame-bg: #e9edf3;
  container-type: inline-size; container-name: mgcard;
  position: relative; width: var(--mg-w); max-width: 100%; min-width: 0;
  background: #fff; border: 1px solid rgba(148,163,184,.40); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column;
}
.wnx-media[data-kind="image"] .wnx-media__card { --mg-frame-bg: #e7ecf3; }
.wnx-media[data-kind="video"] .wnx-media__card { --mg-frame-bg: #0b1220; }

/* Owner (case 029, 2026-11-09): a delivered picture must stay readable but not
   dominate the answer. Owner (2026-11-11): the 80vh ceiling made a 1024x1024
   picture ~700px tall — half of the viewport — so the frame is now capped at
   40vh (half the former size in both dimensions) with a 280px floor so a narrow
   portrait card keeps its controls usable. A wide answer column still lets the
   picture grow up to that ceiling; the aspect term keeps 16:9 wide and 9:16
   tall instead of forcing one silhouette. */
.wnx-media[data-kind="image"] .wnx-media__card {
  /* Intrinsic, not `min(100%, …)`: a percentage here resolves against the
     max-content grid column that this same width defines, which collapsed a
     delivered card to its 2px border once the history rail was visible. */
  width: max(280px, calc(40vh * var(--mg-ar, 1)));
  width: max(280px, calc(40dvh * var(--mg-ar, 1)));
  /* Owner (2026-11-11): a small delivered file must not float inside a wide empty
     card — the card never grows past the picture's own width (--mg-natw comes
     from naturalWidth), with the same 280px floor for the controls. */
  max-width: min(100%, max(280px, var(--mg-natw, 100vw)));
}
.wnx-media__frame {
  position: relative; width: 100%; aspect-ratio: var(--mg-ar, 1);
  overflow: hidden; background: var(--mg-frame-bg);
}
.wnx-media__frame > img, .wnx-media__frame > video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.wnx-media__frame > img { object-fit: cover; }
.wnx-media__frame > video { object-fit: contain; background: #0b1220; }

/* Owner (case 029, 2026-11-11): the frame took the requested aspect (1:1), so a
   delivered portrait file (1280×1699) was painted into a square box with
   object-fit: cover — cropped top and bottom, its proportions lost. Once the
   delivered picture is in the frame, the frame follows the picture: the image
   sits in flow at its own ratio and nothing is cropped. The 40vh bound (half
   the former ceiling) keeps the card from eating the viewport, and the 240px
   floor upscales a small delivered file instead of leaving a thumbnail in a
   full-width row. A card without a picture yet (empty/pending) keeps the
   requested frame, and video keeps its own template. */
.wnx-media[data-kind="image"] .wnx-media__frame:has(> img:not([hidden])) {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  aspect-ratio: auto;
  background: transparent;
}
.wnx-media[data-kind="image"] .wnx-media__frame > img:not([hidden]) {
  position: static;
  display: block;
  width: auto;
  height: auto;
  min-width: 240px;
  max-width: 100%;
  max-height: 40vh;
  max-height: 40dvh;
  margin-inline: auto;
  object-fit: contain;
}
/* Fullscreen must not inherit the compact inline-card height ceiling. */
.wnx-media[data-kind="image"] .wnx-media__frame:fullscreen > img:not([hidden]) {
  min-width: 0;
  max-height: 96vh;
  max-height: 96dvh;
}
.wnx-media__empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  align-items: center; justify-content: center; color: #94a3b8; font-size: 11.5px;
  background: linear-gradient(135deg, #eef2f7, #e3e9f1);
}
.wnx-media[data-kind="video"] .wnx-media__empty { background: linear-gradient(135deg, #101a2e, #0b1220); color: #64748b; }
.wnx-media__empty svg { width: 34px; height: 34px; opacity: .55; }

/* Owner (2026-11-11): the hover affordances are two small icon buttons — download
   and fullscreen, both tucked into the top-right corner of the picture with download
   just left of fullscreen — and the picture itself is never dimmed: the layer is
   transparent and only the buttons catch the pointer. */
.wnx-media__overlay {
  position: absolute; inset: 0; z-index: 5;
  background: transparent; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .16s, visibility .16s;
}
.wnx-media__frame:hover .wnx-media__overlay,
.wnx-media__frame:focus-within .wnx-media__overlay { opacity: 1; visibility: visible; }
.wnx-media__overlay-actions {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
.wnx-media__overlay-btn {
  appearance: none; display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
  pointer-events: auto; cursor: pointer; color: #fff; text-decoration: none;
  background: rgba(15,23,42,.55); box-shadow: 0 2px 8px rgba(15,23,42,.28);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.wnx-media__overlay-btn svg { width: 14px; height: 14px; }
.wnx-media__overlay-btn:hover { background: rgba(15,23,42,.78); }
.wnx-media__overlay-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Touch screens have no hover: keep both affordances visible instead of hiding them. */
@media (hover: none) {
  .wnx-media__overlay { opacity: 1; visibility: visible; }
}

/* Owner (2026-11-11): «на весь экран» expands the picture inside the page — a fixed
   layer over the chat that fades in while the picture grows from 90% to full size —
   instead of switching the whole browser into fullscreen. */
.wnx-media__zoom {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 2.5vh 2.5vw;
  background: rgba(8, 13, 24, .82);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; cursor: zoom-out;
  transition: opacity .2s ease;
}
.wnx-media__zoom.is-open { opacity: 1; }
.wnx-media__zoom-stage {
  max-width: 100%; max-height: 100%;
  display: flex; align-items: center; justify-content: center;
  transform: scale(.9);
  transition: transform .24s cubic-bezier(.22, 1, .36, 1);
}
.wnx-media__zoom.is-open .wnx-media__zoom-stage { transform: scale(1); }
.wnx-media__zoom-stage img,
.wnx-media__zoom-stage video {
  max-width: 95vw; max-height: 95vh; width: auto; height: auto;
  border-radius: 12px; background: #0b1220;
  box-shadow: 0 26px 80px rgba(0, 0, 0, .55);
}
/* Give the percentage-width viewer a definite containing block in the zoom layer. */
.wnx-media__zoom-stage:has(> model-viewer) { width: min(95vw, 960px); }
.wnx-media__zoom-stage > model-viewer {
  min-width: 0;
  height: min(80vh, 720px) !important;
}
body.wnx-media__zoom-lock { overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .wnx-media__zoom, .wnx-media__zoom-stage { transition: none; }
  .wnx-media__zoom-stage { transform: none; }
}

.wnx-media__player {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: 7px; padding: 16px 9px 8px; color: #fff;
  background: linear-gradient(180deg, rgba(15,23,42,0) 0%, rgba(15,23,42,.66) 62%);
}
.wnx-media__player-btn {
  appearance: none; display: grid; place-items: center; flex: 0 0 auto;
  width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; cursor: pointer;
}
.wnx-media__player-btn svg { width: 11px; height: 11px; }
.wnx-media__player-btn:hover { background: rgba(255,255,255,.30); }
.wnx-media__player-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.wnx-media__seek { flex: 1 1 auto; min-width: 40px; height: 14px; margin: 0; accent-color: #fff; cursor: pointer; }
.wnx-media__time { flex: 0 0 auto; font: 600 10px/1 inherit; font-variant-numeric: tabular-nums; opacity: .88; }

.wnx-media__composer { min-width: 0; padding: 9px 10px 10px; border-bottom: 1px solid rgba(148,163,184,.22); }
.wnx-media__field {
  /* Owner (2026-11-22): one bordered box, text on top and the reference «+» strip along the
     bottom edge. The left-column variant squeezed the prompt into a narrow ribbon. */
  display: flex; flex-direction: column; gap: 7px; min-width: 0;
  padding: 8px 9px 7px; background: #fff;
  border: 1px solid rgba(148,163,184,.42); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.wnx-media__field:focus-within { border-color: rgba(31,95,208,.55); box-shadow: 0 0 0 3px rgba(31,95,208,.10); }
.wnx-media__prompt {
  display: block; width: 100%; min-height: 40px; max-height: 6lh; overflow-y: auto;
  resize: none; border: 0; background: transparent; color: #111827;
  padding: 0; font: 13px/1.45 inherit; font-family: inherit;
}
.wnx-media__prompt:focus { outline: none; }
.wnx-media__refs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.wnx-media__ref { position: relative; width: 36px; height: 36px; flex: 0 0 36px; }
.wnx-media__ref img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 7px; }
.wnx-media__ref-remove {
  position: absolute; right: -3px; top: -3px; display: grid; place-items: center;
  width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%;
  background: #fff; color: #475569; font: 12px/1 system-ui; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(148,163,184,.45);
}
.wnx-media__ref-add {
  display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px;
  padding: 0; background: #e8edf4; border: 0; border-radius: 7px; color: #64748b;
  font: 19px/1 system-ui; cursor: pointer;
}
.wnx-media__ref-add:hover { background: rgba(31,95,208,.10); color: #1f5fd0; }
.wnx-media__ref-add:disabled { opacity: .38; cursor: not-allowed; background: #eef2f7; color: #94a3b8; }
.wnx-media__ref-add:focus-visible { outline: 2px solid #1f5fd0; outline-offset: 2px; }

.wnx-media__chips { display: inline-flex; gap: 2px; padding: 2px; background: #eef2f7; border-radius: 8px; }
.wnx-media__chip {
  appearance: none; border: 0; background: transparent; color: #64748b;
  font: 600 10px/1 inherit; font-family: inherit; padding: 5px 6px; border-radius: 6px;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.wnx-media__chip.is-active { background: #fff; color: #0f172a; box-shadow: 0 1px 2px rgba(15,23,42,.10); }
.wnx-media__chip:focus-visible { outline: 2px solid #1f5fd0; outline-offset: 1px; }

.wnx-media__formats { display: inline-flex; align-items: center; gap: 2px; }
.wnx-media__format { position: relative; display: flex; align-items: center; justify-content: center; width: 26px; height: 28px; cursor: pointer; }
.wnx-media__format input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.wnx-media__format-box {
  display: block; width: 24px; height: 16px; border-radius: 3px;
  border: 1px solid rgba(100,116,139,.55); background: rgba(148,163,184,.20);
  transition: border-color .14s, background .14s;
}
.wnx-media__format-box[data-ar="1:1"] { width: 19px; height: 19px; }
.wnx-media__format-box[data-ar="9:16"] { width: 13px; height: 23px; }
.wnx-media__format-box[data-ar="16:9"] { width: 26px; height: 15px; }
.wnx-media__format input:checked + .wnx-media__format-box {
  border-color: #1f5fd0; background: rgba(31,95,208,.10); box-shadow: inset 0 0 0 1px #1f5fd0;
}
.wnx-media__format input:focus-visible + .wnx-media__format-box { outline: 2px solid #1f5fd0; outline-offset: 2px; }
.wnx-media__format-tip {
  position: absolute; z-index: 5; right: 0; bottom: calc(100% + 5px);
  padding: 3px 7px; border-radius: 6px; background: #0f172a; color: #fff;
  font-size: 10px; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .12s;
}
.wnx-media__format:hover .wnx-media__format-tip,
.wnx-media__format:focus-within .wnx-media__format-tip { opacity: 1; visibility: visible; }

.wnx-media__cost { position: relative; }
.wnx-media__cost summary { list-style: none; pointer-events: none; }
.wnx-media__cost summary::-webkit-details-marker { display: none; }
.wnx-media__cost.is-admin summary { pointer-events: auto; cursor: pointer; }
.wnx-media__cost [data-cost-breakdown] { white-space: pre-line; max-height: 300px; overflow-y: auto; position: absolute; z-index: 5; right: 0; bottom: 100%; width: 240px; padding: 10px; background: #fff; color: #475569; box-shadow: 0 4px 20px #0002; border-radius: 8px; font-size: 11px; }
html.dark .wnx-media__cost [data-cost-breakdown] { background: #1f2937; color: #e5e7eb; }
.wnx-media__pro {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  padding: 4px 3px; border: 0; border-radius: 3px; background: transparent; color: #64748b;
  font-family: inherit; font-size: 12px; font-weight: 750; line-height: 1; letter-spacing: -.035em; cursor: pointer;
  transition: color .16s, transform .16s;
}
.wnx-media__pro:hover { color: #334155; transform: translateY(-1px); }
.wnx-media__pro.is-on { color: #1f5fd0; text-shadow: 0 0 12px #1f5fd055; }
.wnx-media__pro:focus-visible { outline: 2px solid #1f5fd0; outline-offset: 2px; }
.wnx-media__pro:disabled { cursor: not-allowed; opacity: .55; }
.wnx-media[data-kind="image"] .wnx-media__pro {
  padding: 5px 7px; border-radius: 6px; background: #eef2f7; color: #475569;
  transition: background .16s, color .16s, transform .16s;
}
.wnx-media[data-kind="image"] .wnx-media__pro:not(.is-on):hover { background: #e2e8f0; color: #334155; }
.wnx-media[data-kind="image"] .wnx-media__pro.is-on { background: #1f5fd0; color: #fff; text-shadow: none; }
.wnx-media[data-kind="image"] .wnx-media__pro.is-on:hover { background: #194eac; color: #fff; }
.wnx-media[data-kind="video"] .wnx-media__pro { padding: 5px 7px; background: #eef2f7; border-radius: 8px; font-size: 10px; font-weight: 600; }
.wnx-media[data-kind="video"] .wnx-media__pro.is-on { background: #1f5fd0; color: #fff; }
html.dark .wnx-media[data-kind="video"] .wnx-media__pro:not(.is-on) { background: #1f2937; }

.wnx-media__bottom {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-width: 0; padding: 10px 12px 12px;
}
.wnx-media__settings { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 6px; min-width: 0; }
.wnx-media__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.wnx-media__duration { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 0 1 auto; }
.wnx-media__duration input[type=range] { flex: 0 1 52px; width: 52px; min-width: 30px; max-width: 74px; margin: 0; accent-color: #1f5fd0; }
.wnx-media__duration-value { font: 650 11px/1 inherit; color: #0f172a; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.wnx-media__price { font-size: 16px; font-weight: 650; color: #0f172a; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wnx-media__generate {
  appearance: none; border: 0; border-radius: 9px; background: #1f5fd0; color: #fff;
  font: 600 12px/1 inherit; font-family: inherit; padding: 10px 12px; cursor: pointer;
  white-space: nowrap; transition: filter .15s, opacity .15s;
}
.wnx-media__generate:hover { filter: brightness(1.07); }
.wnx-media__generate:disabled { opacity: .6; cursor: default; filter: none; }
.wnx-media__generate:focus-visible { outline: 2px solid #1f5fd0; outline-offset: 2px; }
.wnx-media__status { padding: 0 13px 12px; font-size: 11.5px; color: #64748b; }
.wnx-media__status.is-error { color: #b42318; }

.wnx-media__history {
  min-width: 0; align-self: start; max-height: 460px; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid rgba(148,163,184,.40); border-radius: 14px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.wnx-media__history-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.wnx-media__history-item {
  position: relative; appearance: none; display: flex; align-items: center; gap: 8px;
  width: 100%; border: 1px solid rgba(148,163,184,.30);
  background: #fff; border-radius: 10px; padding: 6px; overflow: hidden;
  cursor: pointer; text-align: left; font-family: inherit; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.wnx-media__history-item:hover { border-color: rgba(31,95,208,.55); box-shadow: 0 2px 8px rgba(15,23,42,.08); transform: translateX(-1px); }
.wnx-media__history-item:focus-visible { outline: 2px solid #1f5fd0; outline-offset: 2px; }
.wnx-media__history-thumb {
  position: relative; display: block; flex: 0 0 56px; width: 56px; aspect-ratio: 1/1;
  overflow: hidden; border-radius: 8px; background: #e9edf3;
}
.wnx-media__history-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.wnx-media__history-thumb.is-video { display: grid; place-items: center; background: linear-gradient(135deg, #101a2e, #0b1220); color: #94a3b8; font-size: 18px; }
.wnx-media__history-meta { display: block; flex: 1 1 auto; min-width: 0; padding: 0; }
.wnx-media__history-prompt {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere; font-size: 10.5px; line-height: 1.3; color: #334155; min-height: 27px;
}
.wnx-media__history-price { display: block; margin-top: 3px; font-size: 10px; color: #64748b; font-variant-numeric: tabular-nums; }
.wnx-media__history-empty { margin: 8px 4px; font-size: 11px; color: #64748b; }
.wnx-media__history-btn {
  appearance: none; width: 100%; border: 1px solid rgba(148,163,184,.40); background: #fff;
  color: #334155; font: 600 11.5px/1 inherit; font-family: inherit;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.wnx-media__history-btn:hover { border-color: #1f5fd0; color: #1f5fd0; }

@media (max-width: 1000px) {
  .wnx-media,
  .wnx-media:not(:has(> .wnx-media__history:not([hidden]))) { grid-template-columns: minmax(0, 1fr); }
  .wnx-media__card { width: 100%; max-width: 100%; }
  .wnx-media__history { max-width: none; width: 100%; max-height: 320px; }
}

/* Owner (2026-11-18): the parameter row and the price/CTA must sit on one line —
   on the default card as well. Everything below is the compact tier for cards that
   are narrower than the widest video card; only a phone-width portrait card
   (~300px) still needs a second row. */
@container mgcard (max-width: 480px) {
  .wnx-media__bottom { gap: 5px; padding: 9px 10px 11px; }
  .wnx-media__settings { gap: 4px 5px; }
  .wnx-media__pro { padding: 4px 5px; font-size: 9.5px; }
  .wnx-media__pro svg { width: 10px; height: 10px; }
  .wnx-media__formats { gap: 1px; }
  .wnx-media__format { width: 21px; height: 26px; }
  .wnx-media__chips { gap: 1px; padding: 2px; }
  .wnx-media__chip { padding: 3px 3px; font-size: 9.5px; }
  .wnx-media__duration { gap: 3px; }
  .wnx-media__duration input[type=range] { flex: 0 1 36px; width: 36px; min-width: 22px; max-width: 56px; }
  .wnx-media__duration-value { font-size: 10px; }
  .wnx-media__price { font-size: 14px; }
  .wnx-media__actions { gap: 6px; }
  .wnx-media__generate { font-size: 11.5px; padding: 8px 9px; }
}

/* Owner (case ICHAT-T400-438, 2026-11-12): the generation card sat on the chat
   surface as an opaque #fff slab, so in the dark theme it read as a white hole
   punched in the page. The card now follows the theme like every other surface:
   a gray-900 panel (#111827) on the gray-800 page, white/10 borders, light text
   and gray-800 control plates. Only surfaces and text change here — the picture
   keeps its own pixels and the delivered-picture frame stays transparent, so a
   transparent or white image is composited exactly as its bytes define it. */
html.dark .wnx-media__card {
  background: #111827;
  border-color: rgba(255, 255, 255, .10);
}
html.dark .wnx-media[data-kind="image"] .wnx-media__card { --mg-frame-bg: #1f2937; }
html.dark .wnx-media[data-kind="video"] .wnx-media__card { --mg-frame-bg: #0b1220; }
html.dark .wnx-media__empty {
  background: linear-gradient(135deg, #1e293b, #111827);
  color: #94a3b8;
}
html.dark .wnx-media__composer { border-bottom-color: rgba(255, 255, 255, .08); }
html.dark .wnx-media__field {
  background: #1f2937;
  border-color: rgba(255, 255, 255, .12);
}
html.dark .wnx-media__field:focus-within {
  border-color: rgba(96, 165, 250, .65);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, .18);
}
html.dark .wnx-media__prompt { color: #f3f4f6; }
html.dark .wnx-media__ref-remove {
  background: #334155; color: #e5e7eb;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
}
html.dark .wnx-media__ref-add { background: #334155; color: #cbd5e1; }
html.dark .wnx-media__ref-add:hover { background: rgba(96, 165, 250, .18); color: #93c5fd; }
html.dark .wnx-media__ref-add:disabled { background: #1f2937; color: #64748b; }
html.dark .wnx-media__chips { background: #1f2937; }
html.dark .wnx-media__chip { color: #94a3b8; }
html.dark .wnx-media__chip.is-active {
  background: #334155; color: #f3f4f6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .40);
}
html.dark .wnx-media__pro:not(.is-on) { background: transparent; color: #94a3b8; }
html.dark .wnx-media__pro:not(.is-on):hover { background: transparent; color: #e5e7eb; }
html.dark .wnx-media[data-kind="image"] .wnx-media__pro:not(.is-on) { background: #334155; color: #cbd5e1; }
html.dark .wnx-media[data-kind="image"] .wnx-media__pro:not(.is-on):hover { background: #475569; color: #f8fafc; }
html.dark .wnx-media[data-kind="image"] .wnx-media__pro.is-on { background: #60a5fa; color: #0f172a; }
html.dark .wnx-media[data-kind="image"] .wnx-media__pro.is-on:hover { background: #93c5fd; color: #0f172a; }
html.dark .wnx-media__duration-value,
html.dark .wnx-media__price { color: #f3f4f6; }
html.dark .wnx-media__status { color: #94a3b8; }
html.dark .wnx-media__status.is-error { color: #fca5a5; }
html.dark .wnx-media__history {
  background: #111827;
  border-color: rgba(255, 255, 255, .10);
}
html.dark .wnx-media__history-item { background: #111827; border-color: rgba(255, 255, 255, .10); }
html.dark .wnx-media__history-item:hover { border-color: rgba(96, 165, 250, .55); box-shadow: 0 2px 8px rgba(0, 0, 0, .38); }
html.dark .wnx-media__history-thumb:not(.is-video) { background: #1f2937; }
html.dark .wnx-media__history-prompt { color: #cbd5e1; }
html.dark .wnx-media__history-price,
html.dark .wnx-media__history-empty { color: #94a3b8; }
html.dark .wnx-media__history-btn {
  background: #1f2937; color: #cbd5e1;
  border-color: rgba(255, 255, 255, .12);
}
html.dark .wnx-media__history-btn:hover { border-color: #60a5fa; color: #93c5fd; }

/* ── Live generation stage (owner, 2026-11-18) ────────────────────────────────
   The wait is deliberately bare: one thin ring with the seconds that are left
   inside it, sitting on top of whatever the card already looks like. No phase
   sentence («Рисую изображение…»), no typed prompt, no references, no full-bleed
   backdrop — the frame keeps its own background and the loader just rides on it.
   One component serves the composer card, the inline ```generate-image```
   placeholder and the regeneration cards. */
.wnx-stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; min-height: 140px; overflow: hidden;
  color: #475569; text-align: center; isolation: isolate;
  background: transparent;
  transition: opacity .3s ease;
}
.wnx-media__frame > .wnx-stage,
.wnx-stage--overlay { position: absolute; inset: 0; z-index: 4; min-height: 0; }
.wnx-stage.is-leaving { opacity: 0; pointer-events: none; }

/* The chat card exists before the picture does (owner, 2026-11-17): the frame is the
   finished card's own, the stage fills it, and the result lands exactly where the wait
   was. The host owns the height because the stage itself is an overlay here. */
/* Pending frames have no intrinsic image width. Override shrink-wrapped result
   cards with an intrinsic size; percentages alone collapse during shrink-to-fit. */
.message-bubble--assistant .aichat-media-card.aichat-media-card--pending,
.aichat-media-card--pending { width: 24rem; max-width: 100%; box-sizing: border-box; }
.aichat-media-card--pending .media-image-stage { min-height: 190px; }

.wnx-stage__ring { position: relative; display: grid; place-items: center; width: 56px; height: 56px; }
.wnx-stage__ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.wnx-stage__ring-track { stroke: rgba(15, 23, 42, .12); }
.wnx-stage__ring-arc { stroke: #1f5fd0; transition: stroke-dashoffset .45s linear; }
.wnx-stage__left {
  font: 600 12px/1 inherit; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em; color: #475569; white-space: nowrap;
}
/* The video and 3D frames are dark in both themes, so their ring flips to light. */
.wnx-media[data-kind="video"] .wnx-stage,
.wnx-media[data-kind="three_d"] .wnx-stage,
.wnx-media[data-kind="3d"] .wnx-stage,
html.dark .wnx-stage { color: #cbd5e1; }
.wnx-media[data-kind="video"] .wnx-stage__ring-track,
.wnx-media[data-kind="three_d"] .wnx-stage__ring-track,
.wnx-media[data-kind="3d"] .wnx-stage__ring-track,
html.dark .wnx-stage__ring-track { stroke: rgba(255, 255, 255, .18); }
.wnx-media[data-kind="video"] .wnx-stage__ring-arc,
.wnx-media[data-kind="three_d"] .wnx-stage__ring-arc,
.wnx-media[data-kind="3d"] .wnx-stage__ring-arc,
html.dark .wnx-stage__ring-arc { stroke: #7dd3fc; }
.wnx-media[data-kind="video"] .wnx-stage__left,
.wnx-media[data-kind="three_d"] .wnx-stage__left,
.wnx-media[data-kind="3d"] .wnx-stage__left,
html.dark .wnx-stage__left { color: #e2e8f5; }
/* While the wait runs the frame's own placeholder art steps aside (its label and
   picture would read as a second message); the frame background stays. */
.wnx-media__frame:has(> .wnx-stage:not([hidden])) .wnx-media__empty > * { visibility: hidden; }

/* The inline ```generate-image``` placeholder wears the same card shape as the
   delivered result instead of a bare spinner: a framed stage and nothing else. */
.wnx-inline-gen {
  width: min(100%, 420px); max-width: 100%; overflow: hidden; border-radius: 16px;
  border: 1px solid rgba(148,163,184,.40); background: #fff;
}
.wnx-inline-gen__frame { position: relative; width: 100%; aspect-ratio: 1/1; max-height: 40dvh; }
html.dark .wnx-inline-gen { background: #111827; border-color: rgba(255,255,255,.10); }

/* The delivered picture arrives with a short settle instead of appearing mid-layout. */
@keyframes wnxMediaReveal {
  from { opacity: 0; transform: scale(.985); }
  to { opacity: 1; transform: none; }
}
.wnx-media__frame > img:not([hidden]),
.wnx-media__frame > video:not([hidden]),
.aichat-media-card .media-image-stage img { animation: wnxMediaReveal .48s cubic-bezier(.22, 1, .36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .wnx-stage,
  .wnx-stage__ring-arc { transition: none; }
  .wnx-media__frame > img:not([hidden]),
  .wnx-media__frame > video:not([hidden]),
  .aichat-media-card .media-image-stage img { animation: none; }
}
