/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #ffffff;
  color: #211922;
  overflow: hidden;
  --waterfall-overlay-left: 12px;
  --waterfall-overlay-width: calc(100vw - 24px);
  --waterfall-overlay-center: 50vw;
  --remix-bottom: 84px;
  --results-bottom: 238px;
}

/* ---- Header ---- */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e0;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}
.header-brand {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; text-decoration: none;
}
.header-brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #f6f6f3;
}
.header-brand-logo {
  width: 100%; height: 100%; display: block; object-fit: cover;
}
.header-brand-name {
  font-size: 13px; font-weight: 700; color: #211922;
  letter-spacing: -0.01em; white-space: nowrap;
}
.header-author-link {
  font-size: 12px; font-weight: 600; color: #8a4a20;
  text-decoration: none; white-space: nowrap;
  padding: 4px 8px; border-radius: 999px;
  background: rgba(255,107,53,.08);
  transition: background 0.15s, color 0.15s;
}
.header-author-link:hover {
  background: rgba(255,107,53,.14);
  color: #e60023;
}
.header-search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  max-width: 500px; margin: 0 auto;
}
.header-search-input {
  flex: 1; height: 36px; border-radius: 20px;
  border: 1px solid #e5e5e0; background: #f6f6f3;
  padding: 0 14px; font-size: 13px; color: #211922; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.header-search-input::placeholder { color: #91918c; }
.header-search-input:focus {
  border-color: #bcbcb3;
  box-shadow: 0 0 0 3px rgba(230, 0, 35, 0.06);
  background: #ffffff;
}
.header-search-btn {
  height: 36px; padding: 0 16px;
  background: #e60023; color: #ffffff; border: none; border-radius: 14px;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.15s;
}
.header-search-btn:hover { background: #c0001e; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-contribute {
  height: 34px; padding: 0 16px;
  border: 1.5px solid transparent; border-radius: 15px;
  background:
    linear-gradient(135deg, #e60023, #ff4f31 48%, #ff8a3d) padding-box,
    linear-gradient(135deg, #ffdf8f, #ff6b35 38%, #e60023 72%, #8b5cf6) border-box;
  color: #ffffff; font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 8px 22px rgba(230,0,35,.22), 0 0 0 3px rgba(255,107,53,.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-contribute:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 11px 28px rgba(230,0,35,.28), 0 0 0 4px rgba(255,107,53,.12);
}
.btn-contribute:active {
  transform: translateY(0);
  box-shadow: 0 5px 16px rgba(230,0,35,.22), 0 0 0 3px rgba(255,107,53,.08);
}

/* ---- Gallery Bar ---- */
#gallery-bar {
  position: fixed; top: 56px; left: 0; right: 0; height: 44px;
  background: #ffffff; border-bottom: 1px solid #e5e5e0; z-index: 90;
  display: flex; align-items: center; padding: 0 16px; gap: 6px; overflow: hidden;
  overscroll-behavior-x: contain;
}
.gallery-chips-wrap {
  display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden; padding: 7px 0;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.gallery-chips-wrap::-webkit-scrollbar { display: none; }
.gallery-chips-wrap::after {
  content: ""; flex: 0 0 2px; height: 1px;
}
.gallery-chip {
  height: 26px; padding: 0 12px; background: #f6f6f3;
  border: none; border-radius: 20px; font-size: 12px; color: #62625b;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.gallery-chip:hover { background: #e0e0d9; color: #211922; }
.gallery-chip.active { background: #211922; color: #ffffff; }
.gallery-more-btn {
  display: none; height: 26px; padding: 0 12px; background: #f6f6f3; border: none;
  border-radius: 20px; font-size: 12px; color: #62625b; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; position: relative;
}
.gallery-more-btn:hover { background: #e0e0d9; color: #211922; }
.gallery-dropdown {
  display: none; position: absolute; top: 34px; right: 0;
  background: #ffffff; border: 1px solid #e5e5e0; border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0,0,0,.14); padding: 6px; z-index: 220;
  min-width: 180px; max-height: min(360px, calc(100dvh - 112px)); overflow-y: auto;
}
.gallery-dropdown.open { display: block; }
.gallery-dropdown-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 12px; font-size: 13px; color: #62625b; cursor: pointer;
  border-radius: 8px; white-space: nowrap;
}
.gallery-dropdown-item:hover { background: #f6f6f3; color: #211922; }
.gallery-dropdown-item.active { color: #e60023; font-weight: 500; }

/* ---- Main Layout ---- */
#main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  padding-top: 100px;
}
#main-layout.drawer-open {
  grid-template-columns: minmax(0, 55fr) minmax(420px, 45fr);
}

/* ---- Waterfall ---- */
#waterfall-col {
  overflow-y: auto; overflow-x: hidden; padding: 12px;
  scrollbar-width: thin; scrollbar-color: #e0e0d9 transparent;
}
#waterfall-col::-webkit-scrollbar { width: 5px; }
#waterfall-col::-webkit-scrollbar-track { background: transparent; }
#waterfall-col::-webkit-scrollbar-thumb { background: #e0e0d9; border-radius: 3px; }
.waterfall { columns: 5; column-gap: 8px; }
#main-layout.drawer-open .waterfall { columns: 3; }

/* ---- Card ---- */
.card {
  display: block; width: 100%; break-inside: avoid; margin: 0 0 8px;
  padding: 0; border: 0; background: transparent; text-align: left;
  cursor: pointer;
  position: relative; border-radius: 12px; overflow: hidden;
  transition: transform 0.18s ease;
}
.card:hover { transform: translateY(-2px); }
.card:hover .card-placeholder { filter: brightness(0.93); }
.card.selected { outline: 3px solid #e60023; outline-offset: 2px; }
.card.selected .card-check { display: flex !important; }
.card-placeholder {
  width: 100%; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; transition: filter 0.18s ease; position: relative;
  overflow: hidden; background: #f6f6f3;
}
.card-placeholder img,
.drawer-img-area > img,
.gen-img-block img {
  width: 100%; height: 100%; display: block; object-fit: cover;
}
.drawer-img-area > img { position: absolute; inset: 0 0 auto; height: var(--drawer-image-visual-height, clamp(260px, 45vh, 520px)); object-fit: contain; z-index: 1; }
.card-placeholder img {
  position: static; height: auto; object-fit: contain;
}
.card-placeholder-label {
  font-size: 10px; font-weight: 500; letter-spacing: 0.02em;
  opacity: 0.35; color: #211922; font-variant-numeric: tabular-nums;
}
.card-gallery-tag {
  position: absolute; bottom: 7px; left: 7px;
  background: rgba(0,0,0,.52); color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 5px; pointer-events: none;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  max-width: calc(100% - 48px); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.card-copy-prompt {
  position: absolute; right: 7px; bottom: 7px; z-index: 6;
  width: 26px; height: 26px; border: none; border-radius: 8px;
  background: rgba(0,0,0,.52); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.card-copy-prompt:hover {
  background: rgba(230,0,35,.9); transform: translateY(-1px);
}
.card-copy-prompt.copied {
  background: linear-gradient(135deg, #e60023, #ff6b35);
}
.card-title-shade {
  position: absolute; top: 0; left: 0; right: 0; min-height: 38%;
  padding: 9px 10px 22px;
  background: linear-gradient(180deg, rgba(0,0,0,.58), rgba(0,0,0,.24) 56%, rgba(0,0,0,0));
  color: #fff; pointer-events: none;
  display: flex; align-items: flex-start;
}
.card-title-text {
  font-size: 12px; font-weight: 700; line-height: 1.28;
  text-shadow: 0 1px 8px rgba(0,0,0,.35);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-check {
  display: none; position: absolute; top: 7px; right: 7px;
  width: 18px; height: 18px; background: #e60023; color: #fff;
  border-radius: 50%; font-size: 10px; align-items: center;
  justify-content: center; font-weight: 700;
}

/* ---- Drawer Col ---- */
#drawer-col {
  border-left: 1px solid #e5e5e0; overflow-y: auto;
  background: #ffffff; position: relative; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: #e0e0d9 transparent;
  display: none; min-width: 0;
  overflow-anchor: none;
}
#main-layout.drawer-open #drawer-col { display: flex; }
#drawer-col::-webkit-scrollbar { width: 5px; }
#drawer-col::-webkit-scrollbar-track { background: transparent; }
#drawer-col::-webkit-scrollbar-thumb { background: #e0e0d9; border-radius: 3px; }
#drawer-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; gap: 12px; color: #91918c;
  padding: 40px; text-align: center;
}
#drawer-empty svg { opacity: 0.25; }
#drawer-empty p { font-size: 13px; line-height: 1.7; }
#drawer-content { display: none; min-height: 100%; }
#drawer-content.visible {
  display: block;
  animation: drawerSlideIn 0.22s ease both;
  overflow-anchor: none;
  padding-bottom: 360px;
}
@keyframes drawerSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.drawer-close-btn {
  position: sticky; top: 12px; margin: 12px 14px -40px auto;
  width: 28px; height: 28px; background: rgba(255,255,255,.82);
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 120;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  backdrop-filter: blur(10px);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.drawer-close-btn:hover {
  background: rgba(255,255,255,.96);
  transform: scale(1.04);
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

/* ---- Drawer: Image Area ---- */
.drawer-img-area {
  position: sticky; top: 0; z-index: 18; background: #f6f6f3;
  height: var(--drawer-image-compact-height, 160px);
  display: flex; align-items: center;
  justify-content: center; cursor: pointer;
  overflow: visible; transition: box-shadow 0.18s ease, background-color 0.18s ease;
  will-change: box-shadow;
  transform: translateZ(0);
  overflow-anchor: none;
}
.drawer-img-area::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: var(--drawer-image-visual-height, clamp(260px, 45vh, 520px));
  background: #f6f6f3;
  z-index: 0;
  pointer-events: none;
}
.drawer-img-area > img,
.drawer-image-carousel {
  transform: scale(var(--drawer-image-scale, 1));
  transform-origin: center center;
  will-change: transform;
}
.drawer-img-area.is-shrinking {
  background: #f4f4ef;
}
.drawer-img-area.is-compact {
  box-shadow: 0 10px 28px rgba(0,0,0,.08);
}
.drawer-img-area:hover .img-input-hint { opacity: 1; }
.img-input-hint {
  position: absolute; inset: 0 0 auto; height: var(--drawer-image-visual-height, 100%);
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; opacity: 0;
  transition: opacity 0.2s; pointer-events: none; z-index: 14;
}
.drawer-img-area.input-selected::after {
  content: ""; position: absolute; inset: 0 0 auto; height: var(--drawer-image-visual-height, 100%); z-index: 16;
  border: 3px solid transparent; pointer-events: none;
  background: linear-gradient(135deg, #e60023, #ff6b35, #ffb347) border-box;
  -webkit-mask:
    linear-gradient(#000 0 0) padding-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) padding-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}
.img-input-badge {
  position: absolute; left: 8px; top: calc(var(--drawer-image-visual-height, 100%) - 34px); z-index: 17;
  background: linear-gradient(135deg, #e60023, #ff6b35);
  color: #fff; font-size: 11px;
  padding: 3px 8px; border-radius: 6px; pointer-events: none;
  display: none;
  box-shadow: 0 6px 18px rgba(230,0,35,.22);
}
.drawer-img-area.input-selected .img-input-badge { display: block; }
.drawer-image-carousel {
  position: absolute; inset: 0 0 auto; height: var(--drawer-image-visual-height, 100%); display: flex; align-items: center;
  justify-content: center; gap: 12px; padding: 18px 48px;
  overflow: hidden; z-index: 1;
}
.drawer-image-slide {
  height: 82%; width: min(46%, 260px); flex: 0 0 auto;
  border-radius: 10px; overflow: hidden; opacity: 0.42;
  transform: scale(0.86); transition: transform 0.2s ease, opacity 0.2s ease;
  background: #f6f6f3; box-shadow: 0 6px 22px rgba(0,0,0,.08);
}
.drawer-image-slide.active {
  opacity: 1; transform: scale(1); width: min(58%, 340px);
  box-shadow: 0 10px 34px rgba(0,0,0,.14);
}
.drawer-image-slide img {
  position: static; width: 100%; height: 100%; object-fit: contain;
}
.img-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.9); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; z-index: 17;
}
.img-nav-btn:hover { background: rgba(255,255,255,1); }
.img-nav-btn.prev { left: 8px; }
.img-nav-btn.next { right: 8px; }
.img-counter {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.45); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 10px;
  font-variant-numeric: tabular-nums;
  z-index: 17;
}

/* ---- Drawer: Info Area ---- */
.drawer-info {
  margin-top: var(--drawer-info-lift-space, 0px);
  padding: 14px 16px 12px; border-bottom: 1px solid #e5e5e0;
  background: #ffffff;
  position: relative;
  z-index: 1;
}
.drawer-info h2 {
  font-size: 15px; font-weight: 700; color: #211922;
  letter-spacing: -0.01em; margin-bottom: 1px; line-height: 1.3;
}
.drawer-info h3 {
  font-size: 11px; font-weight: 400; color: #91918c;
  margin-bottom: 10px; line-height: 1.4;
}
.drawer-gallery-link {
  display: inline-flex; align-items: center; height: 22px;
  padding: 0 8px; margin-bottom: 8px; border: none; border-radius: 11px;
  background: #fef0f0; color: #e60023; cursor: pointer;
  font-size: 11px; font-weight: 600;
}
.drawer-gallery-link:hover { background: #ffe2e5; }
.drawer-pills { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.drawer-pill {
  display: inline-block; padding: 2px 9px;
  border-radius: 20px; background: #f6f6f3;
  border: 1px solid #e5e5e0; font-size: 11px; color: #62625b;
}
.drawer-source { font-size: 11px; color: #91918c; margin-bottom: 10px; }
.drawer-source a { color: #2b48d4; text-decoration: none; }
.drawer-source a:hover { text-decoration: underline; }
.drawer-prompt-label {
  font-size: 11px; font-weight: 600; color: #62625b;
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 6px;
}
.drawer-prompt-box {
  position: relative; background: #f6f6f3;
  border: 1px solid #e5e5e0; border-radius: 8px; overflow: hidden;
}
.drawer-prompt-text {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 11px; line-height: 1.65; color: #211922;
  padding: 10px 36px 10px 12px; max-height: 160px;
  overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  scrollbar-width: thin; scrollbar-color: #e0e0d9 transparent;
}
.drawer-prompt-text::-webkit-scrollbar { width: 4px; }
.drawer-prompt-text::-webkit-scrollbar-thumb { background: #e0e0d9; border-radius: 2px; }
.prompt-copy-btn {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border: none; background: rgba(255,255,255,.8);
  border-radius: 6px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: background 0.15s; color: #62625b;
}
.prompt-copy-btn:hover { background: #fff; color: #211922; }
.copy-tooltip {
  position: absolute; top: -22px; right: 0;
  background: #211922; color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
.copy-tooltip.show { opacity: 1; }

/* ---- Drawer: Tags Area ---- */
.drawer-tags {
  padding: 14px 16px; border-bottom: 1px solid #e5e5e0;
}
.tags-note {
  font-size: 11px; line-height: 1.65; color: #91918c;
  background: #fafaf9; border: 1px solid #f0f0ec;
  border-radius: 10px; padding: 8px 10px; margin-bottom: 10px;
}
.tags-note strong { color: #62625b; font-weight: 700; }
.tags-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.tags-header-title {
  font-size: 12px; font-weight: 700; color: #211922; letter-spacing: -0.01em;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.tags-selected-count {
  color: #91918c; font-size: 11px; font-weight: 500;
}
.tags-quick-btns { display: flex; gap: 6px; }
.tag-quick-btn {
  height: 22px; padding: 0 10px; border-radius: 11px;
  border: 1px solid #e5e5e0; background: #fff;
  font-size: 11px; color: #62625b; cursor: pointer;
  transition: all 0.15s;
}
.tag-quick-btn:hover { border-color: #91918c; color: #211922; }
.tag-category-block { margin-bottom: 10px; }
.tag-category-block:last-child { margin-bottom: 0; }
.tag-category-name {
  font-size: 10px; font-weight: 600; color: #91918c;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 6px;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  height: 24px; padding: 0 10px; border-radius: 12px;
  border: 1px solid #e5e5e0; background: #fff;
  font-size: 12px; color: #211922; cursor: pointer;
  display: inline-flex; align-items: center; gap: 3px;
  transition: all 0.15s; user-select: none;
}
.tag:not(.selected) { color: #9b9b93; border-color: #e5e5e0; background: #fff; }
.tag:hover { border-color: #91918c; background: #fafaf9; }
.tag.selected {
  background: #fef0f0; border-color: #e60023; color: #e60023;
}
.tag.spark {
  border: 1.5px solid transparent;
  background: linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, #e60023, #ff6b35, #ffb347) border-box;
}
.tag.spark:hover {
  background: linear-gradient(#fafaf9, #fafaf9) padding-box,
    linear-gradient(135deg, #e60023, #ff6b35, #ffb347) border-box;
}
.tag.spark.selected {
  background: linear-gradient(#fef0f0, #fef0f0) padding-box,
    linear-gradient(135deg, #e60023, #ff6b35, #ffb347) border-box;
  color: #e60023;
}
.tag-spark-star {
  font-size: 9px; opacity: 0.6; line-height: 1;
}

/* ---- Drawer: Remix Input Area ---- */
.drawer-remix {
  position: fixed;
  left: var(--waterfall-overlay-center);
  right: auto;
  bottom: var(--remix-bottom);
  z-index: 260;
  width: min(760px, calc(var(--waterfall-overlay-width) - 32px));
  padding: 12px;
  border: 1px solid rgba(229,229,224,.92);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 18px 54px rgba(0,0,0,.14);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
#main-layout.drawer-open .drawer-remix {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.remix-drag-handle {
  width: 54px;
  height: 5px;
  border-radius: 999px;
  background: #d4d4cc;
  margin: -2px auto 9px;
  cursor: ns-resize;
  touch-action: none;
}
.remix-drag-handle:hover,
.drawer-remix.dragging .remix-drag-handle {
  background: #a8a89f;
}
.drawer-remix.dragging {
  transition: opacity 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 22px 64px rgba(0,0,0,.18);
}
.remix-label-strip {
  display: flex; align-items: center; gap: 6px;
  width: 100%; overflow-x: auto; overflow-y: hidden;
  white-space: nowrap; scrollbar-width: none;
  padding: 0 1px 8px; margin-top: -1px;
}
.remix-label-strip::-webkit-scrollbar { display: none; }
.remix-label-chip {
  flex: 0 0 auto; height: 22px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid rgba(230,0,35,.5); border-radius: 999px;
  padding: 0 8px; background: rgba(255,255,255,.78);
  color: #e60023; font-size: 11px; line-height: 1;
}
.remix-label-chip.spark {
  border-color: #ff6b35;
  background: linear-gradient(#fff7f4, #fff7f4) padding-box,
    linear-gradient(135deg, #e60023, #ff6b35, #ffb347) border-box;
}
.remix-label-chip .dim {
  color: #91918c; font-size: 10px;
}
.remix-label-empty {
  color: #b0b0a8; font-size: 11px; padding: 1px 0 8px;
}
.remix-attachments {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.remix-attachment-thumb {
  position: relative; width: 48px; height: 48px;
  border-radius: 8px; border: 1px solid #e5e5e0; overflow: hidden;
  flex-shrink: 0; background: #f6f6f3;
  display: flex; align-items: center; justify-content: center;
}
.remix-attachment-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.remix-attachment-thumb .att-placeholder {
  font-size: 9px; color: #91918c; text-align: center; padding: 4px; line-height: 1.3;
}
.att-remove-btn {
  position: absolute; top: 1px; right: 1px;
  width: 14px; height: 14px; background: rgba(0,0,0,.6);
  border: none; border-radius: 50%; color: #fff;
  font-size: 8px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.remix-add-ref {
  width: 48px; height: 48px; border-radius: 8px;
  border: 1.5px dashed #e0e0d9; background: none;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: border-color 0.15s;
  color: #91918c; font-size: 18px; line-height: 1;
}
.remix-add-ref:hover { border-color: #91918c; color: #62625b; }
.remix-input-row {
  display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px;
}
.remix-textarea {
  flex: 1; min-height: 52px; max-height: 100px; border: 1px solid #e5e5e0;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #211922;
  font-family: inherit; resize: none; outline: none;
  background: #fff; transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}
.remix-textarea::placeholder { color: #91918c; }
.remix-textarea:focus {
  border-color: #bcbcb3;
  box-shadow: 0 0 0 3px rgba(230,0,35,.06);
}
.remix-send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #e60023; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.15s, transform 0.15s;
  align-self: flex-end;
}
.remix-send-btn:hover { background: #c0001e; transform: scale(1.05); }
.remix-send-btn:disabled { background: #e0e0d9; cursor: not-allowed; transform: none; }
.remix-params {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid #f0f0ec; padding-top: 8px;
}
.remix-action-row,
.remix-param-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.param-btn {
  height: 24px; padding: 0 10px; border-radius: 12px;
  border: 1px solid #e5e5e0; background: #fff;
  font-size: 11px; color: #62625b; cursor: pointer;
  white-space: nowrap; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.param-btn:hover { border-color: #91918c; color: #211922; }
.param-btn.active { background: #fef0f0; border-color: #e60023; color: #e60023; }
.param-select {
  height: 24px; padding: 0 8px; border-radius: 12px;
  border: 1px solid #e5e5e0; background: #fff;
  font-size: 11px; color: #62625b; cursor: pointer; outline: none;
  transition: border-color 0.15s; appearance: none; -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L4 4L7 1' stroke='%2391918c' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
}
.param-select:focus { border-color: #bcbcb3; }
.remix-job-list {
  display: none;
  border-top: 1px solid #f0f0ec;
  margin-top: 8px; padding-top: 7px;
  overflow: hidden;
}
.remix-job-list.visible { display: block; }
.remix-job-rows {
  display: grid;
  gap: 5px;
}
.remix-job-item {
  width: 100%; min-width: 0; height: 26px;
  border: 1px solid #eeeeea; border-radius: 9px;
  background: rgba(255,255,255,.86);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 6px;
  padding: 0 8px; cursor: pointer; text-align: left;
  font-size: 11px; color: #62625b;
}
.remix-job-item:hover { border-color: #d6d6ce; background: #ffffff; }
.remix-job-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #bcbcb3;
}
.remix-job-item.running .remix-job-dot { background: #0a84ff; box-shadow: 0 0 0 3px rgba(10,132,255,.1); }
.remix-job-item.done .remix-job-dot { background: #20a162; }
.remix-job-item.failed .remix-job-dot { background: #e60023; }
.remix-job-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #211922; font-weight: 600;
}
.remix-job-status {
  color: #91918c; white-space: nowrap; font-size: 10px;
}
.remix-job-time {
  color: #b0b0a8; white-space: nowrap; font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.remix-job-pager {
  display: flex; justify-content: flex-end; align-items: center; gap: 5px;
  height: 22px; margin-top: 5px;
  color: #b0b0a8; font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.remix-job-page-btn {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid #e5e5e0; background: #fff; color: #62625b;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
}
.remix-job-page-btn:hover:not(:disabled) { border-color: #bcbcb3; color: #211922; }
.remix-job-page-btn:disabled { opacity: .38; cursor: default; }

/* ---- Drawer: Results Area ---- */
.drawer-results {
  position: fixed;
  left: var(--waterfall-overlay-center);
  bottom: var(--results-bottom);
  z-index: 250;
  width: min(760px, calc(var(--waterfall-overlay-width) - 32px));
  max-height: min(320px, calc(100vh - 360px));
  overflow: visible;
  padding: 0;
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
#main-layout.drawer-open .drawer-results[style*="block"] {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.results-title {
  display: none;
}
.result-cards-row {
  display: grid; grid-template-columns: 1fr 1.08fr 0.82fr;
  gap: 8px; align-items: stretch;
}
.result-card {
  flex: 1; min-width: 0; background: #ffffff;
  border: 1px solid #e5e5e0; border-radius: 12px;
  padding: 12px; position: relative; overflow: hidden;
  box-shadow: 0 16px 42px rgba(0,0,0,.12);
}
.result-card.brief-card,
.result-card.prompt-card {
  transform: none;
  margin-left: 0;
}
.result-card-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #91918c; margin-bottom: 8px;
}
.result-card-content {
  font-size: 11px; line-height: 1.6; color: #211922;
  max-height: 132px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: #e0e0d9 transparent;
}
.result-card-content.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; white-space: pre-wrap; word-break: break-all;
}
.result-card .card-copy-btn {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border: none;
  background: rgba(255,255,255,.8); border-radius: 5px;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: #62625b; transition: all 0.15s;
}
.result-card .card-copy-btn:hover { background: #fff; color: #211922; }
.result-card.image-card {
  transform: none; display: flex; flex-direction: column;
  overflow: visible;
}
.gen-img-placeholder {
  flex: 1; min-height: 112px; border: 1.5px dashed #e0e0d9;
  border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: #fafaf9; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.gen-img-placeholder:hover { border-color: #e60023; background: rgba(230,0,35,.03); }
.gen-img-placeholder .gen-label { font-size: 12px; font-weight: 600; color: #62625b; }
.gen-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: #e60023; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #fff;
  transition: background 0.15s, transform 0.15s;
}
.gen-btn:hover { background: #c0001e; transform: scale(1.05); }
.gen-loading {
  display: none; flex-direction: column; align-items: center; gap: 6px; padding: 16px;
}
.gen-loading.visible { display: flex; }
.gen-spinner {
  width: 20px; height: 20px; border: 2px solid #e5e5e0;
  border-top-color: #e60023; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gen-img-result { display: none; flex-direction: column; gap: 6px; }
.gen-img-result.visible { display: flex; }
.gen-img-block { width: 100%; border-radius: 8px; overflow: hidden; }
.gen-img-block.has-image { position: relative; background: #f6f6f3; }
.gen-img-block.has-image img { cursor: zoom-in; }
.gen-img-block-inner {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: rgba(0,0,0,.3);
}
.gen-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.86); cursor: pointer; color: #211922;
  display: flex; align-items: center; justify-content: center;
}
.gen-nav.prev { left: 6px; }
.gen-nav.next { right: 6px; }
.gen-counter {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 7px;
  border-radius: 999px; background: rgba(0,0,0,.48); color: #fff;
  font-size: 10px; font-variant-numeric: tabular-nums;
}
.gen-info-btn {
  position: absolute; top: 7px; right: 7px; width: 24px; height: 24px;
  border: 1.5px solid rgba(255,255,255,.95); border-radius: 50%;
  background: rgba(33,25,34,.72);
  color: #fff; cursor: pointer; font-weight: 800;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px; font-style: italic; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  z-index: 2;
}
.gen-info-btn:hover { background: rgba(230,0,35,.88); }
.gen-info-popover {
  position: absolute; right: 0; bottom: calc(100% + 8px);
  width: min(300px, calc(var(--waterfall-overlay-width) - 40px));
  max-height: 220px;
  overflow: auto; display: none; z-index: 30; border-radius: 10px;
  border: 1px solid #e5e5e0; background: rgba(255,255,255,.96);
  box-shadow: 0 12px 30px rgba(0,0,0,.12); padding: 10px;
  font-size: 10px; line-height: 1.55; color: #62625b;
}
.gen-info-popover.open { display: block; }
.gen-info-popover strong { display: block; color: #211922; margin-bottom: 4px; }
.status-line {
  margin-top: 8px; font-size: 11px; color: #91918c; line-height: 1.5;
}
.status-line.error { color: #e60023; }
.gen-img-actions { display: flex; gap: 5px; }
.gen-action-btn {
  flex: 1; height: 26px; border-radius: 8px; border: 1px solid #e5e5e0;
  background: #fff; font-size: 11px; color: #62625b; cursor: pointer;
  transition: all 0.15s;
}
.gen-action-btn:hover { border-color: #91918c; color: #211922; }
.gen-action-btn.share { background: #e60023; border-color: #e60023; color: #fff; }
.gen-action-btn.share:hover { background: #c0001e; }

/* ---- Generated image lightbox ---- */
.generated-lightbox {
  display: none; position: fixed; inset: 0; z-index: 760;
  align-items: center; justify-content: center;
  padding: 28px;
  background: rgba(17, 17, 16, .62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.generated-lightbox.open { display: flex; }
.generated-lightbox-panel {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: min(92vw, 1180px);
  max-height: calc(100vh - 56px);
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 28px 80px rgba(0,0,0,.32);
}
.generated-lightbox-panel img {
  display: block;
  width: auto;
  max-width: calc(92vw - 28px);
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: 12px;
  background: #f6f6f3;
}
.generated-lightbox-close {
  position: absolute; top: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(229,229,224,.75);
  background: rgba(255,255,255,.9);
  color: #211922; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.generated-lightbox-close:hover { background: #fff; }
.generated-lightbox-actions {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 2px 0 0;
}
.lightbox-icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid #e5e5e0; background: #fff;
  color: #62625b; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s, color .15s, background .15s;
}
.lightbox-icon-btn:hover {
  transform: translateY(-1px);
  border-color: #bcbcb3; color: #211922;
}
.lightbox-icon-btn.share {
  background: #e60023; border-color: #e60023; color: #fff;
}
.lightbox-icon-btn.share:hover { background: #c0001e; border-color: #c0001e; }
.lightbox-icon-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.lightbox-icon-btn.done { color: #e60023; border-color: #e60023; }
.lightbox-icon-btn.share.done { background: #11a35a; border-color: #11a35a; color: #fff; }
.loading-dots::after {
  content: ''; animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0%, 20% { content: ''; }
  40%      { content: '.'; }
  60%      { content: '..'; }
  80%,100% { content: '...'; }
}

/* ---- Modal ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 500;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #ffffff; border-radius: 22px; width: min(1120px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow-y: auto; padding: 24px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-title-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; padding-right: 34px;
}
.modal-title { font-size: 17px; font-weight: 700; color: #211922; }
.modal-subtitle { margin-top: 3px; font-size: 12px; color: #91918c; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 26px; height: 26px;
  background: #f6f6f3; border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #e5e5e0; }
.modal-cards {
  display: flex; align-items: flex-start; justify-content: center; gap: 14px;
  overflow-x: auto; padding: 8px 4px 14px; min-height: 430px;
  scrollbar-width: thin; scrollbar-color: #e0e0d9 transparent;
}
.modal-cards::-webkit-scrollbar { height: 5px; }
.modal-cards::-webkit-scrollbar-thumb { background: #e0e0d9; border-radius: 999px; }
.contribution-card {
  position: relative; flex: 0 0 320px; max-width: 320px;
  background: #ffffff; border: 1px solid #e5e5e0; border-radius: 18px;
  padding: 18px; box-shadow: 0 16px 42px rgba(0,0,0,.08);
  transform: rotate(-1.2deg); transform-origin: center bottom;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.contribution-card:nth-child(2) { transform: rotate(1deg); }
.contribution-card:nth-child(3) { transform: rotate(-0.7deg); }
.contribution-card:focus-within,
.contribution-card:hover {
  transform: rotate(0deg) translateY(-2px);
  border-color: #d4d4cc; box-shadow: 0 18px 48px rgba(0,0,0,.12);
}
.contribution-card-add {
  flex: 0 0 auto;
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: #e60023; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 8px 22px rgba(230,0,35,.22);
  transition: background 0.15s, transform 0.15s;
}
.contribution-card-add:hover { background: #c0001e; transform: translateY(-1px); }
.contribution-card-add:disabled {
  background: #e0e0d9; box-shadow: none; cursor: not-allowed;
}
.contribution-card-remove {
  position: absolute; top: 10px; right: 10px;
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: #f6f6f3; color: #62625b; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.contribution-card-remove:hover { background: #e5e5e0; color: #211922; }
.contribution-card-index {
  font-size: 11px; font-weight: 700; color: #e60023;
  margin-bottom: 10px; letter-spacing: 0.04em; text-transform: uppercase;
}
.form-label {
  display: block; font-size: 11px; font-weight: 600; color: #62625b;
  margin-bottom: 5px; margin-top: 14px; letter-spacing: 0.02em;
}
.form-label:first-of-type { margin-top: 0; }
.form-input {
  width: 100%; border: 1px solid #e5e5e0; border-radius: 12px;
  padding: 9px 13px; font-size: 13px; color: #211922; outline: none;
  transition: border-color 0.15s; background: #ffffff; font-family: inherit;
}
.form-input:focus { border-color: #bcbcb3; box-shadow: 0 0 0 3px rgba(230,0,35,.06); }
textarea.form-input { min-height: 72px; resize: vertical; }
.upload-zone {
  border: 2px dashed #e0e0d9; border-radius: 14px; padding: 28px 16px;
  text-align: center; cursor: pointer; transition: all 0.15s; position: relative;
}
.upload-zone:hover { border-color: #bcbcb3; background: #fafaf9; }
.upload-zone.drag-over { border-color: #e60023; background: rgba(230,0,35,.03); }
.upload-zone-text { font-size: 13px; color: #91918c; line-height: 1.6; }
.upload-zone-text strong { color: #211922; }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.upload-preview-item {
  position: relative; width: 68px; height: 68px; border-radius: 8px;
  overflow: hidden; border: 1px solid #e5e5e0;
}
.upload-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-remove {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  background: rgba(0,0,0,.6); border: none; border-radius: 50%; color: #fff;
  font-size: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-submit {
  width: 100%; height: 42px; background: #e60023; color: #ffffff;
  border: none; border-radius: 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-submit:hover { background: #c0001e; }
.btn-submit:disabled { background: #e0e0d9; cursor: not-allowed; }
.modal-submit-area {
  border-top: 1px solid #f0f0ec; padding-top: 14px; margin-top: 0;
}
.modal-add-row {
  display: flex; justify-content: center; padding: 0 0 14px;
}
.modal-feedback {
  margin-top: 14px; padding: 12px 14px; background: #f6f6f3;
  border-radius: 10px; font-size: 12px; color: #62625b; display: none;
}
.modal-feedback.visible { display: block; }
.modal-feedback .feedback-title { font-weight: 700; color: #211922; margin-bottom: 3px; }
