/* Playground image composer */
.pg-body {
  /* Feed + composer share the same content width so columns line up. */
  --pg-content-max: min(1080px, calc(100vw - 2.5rem));
  --pg-gutter: 1.25rem;
  min-height: 100vh;
  min-height: 100dvh;
  background: #000;
  overflow-x: hidden;
  max-width: 100vw;
  /* avoid iOS bounce revealing white edges */
  overscroll-behavior-x: none;
}

.pg {
  max-width: var(--pg-content-max);
  margin: 0 auto;
  padding: 1rem var(--pg-gutter) 280px;
  min-height: calc(100vh - 61px);
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
}
.pg-main,
.pg-empty,
.pg-results,
.examples {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 640px) {
  .pg-body {
    --pg-gutter: 0.6rem;
    /* Real composer height on phones is ~180?210px + safe area */
    --pg-composer-reserve: 200px;
  }
  .pg {
    padding: 0.55rem var(--pg-gutter)
      calc(var(--pg-composer-reserve) + env(safe-area-inset-bottom, 0px) + 16px);
    overflow-x: hidden;
  }
}

.pg-empty {
  padding: 0.5rem 0 1rem;
  color: var(--muted);
}
.pg-empty .faint { color: var(--faint); font-size: 0.9rem; margin-top: 0.35rem; }

/* Example gallery ? Midjourney Explore style (masonry, full-bleed) */
.examples {
  width: 100%;
  max-width: 100%;
}
.examples-head {
  margin: 0 0 0.85rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.examples-head h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e4e4e7;
  letter-spacing: -0.02em;
  margin: 0;
}
.examples-sub {
  font-size: 0.78rem;
  color: #71717a;
  margin: 0;
  font-weight: 500;
}
.examples-fallback {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/*
 * Dense CSS grid (PC + mobile): landscape (16:9) spans full width,
 * portraits fill remaining columns ? tetris-style packing.
 */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
}
@media (max-width: 1180px) {
  .examples-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .examples-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }
}
@media (max-width: 360px) {
  .examples-grid {
    grid-template-columns: 1fr;
  }
}

.example-card {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: #111;
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* 16:9 / wide landscapes ? full row across all columns */
.example-card[data-span="wide"] {
  grid-column: 1 / -1;
}
.example-card .ex-media {
  overflow: hidden;
  background: #0a0a0a;
  line-height: 0;
}
.example-card .ex-media img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  vertical-align: top;
}
/* Wide cards: cinematic 16:9 hero */
.example-card[data-span="wide"] .ex-media {
  aspect-ratio: 16 / 9;
}
.example-card[data-span="wide"] .ex-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
/* Mid / tall: natural image height in a single column */
.example-card[data-span="mid"] .ex-media,
.example-card[data-span="tall"] .ex-media {
  aspect-ratio: auto;
}
.example-card[data-span="wide"] .ex-overlay-title {
  font-size: 0.95rem;
}
.example-card[data-span="wide"] .ex-prompt-clamp {
  -webkit-line-clamp: 2;
}
@media (max-width: 720px) {
  .example-card {
    border-radius: 10px;
  }
  .example-card:hover {
    transform: none;
    box-shadow: none;
  }
  .example-card:active {
    transform: scale(0.985);
  }
  .example-card .ex-overlay {
    padding: 0.5rem 0.55rem 0.55rem;
  }
  .example-card .ex-overlay-title {
    font-size: 0.78rem;
  }
  .example-card[data-span="wide"] .ex-overlay-title {
    font-size: 0.84rem;
  }
  .example-card .ex-overlay-prompt {
    font-size: 0.7rem;
  }
  .example-card .ex-prompt-clamp {
    -webkit-line-clamp: 2;
  }
  .example-card .ex-overlay-hint {
    display: none;
  }
  .example-card .ex-badge {
    top: 0.4rem;
    left: 0.4rem;
    font-size: 0.62rem;
    padding: 0.16rem 0.42rem;
  }
}
@media (max-width: 360px) {
  .example-card[data-span="wide"] {
    grid-column: auto;
  }
}
.example-card:hover {
  transform: scale(1.015);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
  z-index: 2;
}
.example-card:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

/* Image drives card height ? natural aspect ratio */
.example-card .ex-media {
  position: relative;
  display: block;
  width: 100%;
  line-height: 0;
}
.example-card .ex-media img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: top;
}

/* Card chrome ? matches feed chips / composer (quiet, not poster-like) */
.example-card .ex-scrim {
  display: none;
}

/* Same language as .chip ? muted pill, not a loud label */
.example-card .ex-badge {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.48rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 550;
  letter-spacing: 0;
  color: #a1a1aa;
  background: rgba(22, 22, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  line-height: 1.2;
}

.example-card .ex-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 0.7rem 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.28rem;
  /* Soft fade ? less ?heavy caption bar?, more product UI */
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.82) 0%,
    rgba(0, 0, 0, 0.38) 42%,
    transparent 78%
  );
  opacity: 1;
  transition: background 0.18s ease;
  pointer-events: none;
}
.example-card:hover .ex-overlay,
.example-card:focus-within .ex-overlay {
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0.48) 48%,
    transparent 82%
  );
  pointer-events: auto;
}
/* Title = feed-side heading weight */
.example-card .ex-overlay-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #f4f4f5;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-shadow: none;
}
/* Prompt body = muted secondary text (like .chip / var(--muted)) */
.example-card .ex-overlay-prompt {
  position: relative;
  margin: 0;
  font-size: 0.76rem;
  font-weight: 450;
  line-height: 1.4;
  color: #a1a1aa;
  cursor: help;
}
.example-card .ex-prompt-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Hosted on <body> while open ? never clipped by card overflow/transform */
.ex-prompt-pop {
  position: fixed;
  z-index: 300;
  width: min(380px, calc(100vw - 1.5rem));
  max-height: min(45vh, 320px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  color: #e8e8e8;
  font-size: 0.88rem;
  font-weight: 450;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
  box-sizing: border-box;
}
.ex-prompt-pop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
/* Nested (closed) state inside card ? keep out of layout */
.example-card .ex-prompt-pop:not(.is-open) {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.example-card .ex-overlay-hint {
  font-size: 0.68rem;
  font-weight: 500;
  color: #71717a;
  letter-spacing: 0;
}
.example-card:hover .ex-overlay-hint {
  color: #a1a1aa;
}

@media (hover: none) {
  .example-card .ex-overlay {
    padding: 0.5rem 0.55rem 0.55rem;
  }
  .example-card .ex-badge {
    top: 0.4rem;
    left: 0.4rem;
  }
  .example-card .ex-overlay-hint {
    display: none;
  }
  .example-card:hover {
    transform: none;
  }
}

/* ?? Results feed (EL-style: compact grid ? meta right) ??? */
.pg-results {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.feed-day {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--faint);
  margin-bottom: 0.65rem;
  letter-spacing: 0.01em;
}
.feed-row {
  display: grid;
  /* image left ? prompt + chips always on the right */
  grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
  gap: 1rem 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
  position: relative;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.55rem 0.65rem;
  margin-left: -0.65rem;
  margin-right: -0.65rem;
  width: calc(100% + 1.3rem);
  max-width: none;
  box-sizing: border-box;
  overflow: visible;
  transition:
    background 0.45s ease,
    border-color 0.45s ease,
    box-shadow 0.45s ease,
    padding 0.45s ease;
}
/* Barely-there hover wash ? only when not already a solid panel */
@media (hover: hover) {
  .feed-row:not(.is-processing):not(.is-upscale):hover {
    background: rgba(255, 255, 255, 0.028);
    border-color: rgba(255, 255, 255, 0.04);
  }
}
/* In-flight generation: simple quiet panel, no edge chrome */
.feed-row.is-processing {
  padding: 0.9rem 1rem;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  background: #b2b2c11f;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}
.feed-row.is-processing.is-upscale {
  background: #141414;
  border-color: rgba(255, 255, 255, 0.08);
}
/* Upscale jobs ? solid dark panel */
.feed-row.is-upscale {
  padding: 0.85rem 0.9rem;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  border-radius: 16px;
  background-color: #141414;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
@media (hover: hover) {
  .feed-row.is-upscale:hover {
    background-color: #171717;
    border-color: rgba(255, 255, 255, 0.1);
  }
  .feed-row.is-processing:hover {
    background: #b2b2c128;
  }
}
@media (max-width: 720px) {
  .feed-row {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-bottom: 1.15rem;
  }
  .feed-side {
    order: -1;
    position: static;
    padding-right: 0;
    top: auto;
  }
  .feed-side-top {
    align-items: center;
  }
  .feed-prompt {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }
  .feed-row.is-upscale {
    padding: 0.65rem;
  }
  .feed-media-upscale {
    flex-wrap: wrap;
    gap: 0.55rem;
  }
  .upscale-before-frame {
    width: min(120px, 36vw);
  }
  .upscale-after-card .res-card {
    max-width: 100%;
  }
  .feed-media.n1 .res-card {
    max-width: 100%;
  }
  .feed-media.n1 .res-card[data-ratio="1:1"] {
    max-width: min(100%, 360px);
  }
  .feed-media.n1 .res-card[data-ratio="9:16"],
  .feed-media.n1 .res-card[data-ratio="3:4"],
  .feed-media.n1 .res-card[data-ratio="2:3"],
  .feed-media.n1 .res-card[data-ratio="4:5"] {
    max-width: min(100%, 320px);
  }
}

/* Upscale before ? after layout */
.feed-media-upscale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.75rem;
  min-width: 0;
}
.upscale-before,
.upscale-after {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.upscale-label {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b8b94;
}
.upscale-before .upscale-label {
  color: #7a7a84;
}
.upscale-after .upscale-label {
  color: #8eb0ff;
}
.upscale-before-frame {
  width: min(140px, 28vw);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0e0e10;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.upscale-before-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.92);
}
.upscale-before-empty {
  font-size: 0.72rem;
  color: #555;
}
.upscale-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: #6e8fd9;
  flex-shrink: 0;
  padding: 0 0.15rem;
}
.upscale-factor-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: #dce6ff;
  background: rgba(70, 110, 220, 0.28);
  border: 1px solid rgba(120, 160, 255, 0.28);
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.upscale-after-card {
  min-width: 0;
}
.upscale-after-card .res-card {
  max-width: min(420px, 100%);
  border-color: rgba(110, 150, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(80, 120, 255, 0.08);
}
.res-card.is-upscale-pending {
  border-color: rgba(100, 140, 255, 0.18);
}
.res-card.is-upscale-pending .prog-badge {
  background: rgba(36, 48, 78, 0.92);
  border-color: rgba(140, 170, 255, 0.22);
  color: #e8eeff;
}
.res-card.is-upscale-pending .prog-ring {
  background: conic-gradient(
    from -90deg,
    rgba(140, 175, 255, 0.95) calc(var(--p, 0) * 1%),
    rgba(255, 255, 255, 0.08) 0
  );
}

.feed-kind-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  width: fit-content;
}
.feed-kind-upscale {
  color: #c8d8ff;
  background: rgba(60, 100, 220, 0.22);
  border: 1px solid rgba(120, 160, 255, 0.28);
}
.feed-prompt-muted {
  color: #9a9aa3 !important;
  font-weight: 450 !important;
  font-size: 0.95rem !important;
}
.feed-media {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
  overflow: visible;
}
/* 1 image: left column, not full page width */
.feed-media.n1 {
  grid-template-columns: minmax(0, min(100%, 480px));
}
/* 2 side-by-side */
.feed-media.n2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 560px;
}
/* 3?4: 2?2 */
.feed-media.n3,
.feed-media.n4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 560px;
}
@media (max-width: 560px) {
  .feed-media.n2,
  .feed-media.n3,
  .feed-media.n4 {
    max-width: 100%;
  }
}

.res-card {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: zoom-in;
  aspect-ratio: 1 / 1; /* pending placeholder; data-ratio overrides */
}
/* Image cards: tooltips need overflow visible on hover */
.res-card.has-image {
  /* Must stay visible so action tooltips can escape the card */
  overflow: visible;
  z-index: 1;
  border-radius: 12px;
}
.res-card.has-image:hover,
.res-card.has-image:focus-within {
  z-index: 40;
}
.res-card.has-image > img.res-img,
.res-card.has-image > img.res-preview {
  border-radius: 12px;
}
.res-card.has-image .card-actions {
  border-radius: 0 0 12px 12px;
  /* NEVER clip tooltips that open above the bottom bar */
  overflow: visible;
}

/* Keep aspect, but no extra max-width that breaks 2?2 grid */
.res-card[data-ratio="1:1"] { aspect-ratio: 1 / 1; }
.res-card[data-ratio="16:9"] { aspect-ratio: 16 / 9; }
.res-card[data-ratio="9:16"] { aspect-ratio: 9 / 16; }
.res-card[data-ratio="4:3"] { aspect-ratio: 4 / 3; }
.res-card[data-ratio="3:4"] { aspect-ratio: 3 / 4; }
.res-card[data-ratio="21:9"] { aspect-ratio: 21 / 9; }
.res-card[data-ratio="3:2"] { aspect-ratio: 3 / 2; }
.res-card[data-ratio="2:3"] { aspect-ratio: 2 / 3; }
.res-card[data-ratio="5:4"] { aspect-ratio: 5 / 4; }
.res-card[data-ratio="4:5"] { aspect-ratio: 4 / 5; }

/* Until JS sets pixel aspect: never force landscape crop */
.res-card.has-image:not(.ratio-set) {
  aspect-ratio: auto;
  max-width: min(100%, 480px);
}
.res-card.has-image:not(.ratio-set) img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Single image stays in the left column with a sensible cap */
.feed-media.n1 .res-card {
  width: 100%;
  max-width: 480px;
}
.feed-media.n1 .res-card[data-ratio="1:1"] {
  max-width: 340px;
}
.feed-media.n1 .res-card[data-ratio="9:16"],
.feed-media.n1 .res-card[data-ratio="3:4"],
.feed-media.n1 .res-card[data-ratio="2:3"],
.feed-media.n1 .res-card[data-ratio="4:5"] {
  max-width: 280px;
}

.res-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Pixel-matched frame: cover fills without cropping the subject */
.res-card.ratio-set img {
  object-fit: cover;
}
/* Progressive reveal: skeleton stays until pixels paint, then unblur */
.res-card.is-revealing {
  cursor: default;
}
.res-card.is-revealing .card-dl,
.res-card.is-revealing .card-edit,
.res-card.is-revealing .card-actions {
  opacity: 0 !important;
  pointer-events: none !important;
}
/* While downloading: skeleton stays; image sits invisible on top */
.res-card img.res-img,
.res-card img.res-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  backface-visibility: hidden;
  will-change: filter, transform, opacity;
  transition:
    filter 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.45s ease;
}
/* Not yet decoded ? transparent so skeleton shows through (no empty card) */
.res-card img.res-img.is-loading,
.res-card img.res-preview.is-loading {
  opacity: 0;
  visibility: hidden;
}
.res-card img.res-img.is-visible,
.res-card img.res-preview.is-visible {
  opacity: 1;
  visibility: visible;
}
.res-card img.res-img.is-blur {
  filter: blur(28px) saturate(1.08) brightness(0.96);
  transform: scale(1.1);
}
.res-card img.res-img.is-sharp {
  filter: blur(0) saturate(1) brightness(1);
  transform: scale(1);
}
.res-card img.res-preview {
  z-index: 1;
  filter: blur(22px) saturate(1.05);
  transform: scale(1.08);
}
.res-card img.res-preview.is-gone {
  opacity: 0;
  filter: blur(8px);
}
/* Full image above preview when both present */
.res-card img.res-img {
  z-index: 2;
}
/* Fade progress chrome out instead of hard-removing */
.prog-center.is-fading {
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .res-card img.res-img,
  .res-card img.res-preview {
    transition: none !important;
    filter: none !important;
    transform: none !important;
  }
  .res-card img.res-img.is-loading,
  .res-card img.res-preview.is-loading {
    opacity: 1;
    visibility: visible;
  }
}

/* Hover actions: Edit top-left ? Download top-right ? Reference/Upscale bottom */
.res-card.has-image {
  cursor: zoom-in;
}

/*
 * Corner buttons ? MUST beat:
 *   .has-tip[data-tip]{position:relative}
 *   .res-card .card-act{position:relative} (mobile icon-only pills)
 * or Edit falls into document flow and ends up under the bottom bar.
 */
.res-card .card-dl,
.res-card .card-dl.has-tip,
.res-card .card-dl.has-tip[data-tip],
.res-card .card-edit,
.res-card .card-edit.has-tip,
.res-card .card-edit.has-tip[data-tip],
.res-card .card-edit.card-act {
  position: absolute !important;
  top: 10px !important;
  z-index: 8;
  height: 34px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(22, 22, 22, 0.88);
  color: #f2f2f2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.12s,
    border-color 0.12s;
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  box-sizing: border-box;
}
.res-card .card-dl,
.res-card .card-dl.has-tip,
.res-card .card-dl.has-tip[data-tip] {
  right: 10px !important;
  left: auto !important;
  bottom: auto !important;
  width: 34px;
}
/* Edit ? pinned top-left */
.res-card .card-edit,
.res-card .card-edit.has-tip,
.res-card .card-edit.has-tip[data-tip],
.res-card .card-edit.card-act {
  left: 10px !important;
  right: auto !important;
  bottom: auto !important;
  width: auto;
  min-width: 34px;
  padding: 0 0.65rem 0 0.5rem;
}
.res-card .card-dl svg,
.res-card .card-edit svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}
.res-card .card-dl:hover,
.res-card .card-edit:hover {
  background: rgba(42, 42, 42, 0.96);
  border-color: rgba(255, 255, 255, 0.24);
}
.res-card .card-dl:active,
.res-card .card-edit:active {
  transform: scale(0.96);
}

.res-card .card-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 0.5rem 0.7rem;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.35) 55%,
    transparent 100%
  );
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
  overflow: visible;
}
.res-card.has-image:hover .card-actions,
.res-card.has-image:focus-within .card-actions,
.res-card.has-image:hover .card-dl,
.res-card.has-image:focus-within .card-dl,
.res-card.has-image:hover .card-edit,
.res-card.has-image:focus-within .card-edit {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
/* Touch: always show so buttons are usable */
@media (hover: none) {
  .res-card.has-image .card-actions {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    padding: 0.45rem 0.35rem 0.5rem;
    background: linear-gradient(
      to top,
      rgba(0, 0, 0, 0.72) 0%,
      rgba(0, 0, 0, 0.28) 60%,
      transparent 100%
    );
  }
  .res-card.has-image .card-dl,
  .res-card.has-image .card-edit {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}
.card-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(22, 22, 22, 0.94);
  color: #f0f0f0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease,
    transform 0.1s ease;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  max-width: 100%;
}
.card-act:hover {
  background: rgba(40, 40, 40, 0.96);
  border-color: rgba(255, 255, 255, 0.22);
  color: #f5f5f5;
}
.card-act:active {
  transform: scale(0.97);
  background: rgba(34, 34, 34, 0.96);
}
.card-act svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.95;
  color: inherit;
}
.card-act:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/*
 * Phone / narrow cards: 3 text pills overflow (Edit | Reference | Upscale).
 * Use icon-only round buttons so they fit 2?2 grids on mobile.
 */
@media (max-width: 720px), (hover: none) {
  .res-card .card-actions {
    gap: 0.3rem;
    padding: 0.4rem 0.3rem 0.45rem;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
  }
  /* Only bottom-bar pills ? never corner Edit/Download */
  .res-card .card-actions .card-act {
    position: relative;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
    font-size: 0;
    line-height: 0;
    box-sizing: border-box;
  }
  .res-card .card-actions .card-act span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
  }
  .res-card .card-actions .card-act svg {
    width: 16px;
    height: 16px;
  }
  .res-card .card-dl,
  .res-card .card-dl.has-tip {
    width: 34px;
    height: 34px;
    top: 8px !important;
    right: 8px !important;
    border-radius: 50%;
  }
  /* Edit stays top-left icon-only */
  .res-card .card-edit,
  .res-card .card-edit.has-tip,
  .res-card .card-edit.card-act {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    right: auto !important;
    bottom: auto !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    gap: 0;
    font-size: 0;
    line-height: 0;
  }
  .res-card .card-edit span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .res-card .card-edit svg {
    width: 16px;
    height: 16px;
  }
}

/* Very small phones: slightly tighter hit targets still tappable */
@media (max-width: 380px) {
  .res-card .card-act {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }
  .res-card .card-act svg {
    width: 15px;
    height: 15px;
  }
  .res-card .card-actions {
    gap: 0.22rem;
    padding: 0.35rem 0.25rem 0.4rem;
  }
}

/* Desktop narrow window still keeps text labels on hover devices */
@media (min-width: 721px) and (hover: hover) {
  .res-card .card-act span {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
  }
}

/* Loading skeleton ? calm surface + full-width soft light sweep */
.res-card.pending {
  cursor: default;
  background:
    radial-gradient(ellipse 100% 90% at 50% 45%, #181818 0%, #101010 55%, #0c0c0c 100%);
  overflow: hidden;
  isolation: isolate;
}
/*
 * Soft light sweep: a wide feathered band that travels fully across the card.
 * Uses transform (not background-position) so edges never look ?cut in half?.
 */
.res-card.pending::before {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 55%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.015) 22%,
    rgba(255, 255, 255, 0.07) 48%,
    rgba(255, 255, 255, 0.09) 52%,
    rgba(255, 255, 255, 0.04) 68%,
    transparent 100%
  );
  filter: blur(14px);
  opacity: 0.85;
  transform: translateX(-130%) skewX(-12deg);
  animation: skeletonSheen 2.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
/* Soft breathing glow behind the ring */
.res-card.pending::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(55%, 160px);
  height: min(55%, 160px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.02) 42%,
    transparent 72%
  );
  animation: skeletonBreath 2.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes skeletonSheen {
  0% {
    transform: translateX(-130%) skewX(-12deg);
    opacity: 0;
  }
  12% {
    opacity: 0.9;
  }
  88% {
    opacity: 0.9;
  }
  100% {
    transform: translateX(240%) skewX(-12deg);
    opacity: 0;
  }
}
@keyframes skeletonBreath {
  0%, 100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.9);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }
}
@media (prefers-reduced-motion: reduce) {
  .res-card.pending::before,
  .res-card.pending::after {
    animation: none;
  }
  .res-card.pending::before {
    display: none;
  }
}

/* Centered progress ? SVG stroke ring (round caps, no hard clip) */
.prog-center {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
  /* Soft enter when skeleton mounts */
  opacity: 0;
  animation: progCenterIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s forwards;
}
.prog-center.is-fading {
  animation: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
@keyframes progCenterIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.prog-ring {
  --p: 0;
  position: relative;
  width: min(30%, 76px);
  height: min(30%, 76px);
  min-width: 58px;
  min-height: 58px;
  display: grid;
  place-items: center;
}
.prog-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.prog-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3.2;
  transition: stroke 0.4s ease;
}
.prog-ring-arc {
  fill: none;
  stroke: rgba(255, 255, 255, 0.94);
  stroke-width: 3.2;
  stroke-linecap: round; /* soft tip ? never a hard cut */
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--p, 0));
  /* Longer ease so % jumps (and 95?Almost) don't snap the ring */
  transition:
    stroke-dashoffset 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    stroke 0.4s ease,
    opacity 0.35s ease;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.25));
}
/* Indeterminate: spinning arc with soft ends */
.prog-ring.is-indeterminate .prog-ring-arc {
  stroke-dasharray: 28 72;
  stroke-dashoffset: 0;
  animation: progSpin 1.05s linear infinite;
  transition: opacity 0.35s ease;
}
@keyframes progSpin {
  to { transform: rotate(360deg); }
}
/* SVG itself rotates for indeterminate; keep group centered */
.prog-ring.is-indeterminate .prog-ring-svg {
  animation: progSpin 1.05s linear infinite;
}
.prog-ring.is-indeterminate .prog-ring-arc {
  animation: none;
}

.prog-badge {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  color: #f0f0f0;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 0 0.15rem;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-align: center;
  max-width: 4.6rem;
  transition: opacity 0.22s ease, color 0.25s ease, font-size 0.25s ease;
}
.prog-badge.is-swap {
  opacity: 0;
}
/* Status words (Queued / Almost?) ? readable inside the ring */
.prog-badge.is-status {
  font-size: 0.72rem;
  font-weight: 650;
  color: #ececef;
  max-width: 4.8rem;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
@media (prefers-reduced-motion: reduce) {
  .prog-center {
    animation: none;
    opacity: 1;
  }
  .prog-ring-arc {
    transition: none;
  }
  .prog-badge {
    transition: none;
  }
}

.res-card.failed {
  cursor: default;
  display: grid;
  place-items: center;
  color: var(--err);
  font-size: 0.9rem;
  background: #1a1010;
  padding: 0.75rem;
  text-align: center;
}
.res-card.failed .fail-label {
  max-width: 90%;
  line-height: 1.3;
  word-break: break-word;
}

/* Right-side meta (prompt + chips) ? always beside image on desktop */
.feed-side {
  position: sticky;
  top: 5.5rem;
  min-width: 0;
  padding: 0.1rem 0;
}
.feed-side-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.15rem;
}
.feed-side-main {
  min-width: 0;
  flex: 1;
}
.feed-side-top .feed-prompt {
  margin-bottom: 0.55rem;
}
/*
 * Dismiss control ? quiet icon button (?).
 * Desktop: only on row hover. Phone: always visible.
 * No red pill / long tooltip ? secondary, not alarming.
 */
.feed-delete {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6e6e76;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: color 0.12s, background 0.12s, opacity 0.14s;
}
.feed-delete svg {
  display: block;
  pointer-events: none;
}
.feed-row:hover .feed-delete,
.feed-row:focus-within .feed-delete {
  opacity: 1;
  pointer-events: auto;
}
.feed-delete:hover {
  color: #e8e8ec;
  background: rgba(255, 255, 255, 0.07);
}
.feed-delete:active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.feed-delete:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.28);
  outline-offset: 2px;
  opacity: 1;
  pointer-events: auto;
}
/* Tip short + open left so it doesn?t clip off the side panel */
.feed-delete.has-tip[data-tip]::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
  max-width: 140px;
  white-space: nowrap;
}
.feed-delete.has-tip[data-tip]::after {
  left: auto;
  right: 10px;
  transform: translateX(0) translateY(4px);
}
.feed-delete.has-tip[data-tip]:hover::before,
.feed-delete.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.feed-delete.has-tip[data-tip]:hover::after,
.feed-delete.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* Phone / touch: always available */
@media (hover: none), (max-width: 720px) {
  .feed-delete {
    opacity: 0.75;
    pointer-events: auto;
    width: 34px;
    height: 34px;
  }
  .feed-row:hover .feed-delete {
    opacity: 1;
  }
}
.feed-prompt {
  position: relative;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.45;
  margin: 0 0 0.7rem;
  word-break: break-word;
}
.feed-prompt.is-truncated {
  cursor: help;
}
.feed-prompt.is-truncated .feed-prompt-short {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Full prompt popup on hover / focus */
.feed-prompt-pop {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 40;
  width: max(100%, min(360px, 70vw));
  max-width: min(420px, 90vw);
  max-height: min(50vh, 320px);
  overflow: auto;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  color: #e8e8e8;
  font-size: 0.9rem;
  font-weight: 450;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease,
    visibility 0.14s;
}
.feed-prompt.is-truncated:hover .feed-prompt-pop,
.feed-prompt.is-truncated:focus-within .feed-prompt-pop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
@media (max-width: 720px) {
  .feed-side {
    position: static;
  }
  .feed-prompt-pop {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 6.5rem;
    width: auto;
    max-width: none;
    max-height: 40vh;
  }
}
.feed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  background: #161616;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.38rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}
.chip img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  background: #0a0a0a;
}
.chip .chip-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
  display: block;
}
.chip .ratio-chip {
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip .ratio-chip .ratio-box {
  border-radius: 1px;
  outline: 1.25px solid currentColor;
  box-sizing: border-box;
}

/* ?? Composer dock ????????????????????????????????????????????? */
.composer-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  /* Same horizontal inset as .pg so the bar lines up with results */
  padding: 0 var(--pg-gutter, 1.25rem) 1.15rem;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.96) 35%,
    rgba(0, 0, 0, 0.45) 72%,
    transparent
  );
}

/* Visible toast above composer (errors used to hide on send-tip hover only) */
.pg-toast {
  pointer-events: none;
  width: 100%;
  max-width: var(--pg-content-max, 980px);
  margin: 0 auto 0.55rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 550;
  line-height: 1.35;
  color: #f4f4f5;
  background: #222;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  animation: pgToastIn 0.16s ease;
}
.pg-toast[hidden] {
  display: none !important;
}
.pg-toast.is-err {
  color: #fecaca;
  background: #2a1216;
  border-color: rgba(248, 113, 113, 0.4);
}
.pg-toast.is-ok {
  color: #bbf7d0;
  background: #0f1f16;
  border-color: rgba(74, 222, 128, 0.3);
}
@keyframes pgToastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.composer {
  pointer-events: auto;
  width: 100%;
  max-width: var(--pg-content-max, 980px);
  margin-left: auto;
  margin-right: auto;
  background: #161616;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  padding: 0.95rem 1.1rem 0.95rem;
  box-sizing: border-box;
  /* allow tooltips to paint outside the card */
  overflow: visible;
}
.composer.is-dragover {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 16px 48px rgba(0, 0, 0, 0.55);
}

/*
 * Reference rail ? chat-style attachments at top of composer.
 * Not icon buttons: text pill + horizontal image chips.
 */
.ref-rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  /* Align with prompt text column */
  margin-left: 0.35rem;
  margin-right: 0.35rem;
  min-width: 0;
}
.ref-rail.is-empty {
  margin-bottom: 0.45rem;
}
.ref-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
/* Attachment chip: thumb + filename + remove */
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: min(220px, 55vw);
  height: 36px;
  padding: 0 0.35rem 0 0.3rem;
  border-radius: 10px;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d4d4d8;
  transition: border-color 0.12s, background 0.12s;
}
.ref-chip:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: #222;
}
.ref-chip img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: #0a0a0a;
  display: block;
}
.ref-chip-name {
  font-size: 0.78rem;
  font-weight: 550;
  color: #c4c4c8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 120px;
  line-height: 1.2;
}
.ref-chip-x {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #8a8a8a;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.ref-chip-x:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
}
.ref-chip-x:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}
/* Legacy class hooks (JS still uses data-remove on .ref-x) */
.ref-chip .ref-x,
.ref-chip .ref-x.has-tip {
  /* mapped via .ref-chip-x in markup */
}
.ref-chip .ref-link {
  display: none;
}

/* Text ?+ Reference? ? not a square icon button */
.ref-attach {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 0.9rem 0 0.7rem;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #9a9aa3;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.ref-attach svg {
  display: block;
  opacity: 0.85;
}
.ref-attach:hover {
  color: #e8e8e8;
  border-color: rgba(255, 255, 255, 0.28);
  border-style: solid;
  background: rgba(255, 255, 255, 0.05);
}
.ref-attach:active {
  transform: scale(0.98);
}
.ref-attach:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}
/* When refs exist, keep attach quiet at the end of the row */
.ref-rail:not(.is-empty) .ref-attach {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.1);
  background: #1a1a1a;
  color: #a1a1aa;
}
.ref-rail.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* Feed-side reference chips */
.feed-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
}
.feed-refs:empty {
  display: none;
}
.feed-ref {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.feed-ref img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.feed-ref::after,
.feed-ref svg {
  display: none;
}


.prompt-wrap {
  position: relative;
  margin-bottom: 0.55rem;
  /* visible so @ mention menu isn't clipped; collapse uses max-height */
  overflow: visible;
  max-height: 280px;
  opacity: 1;
  transform: translateY(0);
  /* Slight inset so text lines up with control chips, not flush to the card edge */
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  transition:
    max-height 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.26s ease,
    margin 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.composer-input {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.5;
  /* Starts compact; grows with content up to former max */
  min-height: 1.5em;
  height: 1.5em;
  max-height: 160px;
  overflow-y: hidden;
  outline: none;
  margin-bottom: 0.35rem;
  /* Match chip row optical start (logo + label sit inset) */
  padding-left: 0.2rem;
  padding-right: 0.15rem;
  box-sizing: border-box;
  field-sizing: content; /* progressive enhancement where supported */
}
.composer-input::placeholder { color: #5c5c5c; }
.composer-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Hidden textarea mirror ? keeps form/persist APIs working */
.composer-input-mirror {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
/* Contenteditable prompt with inline @Image chips */
.prompt-editor {
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  overflow-y: auto;
}
.prompt-editor:empty::before,
.prompt-editor.is-empty::before {
  content: attr(data-placeholder);
  color: #5c5c5c;
  pointer-events: none;
}
.prompt-editor:focus {
  outline: none;
}
.prompt-editor .img-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  vertical-align: middle;
  margin: 0 0.12rem;
  padding: 0.12rem 0.4rem 0.12rem 0.18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f0f0f0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
  max-width: min(160px, 40vw);
}
.prompt-editor .img-tag img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #222;
}
.prompt-editor .img-tag-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-editor .img-tag-x {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-left: 0.05rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #9a9a9a;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.prompt-editor .img-tag-x:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
/* Click ref chip ? insert @Image into prompt */
.ref-chip {
  cursor: pointer;
}
.ref-chip .ref-chip-at {
  display: none;
  font-size: 0.65rem;
  font-weight: 700;
  color: #9ab0ff;
  margin-left: 0.15rem;
}
.ref-chip:hover .ref-chip-at {
  display: inline;
}

/* @ mention popover ? fixed on body, never clipped by composer */
.prompt-mention-menu {
  position: fixed;
  z-index: 200;
  box-sizing: border-box;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(240px, 40vh);
  overflow-x: hidden;
  overflow-y: auto;
  /* Inner padding so rows / thumbs never look half-cut against the edge */
  padding: 0.4rem;
  border-radius: 14px;
  background: #1a1a1c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  /* Extra safe-area on mobile */
  margin: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
.prompt-mention-menu[hidden] {
  display: none !important;
}
.prompt-mention-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  /* Generous hit padding ? thumb + label fully inside */
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #e8e8e8;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  flex-shrink: 0;
}
.prompt-mention-item:hover,
.prompt-mention-item.is-active {
  background: rgba(124, 156, 255, 0.16);
}
.prompt-mention-item img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: #2a2a2c;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.prompt-mention-meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex: 1;
}
.prompt-mention-label {
  font-size: 0.86rem;
  font-weight: 650;
  color: #f2f2f2;
  line-height: 1.2;
}
.prompt-mention-name {
  font-size: 0.7rem;
  color: #8a8a90;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-mention-hint {
  font-size: 0.68rem;
  font-weight: 600;
  color: #8fa4ff;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.prompt-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.12rem;
  min-height: 28px;
}
.prompt-count {
  font-size: 0.72rem;
  font-weight: 550;
  color: #666;
  font-variant-numeric: tabular-nums;
  margin-left: 0;
  cursor: help;
  flex-shrink: 0;
}
.prompt-count.warn { color: #c4a35a; }
.prompt-count.err { color: #f87171; }
/* Character counter sits on the right ? tip opens left so it stays on screen */
.prompt-count.has-tip[data-tip]::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
  max-width: min(280px, 70vw);
  text-align: left;
}
.prompt-count.has-tip[data-tip]::after {
  left: auto;
  right: 12px;
  transform: translateX(0) translateY(4px);
}
.prompt-count.has-tip[data-tip]:hover::before,
.prompt-count.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.prompt-count.has-tip[data-tip]:hover::after,
.prompt-count.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}

/* AI enhance toggle ? stacked above character count (prompt-meta column) */
.enhance-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  border: none;
  background: transparent;
  color: #8a8a8a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.22rem 0.45rem;
  height: auto;
  min-height: 26px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
  white-space: nowrap;
}
.enhance-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.enhance-btn:hover:not(:disabled) {
  color: #d4d4d8;
  background: rgba(255, 255, 255, 0.06);
}
.enhance-btn[aria-pressed="true"] {
  color: #e4e4e7;
  background: rgba(167, 139, 250, 0.14);
}
.enhance-btn[aria-pressed="true"]:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.2);
  color: #f4f4f5;
}
.enhance-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.enhance-btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Soft floating tooltip (data-tip) ? playground-wide */
.has-tip[data-tip] {
  position: relative;
}
.has-tip[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  max-width: min(300px, 78vw);
  width: max-content;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  background: #222;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8e8e8;
  font-size: 0.75rem;
  font-weight: 550;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 120;
}
.has-tip[data-tip]::after {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: #222;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 120;
}
.has-tip[data-tip]:hover::before,
.has-tip[data-tip]:focus-visible::before,
.has-tip[data-tip]:hover::after,
.has-tip[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.has-tip[data-tip]:disabled:hover::before,
.has-tip[data-tip]:disabled:hover::after {
  opacity: 0;
}

/*
 * Nav sits at the top of the viewport ? tooltips MUST open BELOW the links.
 * Default (above) was clipping outside the screen / browser chrome.
 * Use high specificity + !important so nothing reverts them to "above".
 */
.nav,
.nav-inner {
  overflow: visible !important;
}
/* Align top nav with fluid playground content width */
.pg-body .nav-inner {
  max-width: var(--pg-content-max, 1080px);
  width: 100%;
  box-sizing: border-box;
  padding-left: var(--pg-gutter, 1.25rem);
  padding-right: var(--pg-gutter, 1.25rem);
}
/* Desktop only: kill the white Windows scrollbar next to Status */
@media (min-width: 701px) {
  .nav-links {
    overflow: visible !important;
    scrollbar-width: none;
  }
  .nav-links::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }
}
.nav .nav-links a.has-tip[data-tip]::before {
  bottom: auto !important;
  top: calc(100% + 10px) !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) translateY(-4px) !important;
  max-width: min(220px, 68vw);
  z-index: 300;
}
.nav .nav-links a.has-tip[data-tip]::after {
  bottom: auto !important;
  top: calc(100% + 2px) !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) translateY(-4px) !important;
  border: 5px solid transparent !important;
  border-top-color: transparent !important;
  border-bottom-color: #222 !important;
  z-index: 300;
}
.nav .nav-links a.has-tip[data-tip]:hover::before,
.nav .nav-links a.has-tip[data-tip]:focus-visible::before {
  transform: translateX(-50%) translateY(0) !important;
}
.nav .nav-links a.has-tip[data-tip]:hover::after,
.nav .nav-links a.has-tip[data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(0) !important;
}
/* Right-side nav items ? tip anchors to the right edge so it stays on-screen */
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2)::before {
  left: auto !important;
  right: 0 !important;
  transform: translateX(0) translateY(-4px) !important;
  text-align: right;
}
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2)::after {
  left: auto !important;
  right: 14px !important;
  transform: translateX(0) translateY(-4px) !important;
}
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2):hover::before,
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2):focus-visible::before {
  transform: translateX(0) translateY(0) !important;
}
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2):hover::after,
.nav .nav-links a.has-tip[data-tip]:nth-last-child(-n + 2):focus-visible::after {
  transform: translateX(0) translateY(0) !important;
}
/* Workspace switch (Image | Canvas) also near top */
.workspace-switch .ws-btn.has-tip[data-tip]::before,
.workspace-switch .ws-btn[data-tip]::before {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
}
.workspace-switch .ws-btn.has-tip[data-tip]::after,
.workspace-switch .ws-btn[data-tip]::after {
  bottom: auto;
  top: calc(100% + 0px);
  border-top-color: transparent;
  border-bottom-color: #222;
  transform: translateX(-50%) translateY(-4px);
}
.workspace-switch .ws-btn.has-tip[data-tip]:hover::before,
.workspace-switch .ws-btn.has-tip[data-tip]:focus-visible::before {
  transform: translateX(-50%) translateY(0);
}
.workspace-switch .ws-btn.has-tip[data-tip]:hover::after,
.workspace-switch .ws-btn.has-tip[data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}
/* Composer bottom bar ? tips open upward */
.ctrl-btn.has-tip[data-tip]::before,
.send-btn.has-tip[data-tip]::before,
.ref-attach.has-tip[data-tip]::before {
  max-width: min(220px, 70vw);
  bottom: calc(100% + 10px);
}
/* Feed chips */
.chip.has-tip[data-tip]::before {
  max-width: min(260px, 70vw);
  z-index: 50;
}
/*
 * Bottom bar (Reference / Upscale): tips open ABOVE the buttons.
 * Opening below was clipped by the image edge / next feed row.
 */
.res-card .card-actions .card-act.has-tip[data-tip] {
  position: relative;
  z-index: 50;
}
.res-card .card-actions .card-act.has-tip[data-tip]::before {
  bottom: calc(100% + 10px);
  top: auto;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  max-width: min(240px, 70vw);
  z-index: 60;
  white-space: normal;
}
.res-card .card-actions .card-act.has-tip[data-tip]::after {
  bottom: calc(100% + 2px);
  top: auto;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 5px solid transparent;
  border-top-color: #222;
  border-bottom-color: transparent;
  z-index: 60;
}
.res-card .card-actions .card-act.has-tip[data-tip]:hover::before,
.res-card .card-actions .card-act.has-tip[data-tip]:focus-visible::before {
  transform: translateX(-50%) translateY(0);
}
.res-card .card-actions .card-act.has-tip[data-tip]:hover::after,
.res-card .card-actions .card-act.has-tip[data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}
/* Download (top-right): tip below-left so it isn't clipped */
.res-card .card-dl.has-tip[data-tip]::before {
  bottom: auto;
  top: calc(100% + 10px);
  left: auto;
  right: 0;
  transform: translateX(0) translateY(-4px);
  text-align: right;
  max-width: min(220px, 70vw);
  z-index: 50;
}
.res-card .card-dl.has-tip[data-tip]::after {
  bottom: auto;
  top: calc(100% + 2px);
  left: auto;
  right: 12px;
  transform: translateX(0) translateY(-4px);
  border: 5px solid transparent;
  border-top-color: transparent;
  border-bottom-color: #222;
  z-index: 50;
}
.res-card .card-dl.has-tip[data-tip]:hover::before,
.res-card .card-dl.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.res-card .card-dl.has-tip[data-tip]:hover::after,
.res-card .card-dl.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* Edit (top-left): tip below-right so it isn't clipped */
.res-card .card-edit.has-tip[data-tip]::before {
  bottom: auto;
  top: calc(100% + 10px);
  left: 0;
  right: auto;
  transform: translateX(0) translateY(-4px);
  text-align: left;
  max-width: min(240px, 70vw);
  z-index: 50;
}
.res-card .card-edit.has-tip[data-tip]::after {
  bottom: auto;
  top: calc(100% + 2px);
  left: 14px;
  right: auto;
  transform: translateX(0) translateY(-4px);
  border: 5px solid transparent;
  border-top-color: transparent;
  border-bottom-color: #222;
  z-index: 50;
}
.res-card .card-edit.has-tip[data-tip]:hover::before,
.res-card .card-edit.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.res-card .card-edit.has-tip[data-tip]:hover::after,
.res-card .card-edit.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* Option rows / filter chips (model list uses rich panel instead of data-tip) */
.opt.has-tip[data-tip]::before,
.filter-chip.has-tip[data-tip]::before {
  max-width: min(280px, 70vw);
  z-index: 140;
}
/* Enhance tip opens above, slightly left of send so it stays on-screen */
.enhance-btn.has-tip[data-tip]::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
  max-width: min(240px, 70vw);
  text-align: right;
}
.enhance-btn.has-tip[data-tip]::after {
  left: auto;
  right: 18px;
  transform: translateX(0) translateY(4px);
}
.enhance-btn.has-tip[data-tip]:hover::before,
.enhance-btn.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.enhance-btn.has-tip[data-tip]:hover::after,
.enhance-btn.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* Send button tip (right edge) ? shift left so it stays on screen */
.send-btn.has-tip[data-tip]::before {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
  text-align: right;
}
.send-btn.has-tip[data-tip]::after {
  left: auto;
  right: 18px;
  transform: translateX(0) translateY(4px);
}
.send-btn.has-tip[data-tip]:hover::before,
.send-btn.has-tip[data-tip]:focus-visible::before {
  transform: translateX(0) translateY(0);
}
.send-btn.has-tip[data-tip]:hover::after,
.send-btn.has-tip[data-tip]:focus-visible::after {
  transform: translateX(0) translateY(0);
}
/* Lightbox close ? tip below button (top of screen) */
.lb-close.has-tip[data-tip]::before {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-4px);
}
.lb-close.has-tip[data-tip]::after {
  bottom: auto;
  top: calc(100% + 0px);
  border-top-color: transparent;
  border-bottom-color: #222;
  transform: translateX(-50%) translateY(-4px);
}
.lb-close.has-tip[data-tip]:hover::before,
.lb-close.has-tip[data-tip]:focus-visible::before,
.lb-close.has-tip[data-tip]:hover::after,
.lb-close.has-tip[data-tip]:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}
@media (hover: none) {
  /* Touch: no sticky hover tooltips; focus-visible still works */
  .has-tip[data-tip]:hover::before,
  .has-tip[data-tip]:hover::after {
    opacity: 0;
  }
  .has-tip[data-tip]:focus-visible::before,
  .has-tip[data-tip]:focus-visible::after {
    opacity: 1;
  }
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}
.composer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.ctrl { position: relative; }
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1e1e1e;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  max-width: 240px;
  min-height: 40px;
  transition: background 0.12s, border-color 0.12s;
}
.ctrl-btn:hover {
  background: #2a2a2a;
  border-color: rgba(255, 255, 255, 0.16);
}
.ctrl-btn .chev { opacity: 0.45; font-size: 0.7rem; margin-left: 0.05rem; }
.ctrl-btn > span:not(.ico):not(.chev):not(.ico-ratio) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctrl-logo {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  object-fit: contain;
  background: #0a0a0a;
  flex-shrink: 0;
}
.ctrl-btn .ico-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
  display: block;
}
.ctrl-btn .ico-ratio {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.ctrl-btn .ratio-box {
  max-width: 100%;
  border-radius: 1px;
  outline: 1.5px solid currentColor;
  outline-offset: 0;
  transition: width 0.2s ease, height 0.2s ease;
  width: 65%;
  height: calc(65% * 9 / 16);
  box-sizing: border-box;
}
.ctrl.hidden { display: none; }

.send-wrap {
  position: relative;
  flex-shrink: 0;
}
.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.1s, background 0.12s, width 0.12s,
    padding 0.12s, border-radius 0.12s;
  padding: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.send-btn:hover:not(:disabled) { transform: scale(1.04); }
.send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  background: #c8c8c8;
}
/* keep hover events when disabled so tooltip can show */
.send-btn.loading {
  opacity: 0.7;
  pointer-events: auto;
  cursor: not-allowed;
}
.send-btn svg,
.send-btn .send-ico {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.send-label {
  display: none;
  line-height: 1;
}
/* Upscale mode: animate prompt collapse + pill ?Make Upscale? send */
.composer.is-upscale-mode .prompt-wrap {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  margin-top: 0;
  transform: translateY(-6px);
  pointer-events: none;
}
.composer.is-upscale-mode .prompt-wrap .composer-input,
.composer.is-upscale-mode .prompt-wrap .prompt-meta {
  pointer-events: none;
}
/* Upscale doesn't use prompt enhance ? tuck it away */
.composer.is-upscale-mode .enhance-btn {
  display: none;
}
.composer.is-upscale-mode .send-btn {
  width: auto;
  min-width: 48px;
  height: 44px;
  padding: 0 1.05rem 0 0.85rem;
  border-radius: 999px;
  gap: 0.4rem;
  transition: transform 0.1s, opacity 0.1s, background 0.12s, width 0.28s ease,
    padding 0.28s ease, border-radius 0.28s ease;
}
.composer.is-upscale-mode .send-btn .send-label {
  display: inline;
  animation: sendLabelIn 0.28s ease both;
}
.composer.is-upscale-mode .send-btn .send-ico {
  width: 18px;
  height: 18px;
}
@keyframes sendLabelIn {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .prompt-wrap {
    transition: none;
  }
  .composer.is-upscale-mode .send-btn .send-label {
    animation: none;
  }
}

/* Phone / narrow screens ? fit viewport, no horizontal overflow */
@media (max-width: 640px) {
  .pg-body {
    --pg-gutter: 0.6rem;
    --pg-composer-reserve: 200px;
  }
  .pg {
    padding: 0.55rem var(--pg-gutter)
      calc(var(--pg-composer-reserve) + env(safe-area-inset-bottom, 0px) + 16px);
    max-width: 100%;
    overflow-x: hidden;
  }
  .examples-head {
    margin-bottom: 0.5rem;
  }
  .examples-head h2 {
    font-size: 0.88rem;
  }
  .examples-sub {
    font-size: 0.7rem;
  }

  /*
   * Composer dock sits fully inside the visual viewport.
   * Extra bottom padding = home indicator + browser chrome.
   */
  .composer-dock {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(0.65rem, calc(env(safe-area-inset-bottom, 0px) + 0.35rem));
    padding-top: 0.65rem;
    background: linear-gradient(
      to top,
      #000 0%,
      #000 48%,
      rgba(0, 0, 0, 0.94) 68%,
      rgba(0, 0, 0, 0.4) 88%,
      transparent 100%
    );
  }
  .composer {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 16px;
    padding: 0.5rem 0.55rem 0.5rem;
    /* Pops reparent to body ? no need to clip the card (was cutting popovers) */
    overflow: visible;
  }
  .ref-rail {
    margin: 0 0.2rem 0.3rem;
    gap: 0.3rem;
  }
  .ref-chip {
    height: 32px;
    max-width: min(140px, 55vw);
  }
  .ref-chip img {
    width: 24px;
    height: 24px;
  }
  .ref-chip-name {
    max-width: 72px;
    font-size: 0.7rem;
  }
  .ref-attach {
    height: 32px;
    font-size: 0.8rem;
    padding: 0 0.65rem 0 0.5rem;
  }
  .feed-ref {
    width: 28px;
    height: 28px;
  }

  .prompt-wrap {
    margin-bottom: 0.3rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }
  .composer-input {
    font-size: 16px; /* iOS: avoid focus zoom */
    min-height: 1.4em;
    height: 1.4em;
    max-height: 72px;
    margin-bottom: 0.25rem;
    line-height: 1.4;
  }
  .prompt-meta {
    min-height: 40px;
    gap: 0.08rem;
  }
  .prompt-count {
    font-size: 0.66rem;
  }
  /* bottom bar: chips scroll, send fully on-screen */
  .composer-bar {
    gap: 0.3rem;
    align-items: center;
    min-width: 0;
    width: 100%;
  }
  .enhance-btn {
    font-size: 0.7rem;
    min-height: 24px;
    padding: 0.12rem 0.35rem;
    gap: 0.2rem;
  }
  .enhance-btn svg {
    width: 12px;
    height: 12px;
  }
  .composer-controls {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0.22rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0;
    /* no mask ? mask was eating half the last chip */
    mask-image: none;
    -webkit-mask-image: none;
  }
  .composer-controls::-webkit-scrollbar {
    display: none;
  }
  .ctrl {
    flex-shrink: 0;
  }
  .ctrl-btn {
    font-size: 0.72rem;
    min-height: 34px;
    padding: 0.26rem 0.45rem;
    gap: 0.22rem;
    max-width: none;
    border-radius: 999px;
  }
  /* Model label truncates so bar never overflows the send button */
  #btnModel {
    max-width: min(38vw, 140px);
  }
  #btnModel > span:not(.ico):not(.chev):not(.ico-ratio) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 5.5rem;
  }
  .ctrl-logo,
  .ctrl-btn .ico-svg,
  .ctrl-btn .ico-ratio {
    width: 13px;
    height: 13px;
  }
  .send-wrap {
    align-self: center;
    flex-shrink: 0;
  }
  .send-btn {
    width: 40px;
    height: 40px;
  }
  .send-btn svg,
  .send-btn .send-ico {
    width: 16px;
    height: 16px;
  }
  .composer.is-upscale-mode .send-btn {
    height: 40px;
    padding: 0 0.9rem 0 0.7rem;
    font-size: 0.8rem;
  }
  .composer.is-upscale-mode .send-btn .send-ico {
    width: 15px;
    height: 15px;
  }

  .prog-ring {
    min-width: 52px;
    min-height: 52px;
  }

  /* Tooltips off on touch for composer (they clip / overlap) */
  .composer .has-tip[data-tip]::before,
  .composer .has-tip[data-tip]::after {
    display: none !important;
  }

  /* Feed media fills width; no half-cut cards under composer */
  .feed-media.n1 .res-card,
  .feed-media.n1 .res-card[data-ratio="1:1"],
  .feed-media.n1 .res-card[data-ratio="9:16"],
  .feed-media.n1 .res-card[data-ratio="3:4"],
  .feed-media.n1 .res-card[data-ratio="2:3"],
  .feed-media.n1 .res-card[data-ratio="4:5"] {
    max-width: 100%;
  }
  .upscale-after-card .res-card {
    max-width: 100%;
  }

  /*
   * Mobile popovers: fixed bottom sheet.
   * Scrim is UNDER the sheet. Composer-dock must rise above the scrim while open,
   * otherwise fixed .pop stays trapped in dock's z-index:40 stacking context
   * and only the blur is visible.
   */
  .pop-scrim {
    display: none;
  }
  body.pop-open .pop-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  body.pop-open {
    overflow: hidden;
  }
  /* Lift entire dock (and its fixed pops) above the scrim */
  body.pop-open .composer-dock {
    z-index: 100;
    pointer-events: none; /* keep; .composer / body>.pop re-enable */
  }
  body.pop-open .composer {
    pointer-events: auto;
  }
  /* Pops reparented to <body> must stay clickable even when dock is none */
  body.pop-open > .pop,
  body.pop-open > .pop-sm,
  body.pop-open > .pop-model,
  body > .pop.pop-ported,
  body > .pop-sm.pop-ported,
  body > .pop-model.pop-ported {
    pointer-events: auto !important;
  }

  .pop,
  .pop-sm,
  .pop-model {
    position: fixed !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    max-height: min(72vh, 560px) !important;
    z-index: 110 !important;
    border-radius: 18px;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.55);
    pointer-events: auto !important;
    display: flex !important;
    flex-direction: column;
    touch-action: manipulation;
  }
  /* [hidden] must still win over display:flex above */
  .pop[hidden],
  .pop-sm[hidden],
  .pop-model[hidden] {
    display: none !important;
  }
  .pop-model {
    max-height: min(78vh, 640px) !important;
  }
  .pop-list {
    max-height: min(52vh, 420px);
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .pop-search input {
    font-size: 16px; /* iOS zoom prevent */
  }
}

/* Busy / error tip above send button */
.send-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 550;
  color: #e8e8e8;
  background: #222;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 70;
}
.send-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 14px;
  border: 5px solid transparent;
  border-top-color: #222;
}
.send-wrap:hover .send-tip:not([hidden]),
.send-wrap:focus-within .send-tip:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}
.send-tip[hidden] {
  display: none !important;
}
.send-tip.err {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
}

/* Popovers */
.pop-scrim[hidden] {
  display: none !important;
}
.pop-scrim {
  display: none; /* only used on mobile via media query */
}
.pop[hidden] {
  display: none !important;
}
.pop {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 60;
  background: #161616;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65);
  min-width: 180px;
  max-height: min(440px, 55vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* hide native scrollbars (Chrome/Edge/Firefox) */
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
  /* Don't chain wheel scroll into the page behind the popover */
  overscroll-behavior: contain;
}
/* Reparented to <body> while open ? always above composer / scrim */
body > .pop,
body > .pop-sm,
body > .pop-model,
body > .pop-ported {
  z-index: 110;
  pointer-events: auto;
}
/* Desktop: fixed float (JS sets left/bottom/top) ? not clipped by composer */
body > .pop.pop-desktop-float,
body > .pop-sm.pop-desktop-float,
body > .pop-model.pop-desktop-float {
  position: fixed !important;
  z-index: 120 !important;
  /* left/top/bottom/width set inline by positionDesktopPop */
  max-width: min(400px, calc(100vw - 24px));
  overflow: hidden;
  display: flex !important;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}
body > .pop.pop-desktop-float[hidden],
body > .pop-sm.pop-desktop-float[hidden],
body > .pop-model.pop-desktop-float[hidden] {
  display: none !important;
}
body > .pop.pop-desktop-float .pop-list,
body > .pop-model.pop-desktop-float .pop-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none; /* parent max-height constrains the sheet */
  overflow-y: auto;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
}
.pop-sm { min-width: 160px; }
.pop-model {
  width: min(400px, 92vw);
  left: 0;
  overflow-x: hidden;
}
.pop-title {
  font-size: 0.72rem;
  font-weight: 650;
  color: #6b6b6b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1rem 0.4rem;
}
.pop-search {
  padding: 0.85rem 0.85rem 0.45rem;
}
.pop-search input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0d0d0d;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.pop-search input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.16);
}
.pop-search input::placeholder { color: #555; }

.pop-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem 0.65rem;
}
.filter-chip {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1c1c1c;
  color: #9a9a9a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.filter-chip:hover {
  color: #e0e0e0;
  border-color: rgba(255, 255, 255, 0.14);
}
.filter-chip.active {
  background: #2a2a2a;
  color: #f5f5f5;
  border-color: rgba(255, 255, 255, 0.16);
}

.pop-list {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.2rem 0.35rem 0.65rem 0.5rem;
  max-height: 320px;
  scrollbar-width: thin; /* Firefox: thin vertical only */
  scrollbar-color: #3a3a3a transparent;
  /* Stop wheel scroll from leaking to the page when list hits top/bottom */
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
}
/* Vertical scrollbar only ? no bottom horizontal gutter */
.pop-list::-webkit-scrollbar {
  width: 6px;
  height: 0;
}
.pop-list::-webkit-scrollbar:horizontal {
  display: none;
  height: 0;
}
.pop-list::-webkit-scrollbar-track {
  background: transparent;
}
.pop-list::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 99px;
}
.pop-list::-webkit-scrollbar-corner {
  background: transparent;
  display: none;
}
.pop-list::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.model-opt {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.5rem;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
  overflow: hidden;
  /* Samsung/Android: let the browser handle taps without 300ms quirks / image drag */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
  pointer-events: auto;
  position: relative;
  z-index: 1;
  min-height: 48px; /* comfortable touch target */
}
.model-opt:hover { background: #222; }
.model-opt.active { background: #252525; }
.model-opt:active { background: #2a2a2a; }
.model-opt img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 5px;
  object-fit: contain;
  /* Taps on the logo must hit the button, not drag the image */
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.model-opt .name,
.model-opt .desc {
  pointer-events: none; /* entire row is the hit target */
}
.model-opt .name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.model-opt .desc {
  font-size: 0.78rem;
  color: #6b6b6b;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rich model detail panel (hover / long-press) */
.model-detail-pop {
  position: fixed;
  z-index: 200;
  width: min(340px, calc(100vw - 1.25rem));
  max-height: min(70vh, 420px);
  overflow: auto;
  padding: 0.85rem 0.95rem 0.95rem;
  border-radius: 14px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.35);
  color: #e8e8e8;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
  animation: mdPopIn 0.12s ease;
}
@keyframes mdPopIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.model-detail-pop[hidden] {
  display: none !important;
}
.model-detail-pop .md-head {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.model-detail-pop .md-head img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px;
  object-fit: contain;
}
.model-detail-pop .md-name {
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: #f4f4f5;
  line-height: 1.25;
}
.model-detail-pop .md-sub {
  font-size: 0.72rem;
  color: #8a8a8a;
  margin-top: 0.12rem;
}
.model-detail-pop .md-desc {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #c4c4c8;
}
.model-detail-pop .md-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}
.model-detail-pop .md-chip {
  font-size: 0.68rem;
  font-weight: 600;
  color: #d4d4d8;
  background: #252525;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.model-detail-pop .md-params {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  /* Space between the divider and first param row (Aspect ratios?) */
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.model-detail-pop .md-row {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 0.45rem;
  align-items: start;
}
.model-detail-pop .md-k {
  font-size: 0.7rem;
  font-weight: 650;
  color: #8b8b90;
  text-transform: capitalize;
  padding-top: 0.1rem;
}
.model-detail-pop .md-v {
  font-size: 0.75rem;
  color: #e4e4e7;
  line-height: 1.35;
  word-break: break-word;
}
.model-detail-pop .md-id {
  margin-top: 0.7rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.68rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #6b6b70;
  word-break: break-all;
}

@media (max-width: 640px) {
  .model-detail-pop {
    /* On phone, pin near bottom of viewport so it isn't clipped */
    left: 0.6rem !important;
    right: 0.6rem !important;
    width: auto !important;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    top: auto !important;
    max-height: 45vh;
  }
}

.pop-opts { padding: 0.3rem 0.4rem 0.55rem; }
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.opt:hover { background: #222; }
.opt.active { color: #fff; background: #222; }
.opt .check { color: var(--ok); font-size: 0.9rem; }
.opt-logo {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  background: #0a0a0a;
  margin-right: 0.45rem;
}
#audioToolList .opt {
  justify-content: flex-start;
}

/* TTS voice library popover */
.pop-voice {
  width: min(360px, 92vw);
  max-height: min(480px, 70vh);
  display: flex;
  flex-direction: column;
}
.pop-voice .pop-search {
  padding: 0 0.65rem 0.45rem;
}
.pop-voice .pop-search input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c0c0e;
  color: #f0f0f0;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.7rem;
  outline: none;
}
.pop-voice .pop-search input:focus {
  border-color: rgba(255, 255, 255, 0.28);
}
.voice-list {
  flex: 1;
  overflow-y: auto;
  max-height: 280px;
  padding: 0.15rem 0.4rem 0.4rem;
}
.voice-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: none;
  background: transparent;
  color: #e8e8ee;
  font: inherit;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
}
.voice-row:hover {
  background: #222;
}
.voice-row.active {
  background: #2a2a30;
}
.voice-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.voice-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-row-meta {
  font-size: 0.72rem;
  color: #8a8a90;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-preview {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1a1a1e;
  color: #e8e8ee;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0;
}
.voice-preview:hover {
  background: #2a2a30;
}
.voice-list-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.voice-list-count {
  font-size: 0.75rem;
}
.pop-empty {
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: 0.85rem;
}

/* TTS settings popover */
.pop-tts-settings {
  width: min(300px, 92vw);
}
.tts-settings {
  padding: 0.35rem 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.tts-slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #b0b0b8;
  font-weight: 550;
}
.tts-slider-row em {
  font-style: normal;
  color: #f0f0f0;
  font-variant-numeric: tabular-nums;
  float: right;
}
.tts-slider-row input[type="range"] {
  width: 100%;
  accent-color: #e8e8ee;
}
.tts-check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #d4d4d8;
  cursor: pointer;
}
.tts-check-row input {
  accent-color: #e8e8ee;
}
.tts-select-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: #b0b0b8;
  font-weight: 550;
}
.tts-select-row select,
.tts-seed-input {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0c0c0e;
  color: #f0f0f0;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  outline: none;
}
.tts-seed-input {
  width: 100%;
  box-sizing: border-box;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 2rem;
  padding-top: max(2rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
}
.lightbox[hidden] { display: none !important; }
.lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 88vh;
  max-height: 88dvh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
@media (max-width: 640px) {
  .lightbox {
    padding: 0.75rem;
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  }
  .lightbox img {
    max-width: 100%;
    max-height: min(88dvh, 88vh);
    border-radius: 8px;
  }
}
/* Must beat .has-tip[data-tip]{position:relative} so grid doesn't center the ? */
.lightbox .lb-close,
.lightbox .lb-close.has-tip {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  left: auto;
  bottom: auto;
  margin: 0;
  border: none;
  background: #222;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.lightbox .lb-close:hover {
  background: #2e2e2e;
}
.lightbox .lb-actions {
  position: absolute;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  z-index: 2;
  max-width: calc(100vw - 2rem);
}
.lightbox .lb-actions[hidden] {
  display: none !important;
}
.lb-act {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(28, 28, 28, 0.94);
  color: #f0f0f0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
  white-space: nowrap;
}
.lb-act:hover {
  background: rgba(48, 48, 48, 0.96);
  border-color: rgba(255, 255, 255, 0.28);
}
.lb-act:active {
  transform: scale(0.98);
}
.lb-act.primary {
  background: rgba(124, 156, 255, 0.22);
  border-color: rgba(124, 156, 255, 0.45);
  color: #e8eeff;
}
.lb-act.primary:hover {
  background: rgba(124, 156, 255, 0.32);
  border-color: rgba(124, 156, 255, 0.6);
}
.lb-act svg {
  flex-shrink: 0;
}
/* Edit = same dark pill as Reference/Upscale, subtle blue border only (no flash) */
.card-act[data-act="open-canvas"] {
  background: rgba(22, 22, 22, 0.94);
  border-color: rgba(124, 156, 255, 0.4);
  color: #e8eeff;
}
.card-act[data-act="open-canvas"]:hover {
  background: rgba(40, 40, 40, 0.96);
  border-color: rgba(124, 156, 255, 0.55);
  color: #f0f4ff;
}
.card-act[data-act="open-canvas"]:active {
  background: rgba(34, 34, 34, 0.96);
  border-color: rgba(124, 156, 255, 0.6);
  color: #e8eeff;
}

/* Workspace switch (Image | Music | Canvas) ? full-width segmented bar */
.workspace-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  max-width: 100%;
  margin: 0 0 0.85rem;
  flex: 0 0 auto;
}
.workspace-bar .workspace-switch {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
.workspace-switch {
  display: flex;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 0.25rem;
  padding: 0.28rem;
  margin: 0 0 0.85rem;
  background: #0c0c0c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  overflow: visible;
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
}
.ws-btn {
  border: none;
  background: transparent;
  color: #8a8a8a;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 11px;
  cursor: pointer;
  min-height: 40px;
  flex: 1 1 0;
  justify-content: center;
  transition:
    color 0.14s ease,
    background 0.14s ease,
    box-shadow 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: -0.01em;
}
/* Author display:flex must not override the hidden attribute (NSFW tab until unlock) */
.ws-btn[hidden] {
  display: none !important;
}
.ws-btn:hover {
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.04);
}
.ws-btn.active {
  background: #262626;
  color: #fafafa;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.35);
}
.ws-btn:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.55);
  outline-offset: 2px;
}
.ws-panel[hidden] { display: none !important; }
.ws-panel.is-active { display: block; }
.ws-panel.is-active.canvas-workspace { display: flex; }
.ws-panel.is-active.nsfw-workspace { display: flex; }

/* ?? Audio workspace (feed top + composer dock) ?? */
.audio-workspace {
  width: 100%;
  /* Leave room for fixed composer; fill viewport so empty state can truly center */
  min-height: calc(100dvh - 61px - 12rem);
  min-height: calc(100vh - 61px - 12rem);
  padding-bottom: 8.5rem;
  display: flex;
  flex-direction: column;
}
.ws-panel.is-active.audio-workspace {
  display: flex;
}

/* Empty state: dead-center in the available area (above composer) */
.audio-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  gap: 1.35rem;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  /* Optical center: composer sits lower, shift content slightly up */
  transform: translateY(-6vh);
}
.audio-empty[hidden] {
  display: none !important;
}
.audio-empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
.audio-empty-hero h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: #f4f4f5;
}
.audio-empty-sub {
  margin: 0;
  font-size: 0.92rem;
  color: #71717a;
  line-height: 1.45;
  font-weight: 500;
}
.audio-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}
.audio-chip-prompt {
  appearance: none;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #141416;
  color: #d4d4d8;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.audio-chip-prompt:hover {
  background: #1c1c20;
  border-color: rgba(255, 255, 255, 0.18);
  color: #fafafa;
}

/* Generations list ? only when there are results */
.audio-feed[hidden] {
  display: none !important;
}
.audio-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.25rem 0 0.75rem;
}
.audio-feed-head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  color: #e4e4e7;
  letter-spacing: -0.02em;
}
.audio-results-feed {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 1rem;
}
.audio-composer-dock[hidden] {
  display: none !important;
}
.audio-composer .prompt-wrap {
  margin-bottom: 0.15rem;
}
.audio-composer .composer-input {
  min-height: 52px;
  max-height: 140px;
  resize: none;
}
.audio-influence-pop {
  padding: 0.65rem 0.85rem 0.85rem;
  min-width: 200px;
}
.audio-influence-pop input[type="range"] {
  width: 100%;
  accent-color: #e8e8ee;
}
.audio-influence-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #7a7a82;
  margin-top: 0.35rem;
}
#audioStatus.is-show {
  display: inline-block !important;
  pointer-events: none;
  font-size: 0.8rem;
  color: #c8c8d0;
  max-width: 12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#audioStatus.is-err {
  color: #f87171;
}
#audioStatus.is-ok {
  color: #34d399;
}
.ctrl-btn.active,
.ctrl-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Audio generation rows (in same feed width as Image) */
.audio-feed-row.feed-row {
  /* reset image feed 2-col grid */
  grid-template-columns: 36px minmax(0, 1.15fr) minmax(90px, 1.4fr) 42px 34px;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.45rem;
  margin-bottom: 0.25rem;
}
.sfx-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1.15fr) minmax(90px, 1.4fr) 42px 34px;
  align-items: center;
  gap: 0.55rem 0.65rem;
  padding: 0.55rem 0.45rem;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.sfx-row:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.06);
}
.sfx-row.is-playing {
  background: rgba(124, 156, 255, 0.07);
  border-color: rgba(124, 156, 255, 0.18);
}
.sfx-play {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1a1a1e;
  color: #f2f2f5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.sfx-play:hover:not(:disabled) {
  background: #26262c;
  border-color: rgba(255, 255, 255, 0.22);
}
.sfx-play:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sfx-row.is-playing .sfx-play {
  background: #f5f5f7;
  color: #111;
  border-color: #f5f5f7;
}
.sfx-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.sfx-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #ececf0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sfx-sub {
  font-size: 0.72rem;
  color: #7d7d88;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sfx-wave {
  position: relative;
  height: 36px;
  border: none;
  background: transparent;
  padding: 0 0.15rem;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  border-radius: 6px;
}
.sfx-wave:disabled {
  cursor: default;
  opacity: 0.55;
}
.sfx-wave-bars {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5px;
  height: 100%;
  width: 100%;
}
.sfx-bar {
  flex: 1 1 0;
  min-width: 1.5px;
  max-width: 3px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.28);
  align-self: center;
  transition: background 0.12s;
}
.sfx-row:hover .sfx-bar {
  background: rgba(255, 255, 255, 0.42);
}
.sfx-row.is-playing .sfx-bar {
  background: rgba(180, 200, 255, 0.55);
}
.sfx-wave-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(124, 156, 255, 0.22),
    rgba(124, 156, 255, 0.08)
  );
  border-right: 1px solid rgba(180, 200, 255, 0.55);
  transition: width 0.08s linear;
}
.sfx-dur {
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #9a9aa3;
  text-align: right;
}
.sfx-dl {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a0a0aa;
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.sfx-dl:hover {
  color: #f0f0f4;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
.sfx-dl.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

@media (max-width: 720px) {
  .sfx-row {
    grid-template-columns: 34px minmax(0, 1fr) 36px;
    grid-template-areas:
      "play meta dl"
      "play wave wave"
      "play dur dur";
  }
  .sfx-play { grid-area: play; align-self: start; margin-top: 2px; }
  .sfx-meta { grid-area: meta; }
  .sfx-wave { grid-area: wave; height: 32px; }
  .sfx-dur { grid-area: dur; text-align: left; }
  .sfx-dl { grid-area: dl; justify-self: end; }
}

/* Hide image composer + image results feed in audio mode; audio dock stays */
.pg-body.is-audio-mode .composer-dock:not(.audio-composer-dock),
.pg-body.is-audio-mode > .pg > .pg-main > .pg-results,
.pg-body.is-audio-mode #results {
  display: none !important;
}
.pg-body.is-audio-mode .audio-composer-dock {
  display: block;
}
.pg-body.is-audio-mode .audio-composer-dock[hidden] {
  display: none !important;
}

/* ?? Canvas workspace ?????????????????????????????????????????? */
.canvas-workspace {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: min(62vh, 560px);
  margin-bottom: 0.5rem;
}
.canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem;
  background: #121212;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}
.cv-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
label.cv-tool { cursor: pointer; }
.cv-tool:hover { color: #e8e8e8; background: rgba(255, 255, 255, 0.06); }
.cv-tool.active {
  color: #f5f5f5;
  background: #262626;
  border-color: rgba(255, 255, 255, 0.12);
}
.cv-tool svg { display: block; pointer-events: none; }
.cv-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 0.15rem;
  flex-shrink: 0;
}
.cv-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}
.cv-draw-opts,
.cv-pen-opts {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.15rem;
  flex-wrap: wrap;
}
.cv-draw-opts[hidden],
.cv-pen-opts[hidden] { display: none !important; }
.cv-draw-opts input[type="color"],
.cv-pen-opts input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: #1a1a1a;
  cursor: pointer;
}
.cv-draw-opts input[type="range"],
.cv-pen-opts input[type="range"] {
  width: 72px;
  accent-color: #a1a1aa;
}
.cv-swatches {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}
.cv-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: var(--sw, #7c9cff);
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.cv-swatch.active {
  outline: 2px solid #e8e8e8;
  outline-offset: 1px;
}
.cv-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #8a8a8a;
  font-size: 0.72rem;
  font-weight: 600;
}
.cv-size-wrap span {
  min-width: 1.2rem;
  color: #a1a1aa;
}
.cv-zoom-label {
  border: 1px solid transparent;
  background: transparent;
  color: #a1a1aa;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  min-width: 2.6rem;
  text-align: center;
}
.cv-zoom-label:hover {
  color: #e8e8e8;
  background: rgba(255, 255, 255, 0.06);
}
.canvas-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 200px);
  gap: 0.65rem;
  min-height: min(52vh, 480px);
  flex: 1;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
}
.canvas-stage-wrap {
  min-width: 0;
  min-height: min(52vh, 480px);
  height: 100%;
  align-self: stretch;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  overflow: auto;
  /* Absolute stage fills this box so empty-state can true-center */
  position: relative;
}
.canvas-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  outline: none;
  touch-action: none;
  box-sizing: border-box;
  /* Grow with content when image is larger than the panel (scrollable wrap) */
  overflow: visible;
}
/* Empty drop zone fills the full panel and centers content */
.canvas-empty {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  color: #a1a1aa;
  text-align: center;
  padding: 1.5rem;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 1;
}
.canvas-empty[hidden] {
  display: none !important;
}
.canvas-empty p {
  margin: 0;
}
/* Loaded image: flow inside stage for scroll; stage grows with content */
.canvas-stage:has(#canvasStack:not([hidden])) {
  position: relative;
  inset: auto;
  height: auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.canvas-empty .faint { color: #5c5c5c; font-size: 0.85rem; }
.canvas-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin-top: 0.5rem;
  pointer-events: auto;
}
.canvas-empty .cv-upload-btn {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1a1a1a;
  color: #e8e8e8;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}
.canvas-empty .cv-upload-btn.ghost {
  background: transparent;
  color: #a1a1aa;
}
.canvas-empty .cv-upload-btn:hover {
  background: #222;
  border-color: rgba(255, 255, 255, 0.18);
  color: #e8e8e8;
}
.cv-shortcuts-hint {
  margin-top: 0.75rem !important;
  max-width: 28rem;
  line-height: 1.4;
  font-size: 0.72rem !important;
}
.canvas-stack {
  position: relative;
  display: block;
  margin: 12px auto;
  line-height: 0;
  user-select: none;
}
.canvas-stack[hidden] { display: none !important; }
.canvas-stack img#canvasBaseImg {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}
.canvas-stack canvas#canvasDraw {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.canvas-html-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.canvas-html-layer .cv-sticker,
.canvas-html-layer .cv-note {
  pointer-events: auto;
  position: absolute;
  transform-origin: center center;
  cursor: grab;
}
.canvas-html-layer .cv-sticker {
  border: 1.5px solid transparent;
  border-radius: 4px;
  box-sizing: border-box;
}
.canvas-html-layer .cv-sticker img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.canvas-html-layer .cv-sticker.selected {
  border-color: rgba(124, 156, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(124, 156, 255, 0.35);
}
.canvas-html-layer .cv-sticker .cv-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  right: -6px;
  bottom: -6px;
  border-radius: 3px;
  background: #7c9cff;
  border: 1px solid #fff;
  cursor: nwse-resize;
  display: none;
}
.canvas-html-layer .cv-sticker.selected .cv-handle,
.canvas-html-layer .cv-sticker.selected .cv-handle-rot {
  display: block;
}
.canvas-html-layer .cv-sticker .cv-handle-rot {
  position: absolute;
  width: 12px;
  height: 12px;
  left: 50%;
  top: -18px;
  margin-left: -6px;
  border-radius: 50%;
  background: #f0c14b;
  border: 1px solid #fff;
  cursor: grab;
  display: none;
}
.canvas-html-layer .cv-sticker .cv-handle-rot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 8px;
  background: rgba(240, 193, 75, 0.8);
  transform: translateX(-50%);
}
/* Pin: position is the DOT center. Label expands to the right only. */
.canvas-html-layer .cv-pin {
  pointer-events: auto;
  position: absolute;
  /* Anchor at pin center ? do NOT re-center when label grows */
  transform: translate(-50%, -50%);
  cursor: grab;
  z-index: 5;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: 0;
  height: 0;
  overflow: visible;
}
.canvas-html-layer .cv-pin:active {
  cursor: grabbing;
}
.canvas-html-layer .cv-pin-inner {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  /* Shift so the DOT (not the whole row) sits on the anchor */
  margin-left: -13px; /* half of 26px dot */
  max-width: min(280px, 55vw);
  pointer-events: none;
}
.canvas-html-layer .cv-pin-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pin, #7c9cff);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
  pointer-events: none;
}
.canvas-html-layer .cv-pin.selected .cv-pin-dot {
  box-shadow: 0 0 0 2px rgba(124, 156, 255, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
}
.canvas-html-layer .cv-pin-label {
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(240px, 50vw);
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  background: rgba(22, 22, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e8e8e8;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.canvas-html-layer .cv-note {
  min-width: 100px;
  max-width: min(220px, 50vw);
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(22, 22, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e8e8e8;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  cursor: grab;
  white-space: pre-wrap;
  word-break: break-word;
}
.canvas-html-layer .cv-note.selected {
  border-color: rgba(124, 156, 255, 0.7);
}
.canvas-html-layer .cv-note.is-empty {
  color: #71717a;
  font-style: italic;
}
.canvas-side {
  min-width: 0;
  max-width: 100%;
  background: #121212;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.65rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(52vh, 480px);
  /* Vertical only ? no bottom horizontal scrollbar */
  overflow-x: clip;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.canvas-side::-webkit-scrollbar {
  width: 6px;
  height: 0; /* hide horizontal track entirely */
}
.canvas-side::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.canvas-side-head {
  font-size: 0.78rem;
  font-weight: 650;
  color: #a1a1aa;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.canvas-layers {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.cv-layer-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.35rem 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #1a1a1a;
  color: #c4c4c8;
  font-size: 0.78rem;
  font-weight: 550;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
.cv-layer-item:hover { border-color: rgba(255, 255, 255, 0.1); }
.cv-layer-item.selected {
  border-color: rgba(124, 156, 255, 0.4);
  background: #1e2230;
  color: #e8eeff;
}
.cv-layer-item.locked {
  opacity: 0.85;
  cursor: default;
}
.cv-layer-item.is-base .cv-layer-del {
  opacity: 0.7;
}
.cv-layer-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cv-layer-del {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b6b72;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.cv-layer-item:hover .cv-layer-del,
.cv-layer-item.selected .cv-layer-del {
  opacity: 1;
}
.cv-layer-del:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
}

/* Canvas right-click context menu */
.cv-ctx-menu {
  position: fixed;
  z-index: 12000;
  min-width: 11.5rem;
  max-width: min(260px, calc(100vw - 16px));
  padding: 0.3rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #1a1a1f 0%, #121216 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 1px;
  color-scheme: dark;
}
.cv-ctx-menu[hidden] {
  display: none !important;
}
.cv-ctx-head {
  padding: 0.35rem 0.55rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #71717a;
  user-select: none;
}
.cv-ctx-sep {
  height: 1px;
  margin: 0.25rem 0.35rem;
  background: rgba(255, 255, 255, 0.08);
}
.cv-ctx-item {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  color: #e4e4e7;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.25;
  box-sizing: border-box;
  transition: background 0.1s, color 0.1s;
}
.cv-ctx-item:hover,
.cv-ctx-item:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: #fafafa;
  outline: none;
}
.cv-ctx-item.is-danger {
  color: #fca5a5;
}
.cv-ctx-item.is-danger:hover,
.cv-ctx-item.is-danger:focus-visible {
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
}
.cv-ctx-label {
  flex: 1 1 auto;
  min-width: 0;
}
.cv-ctx-kbd {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  color: #71717a;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cv-ctx-item:hover .cv-ctx-kbd,
.cv-ctx-item:focus-visible .cv-ctx-kbd {
  color: #a1a1aa;
}
.canvas-props,
.canvas-note-edit {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.canvas-props[hidden],
.canvas-note-edit[hidden] { display: none !important; }
.canvas-side-head.subtle {
  font-size: 0.72rem;
  color: #71717a;
  margin: 0;
}
.canvas-note-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #8a8a8a;
}
#canvasNoteInput {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: #0c0c0c;
  color: #e8e8e8;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 0.6rem;
  outline: none;
}
#canvasNoteInput:focus {
  border-color: rgba(124, 156, 255, 0.4);
}
.canvas-prop-extra {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.canvas-prop-extra[hidden] { display: none !important; }
.canvas-prop-extra input[type="range"] {
  width: 100%;
  accent-color: #7c9cff;
}
.canvas-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.cv-mini {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #222;
  color: #e8e8e8;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}
.cv-mini:hover { background: #2a2a2a; }
.cv-mini.ghost {
  background: transparent;
  color: #a1a1aa;
}
.canvas-side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.canvas-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 0.55rem 0.85rem;
  border: none;
  border-radius: 12px;
  background: #f4f4f5;
  color: #0a0a0a;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s, opacity 0.12s;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset;
  box-sizing: border-box;
}
.canvas-generate-btn:hover:not(:disabled) {
  background: #ffffff;
}
.canvas-generate-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.canvas-generate-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.canvas-generate-btn.loading {
  opacity: 0.7;
  cursor: wait;
}
.canvas-generate-btn svg {
  flex-shrink: 0;
}
/* Canvas mode: keep USING CANVAS chip; still allow Image reference chips + attach
   (users were confused when chips vanished / only feed "use as reference" seemed to work). */
.pg-body.is-canvas-mode .ref-rail {
  opacity: 1;
  pointer-events: auto;
}
.pg-body.is-canvas-mode .ref-chips {
  display: flex !important;
}
.pg-body.is-canvas-mode .ref-attach {
  display: inline-flex !important;
}
.pg-body.is-canvas-mode .ref-rail.is-empty {
  margin-bottom: 0.55rem;
}
.pg-body:not(.is-canvas-mode) .canvas-using {
  display: none !important;
}

.canvas-using {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 0.85rem 0 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(124, 156, 255, 0.35);
  background: rgba(30, 34, 48, 0.95);
  color: #d4dcff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  user-select: none;
}
.canvas-using[hidden] {
  display: none !important;
}
.canvas-using-thumb {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.canvas-using-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.canvas-using-thumb img[hidden] {
  display: none !important;
}
.canvas-using-placeholder {
  color: #5c5c66;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}
.canvas-using-thumb:has(img:not([hidden])) .canvas-using-placeholder {
  display: none;
}
.canvas-using-label {
  white-space: nowrap;
}

/* Feed sits under canvas stage so results stay visible after generate */
.pg-body.is-canvas-mode .pg-results {
  margin-top: 0.75rem;
}
.pg-body.is-canvas-mode .pg-results:empty {
  display: none;
}

@media (max-width: 720px) {
  .canvas-body {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .canvas-side {
    max-height: 280px;
    order: 2;
  }
  .canvas-stage-wrap {
    min-height: 240px;
    order: 1;
  }
  .canvas-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .canvas-toolbar::-webkit-scrollbar { display: none; }
  .cv-tool {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }
  .canvas-html-layer .cv-sticker .cv-handle {
    width: 16px;
    height: 16px;
    right: -8px;
    bottom: -8px;
  }
  .canvas-html-layer .cv-sticker .cv-handle-rot {
    width: 16px;
    height: 16px;
    top: -22px;
    margin-left: -8px;
  }
  .cv-shortcuts-hint {
    display: none;
  }
  .canvas-toolbar {
    row-gap: 0.35rem;
  }
}

/* ?? Agent workspace ????????????????????????????????????????? */
.ws-panel.is-active.agent-workspace {
  display: flex;
  flex-direction: column;
}
.agent-workspace {
  min-height: min(72vh, 680px);
  margin-bottom: 0.5rem;
}
.agent-shell {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 680px);
  max-height: calc(100vh - 130px);
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow: hidden;
}
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: #0c0c0c;
}
.agent-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: #f4f4f5;
  letter-spacing: -0.02em;
}
.agent-sub {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: #71717a;
}
.agent-clear-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #a1a1aa;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}
.agent-clear-btn:hover {
  color: #e8e8e8;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

/* Messages ? thin modern scrollbar (no Windows arrow chrome) */
.agent-messages {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.1rem 1.15rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 200px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.agent-messages::-webkit-scrollbar {
  width: 6px;
}
.agent-messages::-webkit-scrollbar-track {
  background: transparent;
}
.agent-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.agent-messages::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.agent-welcome {
  margin: auto;
  text-align: center;
  max-width: 26rem;
  padding: 1.5rem 1rem;
  color: #a1a1aa;
}
.agent-welcome p {
  margin: 0 0 0.4rem;
}
.agent-welcome .faint {
  color: #5c5c66;
  font-size: 0.88rem;
  line-height: 1.45;
}
.agent-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 1rem;
}
.agent-chip {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #161616;
  color: #c4c4c8;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 550;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.agent-chip:hover {
  background: #1e1e1e;
  border-color: rgba(124, 156, 255, 0.35);
  color: #e8eeff;
}
.agent-msg {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: min(560px, 92%);
}
.agent-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.agent-msg-bot {
  align-self: flex-start;
  align-items: flex-start;
}
.agent-bubble {
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}
.agent-msg-user .agent-bubble {
  background: #262626;
  color: #f4f4f5;
  border-bottom-right-radius: 6px;
}
.agent-msg-bot .agent-bubble {
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e4e4e7;
  border-bottom-left-radius: 6px;
}
.agent-bubble.faint {
  color: #71717a;
}
.agent-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #a1a1aa !important;
}
.agent-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #71717a;
  animation: agent-pulse 1s ease-in-out infinite;
}
.agent-dot:nth-child(2) { animation-delay: 0.15s; }
.agent-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes agent-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}
.agent-status-text {
  font-size: 0.82rem;
  margin-left: 0.25rem;
}
.agent-msg-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.agent-img-btn {
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  display: block;
  max-width: min(280px, 70vw);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.agent-img-btn img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: cover;
  background: #0a0a0a;
}
.agent-result {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.agent-result-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.agent-mini {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a1a1a;
  color: #c4c4c8;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}
.agent-mini:hover {
  background: #242424;
  color: #f0f0f0;
  border-color: rgba(255, 255, 255, 0.16);
}

/* Composer bar ? single clean pill, no native textarea chrome */
.agent-composer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.75rem 0.9rem 0.95rem;
  background: #0c0c0c;
}
.agent-attach-row {
  margin-bottom: 0.5rem;
}
.agent-attach-row[hidden] {
  display: none !important;
}
.agent-attach-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.agent-att {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.agent-att img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.agent-att-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.agent-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  min-width: 0;
}
.agent-icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: #141414;
  color: #a1a1aa;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.agent-icon-btn:hover {
  color: #e8e8e8;
  background: #1c1c1c;
}
.agent-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.agent-input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: #121212;
  color: #f4f4f5;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 0.65rem 0.9rem;
  min-height: 42px;
  max-height: 120px;
  height: 42px;
  outline: none;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  /* Kill native Windows textarea scrollbar chrome */
  scrollbar-width: none;
  -ms-overflow-style: none;
  field-sizing: fixed;
  appearance: none;
  -webkit-appearance: none;
}
.agent-input::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.agent-input::-webkit-resizer,
.agent-input::-webkit-scrollbar-button,
.agent-input::-webkit-inner-spin-button,
.agent-input::-webkit-outer-spin-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
.agent-input:focus {
  border-color: rgba(255, 255, 255, 0.18);
  background: #141414;
}
.agent-input:disabled {
  opacity: 0.6;
}
.agent-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: #e8e8e8;
  color: #0a0a0a;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, transform 0.1s;
}
.agent-send:hover {
  background: #fff;
}
.agent-send:active {
  transform: scale(0.97);
}
.agent-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pg-body.is-agent-mode .composer-dock {
  display: none !important;
}
.pg-body.is-agent-mode .pg-results {
  display: none !important;
}
/* Agent fills page without bottom composer dock */
.pg-body.is-agent-mode .pg {
  padding-bottom: 1.25rem;
}
@media (max-width: 720px) {
  .agent-shell {
    max-height: calc(100vh - 110px);
    min-height: 62vh;
    border-radius: 14px;
  }
  .agent-img-btn {
    max-width: min(220px, 80vw);
  }
  .agent-messages {
    padding: 0.85rem 0.75rem 0.75rem;
  }
  .agent-composer {
    padding: 0.65rem 0.7rem 0.8rem;
  }
}

/* ?? Music workspace ??????????????????????????????????????????????? */
/* Same content width as Image/Canvas ? only drop bottom composer reserve */
.pg-body.is-music-mode .pg {
  max-width: var(--pg-content-max, 980px);
  padding-top: 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  min-height: 0;
}
.pg-body.is-music-mode .pg-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* nav(~61) + switch(~48) + pg pad ? keep panels fully on screen */
  height: calc(100dvh - 61px - 3.25rem);
  height: calc(100vh - 61px - 3.25rem);
  max-height: calc(100dvh - 61px - 3.25rem);
  max-height: calc(100vh - 61px - 3.25rem);
}
.pg-body.is-music-mode .workspace-switch {
  margin-bottom: 0.65rem;
}

.music-workspace {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.ws-panel.is-active.music-workspace {
  display: flex;
}
.music-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  align-items: stretch;
  box-sizing: border-box;
}
.music-lyrics-pane {
  display: flex;
  flex-direction: column;
  background: #121214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
}
.music-lyrics-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.9rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.music-lyrics-titles {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 0.25rem;
}
.music-pane-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #f4f4f5;
  line-height: 1.25;
}
.music-pane-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: #71717a;
  font-weight: 500;
  line-height: 1.35;
  /* Keep subtitle from shoving the toggle down */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.music-mode-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-self: flex-start; /* top-right, aligned with title */
  margin-top: 0;
  padding: 3px;
  border-radius: 999px;
  background: #0a0a0b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 2px;
  white-space: nowrap;
}
.music-mode-btn {
  appearance: none;
  border: 0;
  margin: 0;
  background: transparent;
  color: #a1a1aa;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.music-mode-btn:hover {
  color: #e4e4e7;
}
.music-mode-btn.is-active {
  background: #262626;
  color: #fafafa;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.music-lyrics-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.65rem 0.85rem 0.75rem;
  gap: 0.45rem;
  overflow: hidden;
}
.music-lyrics-input {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  resize: none;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: #0c0c0e;
  color: #e4e4e7;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.55;
  padding: 0.75rem 0.85rem;
  outline: none;
  transition: border-color 0.12s;
  overflow-y: auto;
  /* Dark thin scrollbar ? no white Windows chrome */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.music-lyrics-input::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.music-lyrics-input::-webkit-scrollbar-track {
  background: transparent;
}
.music-lyrics-input::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.music-lyrics-input::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}
.music-lyrics-input::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.music-lyrics-input::-webkit-scrollbar-corner {
  background: transparent;
}
.music-lyrics-input:focus {
  border-color: rgba(255, 255, 255, 0.2);
}
.music-lyrics-input::placeholder {
  color: #52525b;
}
.music-lyrics-input.is-enhancing {
  cursor: wait;
  color: #d4d4d8;
  border-color: hsla(210, 70%, 55%, 0.35);
  background:
    linear-gradient(
      110deg,
      #0c0c0e 0%,
      #12141a 40%,
      #0c0c0e 80%
    );
  background-size: 200% 100%;
  animation: musicEnhanceShimmer 1.6s ease-in-out infinite;
  caret-color: transparent;
  user-select: none;
}
.music-lyrics-input.is-enhancing:focus {
  border-color: hsla(210, 70%, 55%, 0.45);
  outline: none;
}
@keyframes musicEnhanceShimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .music-lyrics-input.is-enhancing {
    animation: none;
  }
}
.music-lyrics-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  padding-top: 0.1rem;
}
.music-lyrics-foot-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  min-width: 0;
}
.music-token-count {
  font-weight: 600;
  color: #a1a1aa;
  font-variant-numeric: tabular-nums;
}
.music-token-count.is-over,
.music-token-hint.is-over {
  color: #f87171;
}
.music-enhance-btn {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e4e4e7;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}
.music-enhance-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fafafa;
}
.music-enhance-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.music-enhance-btn.is-busy {
  opacity: 0.7;
}
.music-instrumental-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.music-instrumental-body::-webkit-scrollbar {
  width: 6px;
}
.music-instrumental-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.music-instrumental-body::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.music-instrumental-body[hidden] {
  display: none !important;
}
.music-lyrics-body[hidden] {
  display: none !important;
}
.music-instrumental-card {
  text-align: center;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.music-instrumental-ico {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #1a1a1e;
  color: #d4d4d8;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.music-instrumental-card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: #f4f4f5;
}
.music-instrumental-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.music-main-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  background: #121214;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}
.music-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.25rem 1rem;
  gap: 1rem;
  min-height: 0;
  overflow: auto;
}
.music-empty[hidden] {
  display: none !important;
}
.music-empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.music-empty-hero h2 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: #f4f4f5;
}
.music-empty-sub {
  margin: 0;
  max-width: 360px;
  font-size: 0.9rem;
  color: #71717a;
  line-height: 1.45;
  font-weight: 500;
}

/* Empty-state equalizer ? same vibe as voice-wave */
.music-empty-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3.5px;
  height: 44px;
  margin: 0 0 0.85rem;
  color: #7c9cff;
  filter: drop-shadow(0 0 12px rgba(124, 156, 255, 0.28));
}
.music-empty-wave span {
  display: block;
  width: 3.5px;
  border-radius: 99px;
  background: linear-gradient(180deg, #a5b8ff 0%, #7c9cff 55%, #6366f1 100%);
  opacity: 0.8;
  transform-origin: center bottom;
  animation: musicEmptyWave 1.15s ease-in-out infinite;
}
.music-empty-wave span:nth-child(1)  { height: 11px; animation-delay: 0s; }
.music-empty-wave span:nth-child(2)  { height: 20px; animation-delay: 0.07s; }
.music-empty-wave span:nth-child(3)  { height: 30px; animation-delay: 0.14s; }
.music-empty-wave span:nth-child(4)  { height: 16px; animation-delay: 0.21s; }
.music-empty-wave span:nth-child(5)  { height: 36px; animation-delay: 0.28s; }
.music-empty-wave span:nth-child(6)  { height: 22px; animation-delay: 0.35s; }
.music-empty-wave span:nth-child(7)  { height: 14px; animation-delay: 0.42s; }
.music-empty-wave span:nth-child(8)  { height: 28px; animation-delay: 0.49s; }
.music-empty-wave span:nth-child(9)  { height: 38px; animation-delay: 0.56s; }
.music-empty-wave span:nth-child(10) { height: 18px; animation-delay: 0.63s; }
.music-empty-wave span:nth-child(11) { height: 32px; animation-delay: 0.7s; }
.music-empty-wave span:nth-child(12) { height: 12px; animation-delay: 0.77s; }
.music-empty-wave span:nth-child(13) { height: 24px; animation-delay: 0.84s; }
.music-empty-wave span:nth-child(14) { height: 34px; animation-delay: 0.91s; }
.music-empty-wave span:nth-child(15) { height: 15px; animation-delay: 0.98s; }
.music-empty-wave span:nth-child(16) { height: 21px; animation-delay: 1.05s; }
@keyframes musicEmptyWave {
  0%, 100% { transform: scaleY(0.45); opacity: 0.4; }
  50% { transform: scaleY(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .music-empty-wave span {
    animation: none;
    opacity: 0.7;
    transform: none;
  }
}
.music-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}
.music-chip-prompt {
  appearance: none;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #141416;
  color: #d4d4d8;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.music-chip-prompt:hover {
  background: #1c1c20;
  border-color: rgba(255, 255, 255, 0.18);
  color: #fafafa;
}

.music-feed {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.9rem 1rem 0.75rem;
  gap: 0.75rem;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.music-feed::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.music-feed::-webkit-scrollbar-track {
  background: transparent;
}
.music-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}
.music-feed::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}
.music-feed::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
.music-feed::-webkit-scrollbar-corner {
  background: transparent;
}
.music-feed[hidden] {
  display: none !important;
}
.music-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.music-feed-head-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.music-feed-head-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}
.music-vol {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.45rem 0.2rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #a1a1aa;
  cursor: pointer;
}
.music-vol:hover {
  color: #e4e4e7;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}
.music-vol-ico {
  flex-shrink: 0;
  opacity: 0.9;
}
.music-vol.is-muted .music-vol-wave,
.music-vol.is-muted .music-vol-wave2,
.music-vol.is-low .music-vol-wave2 {
  opacity: 0.25;
}
.music-vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 72px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}
.music-vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f4f4f5;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.music-vol input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f4f4f5;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
.music-vol input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.music-row-badges:empty {
  display: none;
}
.music-feed-head h3 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 650;
  color: #71717a;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.music-feed-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.music-feed-count[hidden] {
  display: none !important;
}
.music-results-feed {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.music-row {
  --music-hue: 220;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem 0.75rem;
  border-radius: 16px;
  background:
    linear-gradient(
      145deg,
      hsla(var(--music-hue), 45%, 14%, 0.55) 0%,
      #0c0c0e 48%,
      #0a0a0c 100%
    );
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}
.music-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
/* When something is playing, dim siblings so the active track pops */
.music-results-feed:has(.music-row.is-playing) .music-row:not(.is-playing) {
  opacity: 0.52;
  filter: saturate(0.75);
  transform: scale(0.985);
}
.music-results-feed:has(.music-row.is-playing) .music-row:not(.is-playing):hover {
  opacity: 0.78;
  filter: saturate(0.9);
}
.music-row.is-playing {
  position: relative;
  z-index: 1;
  opacity: 1 !important;
  filter: none !important;
  transform: none;
  border-color: hsla(var(--music-hue), 78%, 62%, 0.65);
  background:
    linear-gradient(
      145deg,
      hsla(var(--music-hue), 55%, 18%, 0.85) 0%,
      #101014 42%,
      #0c0c10 100%
    );
  box-shadow:
    0 0 0 1px hsla(var(--music-hue), 75%, 58%, 0.35),
    0 0 28px hsla(var(--music-hue), 80%, 50%, 0.22),
    0 16px 40px rgba(0, 0, 0, 0.5);
}
.music-row.is-playing::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(
    180deg,
    hsla(var(--music-hue), 85%, 72%, 1),
    hsla(var(--music-hue), 70%, 52%, 0.85)
  );
  box-shadow: 0 0 12px hsla(var(--music-hue), 80%, 60%, 0.55);
  pointer-events: none;
}
.music-row.is-playing .music-row-title {
  color: #fff;
  font-weight: 700;
}
.music-row-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.music-cover {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #f4f4f5;
  background:
    radial-gradient(
      120% 120% at 30% 20%,
      hsla(var(--music-hue), 80%, 62%, 0.55) 0%,
      hsla(var(--music-hue), 40%, 22%, 0.9) 55%,
      #141416 100%
    );
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.music-row.is-playing .music-cover {
  animation: musicCoverPulse 2.2s ease-in-out infinite;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 2px hsla(var(--music-hue), 80%, 65%, 0.45),
    0 0 18px hsla(var(--music-hue), 75%, 55%, 0.4);
}
.music-row-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.music-row-title {
  font-size: 0.92rem;
  font-weight: 650;
  color: #fafafa;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.music-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #a1a1aa;
}
.music-badge.is-lyrics {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(167, 139, 250, 0.22);
}
.music-badge.is-inst {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.12);
  border-color: rgba(56, 189, 248, 0.22);
}
.music-badge.is-now {
  color: #0a0a0c;
  background: hsla(var(--music-hue), 85%, 72%, 1);
  border-color: hsla(var(--music-hue), 80%, 80%, 0.5);
  font-weight: 750;
  letter-spacing: 0.01em;
  box-shadow:
    0 0 0 1px hsla(var(--music-hue), 80%, 60%, 0.25),
    0 4px 14px hsla(var(--music-hue), 70%, 50%, 0.35);
  gap: 0.35rem;
  animation: musicNowPulse 1.8s ease-in-out infinite;
}
.music-now-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.72rem;
  width: 0.7rem;
}
.music-now-eq i {
  display: block;
  width: 2px;
  border-radius: 1px;
  background: currentColor;
  height: 40%;
  animation: musicEqBar 0.85s ease-in-out infinite;
}
.music-now-eq i:nth-child(1) {
  animation-delay: 0s;
  height: 35%;
}
.music-now-eq i:nth-child(2) {
  animation-delay: 0.15s;
  height: 70%;
}
.music-now-eq i:nth-child(3) {
  animation-delay: 0.3s;
  height: 50%;
}
@keyframes musicEqBar {
  0%,
  100% {
    transform: scaleY(0.45);
  }
  50% {
    transform: scaleY(1);
  }
}
@keyframes musicNowPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px hsla(var(--music-hue), 80%, 60%, 0.25),
      0 4px 14px hsla(var(--music-hue), 70%, 50%, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 1px hsla(var(--music-hue), 80%, 60%, 0.4),
      0 4px 18px hsla(var(--music-hue), 70%, 50%, 0.5);
  }
}
.music-badge.is-sample {
  color: #fde68a;
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(250, 204, 21, 0.2);
}
.music-badge.is-gen {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(129, 140, 248, 0.28);
  gap: 0.28rem;
  animation: musicBadgePulse 1.5s ease-in-out infinite;
}
.music-gen-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.55);
  animation: musicGenDotPulse 1.2s ease-out infinite;
  flex: 0 0 auto;
}
.music-gen-ellipsis::after {
  content: "";
  display: inline-block;
  width: 1.1em;
  text-align: left;
  animation: musicGenEllipsis 1.2s steps(4, end) infinite;
}
.music-badge.is-stream {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.28);
  animation: musicBadgePulse 1.4s ease-in-out infinite;
}
.music-badge.is-fail {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.25);
}
.music-row.is-pending {
  opacity: 0.96;
}
.music-row.is-generating {
  position: relative;
  overflow: hidden;
  border-color: hsla(var(--music-hue), 55%, 55%, 0.22);
  box-shadow:
    0 0 0 1px hsla(var(--music-hue), 60%, 50%, 0.08),
    0 10px 30px rgba(0, 0, 0, 0.32);
}
.music-row.is-generating::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    110deg,
    transparent 0%,
    transparent 40%,
    hsla(var(--music-hue), 70%, 65%, 0.07) 50%,
    transparent 60%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: musicRowShimmer 2.2s ease-in-out infinite;
  z-index: 0;
}
.music-row.is-generating > * {
  position: relative;
  z-index: 1;
}
.music-row.is-optimistic {
  animation: musicRowEnter 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.music-row.is-optimistic:nth-child(2) {
  animation-delay: 0.07s;
}
.music-row.is-streaming .music-wave-bar {
  animation: musicWaveLive 0.9s ease-in-out infinite alternate;
}
.music-play:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}
.music-wave:disabled {
  cursor: default;
  opacity: 0.55;
}
@keyframes musicBadgePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}
@keyframes musicWaveLive {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}
.music-row-style {
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-play {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 0;
  background: #f4f4f5;
  color: #0a0a0c;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.12);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.music-play .ico-pause {
  display: none;
}
.music-play .ico-play {
  display: block;
  margin-left: 1px;
}
.music-row.is-playing .music-play {
  background: hsla(var(--music-hue), 85%, 72%, 1);
  color: #0a0a0c;
  box-shadow:
    0 0 0 3px hsla(var(--music-hue), 80%, 60%, 0.35),
    0 6px 22px hsla(var(--music-hue), 70%, 50%, 0.45);
}
.music-row.is-playing .music-play .ico-play {
  display: none;
}
.music-row.is-playing .music-play .ico-pause {
  display: block;
}
.music-play:hover {
  transform: scale(1.06);
  background: #fff;
}
.music-play:active {
  transform: scale(0.96);
}

/* Waveform seek bar */
.music-wave {
  position: relative;
  display: block;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 0.1rem;
  border: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
}
.music-wave.is-scrubbing {
  cursor: grabbing;
}
.music-wave.is-scrubbing .music-wave-progress {
  transition: none;
}
.music-wave-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 100%;
  width: 100%;
  padding: 0 2px;
  box-sizing: border-box;
}
.music-wave-bar {
  flex: 1 1 0;
  min-width: 2px;
  max-width: 4px;
  height: var(--h, 40%);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  align-self: center;
  transition: background 0.12s ease, opacity 0.12s ease;
}
.music-row:hover .music-wave-bar {
  background: rgba(255, 255, 255, 0.34);
}
.music-row.is-playing .music-wave-bar {
  background: hsla(var(--music-hue), 80%, 72%, 0.75);
}
.music-row.is-playing .music-wave {
  background: hsla(var(--music-hue), 40%, 12%, 0.55);
  box-shadow: inset 0 0 0 1px hsla(var(--music-hue), 70%, 55%, 0.18);
}
.music-row.is-playing .music-wave-progress {
  background: linear-gradient(
    90deg,
    hsla(var(--music-hue), 75%, 55%, 0.42),
    hsla(var(--music-hue), 75%, 55%, 0.1)
  );
  border-right-color: hsla(var(--music-hue), 90%, 78%, 0.95);
}
.music-wave-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    hsla(var(--music-hue), 70%, 55%, 0.28),
    hsla(var(--music-hue), 70%, 55%, 0.06)
  );
  border-right: 1.5px solid hsla(var(--music-hue), 80%, 75%, 0.75);
  transition: width 0.08s linear;
}
.music-row-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: #71717a;
  font-variant-numeric: tabular-nums;
}
.music-time {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.music-foot-action {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 4.5rem;
}
.music-dl {
  color: #a1a1aa;
  text-decoration: none;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.music-dl:hover {
  color: #f4f4f5;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
.music-foot-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.music-del {
  flex: 0 0 auto;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #a1a1aa;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.music-del:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.28);
}
/* Live generation % chip (replaces Download until complete) */
.music-gen-pct {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.1rem;
  height: 1.45rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid hsla(var(--music-hue), 55%, 50%, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #e4e4e7;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.music-gen-pct-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(
    90deg,
    hsla(var(--music-hue), 70%, 48%, 0.35),
    hsla(var(--music-hue), 75%, 58%, 0.55)
  );
  transition: width 0.45s ease;
  pointer-events: none;
}
.music-gen-pct-label {
  position: relative;
  z-index: 1;
  font-size: 0.7rem;
}
/* Skeleton / loading state before playable */
.music-row.is-skeleton {
  pointer-events: auto;
}
.music-row.is-skeleton .music-play:disabled {
  opacity: 0.35;
}
.music-row.is-skeleton .music-wave {
  opacity: 0.7;
}
.music-wave.is-skeleton-wave .music-wave-bar {
  animation: musicSkelPulse 1.05s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.035s);
  transform-origin: center bottom;
}
.music-row.is-generating .music-wave.is-skeleton-wave .music-wave-bar {
  animation-name: musicSkelPulse, musicWaveBob;
  animation-duration: 1.05s, 0.9s;
  animation-timing-function: ease-in-out, ease-in-out;
  animation-iteration-count: infinite, infinite;
  animation-direction: normal, alternate;
  animation-delay: calc(var(--i, 0) * 0.035s), calc(var(--i, 0) * 0.04s);
}
.music-skel-line {
  display: inline-block;
  height: 0.72em;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.14) 50%,
    rgba(255, 255, 255, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: musicSkelShimmer 1.35s ease-in-out infinite;
  vertical-align: middle;
}
.music-row-title.is-skel-text {
  min-height: 1.05em;
}
.music-cover.is-spinning {
  position: relative;
  animation: musicCoverGlow 1.8s ease-in-out infinite;
}
.music-cover-spin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: hsla(var(--music-hue), 80%, 72%, 0.95);
  animation: musicCoverSpin 0.75s linear infinite;
  position: relative;
  z-index: 1;
}
.music-cover-ring {
  position: absolute;
  inset: 4px;
  border-radius: 10px;
  border: 1px solid hsla(var(--music-hue), 70%, 65%, 0.35);
  animation: musicCoverRing 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes musicCoverSpin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes musicCoverGlow {
  0%,
  100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      0 0 0 0 hsla(var(--music-hue), 70%, 60%, 0);
  }
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 0 18px 2px hsla(var(--music-hue), 70%, 55%, 0.28);
  }
}
@keyframes musicCoverRing {
  0% {
    transform: scale(0.92);
    opacity: 0.85;
  }
  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}
@keyframes musicSkelShimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
@keyframes musicSkelPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.9;
  }
}
@keyframes musicWaveBob {
  from {
    transform: scaleY(0.55);
  }
  to {
    transform: scaleY(1.15);
  }
}
@keyframes musicRowShimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}
@keyframes musicRowEnter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes musicGenDotPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.55);
    transform: scale(1);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(129, 140, 248, 0);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0);
    transform: scale(1);
  }
}
@keyframes musicGenEllipsis {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}
.music-audio {
  display: none;
}
@keyframes musicCoverPulse {
  0%,
  100% {
    filter: brightness(1);
    transform: scale(1);
  }
  50% {
    filter: brightness(1.12);
    transform: scale(1.03);
  }
}
@media (prefers-reduced-motion: reduce) {
  .music-row.is-playing .music-cover {
    animation: none;
  }
  .music-badge.is-now {
    animation: none;
  }
  .music-now-eq i {
    animation: none;
    transform: none;
  }
  .music-results-feed:has(.music-row.is-playing) .music-row:not(.is-playing) {
    transform: none;
  }
  .music-cover-spin,
  .music-cover-ring,
  .music-cover.is-spinning,
  .music-skel-line,
  .music-wave.is-skeleton-wave .music-wave-bar,
  .music-row.is-generating,
  .music-row.is-generating::before,
  .music-row.is-optimistic,
  .music-badge.is-gen,
  .music-gen-dot,
  .music-generate-btn.is-busy,
  .music-generate-btn.is-busy .music-gen-shine {
    animation: none !important;
  }
  .music-gen-ellipsis::after {
    content: "?";
    animation: none;
  }
}

/* Left bottom: style + generate (under lyrics / instrumental) */
.music-left-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 0.9rem 0.9rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #0e0e10;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}
.music-style-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.music-style-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a1a1aa;
  margin: 0;
}
.music-style-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #0c0c0e;
  color: #e4e4e7;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.6rem 0.8rem;
  outline: none;
}
.music-style-input:focus {
  border-color: rgba(255, 255, 255, 0.2);
}
.music-compose-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-height: 2.6rem;
}
.music-lyrics-pane.is-instrumental .music-lyrics-body {
  display: none !important;
}
/* Status sits on the same row as Generate (left), not stacked above */
.music-status {
  order: 0;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.3;
  color: #a1a1aa;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
}
.music-status[hidden] {
  display: none !important;
}
.music-status.is-err {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.28);
}
/* Hard generate errors: pulse once so the eye catches them, then stay */
.music-status.is-sticky-err {
  animation: musicStatusErrIn 0.45s ease-out both;
  font-weight: 600;
  max-height: 4.5rem;
  overflow-y: auto;
  white-space: normal;
  word-break: break-word;
}
@keyframes musicStatusErrIn {
  0% {
    opacity: 0;
    transform: translateY(4px);
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45);
  }
  40% {
    opacity: 1;
    transform: translateY(0);
    box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(248, 113, 113, 0);
  }
}
.music-status.is-ok {
  color: #bbf7d0;
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.22);
}
@media (prefers-reduced-motion: reduce) {
  .music-status.is-sticky-err {
    animation: none;
  }
}
.music-compose-actions .music-generate-btn {
  flex: 0 0 auto;
  margin-left: auto;
}
.music-generate-btn {
  --mg-x: 50%;
  --mg-y: 50%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  gap: 0.4rem;
  padding: 0.72rem 1.05rem 0.72rem 1.15rem;
  border: 0;
  background:
    radial-gradient(
      120% 180% at var(--mg-x) var(--mg-y),
      rgba(255, 255, 255, 0.95) 0%,
      rgba(244, 244, 245, 0.92) 42%,
      #e4e4e7 100%
    );
  color: #0a0a0c;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 8px 28px rgba(255, 255, 255, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s ease,
    filter 0.28s ease;
  will-change: transform;
}
.music-generate-btn .music-gen-label {
  position: relative;
  z-index: 2;
  letter-spacing: 0;
  font-weight: 700;
  background: linear-gradient(180deg, #18181b 0%, #09090b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  transition: filter 0.28s ease;
}
.music-generate-btn .music-gen-ico {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #0a0a0c;
  line-height: 0;
  flex: 0 0 auto;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), filter 0.3s ease;
}
.music-generate-btn .music-gen-ico svg {
  display: block;
}
.music-generate-btn .mg-ico-note {
  transform-origin: 55% 50%;
}
/* Sliding light sweep across the pill */
.music-generate-btn .music-gen-shine {
  position: absolute;
  inset: -40% -60%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 0%,
    transparent 38%,
    rgba(255, 255, 255, 0) 42%,
    rgba(255, 255, 255, 0.75) 50%,
    rgba(255, 255, 255, 0) 58%,
    transparent 62%,
    transparent 100%
  );
  transform: translateX(-55%) rotate(8deg);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.music-generate-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.035);
  filter: saturate(1.05);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 0 0 1px rgba(255, 255, 255, 0.35),
    0 12px 36px rgba(255, 255, 255, 0.22),
    0 4px 14px rgba(0, 0, 0, 0.4);
}
.music-generate-btn:hover:not(:disabled) .music-gen-shine {
  opacity: 1;
  animation: musicGenShine 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.music-generate-btn:hover:not(:disabled) .music-gen-label {
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.35));
}
.music-generate-btn:hover:not(:disabled) .music-gen-ico {
  transform: translateX(1px);
  filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.2));
}
.music-generate-btn:hover:not(:disabled) .mg-ico-note {
  animation: musicGenNoteBob 0.85s ease-in-out infinite;
}
.music-generate-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 4px 14px rgba(255, 255, 255, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.35);
  transition-duration: 0.1s;
}
.music-generate-btn:active:not(:disabled) .music-gen-ico {
  animation: none;
  transform: scale(0.94);
}
.music-generate-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.15);
  box-shadow: none;
}
/* Generate in-flight: keep button visible with busy animation */
.music-generate-btn.is-busy,
.music-generate-btn.is-busy:disabled {
  opacity: 1;
  cursor: wait;
  filter: none;
  pointer-events: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 0 0 1px rgba(255, 255, 255, 0.2),
    0 8px 28px rgba(255, 255, 255, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.35);
}
.music-generate-btn.is-busy .music-gen-shine {
  opacity: 1;
  animation: musicGenShine 1.15s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.music-generate-btn.is-busy .music-gen-label {
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.25));
}
.music-generate-btn.is-busy .music-gen-ico {
  animation: musicGenIcoSpin 0.9s linear infinite;
}
.music-generate-btn.is-busy .mg-ico-note {
  animation: musicGenNoteBob 0.7s ease-in-out infinite;
}
@keyframes musicGenIcoSpin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes musicGenShine {
  0% {
    transform: translateX(-55%) rotate(8deg);
  }
  100% {
    transform: translateX(55%) rotate(8deg);
  }
}
@keyframes musicGenNoteBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1.5px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .music-generate-btn,
  .music-generate-btn .music-gen-shine,
  .music-generate-btn .music-gen-label,
  .music-generate-btn .music-gen-ico,
  .music-generate-btn .mg-ico-note {
    transition: none !important;
    animation: none !important;
  }
  .music-generate-btn:hover:not(:disabled) {
    transform: none;
  }
  .music-generate-btn:hover:not(:disabled) .music-gen-ico {
    transform: none;
  }
}

.pg-body.is-music-mode .composer-dock,
.pg-body.is-music-mode > .pg > .pg-main > .pg-results,
.pg-body.is-music-mode #results {
  display: none !important;
}

/* --- Voice Clone workspace --- */
.pg-body.is-voice-mode .pg {
  max-width: var(--pg-content-max, 980px);
  padding-top: 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  min-height: 0;
}
.pg-body.is-voice-mode .pg-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100dvh - 61px - 3.25rem);
  height: calc(100vh - 61px - 3.25rem);
  max-height: calc(100dvh - 61px - 3.25rem);
  max-height: calc(100vh - 61px - 3.25rem);
}
.pg-body.is-voice-mode .workspace-switch {
  margin-bottom: 0.65rem;
}
.pg-body.is-voice-mode .composer-dock,
.pg-body.is-voice-mode > .pg > .pg-main > .pg-results,
.pg-body.is-voice-mode #results {
  display: none !important;
}
.voice-workspace {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ws-panel.is-active.voice-workspace {
  display: flex;
}

.voice-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.2fr);
  gap: 0.85rem;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  align-items: stretch;
  box-sizing: border-box;
}

.voice-sample-pane,
.voice-speak-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #121214;
  overflow: hidden;
}
/* Allow language / emotion menus to escape the pane */
.voice-speak-pane {
  overflow: visible;
}
.voice-speak-pane .voice-pane-head {
  position: relative;
  z-index: 6;
  border-radius: 16px 16px 0 0;
  background: #121214;
}

.voice-pane-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.9rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}
.voice-pane-titles {
  flex: 1 1 auto;
  min-width: 0;
}
.voice-pane-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #f4f4f5;
  line-height: 1.25;
}
.voice-pane-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: #71717a;
  font-weight: 500;
  line-height: 1.35;
}

.voice-ready-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  color: #bbf7d0;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.22);
  white-space: nowrap;
}
.voice-ready-badge[hidden] {
  display: none !important;
}
.voice-ready-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.voice-sample-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.85rem 0.95rem 1rem;
  overflow: auto;
}

.voice-drop {
  flex: 1 1 auto;
  min-height: 180px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(139, 92, 246, 0.1), transparent 55%),
    #0c0c0e;
  padding: 1.15rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.voice-drop:hover,
.voice-drop.is-drag {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.12);
}
.voice-drop.is-optional {
  min-height: 140px;
  opacity: 0.92;
}
.voice-drop-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.voice-drop-inner[hidden] {
  display: none !important;
}
.voice-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 36px;
  margin-bottom: 0.45rem;
  color: #a78bfa;
}
.voice-wave span {
  display: block;
  width: 3px;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.75;
  animation: voiceWave 1.2s ease-in-out infinite;
}
.voice-wave span:nth-child(1) { height: 10px; animation-delay: 0s; }
.voice-wave span:nth-child(2) { height: 18px; animation-delay: 0.08s; }
.voice-wave span:nth-child(3) { height: 26px; animation-delay: 0.16s; }
.voice-wave span:nth-child(4) { height: 14px; animation-delay: 0.24s; }
.voice-wave span:nth-child(5) { height: 30px; animation-delay: 0.32s; }
.voice-wave span:nth-child(6) { height: 20px; animation-delay: 0.4s; }
.voice-wave span:nth-child(7) { height: 12px; animation-delay: 0.48s; }
.voice-wave span:nth-child(8) { height: 24px; animation-delay: 0.56s; }
.voice-wave span:nth-child(9) { height: 16px; animation-delay: 0.64s; }
.voice-wave span:nth-child(10) { height: 28px; animation-delay: 0.72s; }
.voice-wave span:nth-child(11) { height: 11px; animation-delay: 0.8s; }
.voice-wave span:nth-child(12) { height: 19px; animation-delay: 0.88s; }
@keyframes voiceWave {
  0%, 100% { transform: scaleY(0.55); opacity: 0.45; }
  50% { transform: scaleY(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .voice-wave span { animation: none; opacity: 0.7; }
}
.voice-drop-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  color: #e4e4e7;
  letter-spacing: -0.01em;
}
.voice-drop-hint {
  margin: 0;
  font-size: 0.72rem;
  color: #71717a;
  font-weight: 500;
}

.voice-clip-preview {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}
.voice-clip-preview[hidden] {
  display: none !important;
}
.voice-clip-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.voice-clip-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.22);
}
.voice-clip-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.voice-clip-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #f4f4f5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-clip-dur {
  font-size: 0.72rem;
  color: #71717a;
  font-weight: 500;
}
.voice-clip-x {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  background: transparent;
  color: #71717a;
  font-size: 1.15rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
}
.voice-clip-x:hover {
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.1);
}
.voice-clip-dl {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #a1a1aa;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1;
}
.voice-clip-dl:hover {
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.06);
}
.voice-clip-dl[hidden] {
  display: none !important;
}
/* Custom dark audio player (no native Chrome controls) */
.vplayer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 12px;
  background: #0a0a0b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-sizing: border-box;
}
.vplayer audio {
  display: none !important;
}
.vplayer-play {
  appearance: none;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 0;
  background: #fafafa;
  color: #0a0a0b;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
}
.vplayer-play:hover {
  filter: brightness(0.96);
}
.vplayer-play:active {
  transform: scale(0.96);
}
.vplayer-play .vplayer-ico-play,
.vplayer-play .vplayer-ico-pause {
  display: block;
}
.vplayer.is-playing .vplayer-ico-play {
  display: none !important;
}
.vplayer:not(.is-playing) .vplayer-ico-pause {
  display: none !important;
}
.vplayer-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: hidden;
}
.vplayer-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #a78bfa, #c4b5fd);
  pointer-events: none;
  transition: width 0.05s linear;
}
.vplayer-track:hover .vplayer-fill {
  filter: brightness(1.08);
}
/* 10s trim selector (shown when sample is longer than 10s) */
.voice-trim {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.6rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  background: rgba(139, 92, 246, 0.06);
}
.voice-trim[hidden] {
  display: none !important;
}
.voice-trim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.voice-trim-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #c4b5fd;
}
.voice-trim-range {
  font-size: 0.74rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #e4e4e7;
}
.voice-trim-track {
  position: relative;
  width: 100%;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(180deg, #1a1a1e 0%, #121214 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  cursor: grab;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}
.voice-trim-track:active {
  cursor: grabbing;
}
.voice-trim-wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
}
.voice-trim-window {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 40%;
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.22);
  border: 1.5px solid rgba(221, 214, 254, 0.9);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.3),
    inset 0 0 16px rgba(196, 181, 253, 0.18);
  pointer-events: none;
  box-sizing: border-box;
  z-index: 1;
}
.voice-trim-handle {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 5px;
  border-radius: 2px;
  background: #f5f3ff;
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.4);
}
.voice-trim-handle-l {
  left: 4px;
}
.voice-trim-handle-r {
  right: 4px;
}
.voice-trim-hint {
  margin: 0;
  font-size: 0.7rem;
  color: #71717a;
  font-weight: 500;
  line-height: 1.3;
}

.vplayer-time {
  flex: 0 0 auto;
  min-width: 2.4rem;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #a1a1aa;
}

.voice-record-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
}
.voice-rec-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0c0c0e;
  color: #e4e4e7;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.voice-rec-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: #141416;
}
.voice-rec-btn.is-recording {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
}
.voice-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #71717a;
}
.voice-rec-btn.is-recording .voice-rec-dot {
  background: #f87171;
  box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5);
  animation: voiceRecPulse 1.2s ease-out infinite;
}
@keyframes voiceRecPulse {
  70% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}
.voice-rec-timer {
  font-size: 0.8rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #fca5a5;
}
.voice-rec-timer[hidden] {
  display: none !important;
}

.voice-steps {
  list-style: none;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 0 0 auto;
}
.voice-steps li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.76rem;
  color: #a1a1aa;
  font-weight: 500;
  line-height: 1.3;
}
.voice-step-n {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.22);
}

/* Custom dark dropdowns (lang + emotion) ? match model pop UI */
.voice-dd {
  position: relative;
  flex: 0 0 auto;
  align-self: flex-start;
  z-index: 5;
}
.voice-dd.is-open {
  z-index: 40;
}
.voice-dd-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #16161a;
  color: #f4f4f5;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.55rem 0.4rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  max-width: 11rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.voice-dd-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: #1c1c22;
}
.voice-dd.is-open .voice-dd-btn {
  border-color: rgba(167, 139, 250, 0.4);
  background: #1a1824;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}
.voice-dd-btn-emo {
  border-radius: 10px;
  max-width: 12rem;
  min-width: 7.75rem;
}
.voice-dd-flag {
  font-size: 1rem;
  line-height: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  min-width: 1.35rem;
}
.voice-flag-img {
  width: 20px;
  height: 15px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
}
.voice-emo-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.voice-dd-opt .voice-flag-img,
.voice-dd-opt .voice-emo-img {
  margin-right: 0.05rem;
}
.voice-dd-code {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: #e4e4e7;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.voice-dd-chev {
  flex: 0 0 auto;
  color: #71717a;
  font-size: 0.65rem;
  transition: transform 0.12s, color 0.12s;
}
.voice-dd.is-open .voice-dd-chev {
  transform: rotate(180deg);
  color: #a1a1aa;
}
.voice-dd-menu {
  /* position/size set in JS (fixed, flip up when near bottom) */
  position: fixed;
  min-width: 11.5rem;
  max-height: min(320px, 55vh);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.3rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #1a1a1f 0%, #121216 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 9999;
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  /* Dark thin scrollbar (no Windows white track / arrows) */
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
  color-scheme: dark;
  -webkit-overflow-scrolling: touch;
}
.voice-dd-menu::-webkit-scrollbar {
  width: 6px;
  height: 0;
}
.voice-dd-menu::-webkit-scrollbar:horizontal {
  display: none;
  height: 0;
}
.voice-dd-menu::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}
.voice-dd-menu::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 99px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
.voice-dd-menu::-webkit-scrollbar-thumb:hover {
  background: #4a4a4a;
  background-clip: padding-box;
}
.voice-dd-menu::-webkit-scrollbar-corner {
  background: transparent;
  display: none;
}
.voice-dd-menu::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
.voice-dd-menu[hidden] {
  display: none !important;
}
.voice-dd-menu.is-drop-up {
  box-shadow:
    0 -14px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.voice-dd-opt {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: #d4d4d8;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-radius: 9px;
  cursor: pointer;
  line-height: 1.25;
  transition: background 0.1s, color 0.1s;
  box-sizing: border-box;
}
.voice-dd-opt span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-dd-opt em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #71717a;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.voice-dd-opt:hover,
.voice-dd-opt:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: #fafafa;
  outline: none;
}
.voice-dd-opt:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.35);
}
.voice-dd-opt.is-active {
  background: rgba(139, 92, 246, 0.18);
  color: #f4f4f5;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.32);
}
.voice-dd-opt.is-active:hover {
  background: rgba(139, 92, 246, 0.22);
}
.voice-dd-opt.is-active em {
  color: #c4b5fd;
}
.voice-ctrl-dd {
  gap: 0.5rem;
}

.voice-speak-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.95rem 0.95rem;
  gap: 0.65rem;
  overflow: visible;
}
.voice-transcript-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 140px;
  display: flex;
  flex-direction: column;
}
.voice-transcript {
  flex: 1 1 auto;
  width: 100%;
  min-height: 140px;
  height: 100%;
  resize: none;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: #0c0c0e;
  color: #e4e4e7;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.85rem 0.95rem 1.85rem;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  /* Never force case ? Caps Lock / Shift must work */
  text-transform: none;
  -webkit-text-security: none;
}
.voice-transcript:focus {
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}
.voice-transcript::placeholder {
  color: #52525b;
}
.voice-char-count {
  position: absolute;
  right: 0.75rem;
  bottom: 0.55rem;
  font-size: 0.7rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #52525b;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.voice-char-count.is-warn {
  color: #fbbf24;
}
.voice-char-count.is-full {
  color: #f87171;
}

.voice-speak-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  z-index: 4;
  overflow: visible;
}
.voice-speak-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  position: relative;
  z-index: 5;
  overflow: visible;
}
.voice-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: #a1a1aa;
}
.voice-ctrl input[type="range"] {
  width: 100px;
  accent-color: #a78bfa;
}
.voice-ctrl-val {
  min-width: 2.4rem;
  font-variant-numeric: tabular-nums;
  color: #d4d4d8;
}

.voice-status {
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #a1a1aa;
  font-weight: 500;
}
.voice-status.is-err {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.voice-status.is-ok {
  color: #bbf7d0;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.22);
}
.voice-status[hidden] {
  display: none !important;
}

.voice-generate-btn {
  appearance: none;
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #fafafa 0%, #e4e4e7 100%);
  color: #0a0a0b;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.1s, filter 0.12s, opacity 0.12s;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 20px rgba(0, 0, 0, 0.25);
}
.voice-generate-btn:hover:not(:disabled) {
  filter: brightness(1.03);
}
.voice-generate-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.voice-generate-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.voice-result {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.7rem 0.75rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0c0c0e;
}
.voice-result[hidden] {
  display: none !important;
}
.voice-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.voice-result-title {
  font-size: 0.75rem;
  font-weight: 650;
  color: #a1a1aa;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.voice-result-dl {
  font-size: 0.76rem;
  font-weight: 650;
  color: #c4b5fd;
  text-decoration: none;
}
.voice-result-dl:hover {
  color: #ddd6fe;
}
.voice-result-dl[hidden] {
  display: none !important;
}
.voice-result .vplayer {
  margin-top: 0.1rem;
}

@media (max-width: 900px) {
  .pg-body.is-voice-mode .pg-main {
    height: auto;
    max-height: none;
  }
  .voice-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .voice-sample-pane,
  .voice-speak-pane {
    height: auto;
    max-height: none;
    min-height: min(48vh, 420px);
  }
  .voice-drop {
    min-height: 150px;
  }
  .voice-transcript {
    min-height: 160px;
  }
}

@media (max-width: 900px) {
  .pg-body.is-music-mode .pg-main {
    height: auto;
    max-height: none;
  }
  .music-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .music-lyrics-pane,
  .music-main-pane {
    height: auto;
    max-height: none;
    min-height: min(52vh, 420px);
  }
  .music-lyrics-input {
    min-height: 180px;
  }
}

/* ?? Playground login gate ????????????????????????????????????? */
body.pg-login-open {
  overflow: hidden;
}
.pg-login-gate[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  position: fixed !important;
  top: -99999px !important;
  left: -99999px !important;
  opacity: 0 !important;
}
.pg-login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(124, 156, 255, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(167, 139, 250, 0.08), transparent 50%),
    rgba(5, 5, 6, 0.94);
  backdrop-filter: blur(12px);
}
.pg-login-card {
  width: min(400px, 100%);
  padding: 2rem 1.75rem 1.85rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(165deg, #141416 0%, #0c0c0e 100%);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.pg-login-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 1rem;
}
.pg-login-mark svg {
  width: 100%;
  height: 100%;
}
.pg-login-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  color: #fafafa;
}
.pg-login-sub {
  margin: 0 0 1.35rem;
  color: #8a8a8a;
  font-size: 0.92rem;
}
.pg-login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.pg-login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #a1a1aa;
}
.pg-login-field input {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0a0a0c;
  color: #f4f4f5;
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pg-login-field input:focus {
  border-color: rgba(124, 156, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.12);
}
.pg-login-err {
  margin: 0;
  font-size: 0.85rem;
  color: #f87171;
  line-height: 1.4;
}
.pg-login-submit {
  margin-top: 0.25rem;
  border: none;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #5b7cff 0%, #7c5cff 100%);
  box-shadow: 0 8px 24px rgba(91, 124, 255, 0.25);
  transition: opacity 0.15s ease, transform 0.12s ease;
}
.pg-login-submit:hover:not(:disabled) {
  opacity: 0.95;
}
.pg-login-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ?? Profile menu (workspace bar, right of Canvas) ????????????? */
.pg-profile-wrap {
  position: relative;
  flex: 0 0 auto;
}
.pg-profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #141414;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.pg-profile-btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: #1c1c1c;
}
.pg-profile-btn:focus-visible {
  outline: 2px solid rgba(167, 139, 250, 0.55);
  outline-offset: 2px;
}
.pg-profile-btn:not(:has(img[src]))::after {
  content: attr(data-initials);
  font-size: 0.72rem;
  font-weight: 700;
  color: #d4d4d8;
  letter-spacing: 0.02em;
}
.pg-profile-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.pg-profile-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 60;
  width: min(320px, calc(100vw - 2rem));
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #111114;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.pg-profile-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.pg-profile-head .pg-profile-img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: 0 0 auto;
}
.pg-profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.pg-profile-meta strong {
  font-size: 0.92rem;
  color: #fafafa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-profile-meta span {
  font-size: 0.78rem;
  color: #71717a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pg-profile-usage {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}
.pg-usage-row {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.pg-usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #a1a1aa;
}
.pg-usage-bar {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.pg-usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5b7cff, #a78bfa);
  transition: width 0.25s ease;
}
.pg-usage-admin {
  margin: 0;
  font-size: 0.82rem;
  color: #34d399;
}
.pg-profile-logout {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e4e4e7;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.pg-profile-logout:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

/* ?? NSFW access code (profile menu) ????????????????????????? */
.pg-nsfw-gate {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.75rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(251, 146, 60, 0.18);
  background:
    linear-gradient(165deg, rgba(251, 146, 60, 0.07) 0%, transparent 42%),
    rgba(255, 255, 255, 0.02);
}
.pg-nsfw-gate[data-state="unlocked"] {
  border-color: rgba(52, 211, 153, 0.28);
  background:
    linear-gradient(165deg, rgba(52, 211, 153, 0.08) 0%, transparent 45%),
    rgba(255, 255, 255, 0.02);
}
.pg-nsfw-head {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}
.pg-nsfw-ico {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fdba74;
  background: rgba(251, 146, 60, 0.12);
  border: 1px solid rgba(251, 146, 60, 0.2);
}
.pg-nsfw-gate[data-state="unlocked"] .pg-nsfw-ico {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.22);
}
.pg-nsfw-titles {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.pg-nsfw-titles strong {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e4e4e7;
  letter-spacing: 0.02em;
}
.pg-nsfw-sub {
  font-size: 0.68rem;
  line-height: 1.4;
  color: #8b8b93;
  font-weight: 450;
  letter-spacing: 0.01em;
}
.pg-nsfw-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.pg-nsfw-terms-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.pg-nsfw-terms-label {
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a1a1aa;
}
.pg-nsfw-terms {
  max-height: 140px;
  overflow: auto;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.4);
  color: #d4d4d8;
  font-size: 0.68rem;
  line-height: 1.45;
  white-space: pre-wrap;
  scrollbar-width: thin;
}
.pg-nsfw-terms-note {
  margin: 0;
  font-size: 0.6rem;
  color: #71717a;
  font-variant-numeric: tabular-nums;
}
.pg-nsfw-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.15rem 0 0.1rem;
}
.pg-nsfw-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #c4c4cc;
  cursor: pointer;
}
.pg-nsfw-check-row input {
  margin-top: 0.12rem;
  flex-shrink: 0;
  accent-color: #fb923c;
}
.pg-nsfw-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}
.pg-nsfw-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 0.65rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35);
  color: #fafafa;
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pg-nsfw-input::placeholder {
  color: #52525b;
  letter-spacing: 0;
}
.pg-nsfw-input:focus {
  border-color: rgba(251, 146, 60, 0.55);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.12);
}
.pg-nsfw-gate[data-state="error"] .pg-nsfw-input {
  border-color: rgba(248, 113, 113, 0.55);
  animation: pg-nsfw-shake 0.35s ease;
}
.pg-nsfw-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 0.75rem;
  border-radius: 9px;
  border: 1px solid rgba(251, 146, 60, 0.35);
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.22), rgba(251, 146, 60, 0.1));
  color: #ffedd5;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.pg-nsfw-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.32), rgba(251, 146, 60, 0.16));
  border-color: rgba(251, 146, 60, 0.5);
}
.pg-nsfw-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.pg-nsfw-msg {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #fca5a5;
}
.pg-nsfw-msg.is-ok {
  color: #6ee7b7;
}
.pg-nsfw-unlocked {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.pg-nsfw-check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #34d399;
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.28);
}
.pg-nsfw-unlocked-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}
.pg-nsfw-unlocked-meta strong {
  font-size: 0.78rem;
  color: #ecfdf5;
}
.pg-nsfw-unlocked-meta span {
  font-size: 0.66rem;
  color: #6b7280;
}
.pg-nsfw-revoke {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #a1a1aa;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.28rem 0.5rem;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.pg-nsfw-revoke:hover {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
}
.pg-nsfw-gate[data-state="locked"] .pg-nsfw-unlocked,
.pg-nsfw-gate[data-state="error"] .pg-nsfw-unlocked,
.pg-nsfw-gate[data-state="busy"] .pg-nsfw-unlocked {
  display: none;
}
.pg-nsfw-gate[data-state="unlocked"] .pg-nsfw-form {
  display: none;
}
.pg-nsfw-gate[data-state="unlocked"] .pg-nsfw-unlocked {
  display: flex;
}
@keyframes pg-nsfw-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}


/* NSFW local inpaint workspace */
.ws-btn-nsfw {
  color: #fdba74;
}
.ws-btn-nsfw:hover {
  color: #ffedd5;
}
.ws-btn-nsfw.active {
  color: #fff7ed;
  background: rgba(251, 146, 60, 0.22);
  box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.35);
}
.nsfw-workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: min(62vh, 560px);
  margin-bottom: 0.5rem;
  flex: 1 1 auto;
}
.nsfw-terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
  margin: 0;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(251, 146, 60, 0.1), transparent 55%),
    rgba(6, 6, 8, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 0;
}
.nsfw-terms-overlay[hidden] {
  display: none !important;
}
.nsfw-terms-card {
  width: min(640px, 100%);
  max-height: min(86vh, 780px);
  margin: 0 auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.35rem 1.4rem 1.2rem;
  border-radius: 18px;
  border: 1px solid rgba(251, 146, 60, 0.28);
  background:
    linear-gradient(165deg, rgba(251, 146, 60, 0.08) 0%, transparent 40%),
    #121214;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}
.nsfw-terms-card-head h2 {
  margin: 0 0 0.32rem;
  font-size: 1.2rem;
  font-weight: 650;
  color: #fafafa;
  letter-spacing: -0.01em;
}
.nsfw-terms-card-sub {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #a1a1aa;
}
.nsfw-terms-overlay .pg-nsfw-terms,
.nsfw-terms-scroll {
  max-height: min(36vh, 300px);
  width: 100%;
  box-sizing: border-box;
}
.nsfw-terms-overlay .pg-nsfw-check-row {
  font-size: 0.74rem;
}
.nsfw-terms-confirm-note {
  margin: 0.15rem 0 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: #8b8b93;
}
.nsfw-terms-msg {
  margin: 0;
  font-size: 0.72rem;
  color: #fca5a5;
}
.nsfw-terms-msg.is-ok {
  color: #6ee7b7;
}
.nsfw-terms-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding-top: 0.35rem;
  width: 100%;
}
.nsfw-terms-btn {
  appearance: none;
  height: 2.45rem;
  padding: 0 0.9rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 550;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.nsfw-terms-btn-back {
  color: #d4d4d8;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.nsfw-terms-btn-back:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.22);
}
.nsfw-terms-btn-accept {
  color: #e4e4e7;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.nsfw-terms-btn-accept:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fafafa;
}
.nsfw-terms-btn-accept:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
body.nsfw-terms-pending .nsfw-toolbar,
body.nsfw-terms-pending .nsfw-body {
  pointer-events: none;
  user-select: none;
}
.pg-body.is-nsfw-mode .pg {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}
.pg-body.is-nsfw-mode .pg-results {
  margin-top: 0.75rem;
}
.nsfw-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.15rem;
}
.nsfw-tool-group {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 11px;
  background: #0c0c0c;
  border: 1px solid rgba(255,255,255,0.08);
}
.nsfw-tool {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.nsfw-tool:hover { color: #f4f4f5; background: rgba(255,255,255,0.05); }
.nsfw-tool.active {
  color: #ffedd5;
  background: rgba(251, 146, 60, 0.2);
}
.nsfw-brush-size {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.35rem;
  color: #71717a;
  font-size: 0.72rem;
  font-weight: 600;
}
.nsfw-brush-size input[type=range] {
  width: 96px;
  accent-color: #fb923c;
}
.nsfw-body {
  display: flex;
  gap: 0.75rem;
  min-height: 0;
  flex: 1 1 auto;
}
.nsfw-stage-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 420px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0a0a0b;
  overflow: hidden;
  position: relative;
}
.nsfw-stage-wrap.is-drop {
  outline: 2px dashed rgba(251, 146, 60, 0.55);
  outline-offset: -6px;
}
.nsfw-stage {
  width: 100%;
  height: 100%;
  min-height: 420px;
  display: grid;
  place-items: center;
  position: relative;
}
.nsfw-empty {
  text-align: center;
  max-width: 320px;
  padding: 1.5rem;
  color: #a1a1aa;
}
.nsfw-empty strong {
  display: block;
  color: #f4f4f5;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}
.nsfw-empty p {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #71717a;
}
.nsfw-empty-actions { display: flex; justify-content: center; gap: 0.5rem; }
.nsfw-upload-btn {
  border: 1px solid rgba(251, 146, 60, 0.4);
  background: rgba(251, 146, 60, 0.14);
  color: #ffedd5;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  cursor: pointer;
}
.nsfw-upload-btn:hover {
  background: rgba(251, 146, 60, 0.22);
}
.nsfw-stack {
  position: relative;
  line-height: 0;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.nsfw-stack img,
.nsfw-stack canvas {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.nsfw-stack canvas {
  position: absolute;
  left: 0;
  top: 0;
  cursor: crosshair;
  touch-action: none;
}
.nsfw-side {
  width: min(300px, 34vw);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #111114;
  min-height: 420px;
}
.nsfw-side-head {
  font-size: 0.78rem;
  font-weight: 700;
  color: #e4e4e7;
  letter-spacing: 0.02em;
}
.nsfw-side-head.subtle {
  color: #a1a1aa;
  font-weight: 650;
  margin-top: 0.25rem;
}
.nsfw-label {
  font-size: 0.72rem;
  color: #71717a;
  font-weight: 600;
}
.nsfw-prompt {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 110px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.35);
  color: #fafafa;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.65rem 0.7rem;
  outline: none;
}
.nsfw-prompt:focus {
  border-color: rgba(251, 146, 60, 0.5);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.12);
}
.nsfw-hint {
  margin: 0;
  font-size: 0.7rem;
  color: #71717a;
  line-height: 1.35;
}
.nsfw-ref-block {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.nsfw-ref-add {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px dashed rgba(255,255,255,0.14);
  background: transparent;
  color: #d4d4d8;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.55rem;
  border-radius: 10px;
  cursor: pointer;
}
.nsfw-ref-add:hover {
  border-color: rgba(251, 146, 60, 0.4);
  color: #ffedd5;
}
.nsfw-ref-chip {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.nsfw-ref-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nsfw-ref-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.nsfw-side-foot {
  margin-top: auto;
  padding-top: 0.5rem;
}
.nsfw-generate-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #1c1410;
  background: linear-gradient(180deg, #fdba74, #fb923c);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(251, 146, 60, 0.25);
}
.nsfw-generate-btn:hover {
  filter: brightness(1.05);
}
.nsfw-generate-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  filter: none;
}
body.is-nsfw-mode .composer-dock:not(.audio-composer-dock) {
  display: none !important;
}
/* NSFW cards / NSFW workspace: no Topaz upscale or Canvas edit */
body.is-nsfw-mode .res-card .card-act[data-act="upscale"],
body.is-nsfw-mode .res-card .card-edit,
.feed-row.is-nsfw .res-card .card-act[data-act="upscale"],
.feed-row.is-nsfw .res-card .card-edit,
.res-card.is-nsfw-card .card-act[data-act="upscale"],
.res-card.is-nsfw-card .card-edit {
  display: none !important;
}
body.is-nsfw-mode #lbEditCanvas,
body.is-nsfw-mode #lbAsSticker {
  display: none !important;
}
@media (max-width: 900px) {
  .nsfw-body { flex-direction: column; }
  .nsfw-side {
    width: 100%;
    min-height: 0;
  }
  .nsfw-stage-wrap,
  .nsfw-stage { min-height: 320px; }
}
