/* ---------- authenticated app shell (create-workspace, docs/FRONTEND.md section 3) ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  /* The document itself is the scroller (so the wheel works everywhere, no dead zones); the sidebar
     and topbar are pinned with position:sticky. min-height (not height) keeps the shell full-viewport
     on short pages while still letting the grid row grow with content. */
  min-height: 100vh;
}

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
  /* Pinned as a full-height rail while the document scrolls (a wheel over it scrolls the document).
     overflow-y:auto lets a long nav scroll internally on a short viewport; the margin-top:auto footer
     stays pinned. The mobile @media override (position:fixed drawer) wins by source order. */
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  overflow-y: auto;
}

.side .brand {
  margin-bottom: 12px;
  padding: 6px 8px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-tag {
  font-size: 10px;
  color: var(--tx-3);
  letter-spacing: 0.3px;
}

.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--tx-3);
  padding: 12px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--tx-2);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: 0.15s;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--tx);
}

.nav-item.active {
  background: var(--surface);
  color: var(--tx);
}

.nav-item.is-disabled {
  color: var(--tx-3);
  pointer-events: none;
  opacity: 0.5;
}

.nav-gap {
  height: 14px;
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.credits {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.credits-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.credits-lab {
  font-size: 11px;
  color: var(--tx-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.credits-n {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 16px;
  color: var(--tx-2);
}

.bar-mini {
  height: 4px;
  border-radius: 3px;
  background: var(--surface-2);
  margin-top: 9px;
  overflow: hidden;
}

.bar-mini i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--lime);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}

.profile:hover {
  background: var(--surface);
}

.ava {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--lime), var(--good));
  flex: none;
}

.profile-text {
  min-width: 0;
}

.profile-n {
  font-weight: 500;
  font-size: 12px;
  color: var(--tx);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.profile-m {
  font-size: 11px;
  color: var(--tx-3);
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(212, 248, 75, 0.05), transparent 60%),
    var(--bg);
}

.top {
  height: 60px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  flex: none;
  /* Pinned to the viewport top; opaque so the document scrolls under it. */
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
}

/* App-open greeting (F5-2b): in the empty-state hero of the tool pages, replacing the heading. Two
   lines; punch words pop lime. Hides for free with the hero via #grid:not(:empty) ~ #empty. */
.greet {
  max-width: 540px;
  margin: 0 auto;
}

.greet .greet-1 {
  display: block;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(30px, 1.9vw, 44px);
  font-weight: 700;
  color: var(--tx);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.greet .greet-2 {
  display: block;
  font-size: clamp(16px, 1vw, 22px);
  color: var(--tx-2);
  line-height: 1.4;
  margin-top: 8px;
}

.g-pop {
  color: var(--lime);
  font-weight: 700;
}

.g-shout {
  color: var(--lime);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.top-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.top-sub {
  font-size: 12px;
  color: var(--tx-3);
}

.content {
  flex: 1;
  position: relative;
  min-height: 0;
}

/* The document (shell pages) is the scroller, but its scrollbar is hidden - scroll still works via
   trackpad/wheel/keyboard. Scoped to shell pages via :has(.app) so landing/auth keep their normal
   scrollbar. */
html:has(.app) {
  scrollbar-width: none;
}
html:has(.app)::-webkit-scrollbar {
  display: none;
}

/* The few elements that still scroll internally (sidebar on a short viewport, drawer body) also hide
   their scrollbar for consistency. */
.side,
.dr-body {
  scrollbar-width: none;
}
.side::-webkit-scrollbar,
.dr-body::-webkit-scrollbar {
  display: none;
}

.canvas {
  padding: 28px 28px 192px;
}

.empty-state {
  /* Exactly the free band between the sticky topbar (60px) and the fixed composer clearance (the
     canvas paddings, 28 + 192), so an EMPTY tool page never scrolls - the document is precisely one
     viewport tall. The hero centers in that band; the bottom padding biases it ~30px above the
     geometric center (optical centering, Aljaz 2026-07-16). Media blocks mirror the canvas paddings. */
  min-height: calc(100vh - 60px - 28px - 192px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding-bottom: 60px;
}

/* Empty-slot frame holding the Adhook brand mark (replaced the four-point star, which read as the
   Gemini logo). */
.empty-mark {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  border: 1px dashed var(--line-2);
  display: grid;
  place-items: center;
}

.empty-mark .em-a {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--lime);
  color: var(--on-lime);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0;
}

.empty-state p {
  color: var(--tx-3);
  max-width: 340px;
  line-height: 1.5;
  margin: 0;
}

/* ---------- generate bar (visual; Generate enabled in a later step) ---------- */
.gbar-wrap {
  /* Docked to the viewport bottom (fixed) while the document scrolls, offset by the sidebar width so
     it aligns with the content column. left becomes 0 when the sidebar is collapsed (desktop) or an
     overlay (mobile) - see the media rules by the responsive shell block. */
  position: fixed;
  left: 240px;
  right: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  /* Generous bottom padding lifts the bar off the viewport edge (Aljaz 2026-07-16). */
  padding: 16px 28px 38px;
  background: linear-gradient(transparent, var(--bg) 44%);
  pointer-events: none;
}

.gbar {
  pointer-events: auto;
  max-width: 880px;
  margin: 0 auto;
  background: rgba(20, 20, 23, 0.9);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.prod-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--h-control);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding: 0 12px 0 8px;
  cursor: pointer;
  flex: none;
  color: var(--tx);
}

.prod-chip:hover {
  border-color: var(--line-2);
}

.prod-thumb {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px dashed var(--line-2);
  color: var(--tx-3);
  flex: none;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
}

.prod-thumb.has-img {
  border-style: solid;
}

.prod-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.pc-name {
  font-weight: 500;
  font-size: 13px;
}

.pc-sub {
  font-size: 10px;
  color: var(--tx-3);
}

/* Chip + deselect pair: the X is a real sibling button overlaid on the chip's right edge
   (interactive content may not nest inside a button element). */
.pc-wrap {
  position: relative;
  display: flex;
  flex: none;
}

.prod-chip.has-x {
  padding-right: 36px;
}

.pc-x {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--tx-3);
}

.pc-x:hover {
  color: var(--tx);
  background: var(--surface);
}

/* Ad Reference upload control in the generate bar (F3-B) */
.upload-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--h-control);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  padding: 0 12px;
  cursor: pointer;
  flex: none;
  color: var(--tx-2);
  font-size: 12.5px;
}

.upload-chip:hover {
  border-color: var(--line-2);
}

.upload-chip.has-file {
  color: var(--tx);
  border-color: var(--lime);
}

/* Visually hidden, NOT display:none - the input stays keyboard-focusable so a keyboard user
   can Tab to the chip and open the file picker (focus ring via :focus-within below). */
.upload-chip input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-chip:focus-within {
  border-color: var(--lime);
}

.uc-ic {
  width: 14px;
  height: 14px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.uc-lab {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.describe {
  flex: 1;
  min-width: 0;
}

.describe input {
  width: 100%;
  height: var(--h-control);
  background: transparent;
  border: none;
  outline: none;
  color: var(--tx);
  font-size: 14px;
  font-family: inherit;
}

.describe input::placeholder {
  color: var(--tx-3);
}

.fmt-wrap {
  position: relative;
  flex: none;
}

.seg {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--h-control);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  flex: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.seg:hover {
  border-color: var(--line-2);
}

.seg-ic {
  width: 11px;
  height: 15px;
  border-radius: 3px;
  border: 1.5px solid var(--tx-3);
  flex: none;
}

.seg-lab {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--tx-2);
}

.seg-caret {
  display: inline-flex;
  align-items: center;
  color: var(--tx-3);
}

.fmt-pop {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 7px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 5;
}

.fmt-pop.show {
  display: block;
}

.fmt-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.fmt-opt:hover {
  background: var(--surface-2);
}

.fmt-opt.on {
  background: var(--surface-2);
}

.fmt-opt .fo-l {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fmt-opt .fo-ic {
  width: 16px;
  height: 22px;
  border-radius: 3px;
  border: 1.5px solid var(--tx-3);
}

.fmt-opt .fo-ic.feed {
  width: 20px;
  height: 18px;
}

.fmt-opt .fo-ic.both {
  width: 20px;
  height: 20px;
  border-style: dashed;
}

.fmt-opt.on .fo-ic {
  border-color: var(--lime);
}

.fmt-opt .fo-n {
  font-weight: 500;
  font-size: 13px;
  color: var(--tx-2);
}

.fmt-opt .fo-c {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tx-3);
}

.fmt-opt.on .fo-c {
  color: var(--lime);
}

.gen-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--h-control);
  background: var(--lime);
  color: var(--on-lime);
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 14.5px;
  padding: 0 18px;
  border: none;
  border-radius: var(--r-control);
  flex: none;
  cursor: pointer;
}

.gen-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- modal ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  width: 560px;
  max-width: 100%;
  max-height: 88vh;
  overflow: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 12px;
  /* The modal itself scrolls; keep the title + close reachable on long forms. */
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* Scroll anchors inside the modal (htmx show:top targets) must clear the sticky head. */
#entity-msg,
#prod-edit {
  scroll-margin-top: 110px;
}

.modal-head h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  margin: 0;
}

.modal-head p {
  color: var(--tx-3);
  font-size: 13px;
  margin: 5px 0 0;
  line-height: 1.5;
  max-width: 360px;
}

.x {
  width: var(--h-control);
  height: var(--h-control);
  border-radius: var(--r-control);
  display: grid;
  place-items: center;
  color: var(--tx-3);
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  flex: none;
}

.x:hover {
  color: var(--tx);
  border-color: var(--line-2);
}

/* Corner close on the creative detail modal (replaces the old footer Close button). */
.detail-x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  background: rgba(var(--bg-rgb), 0.55);
  backdrop-filter: blur(6px);
}

.modal-body {
  padding: 16px 22px 22px;
}

.url-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.url-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-control);
  padding: 0 13px;
  height: var(--h-control);
}
.url-input:focus-within {
  border-color: var(--lime);
}

.url-input input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--tx);
  font-size: 13.5px;
  font-family: inherit;
}

.url-input input::placeholder {
  color: var(--tx-3);
}

/* Round submit arrow at the end of the URL row (paste link -> arrow -> saved + selected). */
.url-go {
  width: var(--h-control);
  height: var(--h-control);
  flex: none;
  border: none;
  border-radius: 50%;
  background: var(--lime);
  color: var(--on-lime);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.url-go:hover {
  background: var(--lime-hover);
}

.url-go .spinner-sm {
  margin-right: 0;
}

/* Staged fetch feedback under the URL row (fixed copy on a client-side timer). */
.fetch-status {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--tx-3);
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline;
}

/* small in-button spinner, shown while its button's request is in flight */
.spinner-sm {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: currentColor;
  animation: rot 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
.htmx-request .spinner-sm,
.htmx-request.spinner-sm {
  display: inline-block;
}

.saved-lab {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tx-3);
  font-weight: 600;
  margin: 22px 0 11px;
}

.saved-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.saved {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-2);
  text-align: left;
  cursor: pointer;
  color: var(--tx);
  display: flex;
  flex-direction: column;
}

.saved:hover {
  border-color: var(--lime);
}

.sv-img {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.sv-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sv-n {
  padding: 8px 10px 2px;
  font-size: 12px;
  color: var(--tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sv-b {
  padding: 0 10px 8px;
  font-size: 10.5px;
  color: var(--tx-3);
}

/* Currently-selected entity: lime ring + a check badge in the image corner. */
.saved.sel {
  border-color: var(--lime);
}

.sv-on {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--on-lime);
  display: grid;
  place-items: center;
}

.saved-empty {
  color: var(--tx-3);
  font-size: 13px;
  grid-column: 1 / -1;
  margin: 0;
}

.saved-count {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--tx-3);
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Thin cap indicator next to the "N of M used" label. */
.sc-bar {
  flex: 1;
  max-width: 140px;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.sc-bar i {
  display: block;
  height: 100%;
  background: var(--lime);
}

/* kind badge + delete overlay on a saved card (F3-A) */
.sv-kind {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
  padding: 2px 6px;
  border-radius: 6px;
  text-shadow: none;
}

.sv-del {
  position: absolute;
  top: 5px;
  right: 5px;
  /* 24px minimum tap target: always visible (and tappable) on touch devices. Solid red so the
     destructive action is unmistakable next to the neutral edit pencil. */
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 7px;
  background: var(--bad);
  color: var(--on-lime);
  cursor: pointer;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.saved:hover .sv-del {
  opacity: 1;
}

/* Pencil twin of the delete button, sitting to its left. */
.sv-edit {
  position: absolute;
  top: 5px;
  right: 33px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.saved:hover .sv-edit {
  opacity: 1;
}

.sv-edit:hover {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
}

/* No hover on touch devices: keep edit + delete reachable. */
@media (hover: none) {
  .sv-del,
  .sv-edit {
    opacity: 1;
  }
}

.sv-del:hover {
  filter: brightness(1.08);
}

/* Armed state of the two-step delete: widens into a red "Delete?" pill until confirmed. */
.sv-del.arm {
  width: auto;
  padding: 0 9px;
  background: var(--bad);
  color: var(--on-lime);
  opacity: 1;
}

/* The armed pill grows leftward over the pencil's spot - hide the pencil while arming so the
   confirm target is unambiguous. */
.sv-img:has(.sv-del.arm) .sv-edit {
  opacity: 0;
  pointer-events: none;
}

.sv-del-lab {
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* product/service toggle in the add modal (F3-A) */
.kind-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.kt-opt {
  border: none;
  background: transparent;
  color: var(--tx-2);
  padding: 6px 18px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
}

.kt-opt.on {
  background: var(--lime);
  color: #0d0d0d;
  font-weight: 600;
}

/* enrichment images: removable candidate thumbs + upload tile (F3-A) */
.field-hint {
  color: var(--tx-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  font-size: 10.5px;
}

.img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.img-cell {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line-2);
}

.img-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-x {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  display: grid;
  place-items: center;
}

.img-upload {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 9px;
  border: 1px dashed var(--line-2);
  display: grid;
  place-items: center;
  align-content: center;
  cursor: pointer;
  text-align: center;
  color: var(--tx-3);
  gap: 2px;
}

.img-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.img-upload:focus-within {
  border-color: var(--lime);
}

.img-upload-plus {
  display: inline-flex;
  line-height: 0;
}

.img-upload-lab {
  font-size: 8.5px;
  padding: 0 4px;
}

/* ---------- editable scraped fields ---------- */
.scraped {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.scraped-note {
  font-size: 11.5px;
  color: var(--tx-3);
  background: rgba(212, 248, 75, 0.06);
  border: 1px solid rgba(212, 248, 75, 0.18);
  border-radius: 10px;
  padding: 9px 11px;
  line-height: 1.5;
}

.textarea {
  height: auto;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

.swatches {
  display: flex;
  gap: 8px;
}

.sw {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

/* Compact confirm dialogs (billing downgrade). */
.modal-sm {
  width: 440px;
}
.modal-p {
  font-size: 13.5px;
  color: var(--tx-2);
  line-height: 1.5;
  margin: 0 0 16px;
}
.modal-p b {
  color: var(--tx);
}

/* ---------- generation batch + cards (F1 step 3) ---------- */
.batch-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}
.batch-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-content: flex-start;
}
/* empty state hides once the batch has any card */
#grid:not(:empty) ~ #empty {
  display: none;
}
.card {
  width: 208px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
  transition: 0.18s;
}
.card.story {
  aspect-ratio: 9 / 16;
}
.card.done {
  cursor: pointer;
}
.card.done:hover {
  border-color: var(--line-2);
  transform: translateY(-3px);
}
.card .fmt-badge {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 3;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  padding: 3px 8px;
  border-radius: 7px;
  color: var(--tx-2);
}
/* generating */
.card.gen .shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(212, 248, 75, 0.07) 50%,
    transparent 70%
  );
  background-size: 220% 100%;
  animation: sweep 1.7s linear infinite;
}
@keyframes sweep {
  0% {
    background-position: 130% 0;
  }
  100% {
    background-position: -130% 0;
  }
}
.gen-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--tx-3);
}
.spin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-2);
  border-top-color: var(--lime);
  animation: rot 0.8s linear infinite;
}
@keyframes rot {
  to {
    transform: rotate(360deg);
  }
}
.gen-step {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.gen-sub {
  margin-top: 6px;
  font-size: 11.5px;
}
.gen-sub a {
  color: inherit;
  text-decoration: underline;
}
.gen-prog {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 3px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}
.gen-prog i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--lime);
  transition: width 0.4s;
}
.card.failed .gen-center {
  color: var(--bad);
}
.fail-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--bad);
  display: grid;
  place-items: center;
}

/* Corner dismiss on a failed card: removes the card from the batch view (the job row stays). */
.card-dismiss {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 3;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.card-dismiss:hover {
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
}
/* done creative */
.card .art {
  position: absolute;
  inset: 0;
  animation: reveal 0.5s ease both;
}
.card .art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.card .quick {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 3;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: 0.15s;
  transform: translateY(-3px);
}
.card.done:hover .quick {
  opacity: 1;
  transform: none;
}
.qbtn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  color: #fff;
  border: 1px solid var(--line);
  transition:
    transform 0.13s,
    background 0.13s;
}
.qbtn:hover {
  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.14);
}
/* generate error chip */
.gen-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: rgba(255, 128, 128, 0.08);
  border: 1px solid rgba(255, 128, 128, 0.35);
  color: var(--bad);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
}
.gen-error button {
  color: var(--bad);
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
/* ---------- detail popup ---------- */
.detail {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  /* Width hugs the creative (auto art track + fixed side) instead of a fixed 920px, so a tall
     Story ad no longer floats in a wide empty frame. The canvas is sized by height below, so the
     art column shrink-wraps it and the horizontal dead space is gone. */
  width: auto;
  max-width: 95vw;
  max-height: 90vh;
  display: grid;
  grid-template-columns: auto 360px;
  overflow: hidden;
  animation: pop 0.2s ease both;
}
.detail-art {
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.detail-canvas {
  /* Height-driven: fill most of the modal vertically; width follows the format's aspect ratio.
     max-width guards a wide Feed creative on small screens. */
  height: min(74vh, 560px);
  width: auto;
  max-width: 46vw;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}
.detail-canvas[data-fmt="feed"] {
  aspect-ratio: 4 / 5;
}
.detail-tabs {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.detail-tabs button {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 7px;
  color: var(--tx-3);
  font-weight: 500;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.12s;
}
.detail-tabs button.on {
  background: var(--surface-2);
  color: var(--tx);
}
.detail-side {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.detail-side-head {
  /* right inset clears the 40px corner-close circle (12px offset + 40px + breathing room) */
  padding: 18px 60px 6px 18px;
}
.detail-side-head .nm {
  font-weight: 600;
  font-size: 13.5px;
}
.detail-side-head .dt {
  font-size: 11px;
  color: var(--tx-3);
}
.copy-sec {
  padding: 14px 18px;
  position: relative;
}
.copy-sec-lab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.copy-sec-lab span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tx-3);
  font-weight: 600;
}
.copy-val {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--tx);
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease);
}
.copy-val:hover {
  border-color: var(--line-2);
}
.copy-tools {
  display: flex;
  gap: 6px;
}
.copy-tools button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--tx-3);
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.copy-tools button:hover {
  color: var(--lime);
  border-color: var(--line-2);
}
.copy-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.copy-edit textarea,
.cta-select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  color: var(--tx);
  resize: vertical;
}
/* Same focus affordance as .input everywhere: lime border on :focus. NOTE: this selector
   outranks the global element-level :focus-visible ring, so the keyboard ring for these (and
   the other high-specificity outline:none spots) is restored by the dedicated block next to
   the global focus rules at the end of the file. */
.copy-edit textarea:focus,
.cta-select:focus {
  outline: none;
  border-color: var(--lime);
}
.cta-select {
  resize: none;
  cursor: pointer;
}
.edit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--tx-3);
}
.edit-actions {
  display: flex;
  gap: 8px;
}
.copy-edit .btn {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}
/* Placement-only tweak for the shared alert inside the copy block. */
.copy-alert {
  margin: 0 18px 4px;
  font-size: 12.5px;
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition-duration: 0.01ms;
    transform: translateX(-50%);
  }
  .skel:after {
    animation: none;
  }
}
.cta-pill {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 5px 11px;
  font-weight: 600;
  font-size: 12.5px;
}
.variants {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.variant {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--tx-2);
}
.variant button {
  font-size: 11px;
  color: var(--tx-3);
}
.variant button:hover {
  color: var(--lime);
}
.detail-foot {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}
.foot-row {
  display: flex;
  gap: 9px;
}
/* Whole-ad delete in the detail popup: danger-tinted at rest (same always-visible red as the
   entity-card delete), fills in when armed to "Delete?". Base is .btn .btn-ghost. */
.detail-del {
  color: var(--bad);
  border-color: var(--bad-dim);
}
.detail-del:hover,
.detail-del.arm {
  color: var(--bad);
  border-color: var(--bad);
  background: var(--bad-tint);
}

/* Regenerate progress / failure popup: a compact centered card reusing the job-card progress
   language (.spin/.gen-step/.gen-prog), swapped into #detail-host in place of the detail. */
.detail-wait {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 46px 52px 38px;
  width: 360px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: pop 0.2s ease both;
}
.detail-wait .dw-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  align-self: stretch;
}
.detail-wait .gen-step {
  font-size: 13px;
  color: var(--tx-2);
}
/* .gen-prog is absolutely positioned inside grid cards; here it flows under the label. */
.detail-wait .gen-prog {
  position: static;
  width: 190px;
  margin-top: 2px;
}
.detail-wait .fail-mark {
  margin-bottom: 2px;
}
.detail-wait .gen-sub {
  margin-top: 0;
  /* keep the secondary link quieter than the muted message above it */
  color: var(--tx-3);
}
.detail-wait .dw-close {
  flex: none;
  align-self: stretch;
  margin-top: 8px;
}
/* .detail-foot is a 9px-gap column; the alert's own bottom margin would double the rhythm. */
.detail-foot .alert {
  margin-bottom: 0;
}
.gen-btn .gc {
  display: flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.16);
  padding: 2px 7px;
  border-radius: 6px;
}
@media (max-width: 768px) {
  .detail {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .detail-canvas {
    /* Stacked layout: size by width (full column) instead of height, so the image + copy fit. */
    height: auto;
    width: min(100%, 300px);
    max-width: 100%;
  }
}

