/* AI image-edit page (/image-edit). Built on theme.css tokens so light/dark
   both work; follows the site card idiom (path-card / report-preview-card). */

.ie-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.ie-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.ie-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--section-title);
  margin: 0 0 0.5rem;
}

.ie-intro {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-soft);
  max-width: 46rem;
  margin: 0;
}

.ie-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.ie-badge {
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--muted-box);
  color: var(--text-soft);
}

.ie-badge-ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #15803d;
}

.ie-badge-bad {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #b91c1c;
}

html[data-theme="dark"] .ie-badge-ok { color: #4ade80; }
html[data-theme="dark"] .ie-badge-bad { color: #f87171; }

/* ---- mode selector (tablist) ---- */

.ie-mode-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.ie-mode-card {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 1rem;
  border-radius: 18px;
  border: 2px solid var(--panel-border);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  color: var(--text-main);
  cursor: pointer;
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.ie-mode-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  transform: translateY(-2px);
}

.ie-mode-card[aria-selected="true"] {
  border-color: var(--brand-secondary);
  box-shadow: var(--card-raise);
}

.ie-mode-card:focus-visible {
  outline: 3px solid var(--brand-secondary);
  outline-offset: 2px;
}

.ie-mode-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ie-mode-top > div { min-width: 0; }

.ie-mode-thumbs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.ie-mode-thumbs img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--muted-box);
}

.ie-mode-arrow {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.ie-mode-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.ie-mode-desc {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin: 0.25rem 0 0;
}

/* Per-app credit cost, filled from /api/image-edit/defaults. */
.ie-mode-cost {
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--muted-box);
  color: var(--text-soft);
}

.ie-mode-cost:empty { display: none; }

.ie-run-cost {
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* ---- app panel ---- */

.ie-panel {
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.ie-panel[hidden] { display: none; }

.ie-panel-title { font-size: 1.2rem; font-weight: 700; color: var(--section-title); margin: 0; }
.ie-panel-desc { font-size: 0.8rem; color: var(--text-soft); margin: 0.25rem 0 0; }

.ie-example {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--muted-box);
  padding: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.ie-example-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 0.5rem;
}

.ie-example-figs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.ie-example-figs figure { margin: 0; }

.ie-example-figs img {
  height: 128px;
  width: 160px;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.ie-example-figs figcaption {
  font-size: 0.7rem;
  color: var(--text-soft);
  text-align: center;
  margin-top: 0.25rem;
}

.ie-example-arrow { color: var(--text-soft); font-size: 1.2rem; }

.ie-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0.75rem 0 0.25rem;
}

.ie-slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.ie-slots.single { grid-template-columns: 1fr; }

@media (max-width: 575.98px) {
  .ie-slots { grid-template-columns: 1fr; }
}

.ie-drop {
  display: block;
  border: 2px dashed var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 150ms ease, background 150ms ease;
}

.ie-drop:hover,
.ie-drop.is-drag {
  border-color: var(--brand-secondary);
  background: rgba(59, 130, 246, 0.06);
}

.ie-drop:focus-within {
  outline: 3px solid var(--brand-secondary);
  outline-offset: 2px;
}

.ie-drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 128px;
  padding: 0.5rem;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.ie-preview {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: contain;
  background: var(--muted-box);
}

.ie-preview[hidden] { display: none; }

.ie-upload-state { font-size: 0.75rem; min-height: 1rem; margin-top: 0.25rem; color: var(--text-soft); }
.ie-upload-state.is-ok { color: #15803d; }
.ie-upload-state.is-error { color: #b91c1c; }
html[data-theme="dark"] .ie-upload-state.is-ok { color: #4ade80; }
html[data-theme="dark"] .ie-upload-state.is-error { color: #f87171; }

.ie-options {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin-top: 0.75rem;
}

.ie-options .form-select { min-width: 12rem; }

.ie-prompt { min-height: 6rem; }

.ie-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.ie-actions .btn { min-height: 44px; }

.ie-email-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-soft);
  cursor: pointer;
}

.ie-status { font-size: 0.8rem; color: var(--text-soft); }
.ie-status.is-error { color: #b91c1c; }
.ie-status.is-success { color: #15803d; }
html[data-theme="dark"] .ie-status.is-error { color: #f87171; }
html[data-theme="dark"] .ie-status.is-success { color: #4ade80; }

.ie-progress {
  height: 6px;
  background: var(--panel-border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.ie-progress[hidden] { display: none; }

.ie-bar {
  height: 100%;
  width: 0;
  background: var(--brand-secondary);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.ie-result { margin-top: 1rem; display: grid; gap: 0.75rem; }

.ie-result img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.ie-result a { font-size: 0.8rem; }

/* Pose picker (pose_t2i mode): a scrollable grid of gallery thumbnails. */
.ie-poses-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ie-poses-head .ie-label { margin: 0.75rem 0 0; }

.ie-pose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.5rem;
  max-height: 26rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.25rem;
  margin-top: 0.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}

.ie-pose-grid .ie-poses-state {
  grid-column: 1 / -1;
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.ie-pose-grid button {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 150ms ease;
}

.ie-pose-grid button img {
  display: block;
  width: 100%;
  height: auto;
}

.ie-pose-grid button:hover { border-color: var(--brand-secondary); }

.ie-pose-grid button.is-selected {
  border-color: var(--brand-secondary);
  outline: 2px solid var(--brand-secondary);
  outline-offset: 1px;
}

.ie-pose-grid button:focus-visible {
  outline: 3px solid var(--brand-secondary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ie-mode-card, .ie-drop, .ie-bar, .ie-pose-grid button { transition: none; }
  .ie-mode-card:hover { transform: none; }
}
