/* ===========================
   AI Resource Hub — Generator studio layout (Image Studio)
   Feed of your generations + a prompt composer docked at the bottom.
   Loaded after css/style.css.
   =========================== */

.is-studio .site-footer { display: none; }

/* Respect the hidden attribute even on elements given a display value below */
.studio [hidden],
.studio-lightbox[hidden] { display: none !important; }

.studio {
  position: relative;
  min-height: calc(100vh - 62px);
  display: flex;
  flex-direction: column;
}

.studio-feed {
  flex: 1;
  padding: 28px 0 24px;
}

.studio-feed-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Intro / empty state ---------- */

.studio-intro {
  max-width: 760px;
  margin: 8vh auto 40px;
  text-align: center;
}

.studio-intro h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  margin: 0 0 14px;
  color: var(--color-text);
}

.studio-intro p {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin: 0 auto 22px;
  max-width: 52ch;
}

.studio.has-jobs .studio-intro { display: none; }

.studio-starters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.studio-starters button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.studio-starters button:hover { border-color: var(--color-text-muted); }

/* ---------- Job rows ---------- */

.studio-jobs {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.job-head {
  display: flex;
  align-items: baseline;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.job-prompt {
  flex: 1 1 380px;
  min-width: 0;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.job-meta .pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 600;
}

.job-reuse {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.job-reuse:hover { border-color: var(--color-text-muted); }

.job-images {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.shot {
  position: relative;
  flex: 0 0 auto;
  height: clamp(220px, 34vh, 360px);
  border-radius: 14px;
  overflow: hidden;
  background: var(--color-surface-2);
}

.shot img {
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
  cursor: zoom-in;
}

.shot-actions {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.shot:hover .shot-actions,
.shot:focus-within .shot-actions { opacity: 1; }

@media (hover: none) { .shot-actions { opacity: 1; } }

.shot-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
}

.shot-btn:hover { background: rgba(0, 0, 0, 0.75); }

/* Pending placeholders */
.shot.is-pending {
  display: grid;
  place-items: center;
  background:
    linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%) 0 0 / 220% 100%,
    var(--color-surface-2);
  animation: studio-shimmer 1.6s linear infinite;
}

@media (prefers-reduced-motion: reduce) { .shot.is-pending { animation: none; } }

@keyframes studio-shimmer { to { background-position: -220% 0, 0 0; } }

.job-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.job-progress-track {
  flex: 0 1 260px;
  height: 4px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.job-progress-track span {
  display: block;
  height: 100%;
  width: 2%;
  background: var(--color-accent);
  transition: width 0.4s ease;
}

.job-error {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.studio-more {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

/* ---------- Composer ---------- */

.composer {
  position: sticky;
  bottom: 0;
  z-index: 40;
  padding: 10px 24px 18px;
  background: linear-gradient(180deg, transparent, var(--color-bg) 38%);
}

.composer-box {
  position: relative;
  max-width: 980px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.composer-box:focus-within { border-color: var(--color-text-muted); }

.composer.is-dragging .composer-box { border-color: var(--color-gold); }

.composer-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.composer-main textarea {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  padding: 6px 2px;
}

.composer-main textarea::placeholder { color: var(--color-text-muted); }

.ref-slot { flex-shrink: 0; }

.ref-add,
.ref-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.ref-add {
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border);
  cursor: pointer;
}

.ref-add:hover { color: var(--color-text); border-color: var(--color-text-muted); }

.ref-thumb {
  position: relative;
  overflow: visible;
}

.ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--color-border);
}

.ref-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 0;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.composer-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
}

.composer-icon:hover { color: var(--color-gold); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover,
.chip[aria-expanded="true"] { border-color: var(--color-text-muted); }

.chip:disabled { opacity: 0.55; cursor: default; }

.chip.is-set { border-color: rgba(255, 106, 31, 0.5); }

.chev {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-135deg) translate(-1px, -1px);
  opacity: 0.6;
}

.chip-thumb {
  width: 22px;
  height: 22px;
  margin-left: -6px;
  border-radius: 999px;
  background-size: cover;
  background-position: center;
}

.ratio-icon {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.chip-gpu { color: var(--color-text-muted); }

.gpu-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-text-muted);
}

.gpu-dot.is-up { background: var(--color-success); box-shadow: 0 0 0 3px rgba(61, 220, 115, 0.18); }
.gpu-dot.is-busy { background: var(--color-gold); box-shadow: 0 0 0 3px rgba(255, 106, 31, 0.18); }
.gpu-dot.is-down { background: var(--color-red); }

.composer-go {
  flex-shrink: 0;
  height: 44px;
  padding: 0 24px;
}

.composer-go:disabled { opacity: 0.5; cursor: not-allowed; }

.composer-hint {
  margin: 8px 4px 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.composer-hint:empty { display: none; }
.composer-hint.is-error { color: var(--color-red); }

/* ---------- Popovers ---------- */

.pop {
  position: absolute;
  bottom: calc(100% - 4px);
  z-index: 60;
  width: 300px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.pop-model { width: 440px; padding: 10px; }

.pop-title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.pop-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.pop textarea,
.pop-select,
.pop-search {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 9px 11px;
}

.pop textarea { resize: vertical; }

.pop-search { margin-bottom: 8px; }

.pop-row {
  display: flex;
  justify-content: space-between;
  margin: 14px 0 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.pop-upload { margin-top: 12px; }

.pop-link {
  display: block;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Model list */
.model-group-title {
  margin: 10px 6px 4px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.model-opt {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--color-text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.model-opt:hover { background: var(--color-surface-2); }
.model-opt.is-on { border-color: rgba(255, 106, 31, 0.55); background: var(--color-surface-2); }

.model-opt-thumb {
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background-size: cover;
  background-position: center;
}

.model-opt-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.92rem;
}

.model-opt-note {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Ratio grid */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ratio-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px 9px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.ratio-opt small { font-weight: 500; color: var(--color-text-muted); font-size: 0.7rem; }
.ratio-opt .ratio-box { height: 30px; display: grid; place-items: center; }
.ratio-opt.is-on { border-color: var(--color-gold); }

/* Segmented control */
.seg { display: flex; gap: 6px; }

.seg button {
  flex: 1;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.seg button.is-on { border-color: var(--color-gold); }

/* Compute options */
.compute-opt {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
}

.compute-opt span { font-size: 0.8rem; color: var(--color-text-muted); }
.compute-opt.is-on { border-color: var(--color-gold); }
.compute-opt:disabled { opacity: 0.6; }

/* Phones: popovers become bottom sheets */
@media (max-width: 640px) {
  .composer { padding: 8px 10px 12px; }
  .composer-box { border-radius: 20px; padding: 10px; }
  .composer-go { padding: 0 16px; }
  .pop,
  .pop-model {
    position: fixed;
    left: 8px !important;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 72vh;
  }
  .shot { height: 240px; }
}

/* ---------- Drag & drop veil ---------- */

.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(7, 7, 10, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.drop-veil p {
  padding: 28px 40px;
  border: 2px dashed var(--color-gold);
  border-radius: 24px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
}

/* ---------- Lightbox ---------- */

.studio-lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  background: rgba(5, 5, 7, 0.94);
}

.studio-lightbox[hidden] { display: none; }

.lb-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px 64px;
  min-height: 0;
}

.lb-stage img {
  max-width: 100%;
  max-height: calc(100vh - 48px);
  border-radius: 12px;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-side {
  padding: 24px 20px;
  border-left: 1px solid rgba(255,255,255,0.08);
  background: #0c0c10;
  color: #f3f3f1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lb-side p { margin: 0; font-size: 0.92rem; line-height: 1.5; color: #d4d4d8; }
.lb-side .lb-meta { font-size: 0.8rem; color: #9a9aa3; }
.lb-side .btn { justify-content: center; }

.lb-close {
  align-self: flex-end;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

@media (max-width: 860px) {
  .studio-lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-stage { padding: 16px 52px; }
  .lb-stage img { max-height: 60vh; }
  .lb-side { border-left: 0; border-top: 1px solid rgba(255,255,255,0.08); }
}

/* Image whose file can't be loaded (GPU server offline) */
.shot.is-missing {
  width: auto;
  min-width: 200px;
  border: 1px dashed var(--color-border);
  background: var(--color-surface);
}

.shot.is-missing img,
.shot.is-missing .shot-actions { display: none; }

.shot-missing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.shot-missing strong {
  color: var(--color-text);
  font-size: 0.9rem;
}

/* ===========================
   Seamless wall (replaces the per-job rows)
   =========================== */

.studio-jobs.studio-wall {
  display: block;
  columns: 5 230px;
  column-gap: 10px;
}

@media (max-width: 600px) {
  .studio-jobs.studio-wall { columns: 2; column-gap: 8px; }
}

.wtile {
  position: relative;
  display: block;
  break-inside: avoid;
  margin: 0 0 10px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-surface-2);
  cursor: zoom-in;
  transition: transform 0.15s cubic-bezier(.2,.7,.2,1);
}

.wtile:active { transform: scale(0.985); }
.wtile:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }

.wtile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.4s cubic-bezier(.2,.7,.2,1);
}

.wtile.is-loaded img { opacity: 1; }
.wtile:hover img { transform: scale(1.02); }

.wtile-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.72) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wtile-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wtile-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
}

.wtile-btn:hover { background: rgba(0,0,0,0.65); }

.wtile-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.wtile-prompt {
  margin: 0 0 3px;
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wtile-sub { color: rgba(255,255,255,0.7); font-size: 0.72rem; }

.wtile:hover .wtile-shade, .wtile:hover .wtile-actions, .wtile:hover .wtile-meta,
.wtile:focus-within .wtile-shade, .wtile:focus-within .wtile-actions, .wtile:focus-within .wtile-meta { opacity: 1; }

@media (hover: none) {
  .wtile-actions { opacity: 1; }
  .wtile-shade { opacity: 0.6; }
}

/* In-progress tiles */
.wtile.is-pending {
  cursor: default;
  background:
    linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%) 0 0 / 220% 100%,
    var(--color-surface-2);
  animation: studio-shimmer 1.6s linear infinite;
}

@media (prefers-reduced-motion: reduce) { .wtile.is-pending { animation: none; } }

.wtile-pending {
  position: absolute;
  inset: auto 0 0 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wtile-pending-prompt {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wtile .job-progress-track { width: 100%; flex: none; }

.wtile-pending-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--color-text-muted);
}

.wtile-cancel {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

/* Failed render */
.wtile.is-error {
  cursor: default;
  padding: 14px;
  border: 1px dashed var(--color-border);
  background: var(--color-surface);
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.wtile.is-error strong { color: var(--color-text); }
.wtile.is-error p { margin: 6px 0; }
.wtile-err-prompt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Image whose file can't be loaded (GPU server offline) */
.wtile.is-missing { cursor: default; border: 1px dashed var(--color-border); background: var(--color-surface); min-height: 180px; }
.wtile.is-missing img, .wtile.is-missing .wtile-actions, .wtile.is-missing .wtile-shade { display: none; }
.wtile.is-missing .wtile-meta { opacity: 1; position: static; padding: 0 14px 14px; }
.wtile.is-missing .wtile-prompt { color: var(--color-text-muted); }
.wtile.is-missing .wtile-sub { color: var(--color-text-muted); }
.wtile.is-missing { aspect-ratio: auto !important; }
.wtile.is-missing .shot-missing { position: static; padding: 18px 14px 10px; }
.wtile.is-missing { display: flex; flex-direction: column; }
.wtile.is-missing .shot-missing { order: -1; text-align: left; align-items: flex-start; padding-bottom: 6px; }

/* "Photo size" choice for edit models: a small picture icon instead of a ratio box */
.ratio-icon.ratio-icon-photo {
  width: 16px; height: 13px;
  border-radius: 3px;
  background:
    radial-gradient(circle at 70% 32%, currentColor 0 1.6px, transparent 2.2px),
    linear-gradient(135deg, transparent 52%, currentColor 53% 100%);
  opacity: 0.85;
}
.ratio-opt .ratio-icon.ratio-icon-photo { width: 24px; height: 19px; }
#ratioNote { margin: 10px 2px 0; max-width: 300px; }
@media (min-width: 641px) { #popRatio { width: 380px; } }
#popRatio .ratio-opt { min-width: 0; }

/* ===========================
   Composer v2 (Oct 2026): prompt on top, one row of controls,
   tall Generate button on the right. Menus open as lists above.
   =========================== */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  max-width: 1180px;
  padding: 14px 14px 14px 18px;
  border-radius: 22px;
}

.composer-left { min-width: 0; display: flex; flex-direction: column; }

.composer-main { align-items: flex-start; gap: 10px; }
.composer-main textarea { min-height: 44px; font-size: 1.02rem; padding: 4px 2px; }

.ref-thumb { flex-shrink: 0; width: 48px; height: 48px; border-radius: 12px; }
.ref-thumb img { border-radius: 12px; }

.composer-icon { width: 34px; height: 34px; border-radius: 10px; border-color: transparent; background: transparent; }
.composer-icon:hover { background: var(--color-surface-2); }

.composer-bar { margin-top: auto; padding-top: 10px; }
.chips { gap: 8px; align-items: center; }

/* + and @ share one pill */
.tool-pair {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  overflow: hidden;
}
.tool-btn {
  width: 40px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
.tool-btn:hover { background: color-mix(in srgb, var(--color-text) 8%, transparent); }
.tool-sep { width: 1px; height: 18px; background: var(--color-border); }

.chip {
  height: 38px;
  padding: 0 13px;
  border-radius: 12px;
  font-size: 0.88rem;
  gap: 8px;
}
.chip-model { padding-left: 8px; }
.chip-thumb { margin-left: 0; width: 24px; height: 24px; border-radius: 7px; }
.chip-ic { opacity: 0.8; flex-shrink: 0; }
.chev-r {
  width: 7px; height: 7px; margin-left: 2px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); opacity: 0.6;
}

/* Auto ratio icon: four corners */
.ratio-auto {
  display: inline-block; width: 14px; height: 14px; flex-shrink: 0;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 5px 1.6px,
    linear-gradient(currentColor, currentColor) 0 0 / 1.6px 5px,
    linear-gradient(currentColor, currentColor) 100% 0 / 5px 1.6px,
    linear-gradient(currentColor, currentColor) 100% 0 / 1.6px 5px,
    linear-gradient(currentColor, currentColor) 0 100% / 5px 1.6px,
    linear-gradient(currentColor, currentColor) 0 100% / 1.6px 5px,
    linear-gradient(currentColor, currentColor) 100% 100% / 5px 1.6px,
    linear-gradient(currentColor, currentColor) 100% 100% / 1.6px 5px;
  background-repeat: no-repeat;
}

/* − 1/4 + */
.stepper {
  flex-shrink: 0;
  display: inline-flex; align-items: center;
  height: 38px; padding: 0 4px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: 0.88rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper button {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: var(--color-text);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.stepper button:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 8%, transparent); }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper span { min-width: 34px; text-align: center; }

/* Tall Generate button */
.composer-go {
  height: auto;
  min-width: 168px;
  padding: 12px 26px;
  border: 0;
  border-radius: 16px;
  background: var(--color-cta);
  color: var(--color-on-cta);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: inherit; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.composer-go:hover:not(:disabled) { background: var(--color-cta-hover); }
.composer-go:active:not(:disabled) { transform: scale(0.98); }
.composer-go:disabled { opacity: 0.45; cursor: not-allowed; }
.go-label { font-size: 1.08rem; font-weight: 800; letter-spacing: 0.01em; }
.go-sub { font-size: 0.78rem; font-weight: 600; opacity: 0.75; }

.composer-hint { max-width: 1180px; margin: 8px auto 0; padding: 0 6px; }

/* List menus (aspect ratio, quality, resolution) */
.pop-list { width: 220px; padding: 10px; }
.pop-list.pop-wide { width: 300px; }
.pop-list .pop-title { margin: 2px 6px 8px; color: var(--color-text-muted); font-weight: 600; }
.opt-list { display: flex; flex-direction: column; gap: 2px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--color-text);
  font: inherit; text-align: left; cursor: pointer;
}
.opt.opt-tall { padding: 12px; }
.opt:hover:not(:disabled) { background: var(--color-surface-2); }
.opt.is-on { background: var(--color-surface-2); }
.opt:disabled { opacity: 0.45; cursor: not-allowed; }
.opt-ic { width: 22px; display: grid; place-items: center; flex-shrink: 0; color: var(--color-text-muted); }
.opt-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-name { font-weight: 700; font-size: 0.95rem; }
.opt-note { font-size: 0.8rem; color: var(--color-text-muted); }
.opt-check { flex-shrink: 0; visibility: hidden; color: var(--color-gold); }
.opt.is-on .opt-check { visibility: visible; }

/* ---------- Feed toolbar + tile sizes ---------- */
.studio-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 14px;
}
.studio-count { margin: 0; font-size: 0.85rem; color: var(--color-text-muted); font-weight: 600; }
.size-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 12px; border: 1px solid var(--color-border); background: var(--color-surface);
}
.size-seg button {
  width: 34px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--color-text-muted); cursor: pointer;
}
.size-seg button:hover { color: var(--color-text); }
.size-seg button.is-on { background: var(--color-surface-2); color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-border); }

.studio-jobs.studio-wall.tiles-s { columns: 8 150px; column-gap: 8px; }
.studio-jobs.studio-wall.tiles-s .wtile { margin-bottom: 8px; border-radius: 10px; }
.studio-jobs.studio-wall.tiles-s .wtile-meta, .studio-jobs.studio-wall.tiles-s .wtile-pending-prompt { display: none; }
.studio-jobs.studio-wall.tiles-m { columns: 5 230px; }
.studio-jobs.studio-wall.tiles-l { columns: 2 480px; column-gap: 14px; }
.studio-jobs.studio-wall.tiles-l .wtile { margin-bottom: 14px; border-radius: 16px; }

/* ---------- Library ---------- */
body.lib-open { overflow: hidden; }
.lib {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.lib-panel {
  width: min(1100px, 100%);
  height: min(760px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  border-radius: 24px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 6px 20px; }
.lib-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.lib-tabs button {
  height: 36px; padding: 0 16px; border-radius: 999px;
  border: 0; background: transparent; color: var(--color-text-muted);
  font: inherit; font-size: 0.9rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.lib-tabs button:hover { color: var(--color-text); }
.lib-tabs button.is-on { background: var(--color-text); color: var(--color-bg); }
.lib-close {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-surface-2);
  color: var(--color-text); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.lib-sub { margin: 4px 20px 12px; font-size: 0.85rem; color: var(--color-text-muted); }
.lib-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: 170px; gap: 10px;
  padding: 0 20px 20px; align-content: start;
}
.lib-item, .lib-upload {
  position: relative; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--color-border); background: var(--color-surface-2);
  padding: 0; cursor: pointer; color: var(--color-text);
}
.lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.lib-item:hover img { transform: scale(1.04); }
.lib-item:hover, .lib-upload:hover, .lib-item:focus-visible, .lib-upload:focus-visible { border-color: var(--color-gold); outline: none; }
.lib-item.is-missing img { visibility: hidden; }
.lib-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff; font-size: 0.78rem; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-upload {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-style: dashed; font: inherit; font-weight: 600; font-size: 0.88rem;
}
.lib-upload-ic {
  width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center;
  background: var(--color-surface); border: 1px solid var(--color-border);
}
.lib-empty { grid-column: 1 / -1; margin: 40px auto; color: var(--color-text-muted); text-align: center; }
.lib-empty a { color: var(--color-gold); }
.lib-foot { padding: 0 20px 16px; text-align: center; }
.lib-foot:has(> [hidden]) { display: none; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .composer-box { grid-template-columns: 1fr; padding: 12px; gap: 10px; }
  .composer-go { flex-direction: row; gap: 10px; min-width: 0; padding: 12px 18px; }
  .chips { flex-wrap: nowrap; }
  .studio-jobs.studio-wall.tiles-s { columns: 3; column-gap: 6px; }
  .studio-jobs.studio-wall.tiles-m { columns: 2; column-gap: 8px; }
  .studio-jobs.studio-wall.tiles-l { columns: 1; }
  .lib { padding: 0; place-items: end stretch; }
  .lib-panel { width: 100%; height: 88vh; border-radius: 22px 22px 0 0; }
  .lib-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 120px; gap: 6px; padding: 0 12px 16px; }
  .lib-head { padding: 12px 12px 4px 12px; }
  .lib-sub { margin: 4px 14px 10px; }
  .pop-list, .pop-list.pop-wide { width: auto; }
}
.studio-jobs.studio-wall.tiles-s .job-stage { display: none; }
.studio-jobs.studio-wall.tiles-s .wtile-pending { padding: 10px; }

/* 4K upscale button on image tiles */
.wtile-4k { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.02em; line-height: 1; }

.wtile-btn.wtile-pub.is-on { background: var(--color-accent, #f97316); color: #fff; }
.wtile:has(.wtile-pub.is-on) .wtile-actions { opacity: 1; }
