/* Compatibility layer for existing template class names and behavior hooks */
.stack{display:grid;gap:1rem}
.section-header{display:flex;justify-content:space-between;align-items:flex-start;gap:1rem;margin-bottom:.75rem}
.request-actions,.actions{display:flex;gap:.55rem;flex-wrap:wrap}
.request-meta{display:flex;justify-content:space-between;align-items:center;gap:.6rem}
.request-provider{font-size:.82rem;color:#475467;font-weight:600}
.request-error{font-size:.82rem;color:#b42318;margin:.3rem 0 0}
.library-search{display:grid;gap:.6rem}
.search-row{display:grid;gap:.6rem;grid-template-columns:minmax(180px,1fr) auto}
.queue-controls,.filter-panel,.stats-grid{display:grid;gap:.8rem}
.stats-grid{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}
.stats-grid > div{padding:.8rem;border:1px solid #e4eaf5;border-radius:10px;background:#f9fbff}
.viewer-layout{display:grid;gap:1rem;grid-template-columns:minmax(0,1fr) 320px}
.viewer-canvas{width:100%;min-height:520px;background:#0f172a;border-radius:12px;border:1px solid #d7dfef}
.viewer-sidebar{display:grid;gap:.8rem;align-content:start}
.code-block{background:#0f172a;color:#d1e0ff;padding:1rem;border-radius:10px;overflow:auto}
.error-page-card{max-width:760px;margin:2rem auto}
.error-code{font-size:2rem;font-weight:800}
.nav-toggle{display:none;border:1px solid #d7dfef;background:#fff;border-radius:10px;padding:.45rem;cursor:pointer}
.nav-toggle-bar{display:block;width:22px;height:2px;background:#334155;border-radius:2px}
.nav-toggle{gap:4px;flex-direction:column}
.impersonation-banner{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem;border:1px solid #fec84b;background:#fffaeb;color:#7a4b00;border-radius:10px;padding:.6rem .8rem;margin-bottom:1rem}
.image-grid .model-card{padding:.6rem}
.image-meta{display:flex;justify-content:space-between;gap:.5rem;align-items:flex-start}
.image-title{font-size:.95rem;line-height:1.3;margin:0}
.image-date{font-size:.75rem;color:#667085;white-space:nowrap}
.pagination{display:flex;gap:.5rem;align-items:center}
.empty-state{padding:1.1rem;border:1px dashed #d5deef;background:#f8fbff;border-radius:12px}
@media (max-width: 1100px){.viewer-layout{grid-template-columns:1fr}}

.form-field{display:grid;gap:.35rem}
.spaced-top{margin-top:1rem}
.spaced-top-lg{margin-top:1.5rem}
.upload-panel{padding:.9rem;border:1px dashed #cbd7ee;border-radius:12px;background:#f8fbff}
.advanced-panel{display:grid;gap:1rem;padding:1rem;border:1px solid #e4eaf5;border-radius:12px;background:#fbfdff;margin-top:.8rem}
.help,.help-text{font-size:.82rem;color:#667085}
.error{color:#b42318;font-size:.82rem}
.form-errors{margin:.35rem 0 0;padding:0;list-style:none;color:#b42318;font-size:.82rem}
.button-link.ghost{background:transparent}
.status-chip{display:inline-flex;padding:.2rem .45rem;border:1px solid #e1e9f7;border-radius:999px;background:#f8fbff}
.queue-layout{display:grid;gap:1rem}
.queue-cards{display:grid;gap:.8rem;grid-template-columns:repeat(auto-fill,minmax(250px,1fr))}
.queue-card-item{padding:.85rem;border:1px solid #e6ebf5;background:#fff;border-radius:12px;display:grid;gap:.5rem}
.queue-item-actions{display:flex;flex-wrap:wrap;gap:.5rem}
.filter-toggle{margin-bottom:.75rem}
.filter-panel{padding:.9rem;border:1px solid #e4eaf5;border-radius:12px;background:#fbfdff}
.model-view-shell{display:grid;gap:1rem}
.request-meta-grid{display:grid;gap:.65rem;grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.code-block{font-size:.84rem;line-height:1.45}
.request-actions form{display:inline-flex}
.library-search input{min-height:42px}
.preview-wrap{border:1px solid #e4eaf5;border-radius:10px;overflow:hidden;background:#f9fbff}
.empty-title{font-size:1.15rem;margin:0 0 .25rem}
.empty-subtitle{margin:0;color:#667085}
.impersonation-meta{opacity:.8}
.notification-link{position:relative;display:inline-flex;align-items:center;gap:.35rem}
.notification-badge{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;height:18px;padding:0 .3rem;border-radius:999px;
  font-size:.72rem;font-weight:700;
  background:#dc2626;color:#fff;
}
.notification-badge.is-hidden{display:none}
.notification-unread{border-color:#b2ccff;background:#f4f8ff}

/* Wizard */
.wizard{display:grid;gap:1rem}
.wizard-steps{display:flex;gap:.45rem;flex-wrap:wrap}
.wizard-step{font-size:.78rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em;padding:.28rem .6rem;border-radius:999px;border:1px solid #dbe5f6;background:#f8fbff;color:#667085}
.wizard-step.active{background:#eaf2ff;border-color:#c9ddff;color:#1d4ed8}
.wizard-loading-status{display:flex;align-items:center;gap:.5rem}
.wizard-spinner{width:18px;height:18px;border-radius:50%;display:inline-block;border:2px solid rgba(37,99,235,.2);border-top-color:rgba(37,99,235,.95);animation:wizard-spin .9s linear infinite}
.wizard-spinner.large{width:40px;height:40px;border-width:4px}
.wizard-progress{height:10px;border-radius:999px;background:#e6edf8;overflow:hidden}
.wizard-progress-bar{height:100%;background:linear-gradient(90deg,rgba(37,99,235,.3),rgba(37,99,235,.95),rgba(37,99,235,.35));background-size:200% 100%;animation:wizard-bar 1.2s ease-in-out infinite}
.wizard-progress-meta{display:flex;justify-content:space-between;font-size:.83rem}
.wizard-progress-value{font-weight:700;color:#1e3a8a;animation:wizard-pulse 1.8s ease-in-out infinite}
.wizard-error{color:#b42318;font-size:.85rem}
.wizard-project-name{font-size:.85rem;color:#667085;font-weight:600;margin-left:.4rem}
.wizard-preview{width:100%;background:#f8fbff;border:1px solid #dce6f7;border-radius:14px;padding:1rem;display:flex;align-items:center;justify-content:center}
.wizard-preview img{max-height:75vh;object-fit:contain}
.wizard-preview--loading{min-height:280px;position:relative;display:block;margin:1rem 0;overflow:hidden;background:linear-gradient(135deg,#f7faff,#eef4ff)}
.wizard-preview--loading::before{content:"";position:absolute;inset:0;background:linear-gradient(110deg,rgba(255,255,255,.15) 0%,rgba(37,99,235,.12) 50%,rgba(255,255,255,.12) 100%);background-size:200% 100%;animation:wizard-shimmer 2.2s ease-in-out infinite}
.wizard-preview-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;z-index:1}
.wizard-preview-loader{display:flex;flex-direction:column;align-items:center;gap:1rem;width:min(280px,70%)}
.wizard-placeholder{color:#667085}
.wizard-actions{display:flex;gap:.65rem;flex-wrap:wrap;margin-top:.8rem}
.wizard-step-one.is-drag-over{border-color:#8db4ff;box-shadow:0 0 0 1px rgba(37,99,235,.25)}
.wizard-project-field{margin-bottom:.85rem}
.wizard-input-pair{display:grid;grid-template-columns:1fr 1fr;gap:1rem}
.wizard-input-pair textarea{min-height:58px}
.wizard-upload-layout{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:1rem;align-items:stretch}
.wizard-upload-panel{border:1px solid #d8e3f5;border-radius:14px;background:#f8fbff;padding:1rem;display:grid;grid-template-columns:80px 1fr;gap:1rem;align-items:center}
.wizard-upload-icon svg{width:56px;height:56px;stroke:#98a2b3;fill:none;stroke-width:1.2}
.wizard-upload-content h4{margin:0 0 .35rem;font-size:1.05rem}
.wizard-upload-content p{margin:0 0 .75rem}
.wizard-upload-content input[type=file]{display:none}
.wizard-pick-button{min-width:190px}
.wizard-tips{border:1px solid #d8e3f5;border-radius:14px;background:#f8fbff;padding:1rem}
.wizard-tips h4{margin:0 0 .5rem}
.wizard-tips ul{margin:0;padding:0;list-style:none;display:grid;gap:.38rem}
.wizard-tips li{position:relative;padding-left:1rem;color:#475467}
.wizard-tips li::before{content:"";position:absolute;left:0;top:.45rem;width:.45rem;height:.45rem;border-radius:50%;background:#16a34a}
.wizard-submit-row{justify-content:flex-end}
.wizard-generate-button{min-width:180px;min-height:46px;padding:.72rem 1.25rem;font-size:1rem;font-weight:700}
.wizard-credit-chip{display:inline-flex;align-items:center;padding:.45rem .75rem;border-radius:999px;background:#eaf7ee;color:#1a7f37;font-weight:600;margin-right:auto}

.uploaded-photos-section h3{margin:0 0 .75rem;font-size:1rem}
.uploaded-photos-table{border:1px solid #d8e3f5;border-radius:12px;overflow:hidden;background:#f8fbff}
.uploaded-photos-header{display:grid;grid-template-columns:64px minmax(180px,.6fr) minmax(220px,1fr) 36px;gap:.75rem;padding:.6rem .75rem;border-bottom:1px solid #e1eaf8;font-size:.78rem;color:#667085;font-weight:600}
.uploaded-photos-empty{padding:.75rem;color:#667085;font-size:.88rem}
.uploaded-photos-grid{display:flex;flex-direction:column}
.uploaded-row{display:grid;grid-template-columns:64px minmax(180px,.6fr) minmax(220px,1fr) 36px;gap:.75rem;align-items:center;padding:.65rem .75rem;border-bottom:1px solid #e7eef9}
.uploaded-row:last-child{border-bottom:0}
.uploaded-row.uploading{opacity:.85}
.uploaded-photo-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;display:block;background:#eef3fb}
.uploaded-photo-name{font-size:.88rem;font-weight:600;color:#1f2937;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.uploaded-photo-description{width:100%;border:1px solid #d8e0ef;background:#fff;border-radius:10px;padding:.45rem .62rem;font-size:.88rem;color:#111827}
.uploaded-photo-description.uploading-placeholder{background:#f2f5fa;height:38px}
.uploaded-photo-delete-icon{width:30px;height:30px;border:1px solid #f0b3ad;background:#fff1f0;color:#d92d20;padding:0;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;border-radius:8px;transition:color .15s ease,border-color .15s ease,background-color .15s ease,box-shadow .15s ease}
.uploaded-photo-delete-icon svg{width:20px;height:20px;fill:currentColor}
.uploaded-photo-delete-icon:hover{color:#b42318;border-color:#e89289;background:#ffe2df}
.uploaded-photo-delete-icon:active{background:#ffd2cd}
.uploaded-photo-delete-icon:focus-visible{outline:0;box-shadow:0 0 0 3px rgba(59,130,246,.25)}
.uploaded-photo-uploading-state{font-size:.8rem;color:#3b82f6;text-align:center}
.uploading-thumb{display:flex;align-items:center;justify-content:center}

/* Generate page */
.generate-page{display:grid;gap:1rem}
.generate-form{display:grid;gap:1rem}
.step-card{
  display:grid;
  gap:1rem;
  background:var(--app-surface);
  border:1px solid var(--app-border);
  border-radius:var(--app-radius);
  box-shadow:var(--app-shadow);
  padding:clamp(1rem,.8rem + .9vw,1.6rem);
}
.step-card-collapsible{padding:.85rem 1rem}
.step-dropdown{display:grid;gap:.9rem}
.step-dropdown-summary{
  list-style:none;
  cursor:pointer;
  border:1px solid var(--app-border);
  border-radius:12px;
  background:var(--app-surface-soft);
  padding:.7rem .8rem;
}
.step-dropdown-summary::-webkit-details-marker{display:none}
.step-dropdown-summary::after{
  content:"▾";
  float:right;
  color:var(--app-muted);
  font-size:1rem;
  margin-top:.2rem;
}
.step-dropdown[open] .step-dropdown-summary::after{content:"▴"}
.step-header{display:flex;align-items:flex-start;gap:.9rem}
.step-header h2{margin:0 0 .2rem;font-size:1.15rem}
.step-header p{margin:0;color:var(--app-muted);font-size:.9rem}
.step-index{
  width:34px;height:34px;border-radius:999px;flex:0 0 auto;
  display:inline-flex;align-items:center;justify-content:center;
  font-weight:700;background:#eaf2ff;color:#1d4ed8;border:1px solid #cfe0ff;
}
.concept-stack{display:grid;gap:.9rem}
.settings-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:.9rem}
.settings-card{
  display:grid;gap:.75rem;
  border:1px solid var(--app-border);
  border-radius:12px;
  background:var(--app-surface-soft);
  padding:.85rem;
}
.settings-card h3{margin:0;font-size:1rem}
.prompt-panel textarea{min-height:160px}
.field-label{font-weight:600;font-size:.9rem;color:#344054}
.segmented{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:.65rem}
.segmented-option{
  position:relative;display:grid;cursor:pointer;
}
.segmented-option input{position:absolute;opacity:0;pointer-events:none}
.segmented-body{
  display:grid;gap:.2rem;
  border:1px solid var(--app-border);
  border-radius:10px;
  background:#fff;
  padding:.7rem .75rem;
  transition:all .15s ease;
}
.segmented-title{font-weight:700}
.segmented-desc{font-size:.82rem;color:var(--app-muted)}
.segmented-option input:checked + .segmented-body{
  border-color:#90b4f1;
  background:#eff5ff;
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.upload-panel{
  border:1px dashed #c6d8f3;
  background:#f8fbff;
  padding:.9rem;
  border-radius:12px;
}
.upload-panel.is-hidden{display:none}
.upload-header{display:flex;justify-content:space-between;gap:.6rem;align-items:center;margin-bottom:.55rem}
.upload-hint{font-size:.82rem;color:var(--app-muted)}
.selected-image{
  display:grid;grid-template-columns:64px 1fr auto;gap:.75rem;align-items:center;
  border:1px solid var(--app-border);border-radius:10px;background:#fff;padding:.55rem .6rem;margin-bottom:.6rem;
}
.selected-image-preview{
  width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid var(--app-border);background:#f6f8fd;
}
.selected-image-preview img{width:100%;height:100%;object-fit:cover}
.selected-image-meta{display:grid;gap:.15rem}
.selected-image-meta strong{font-size:.9rem;line-height:1.3}
.toggle-row{display:inline-flex;align-items:center;gap:.55rem;cursor:pointer}
.toggle-row input{width:auto}
.range-value{font-size:.82rem;color:var(--app-muted)}
#seed_field_wrap.is-hidden{display:none}
.advanced-panel[hidden]{display:none}
.advanced-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.75rem}
.checkbox-grid ul{list-style:none;margin:0;padding:0;display:grid;gap:.4rem}
.generate-actions{display:flex;gap:.6rem;flex-wrap:wrap;justify-content:flex-end}
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea,
.form-field.has-error .segmented-body,
.form-field.has-error .upload-panel{border-color:#fda29b}

@keyframes wizard-spin{to{transform:rotate(360deg)}}
@keyframes wizard-pulse{0%,100%{opacity:.7}50%{opacity:1}}
@keyframes wizard-bar{0%{background-position:0% 50%}100%{background-position:100% 50%}}
@keyframes wizard-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}

@media (max-width:1023px){
  .wizard-actions{flex-direction:column;align-items:stretch}
  .wizard-input-pair{grid-template-columns:1fr}
  .wizard-upload-layout{grid-template-columns:1fr}
  .selected-image{grid-template-columns:56px 1fr}
  .selected-image .button-link{grid-column:1/-1;justify-self:start}
  .generate-actions{justify-content:stretch}
  .generate-actions .button-link{flex:1 1 auto}
  .uploaded-photos-header{display:none}
  .uploaded-row{grid-template-columns:56px 1fr 30px;grid-template-areas:"thumb name delete" "thumb description delete"}
  .uploaded-row .uploaded-photo-thumb{grid-area:thumb}
  .uploaded-row .uploaded-photo-name{grid-area:name}
  .uploaded-row .uploaded-photo-description{grid-area:description}
  .uploaded-row .uploaded-photo-delete-icon,
  .uploaded-row .uploaded-photo-uploading-state{grid-area:delete}
}

.error-page{padding:1rem 0}
.error-card{max-width:760px;margin:0 auto;display:grid;gap:1rem}
.error-header{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.error-code{font-size:2.2rem;font-weight:800;color:#1d4ed8}
.error-illustration{width:72px;height:72px;color:#93a4c7}
.error-illustration svg{width:100%;height:100%;stroke:currentColor;fill:none;stroke-width:6;stroke-linecap:round}
.error-actions{display:flex;flex-wrap:wrap;gap:.6rem}
