/* Sideline AI — launchpad + studio */

:root {
  --sai-accent: #f4b01f;
  --sai-accent-hover: #e5a318;
  --sai-bg: #f5f6f8;
  --sai-surface: #ffffff;
  --sai-border: #e2e5eb;
  --sai-text: #1a1d26;
  --sai-muted: #6b7280;
  --sai-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  --sai-radius: 14px;
  --sai-radius-sm: 10px;
  --brand-primary: #e8731c;
  --brand-secondary: #af5510;
  --brand-accent: #f4b01f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--sai-bg);
  color: var(--sai-text);
}

button, input, textarea {
  font-family: inherit;
}

.sai-app {
  min-height: 90vh;
  position: relative;
}

/* .sai-composer-chat button#chat-plus-btn {
  display: none;
} */
/* Only one step visible at a time */
.sai-view {
  display: none !important;
}

.sai-view.active {
  display: block !important;
}

.sai-view-studio.active {
  display: flex !important;
  flex-direction: column;
  min-height: 90vh;
}

/* ── Brand kit toggle ── */
.sai-brand-anchor {
  position: fixed;
  top: 70px;
  right: 40px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Credits chip — launch (near Brand Kit) + studio (near Share) */
.sai-credit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--sai-text);
  box-shadow: var(--sai-shadow);
  white-space: nowrap;
}

.sai-credit-chip-label {
  color: var(--sai-muted, #6b7280);
  font-weight: 500;
}

.sai-credit-chip-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.25em;
  text-align: right;
}

.sai-credit-chip.is-empty .sai-credit-chip-count {
  color: #b45309;
}

.sai-credit-info-btn {
  margin-left: 2px;
}

.sai-credit-history-modal {
  width: min(980px, calc(100vw - 40px));
  max-width: none;
  max-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  padding: 28px;
}

.sai-credit-history-modal .sai-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.sai-credit-history-modal .sai-modal-head h2 {
  margin: 0 0 4px;
}

.sai-credit-history-modal .sai-modal-desc {
  margin: 0;
}

.sai-credit-history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 220px));
  gap: 12px;
  margin-bottom: 18px;
}

.sai-credit-history-summary > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px 16px;
  border: 1px solid var(--sai-border);
  border-radius: 12px;
  background: #f8fafc;
}

.sai-credit-history-summary span {
  color: var(--sai-muted, #6b7280);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sai-credit-history-summary strong {
  font-size: 1.35rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sai-credit-history-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--sai-border);
  border-radius: 12px;
  background: #fff;
}

.sai-credit-history-empty {
  margin: 0;
  padding: 16px 4px;
  font-size: 0.85rem;
  color: var(--sai-muted, #6b7280);
  line-height: 1.45;
}

.sai-credit-table-wrap {
  overflow-x: auto;
}

.sai-credit-history-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.sai-credit-history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 12px;
  border-bottom: 1px solid var(--sai-border);
  background: #f8fafc;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sai-credit-history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f3;
  color: var(--sai-text);
  vertical-align: middle;
}

.sai-credit-history-table tbody tr {
  transition: background 0.15s ease;
}

.sai-credit-history-table tbody tr:hover {
  background: #fafafa;
}

.sai-credit-history-table tbody tr:last-child td {
  border-bottom: none;
}

.sai-credit-history-table th:nth-child(1),
.sai-credit-history-table td:nth-child(1) {
  width: 72px;
}

.sai-credit-history-table th:nth-child(2),
.sai-credit-history-table td:nth-child(2) {
  width: 24%;
}

.sai-credit-history-table th:nth-child(3),
.sai-credit-history-table td:nth-child(3) {
  width: 17%;
}

.sai-credit-history-table th:nth-child(4),
.sai-credit-history-table td:nth-child(4) {
  width: 28%;
}

.sai-credit-history-table th:last-child,
.sai-credit-history-table td:last-child {
  width: 72px;
  text-align: right;
}

.sai-credit-history-image-btn {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.sai-credit-history-image-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #e8731c);
  outline-offset: 2px;
}

.sai-credit-history-thumb {
  display: block;
  width: 44px;
  height: 52px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
  background: #e5e7eb;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.12);
  transition: transform 0.15s ease;
}

.sai-credit-history-image-btn:hover .sai-credit-history-thumb {
  transform: scale(1.06);
}

.sai-credit-history-thumb--empty {
  background: repeating-linear-gradient(
    -45deg,
    #e5e7eb,
    #e5e7eb 4px,
    #f3f4f6 4px,
    #f3f4f6 8px
  );
}

.sai-credit-col-graphic {
  min-width: 0;
}

.sai-credit-col-graphic strong,
.sai-credit-col-graphic span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sai-credit-col-graphic strong {
  font-size: 0.82rem;
  font-weight: 650;
}

.sai-credit-col-graphic span {
  margin-top: 3px;
  color: var(--sai-muted, #6b7280);
  font-size: 0.7rem;
  text-transform: capitalize;
}

.sai-credit-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.sai-credit-date {
  color: #64748b !important;
  font-size: 0.73rem;
}

.sai-credit-history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-top: 1px solid var(--sai-border);
  background: #f8fafc;
  color: #64748b;
  font-size: 0.72rem;
}

.sai-credit-load-more {
  padding: 7px 12px;
  border: 1px solid #d7dce2;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sai-credit-load-more:hover {
  border-color: var(--brand-primary, #e8731c);
  color: var(--brand-primary, #e8731c);
}

.sai-credit-history-cost {
  font-size: 0.8rem;
  font-weight: 700;
  color: #b45309;
  font-variant-numeric: tabular-nums;
}

.sai-credit-preview-overlay {
  z-index: 1200;
}

.sai-credit-preview-modal {
  position: relative;
  display: flex;
  max-width: min(86vw, 900px);
  max-height: 88vh;
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.sai-credit-preview-modal img {
  display: block;
  max-width: 100%;
  max-height: calc(88vh - 36px);
  border-radius: 8px;
  object-fit: contain;
}

.sai-credit-preview-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

@media (max-width: 700px) {
  .sai-credit-history-modal {
    width: calc(100vw - 20px);
    max-height: 88vh;
    padding: 18px 14px;
  }

  .sai-credit-history-summary {
    grid-template-columns: 1fr 1fr;
  }

  .sai-credit-history-footer {
    position: sticky;
    left: 0;
  }

  .sai-credit-preview-modal {
    max-width: calc(100vw - 24px);
    padding: 12px;
  }
}

.sai-brand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--sai-shadow);
}

.sai-brand-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sai-brand-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 40px));
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius);
  padding: 18px;
  box-shadow: var(--sai-shadow);
  z-index: 10;
}

.sai-brand-panel[hidden] {
  display: none !important;
}

.sai-brand-panel-tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin: 6px 0 6px 0;
}

.sai-brand-logo-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.sai-brand-logo-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sai-brand-logo-size {
  flex: 1;
  min-width: 0;
}

.sai-brand-logo-size-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.sai-brand-logo-size input[type="range"],
.sai-download-size input[type="range"] {
  width: 100%;
  accent-color: var(--sai-accent, #e8731c);
  cursor: pointer;
}

.sai-brand-logo-size-hint {
  margin: 4px 0 0;
  font-size: 0.65rem;
  color: var(--sai-muted, #6b7280);
  line-height: 1.3;
}

.sai-btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
}

.sai-brand-logo-preview {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--sai-border);
  background: #f3f4f6;
}

.sai-brand-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  box-sizing: border-box;
}

.sai-brand-logo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* ── My Projects — ChatGPT-style collapsible left sidebar ── */
:root {
  --sai-projects-w: 260px;
  --sai-site-header-h: 53px; /* Sideline Design site header */
}

.sai-projects-sidebar {
  position: fixed;
  top: var(--sai-site-header-h);
  left: 0;
  bottom: 0;
  width: var(--sai-projects-w);
  height: calc(100vh - var(--sai-site-header-h));
  z-index: 220;
  background: #ffffff;
  border-right: 1px solid var(--sai-border);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  pointer-events: none;
  visibility: hidden;
}

body.sai-projects-sidebar-open .sai-projects-sidebar {
  transform: translateX(0);
  pointer-events: auto;
  visibility: visible;
}

.sai-projects-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding: 10px 0px 10px 10px;
  box-sizing: border-box;
  font-size: 12px;
  background: #ffffff;
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-height: none;
  position: static;
}

.sai-projects-panel[hidden] {
  display: none !important;
}

body.sai-projects-sidebar-open .sai-projects-panel {
  display: flex !important;
}

.sai-projects-rail-btn {
  position: fixed;
  top: calc(var(--sai-site-header-h) + 12px);
  left: 14px;
  z-index: 230;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--sai-border);
  border-radius: 10px;
  background: var(--sai-surface);
  color: var(--sai-text);
  cursor: pointer;
  box-shadow: var(--sai-shadow);
}

.sai-projects-rail-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.sai-projects-rail-btn[hidden],
body.sai-projects-sidebar-open .sai-projects-rail-btn {
  display: none !important;
}

.sai-projects-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 2px 4px;
}

.sai-projects-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--sai-text);
  cursor: pointer;
}

.sai-projects-toggle:hover,
.sai-projects-toggle[aria-expanded="true"] {
  background: rgba(0, 0, 0, 0.05);
}

.sai-projects-section-label {
  margin: 4px 8px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sai-muted);
}

.sai-projects-refresh {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sai-muted);
  cursor: pointer;
}

.sai-projects-refresh:hover {
  color: var(--sai-text);
  background: rgba(0, 0, 0, 0.05);
}

.sai-projects-refresh[aria-busy="true"] svg {
  animation: saiSpin 0.8s linear infinite;
}

.sai-projects-search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--sai-border);
  border-radius: 10px;
  font-size: 12px;
  margin: 0 0 10px;
  box-sizing: border-box;
  background: var(--sai-surface);
}

.sai-project-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 1px 0;
}

.sai-project-row-wrap .sai-project-row {
  flex: 1;
  min-width: 0;
}

.sai-projects-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding-right: 2px;
}

.sai-projects-group-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin: 10px 8px 4px;
}

.sai-projects-group-label:first-child {
  margin-top: 0;
}

.sai-project-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.sai-project-thumb {
  display: none !important;
}

.sai-project-row:hover {
  background: rgba(0, 0, 0, 0.05);
}

.sai-project-row.is-active {
  background: rgb(249 249 249)
}

.sai-project-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
  border: 1px solid var(--sai-border);
}

.sai-project-meta {
  flex: 1;
  min-width: 0;
}

.sai-project-title {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-project-thumb--missing {
  object-fit: contain;
  padding: 6px;
  opacity: 0.35;
}

.sai-project-date {
  font-size: 11px;
  color: var(--sai-muted);
  margin-top: 2px;
}

.sai-project-delete {
  flex-shrink: 0;
  align-self: center;
  width: 28px;
  height: 28px;
  margin-right: 2px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sai-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
}

.sai-project-row-wrap:hover .sai-project-delete {
  opacity: 1;
}

.sai-project-delete span {
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}

.sai-project-delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.sai-projects-empty,
.sai-projects-loading {
  font-size: 12px;
  color: var(--sai-muted);
  padding: 12px 8px;
  margin: 0;
}

/* Push main content when sidebar is open (desktop) */
body.sai-projects-sidebar-open .sai-view-launch,
body.sai-projects-sidebar-open .sai-view-studio {
  margin-left: var(--sai-projects-w);
  width: calc(100% - var(--sai-projects-w));
  box-sizing: border-box;
}

.sai-view-launch {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 56px);
  padding: 48px 20px;
}

.sai-launch-inner {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 64px;
}

.sai-hero-title {
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  text-align: center;
  margin: 8px 0 12px;
  letter-spacing: -0.02em;
}

.sai-hero-sub {
  text-align: center;
  color: var(--sai-muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 28px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.sai-hero-sub em {
  font-style: italic;
  color: var(--sai-text);
}

/* ── Composer (ChatGPT-style) ── */
.sai-composer-wrap {
  margin-bottom: 5px;
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: 20px;
  padding: 10px 12px;
  box-shadow: var(--sai-shadow);
}

#view-studio .sai-composer-wrap {
  margin-bottom: 0;
}

.sai-composer-disclaimer {
  margin: 8px 0 0;
  padding: 0 12px 4px;
  text-align: center;
  font-size: 10px;
  line-height: 1.45;
  color: #8e8e93;
}

#view-launch .sai-composer-disclaimer {
  margin: 10px 0 20px;
}

/* Step 2 chat composer — ChatGPT look (do not affect launch) */
#view-studio .sai-composer-dock {
  flex-shrink: 0;
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 10px 16px 14px;
  box-sizing: border-box;
  background: transparent;
}

#view-studio .sai-composer-wrap.sai-composer-chat {
  margin: 0;
  padding: 10px 12px 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

#view-studio .sai-composer-disclaimer {
  margin: 3px 0 0;
  padding: 0 8px;
  background: transparent;
  border: none;
}

#view-studio .sai-composer {
  background: transparent;
}

#view-studio .sai-slot-btn {
  background: #f4f4f4;
  border-color: transparent;
  color: #5c5c5c;
}

#view-studio .sai-slot-btn:hover {
  background: #ececec;
  color: #1a1a1a;
}

#view-studio .sai-slot-btn.is-filled {
  background: #fff;
  border: 1px solid #e5e5e5;
  color: #1a1a1a;
}

.sai-composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 4px 10px;
}

.sai-composer-attachments[hidden] {
  display: none !important;
}

.sai-ref-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 8px;
}

.sai-ref-badges[hidden] {
  display: none !important;
}

.sai-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: #f8f9fb;
  font-size: 0.78rem;
  width: 140px;
}

.sai-ref-badge-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--sai-border);
}

.sai-ref-badge-label {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  min-width: 60px;
  max-width: 160px;
  font: inherit;
  color: var(--sai-text);
  outline: none;
}

.sai-ref-badge-label-fixed {
  display: inline-block;
  padding: 0 2px;
  font-weight: 500;
  color: var(--sai-muted);
  pointer-events: none;
}

.sai-ref-badge-label:focus {
  color: var(--brand-primary);
}

.sai-ref-badge-remove {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: var(--sai-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.sai-ref-badge-remove:hover {
  background: rgba(0, 0, 0, 0.14);
  color: var(--sai-text);
}

.sai-attach-chip {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--sai-border);
  background: #f3f4f6;
}

.sai-attach-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sai-attach-chip-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.sai-composer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.sai-composer-toolbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  padding: 5px 5px 0;
}

.sai-composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 0 2px;
}

.sai-composer-left {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  max-width: calc(100% - 90px);
}

/* Mobile attach: + → plug → slot dropdown (desktop keeps flat row) */
.sai-mobile-attach {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}


.sai-mobile-attach-plus {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--sai-border);
  border-radius: 50%;
  background: #fff;
  color: var(--sai-text);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.sai-mobile-attach-plus:hover {
  background: #f5f6f8;
}

.sai-mobile-attach-plus[aria-expanded="true"] {
  background: #111;
  border-color: #111;
  color: #fff;
}

.sai-slot-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sai-slot-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: #f5f6f8;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sai-muted);
  cursor: pointer;
  white-space: nowrap;
}

.sai-slot-btn:hover {
  background: #eceef1;
  color: var(--sai-text);
}

.sai-slot-btn.is-filled {
  color: var(--sai-text);
  border-color: #cfd3d8;
  background: #fff;
}

.sai-slot-count:not(:empty)::before {
  content: ' · ';
}

.sai-composer-input {
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 8px 4px;
  min-height: 24px;
  max-height: 160px;
  overflow-y: auto;
  background: transparent;
  color: var(--sai-text);
}

.sai-composer-model-btn-wrap {
  display: none;
  position: relative;
  flex-shrink: 0;
}

.sai-composer-model-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sai-composer-model-btn:hover {
  background: #f3f4f6;
}

.sai-composer-model-btn[aria-expanded="true"] {
  background: #fef3c7;
}

.sai-composer-model-btn img {
  width: 23px;
  height: 23px;
  object-fit: contain;
  opacity: 0.75;
}

.sai-model-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  min-width: 168px;
  background: #fff;
  border: 1px solid var(--sai-border, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 40;
}

.sai-model-menu button {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--sai-text);
  cursor: pointer;
}

.sai-model-menu button:hover,
.sai-model-menu button.active {
  background: #fff7ed;
  color: #c2410c;
}

.sai-model-menu-hint {
  font-weight: 400;
  color: #9ca3af;
  font-size: 0.75rem;
}

.sai-model-selected {
  margin: 0;
  font-size: 0.72rem;
  color: #9ca3af;
  text-align: right;
  flex-shrink: 0;
}

.sai-size-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 40;
}

.sai-size-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(220px, 52vw);
  height: 34px;
  padding: 0 10px 0 8px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.sai-size-trigger:hover {
  border-color: #d1d5db;
  background: #fafafa;
}

.sai-size-trigger[aria-expanded="true"] {
  border-color: #c7c9d1;
  background: #f9fafb;
}

.sai-size-trigger-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}

.sai-size-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sai-size-chevron {
  flex-shrink: 0;
  color: #9ca3af;
}

.sai-size-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 300px;
  max-height: min(440px, 70vh);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.14);
  scrollbar-width: thin;
  scrollbar-color: #c4c4c4 transparent;
}

.sai-size-menu::-webkit-scrollbar {
  width: 4px;
}

.sai-size-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sai-size-menu::-webkit-scrollbar-thumb {
  background: #c4c4c4;
  border-radius: 4px;
}

.sai-size-menu::-webkit-scrollbar-thumb:hover {
  background: #a3a3a3;
}

#view-launch .sai-size-menu {
  bottom: auto;
  top: calc(100% + 2px);
}

.sai-size-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: #111827;
}

.sai-size-option:hover {
  background: #f3f4f6;
}

.sai-size-option.is-active {
  background: #eef2ff;
}

.sai-size-option-icon {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
}

.sai-size-option-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sai-size-option-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: #111827;
}

.sai-size-option-use {
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.25;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-size-option-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.sai-size-option-dims {
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #374151;
  white-space: nowrap;
}

.sai-size-option-aspect {
  font-size: 0.68rem;
  font-weight: 500;
  color: #9ca3af;
}

.sai-size-check,
.sai-size-check-slot {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .sai-size-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-height: min(60vh, 480px);
    z-index: 1200;
  }

  #view-launch .sai-size-menu {
    top: auto;
    bottom: 12px;
  }

  .sai-size-trigger-label {
    max-width: 110px;
  }
}

.sai-size-label,
.sai-size-select {
  display: none;
}

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

@media (max-width: 520px) {
  .sai-model-selected {
    font-size: 0.68rem;
  }
}

.sai-composer-mic,
.sai-composer-gallery {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sai-composer-gallery {
  display: none;
}

.sai-composer-mic img,
.sai-composer-gallery img,
.sai-menu-icon {
  width: 23px;
  height: 23px;
  object-fit: contain;
  opacity: 0.7;
}

.sai-composer-mic.listening {
  background: #fef3c7;
  animation: saiPulse 1s infinite;
}

@keyframes saiPulse {
  50% { opacity: 0.7; }
}

.sai-composer-send {
  flex-shrink: 0;
  padding: 10px 18px;
  border: none;
  border-radius: 20px;
  background: var(--sai-accent);
  color: #1a1205;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.sai-composer-send:hover {
  background: var(--sai-accent-hover);
}

.sai-composer-send-legacy {
  background: var(--sai-surface);
  color: var(--sai-text);
  border: 1px solid var(--sai-border);
  font-weight: 500;
}

.sai-composer-send-legacy:hover {
  border-color: var(--brand-primary);
  background: #fafafa;
}

.sai-composer-actions-row {
  display: flex;
  align-items: end;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.sai-composer-send-dark {
  background: #0d0b0b;
  color: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.sai-composer-chat .sai-composer {
  border-radius: 10px;
  padding: 10px 10px 10px 10px;
}

/* ── Optional card ── */
.sai-optional-card {
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius);
  padding: 18px 20px;
  box-shadow: var(--sai-shadow);
  margin-bottom: 28px;
}

.sai-optional-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sai-optional-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.sai-optional-links {
  font-size: 0.72rem;
  color: var(--sai-muted);
}

.sai-section-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin: 14px 0 8px;
}

.sai-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sai-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: var(--sai-surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sai-chip:hover {
  border-color: #c5cad3;
}

.sai-chip.selected {
  border-color: var(--sai-accent);
  background: #fffbeb;
}

.sai-chip-simple {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px dashed var(--sai-border);
  font-weight: 500;
  opacity: 0.95;
}

.sai-chip-simple:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  opacity: 1;
}

.sai-chip-simple.selected {
  background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
  border: 1px solid #ffc107;
  font-weight: 600;
}

.sai-type-more {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sai-type-more-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: var(--sai-surface);
  color: var(--sai-muted);
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.sai-type-more-btn:hover,
.sai-type-more-btn.is-open,
.sai-type-more-btn.is-open-parent {
  border-color: var(--sai-accent);
  color: var(--sai-text);
  background: #fffbeb;
}

.sai-type-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  padding: 8px;
  border: 1px solid #e6e8ec;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(26, 18, 5, 0.1), 0 2px 6px rgba(26, 18, 5, 0.04);
}

.sai-type-more-search-wrap {
  padding: 2px 2px 6px;
}

.sai-type-more-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid #e6e8ec;
  border-radius: 10px;
  background: #f8f9fb;
  color: var(--sai-text);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.sai-type-more-search::placeholder {
  color: #9aa3b2;
  font-weight: 400;
}

.sai-type-more-search:focus {
  border-color: var(--sai-accent);
  background: #fff;
}

.sai-type-more-label {
  margin: 0 0 4px;
  padding: 2px 10px 0;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sai-muted);
}

.sai-type-more-list {
  max-height: 168px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sai-type-more-empty {
  margin: 8px 10px;
  font-size: 0.78rem;
  color: var(--sai-muted);
}

.sai-type-more-item.is-filtered-out,
.sai-type-more-empty.is-filtered-out {
  display: none !important;
}

.sai-section-label--style {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.sai-style-header-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--sai-muted, #6b7280);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s;
}

.sai-style-header-info:hover,
.sai-style-header-info.is-open {
  color: var(--brand-primary, #e8731c);
}

.sai-style-info-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(420px, calc(100vw - 48px));
  max-height: min(480px, 60vh);
  overflow-y: auto;
  padding: 12px 14px;
  background: #1a1d26;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.sai-style-info-panel[hidden] {
  display: none !important;
}

.sai-style-info-panel::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 48px;
  border: 6px solid transparent;
  border-bottom-color: #1a1d26;
}

.sai-style-info-item + .sai-style-info-item {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sai-style-info-item strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}

.sai-style-info-item p {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
}

.sai-style-info-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sai-style-info-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 90px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
  background: #0d0f14;
  cursor: zoom-in;
  flex-shrink: 0;
}

.sai-style-info-thumb:hover {
  border-color: rgba(232, 115, 28, 0.7);
}

.sai-style-info-thumb img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sai-chat-image-overlay--br {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sai-chat-try-again[hidden] {
  display: none !important;
}

.sai-type-more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--sai-text);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.sai-type-more-item:hover {
  background: #f6f7f9;
}

.sai-type-more-item.is-active {
  background: #fffbeb;
}

.sai-type-more-item-check {
  color: var(--sai-accent);
  font-size: 0.85rem;
  font-weight: 700;
}

.sai-chip-swatches {
  display: flex;
  gap: 2px;
}

.sai-chip-swatches span {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.sai-dynamic-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.sai-field-full,
.sai-schedule-upload {
  grid-column: 1 / -1;
}

.sai-schedule-drop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px dashed #d5d8de;
  border-radius: 12px;
  background: linear-gradient(180deg, #fcfcfd 0%, #f6f7f9 100%);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sai-schedule-drop:hover {
  border-color: #c4c9d1;
  background: #f8f9fb;
}

.sai-schedule-drop-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--sai-text);
}

.sai-schedule-drop-sub {
  font-size: 0.75rem;
  color: var(--sai-muted);
}

.sai-schedule-upload-status {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--sai-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sai-schedule-upload-status.is-error {
  color: #b42318;
}

.sai-schedule-upload-status.is-loading {
  color: var(--sai-text);
}

.sai-schedule-upload-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d5d8de;
  border-top-color: var(--brand-primary, #E8731C);
  border-radius: 50%;
  animation: saiSpin 0.7s linear infinite;
  flex-shrink: 0;
}

.sai-schedule-drop.is-loading {
  pointer-events: none;
  opacity: 0.75;
}

.sai-launch-hints {
  text-align: center;
  font-size: 0.82rem;
  color: var(--sai-muted);
  margin-top: 24px;
}

.sai-hint-link {
  background: none;
  border: none;
  color: var(--sai-text);
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
}

/* ── Fields ── */
.sai-field {
  margin-bottom: 0px;
}

.sai-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sai-muted);
  margin-bottom: 5px;
  margin-top: 5px;
}

.sai-field input,
.sai-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius-sm);
  font-size: 13px;
  background: #fafafa;
}

.sai-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sai-color-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.sai-color-btn {
  display: flex;
  /* flex-direction: column; */
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius-sm);
  font-size: 0.72rem;
  cursor: pointer;
  position: relative;
}

.sai-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
}

.sai-color-btn input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.sai-thumb {
  margin-top: 8px;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--sai-border);
}

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

/* ── Buttons ── */
.sai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  border-radius: var(--sai-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.sai-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sai-btn-primary {
  background: var(--sai-accent);
  color: #1a1205;
}

.sai-btn-dark {
  background: var(--brand-secondary);
  color: #fff;
}

.sai-btn-outline {
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  color: var(--sai-text);
}

.sai-btn-block {
  width: 100%;
}

.sai-btn-sm {
  padding: 8px 12px;
  font-size: 0.8rem;
}

.sai-link-btn {
  background: none;
  border: none;
  color: var(--sai-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Studio layout ── */
.sai-view-studio {
  flex-direction: column;
  min-height: 100vh;
  padding-top: 0px;
}

.sai-studio-layout {
  flex: 1;
  display: grid;
  /* grid-template-columns: minmax(300px, 360px) 1fr; */
  gap: 0;
  /* max-width: 1280px; */
  width: 100%;
  margin: 0 auto;
  min-height: 0;
  align-items: stretch;
}

.sai-preview-col {
  padding: 20px;
  border-right: 1px solid var(--sai-border);
  background: var(--sai-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sai-preview-frame {
  background: #000;
  border-radius: var(--sai-radius-sm);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  max-height: min(52vh, 500px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sai-preview-frame.ratio-4-5,
.sai-preview-frame.ratio-4-5-hd { aspect-ratio: 4 / 5; max-height: min(52vh, 500px); }
.sai-preview-frame.ratio-2-3,
.sai-preview-frame.ratio-2-3-hd { aspect-ratio: 2 / 3; max-height: min(54vh, 520px); }
.sai-preview-frame.ratio-9-16,
.sai-preview-frame.ratio-9-16-hd { aspect-ratio: 9 / 16; max-height: min(58vh, 560px); }
.sai-preview-frame.ratio-1-1,
.sai-preview-frame.ratio-1-1-hd { aspect-ratio: 1 / 1; max-height: min(42vh, 400px); }
.sai-preview-frame.ratio-5-4 { aspect-ratio: 5 / 4; max-height: min(42vh, 360px); }
.sai-preview-frame.ratio-3-2,
.sai-preview-frame.ratio-3-2-md,
.sai-preview-frame.ratio-3-2-hd { aspect-ratio: 3 / 2; max-height: min(42vh, 360px); }
.sai-preview-frame.ratio-16-9,
.sai-preview-frame.ratio-16-9-hd { aspect-ratio: 16 / 9; max-height: min(42vh, 360px); }
.sai-preview-frame.ratio-21-9 { aspect-ratio: 21 / 9; max-height: min(36vh, 300px); }

.sai-preview-frame img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.sai-preview-image.sai-preview-image--ready {
  cursor: zoom-in;
  transition: opacity 0.2s ease;
}

.sai-preview-image.sai-preview-image--ready:hover {
  opacity: 0.92;
}

.sai-preview-frame img[hidden],
.sai-preview-skeleton[hidden] {
  display: none !important;
}

.sai-preview-skeleton {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border-radius: inherit;
  background: linear-gradient(
    110deg,
    #e8eaef 8%,
    #f3f4f6 18%,
    #e8eaef 33%
  );
  background-size: 200% 100%;
  animation: saiShimmer 1.4s ease-in-out infinite;
}

.sai-preview-col.is-generating .sai-ratio-btn,
.sai-preview-col.is-generating .sai-action-row button {
  opacity: 0.45;
  pointer-events: none;
}

@keyframes saiShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.sai-ratio-row {
  display: flex;
  gap: 6px;
}

.sai-ratio-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 1px solid var(--sai-border);
  border-radius: 8px;
  background: var(--sai-surface);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
}

.sai-ratio-btn-label {
  font-weight: 600;
}

.sai-ratio-btn-size {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--sai-muted, #6b7280);
  letter-spacing: 0.01em;
}

.sai-ratio-btn.active {
  border-color: var(--sai-accent);
  background: #fffbeb;
}

.sai-ratio-btn.active .sai-ratio-btn-size {
  color: #92400e;
}

.sai-download-size {
  margin: 8px 0 4px;
}

.sai-download-size-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.sai-download-size-dims {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--sai-muted, #6b7280);
  font-variant-numeric: tabular-nums;
}

.sai-preview-meta {
  margin-top: 4px;
}

.sai-versions-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin: 0 0 6px;
}

.sai-version-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 28px;
}

.sai-version-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--sai-border);
  background: var(--sai-surface);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--sai-muted);
}

.sai-version-btn.active {
  border-color: var(--sai-accent);
  background: #fffbeb;
  color: var(--sai-text);
}

.sai-action-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.sai-action-row .sai-btn-full {
  grid-column: 1 / -1;
}

.sai-action-row .sai-btn {
  padding: 10px 8px;
  font-size: 0.75rem;
}

.sai-launch-resume {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 5;
}

.sai-launch-resume[hidden] {
  display: none !important;
}

.sai-resume-next {
  min-width: 96px;
  padding: 10px 18px;
  border: 1px solid var(--sai-border);
  border-radius: 20px;
  background: #fff;
  color: var(--sai-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sai-shadow);
  cursor: pointer;
}

.sai-resume-next:hover {
  border-color: var(--sai-accent);
  background: #fffbeb;
}

/* ── Chat column ── */
.sai-chat-col {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 0px);
  max-height: calc(92vh - 0px);
  background: var(--sai-bg);
  padding: 0;
  border-left: 1px solid var(--sai-border);
  overflow: hidden;
}

/* Step 2 — ChatGPT-style thread; header floats so chat uses full height */
#view-studio .sai-chat-col {
  position: relative;
  background: #ffffff;
  border-left: none;
}

#view-studio .sai-chat-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 12px 16px;
  background: transparent;
  border-bottom: none;
  box-sizing: border-box;
  pointer-events: none;
}

#view-studio .sai-chat-header-left,
#view-studio .sai-chat-header-right,
#view-studio .sai-chat-header .sai-back-btn,
#view-studio .sai-chat-header .sai-console-btn,
#view-studio .sai-chat-header .sai-save-chat-btn,
#view-studio .sai-chat-header .sai-share-chat-btn,
#view-studio .sai-chat-header .sai-credit-chip {
  pointer-events: auto;
}

.sai-chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sai-save-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: var(--sai-surface);
  color: var(--sai-text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sai-share-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--sai-text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.sai-share-chat-btn img {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sai-share-chat-btn:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--brand-primary);
}

.sai-save-chat-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

#view-studio .sai-chat-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  padding: 64px 16px 20px;
  border-right: none;
}

#view-studio .sai-chat-body,
#view-studio .sai-schedule-panel {
  width: 100%;
  max-width: 768px;
  box-sizing: border-box;
}

#view-studio .sai-composer-chat {
  flex-shrink: 0;
  margin-top: 0;
  padding: 10px 12px 8px;
  border-top: none;
  /* background/border/radius from #view-studio .sai-composer-wrap.sai-composer-chat */
}

#view-studio #chat-prompt {
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px 4px;
  min-height: 37px;
  height: 37px;
}

#view-studio .sai-composer-toolbar {
  padding: 4px 2px 0;
  align-items: center;
  justify-content: flex-end;
}

#view-studio .sai-composer-bottom {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#view-studio .sai-composer-mic {
  display: flex;
  width: 36px;
  height: 36px;
}

#view-studio .sai-composer-bottom .sai-size-picker {
  margin-left: auto;
  padding-right: 4px;
  z-index: 50;
}

#view-studio .sai-composer-send-dark {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
  background: #0d0d0d;
}

#view-studio .sai-composer-send-dark:hover {
  background: #2a2a2a;
}

#view-studio .sai-composer-attachments,
#view-studio .sai-ref-badges {
  padding-left: 6px;
  padding-right: 6px;
}

.sai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid var(--sai-border);
  flex-shrink: 0;
}

.sai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sai-chat-header-title {
  min-width: 0;
}

.sai-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--sai-text);
  cursor: pointer;
  flex-shrink: 0;
}

.sai-back-btn:hover {
  background: var(--sai-bg);
}

.sai-back-btn img,
.sai-back-btn .sai-nav-stop {
  display: block;
  width: 20px;
  height: 20px;
}

.sai-back-btn img[hidden],
.sai-back-btn .sai-nav-stop[hidden] {
  display: none !important;
}

.sai-back-btn.is-stopping {
  color: #b42318;
}

.sai-back-btn.is-stopping:hover {
  background: rgba(180, 35, 24, 0.08);
}

.sai-console-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: #fff;
  color: #1a1d26c4;
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

/* Permanently hidden unless allowlisted member (JS removes [hidden]) */
.sai-console-btn[hidden] {
  display: none !important;
}

.sai-console-btn:hover {
  border-color: #c5cad3;
  background: #f8f9fb;
}

.sai-console-btn-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sai-chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  min-height: 0;
  border-right: 1px solid #e2e5eb96;
}

.sai-composer-chat {
  flex-shrink: 0;
  margin-top: 0;
  padding: 12px 16px 0px 16px;
  border-top: 1px solid var(--sai-border);
  background: #fff;
}

.sai-composer-chat .sai-composer-wrap {
  margin-bottom: 0;
  box-shadow: none;
}


.sai-chat-header strong {
  font-size: 14px;
  display: block;
}

.sai-chat-header p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--sai-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-chat-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 8px;
}

.sai-msg-assistant p {
  margin: 0;
}

/* ── Generating status in chat (ChatGPT-style shimmer card) ── */
.sai-generating-block {
  align-self: flex-start;
  width: 100%;
  max-width: min(380px, 100%);
  padding: 4px 0 8px;
}

.sai-gen-shimmer-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #ececf1;
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.sai-gen-shimmer-card.ratio-4-5,
.sai-gen-shimmer-card.ratio-4-5-hd,
.sai-gen-shimmer-card.ratio-2-3,
.sai-gen-shimmer-card.ratio-2-3-hd { aspect-ratio: 4 / 5; max-height: 440px; }
.sai-gen-shimmer-card.ratio-9-16,
.sai-gen-shimmer-card.ratio-9-16-hd { aspect-ratio: 9 / 16; max-height: 500px; }
.sai-gen-shimmer-card.ratio-1-1,
.sai-gen-shimmer-card.ratio-1-1-hd { aspect-ratio: 1 / 1; max-height: 340px; }
.sai-gen-shimmer-card.ratio-5-4 { aspect-ratio: 5 / 4; max-height: 300px; }
.sai-gen-shimmer-card.ratio-3-2,
.sai-gen-shimmer-card.ratio-3-2-md,
.sai-gen-shimmer-card.ratio-3-2-hd { aspect-ratio: 3 / 2; max-height: 300px; }
.sai-gen-shimmer-card.ratio-16-9,
.sai-gen-shimmer-card.ratio-16-9-hd { aspect-ratio: 16 / 9; max-height: 300px; }
.sai-gen-shimmer-card.ratio-21-9 { aspect-ratio: 21 / 9; max-height: 240px; }

.sai-gen-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    #ececf1 0%,
    #ececf1 35%,
    #f7f7f8 50%,
    #ececf1 65%,
    #ececf1 100%
  );
  background-size: 200% 100%;
  animation: saiShimmer 1.4s ease-in-out infinite;
}

@keyframes saiShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.sai-gen-card-label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  font-size: 13px;
  font-weight: 550;
  color: var(--sai-text);
}

.sai-gen-status-text {
  line-height: 1.2;
}

.sai-gen-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--sai-border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: saiSpin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes saiSpin {
  to { transform: rotate(360deg); }
}

.sai-gen-step {
  position: relative;
  z-index: 1;
  margin: 12px 16px 0;
  font-size: 0.75rem;
  color: var(--sai-muted);
  text-align: center;
  line-height: 1.35;
  max-width: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: saiGenFade 1.8s ease-in-out infinite;
}

@keyframes saiGenFade {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.8; }
}

.sai-assistant-block {
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}

.sai-msg {
  max-width: 78%;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
}

.sai-msg-assistant {
  background: #eeeeee57;
  border: 1px solid var(--sai-border);
  border-radius: 14px;
  max-width: 100%;
  width: 100%;
}

.sai-msg-assistant p {
  margin: 0;
}

.sai-msg-user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  font-size: 13px;
}

.sai-msg-user:has(.sai-msg-images) {
  padding: 8px;
}

.sai-msg-user:has(.sai-msg-images) .sai-msg-text {
  display: block;
  padding: 4px 8px 2px;
}

.sai-msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sai-msg-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.sai-msg-text {
  display: block;
}

.sai-msg-tag {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin-bottom: 8px;
}

.sai-suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-left: 2px;
}

.sai-suggest-chip {
  padding: 8px 14px;
  border: 1.5px solid var(--brand-primary);
  border-radius: 999px;
  background: var(--sai-surface);
  color: var(--brand-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.sai-suggest-chip:hover {
  background: #fff7ed;
}

.sai-suggest-chip--action {
  background: var(--sai-accent);
  border-color: var(--sai-accent);
  color: #111;
  font-weight: 600;
}

.sai-suggest-chip--action:hover {
  background: #f5c518;
  border-color: #f5c518;
}

/* ChatGPT-style inline graphic in chat */
.sai-chat-image-block {
  max-width: min(380px, 100%);
  margin: 8px 0 20px;
}

.sai-chat-image-frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(26, 18, 5, 0.08);
}

.sai-chat-image-frame.ratio-4-5,
.sai-chat-image-frame.ratio-4-5-hd { aspect-ratio: 4 / 5; max-height: 440px; }
.sai-chat-image-frame.ratio-2-3,
.sai-chat-image-frame.ratio-2-3-hd { aspect-ratio: 2 / 3; max-height: 460px; }
.sai-chat-image-frame.ratio-9-16,
.sai-chat-image-frame.ratio-9-16-hd { aspect-ratio: 9 / 16; max-height: 500px; }
.sai-chat-image-frame.ratio-1-1,
.sai-chat-image-frame.ratio-1-1-hd { aspect-ratio: 1 / 1; max-height: 340px; }
.sai-chat-image-frame.ratio-5-4 { aspect-ratio: 5 / 4; max-height: 300px; }
.sai-chat-image-frame.ratio-3-2,
.sai-chat-image-frame.ratio-3-2-md,
.sai-chat-image-frame.ratio-3-2-hd { aspect-ratio: 3 / 2; max-height: 300px; }
.sai-chat-image-frame.ratio-16-9,
.sai-chat-image-frame.ratio-16-9-hd { aspect-ratio: 16 / 9; max-height: 300px; }
.sai-chat-image-frame.ratio-21-9 { aspect-ratio: 21 / 9; max-height: 240px; }

.sai-chat-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  cursor: zoom-in;
  background: transparent;
}

/* Studio soft-protect: no select/drag on graphics; composer stays selectable */
body.sai-step-studio #view-studio .sai-chat-image-frame,
body.sai-step-studio #view-studio .sai-chat-image,
body.sai-step-studio #view-studio .sai-preview-image,
body.sai-step-studio #view-studio .sai-img-protect-layer,
body.sai-step-studio #sideline-ai-preview-modal .sai-img-protect-wrap,
body.sai-step-studio #sideline-ai-preview-image {
  -webkit-user-drag: none;
  user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

body.sai-step-studio #view-studio .sai-chat-image,
body.sai-step-studio #sideline-ai-preview-image {
  pointer-events: none;
}

body.sai-step-studio #view-studio input,
body.sai-step-studio #view-studio textarea,
body.sai-step-studio #view-studio select,
body.sai-step-studio #view-studio [contenteditable="true"],
body.sai-step-studio #chat-prompt {
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}

/* Transparent hit layer above img; Edit/Download stay above this */
.sai-img-protect-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
}

.sai-img-protect-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: zoom-in;
  background: transparent;
}

/* HTML-only Sideline AI mark on previews (not baked into download/export file) */
.sai-preview-brand-mark {
  position: absolute;
  bottom: 20%;
  right: 2%;
  z-index: 1;
  pointer-events: none;
  line-height: 0;
  text-shadow: 1px 1px 1px #eee;
}

.sai-preview-brand-mark img {
  display: block;
  height: 20px;
  width: auto;
  -webkit-user-drag: none;
  user-select: none;
  opacity: 0.4;
}

.sai-chat-image-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 2;
  pointer-events: auto;
}

.sai-chat-image-overlay {
  position: absolute;
  z-index: 2;
  display: flex;
  pointer-events: auto;
}

.sai-chat-image-overlay--bl {
  left: 10px;
  bottom: 10px;
}

.sai-chat-image-overlay--br {
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.sai-chat-img-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--sai-text);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  transition: background 0.12s, transform 0.12s;
}

.sai-chat-img-icon:hover {
  background: #fff;
  transform: scale(1.04);
}

.sai-chat-img-float {
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--sai-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  transition: background 0.12s;
}

.sai-chat-img-float:hover {
  background: #fff;
}

.sai-chat-image-cta {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  width: 80%;
}

.sai-chat-cta-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.sai-chat-cta-icon {
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sai-chat-cta-icon img {
  width: 17px;
  height: 17px;
  display: block;
}

.sai-chat-cta-save {
  background: linear-gradient(180deg, #fff 0%, #f4f5f7 100%);
  color: var(--sai-text);
  border: 1px solid #e2e5eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sai-chat-cta-save:hover {
  border-color: #cfd4dc;
  box-shadow: 0 4px 14px rgba(26, 18, 5, 0.08);
  transform: translateY(-1px);
}

.sai-chat-cta-post {
  background: #ff8200;
  color: #f8f7f6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sai-chat-cta-post:hover {
  filter: brightness(1.03);
  box-shadow: 0 8px 22px rgba(232, 115, 28, 0.34);
  transform: translateY(-1px);
}

.sai-chat-cta-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .sai-chat-image-cta {
    flex-direction: column;
    gap: 8px;
  }

  .sai-chat-cta-btn {
    width: 100%;
  }
}

.sai-chat-img-menu-wrap {
  position: relative;
}

.sai-chat-img-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 168px;
  padding: 6px;
  border: 1px solid #e6e8ec;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(26, 18, 5, 0.12);
  z-index: 30;
}

.sai-chat-img-menu[hidden] {
  display: none !important;
}

.sai-chat-img-menu-item {
  display: block;
  width: 100%;
  padding: 5px 5px;
  background: transparent;
  color: var(--sai-text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid #eee;
}

.sai-chat-img-menu-item:hover {
  background: #f6f7f9;
}

.sai-fm-tabs button[hidden] {
  display: none !important;
}

.sai-datetime-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
}

/* File modal SD grid */
.sai-fm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sai-fm-actions .sai-btn { flex: 1; }

.sai-file-modal {
  max-width: 640px;
  padding: 22px 22px 18px;
}

.sai-file-modal .sai-modal-head {
  align-items: flex-start;
  margin-bottom: 16px;
}

.sai-fm-head-copy h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.sai-fm-head-sub {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--sai-muted);
  line-height: 1.35;
}

.sai-fm-body {
  min-height: 280px;
}

.sai-fm-panel {
  min-height: 280px;
}

.sai-fm-empty {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  border: 1px solid var(--sai-border);
  border-radius: 14px;
  background: #fafbfc;
}

.sai-fm-sd-subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--sai-bg);
  border-radius: 10px;
  border: 1px solid var(--sai-border);
}

.sai-fm-sd-subtabs button {
  flex: 1;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--sai-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.sai-fm-sd-subtabs button:hover {
  color: var(--sai-text);
}

.sai-fm-sd-subtabs button.active {
  background: #fff;
  color: var(--sai-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sai-fm-sd-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 28px;
}

.sai-fm-sd-toolbar[hidden] {
  display: none !important;
}

.sai-fm-sd-back {
  border: none;
  background: none;
  color: var(--brand-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.sai-fm-sd-back:hover {
  text-decoration: underline;
}

.sai-fm-sd-folder-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sai-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sai-fm-loading,
.sai-fm-loading-inline {
  font-size: 0.85rem;
  color: var(--sai-muted);
  text-align: center;
  padding: 24px 16px;
}

.sai-fm-sd-content {
  min-height: 320px;
  max-height: 420px;
  overflow: hidden;
}

.sai-fm-sd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 2px 4px 8px 2px;
}

.sai-fm-sd-grid[hidden] {
  display: none !important;
}

.sai-fm-sd-folders-grid {
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}

.sai-fm-sd-folder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--sai-border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  font-family: inherit;
  font-size: 0.75rem;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.sai-fm-sd-folder:hover {
  border-color: var(--sai-accent);
  background: #fffbeb;
}

.sai-fm-sd-folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f3f4f6;
}

.sai-fm-sd-folder-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.sai-fm-sd-folder-label {
  display: block;
  width: 100%;
  line-height: 1.35;
  word-break: break-word;
  color: var(--sai-text);
}

.sai-fm-sd-file {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--sai-border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  padding: 0;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sai-fm-sd-file:hover,
.sai-fm-sd-file.selected {
  border-color: var(--sai-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--sai-accent) 35%, transparent);
}

.sai-fm-sd-file.selected {
  background: #fffbeb;
}

.sai-fm-sd-file-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: #f3f4f6;
  overflow: hidden;
}

.sai-fm-sd-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sai-fm-sd-file-thumb img.is-fallback {
  width: 40%;
  height: 40%;
  object-fit: contain;
  opacity: 0.45;
}

.sai-fm-sd-file-label {
  display: block;
  padding: 8px 8px 10px;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--sai-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-fm-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--sai-muted);
  font-size: 0.85rem;
  padding: 32px 20px;
}

@media (max-width: 600px) {
  .sai-file-modal {
    max-width: 100%;
    padding: 20px 16px;
  }

  .sai-fm-sd-content {
    min-height: 260px;
    max-height: 50vh;
  }

  .sai-fm-sd-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    max-height: 50vh;
  }
}

.sai-fm-error { color: #dc2626; }

.sai-fm-local-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  min-height: 120px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--sai-border);
  background: #fafbfc;
}

.sai-fm-local-preview[hidden] {
  display: none !important;
}

.sai-fm-local-preview img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--sai-border);
  background: #fff;
}

/* ── Schedule panel ── */
.sai-schedule-panel {
  background: var(--sai-surface);
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--sai-shadow);
}

.sai-schedule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.sai-schedule-head h3 {
  margin: 0;
  font-size: 1rem;
}

.sai-schedule-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--sai-muted);
  cursor: pointer;
  user-select: none;
}

.sai-schedule-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sai-schedule-toggle-ui {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.sai-schedule-toggle-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.sai-schedule-toggle input:checked + .sai-schedule-toggle-ui {
  background: var(--sai-accent);
}

.sai-schedule-toggle input:checked + .sai-schedule-toggle-ui::after {
  transform: translateX(16px);
}

.sai-schedule-desc {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--sai-muted);
}

.sai-schedule-platform-when {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.sai-schedule-platform-col {
  flex: 1 1 220px;
  min-width: 0;
}

.sai-schedule-platform-col .sai-section-label {
  margin-top: 0;
}

.sai-schedule-when-col {
  flex: 1 1 200px;
  min-width: 0;
  margin-bottom: 0;
}

.sai-schedule-when-col .sai-datetime-input {
  width: 100%;
}

.sai-platform-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.sai-platform-wrap {
  position: relative;
}

.sai-platform-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--sai-border);
  border-radius: 999px;
  background: var(--sai-surface);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  color: #111;
}

.sai-platform-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sai-platform-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sai-platform-btn--instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  border-color: transparent;
  color: #fff;
}

.sai-platform-btn--facebook {
  background: #1877f2;
  border-color: transparent;
  color: #fff;
}

.sai-platform-btn--x {
  background: #111;
  border-color: transparent;
  color: #fff;
}

.sai-platform-btn.has-accounts {
  box-shadow: 0 0 0 2px var(--sai-accent);
}

.sai-platform-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 220px;
  max-width: 280px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--sai-border);
  border-radius: 10px;
  box-shadow: var(--sai-shadow);
  padding: 6px 0;
}

.sai-platform-dropdown[hidden] {
  display: none;
}

.sai-platform-account {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.sai-platform-account:hover {
  background: #f9fafb;
}

.sai-platform-account input {
  margin: 0;
}

.sai-platform-group-label {
  padding: 6px 12px 4px;
  font-size: 0.75rem;
  color: var(--sai-muted);
}

.sai-platform-add {
  display: block;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--sai-accent);
  text-decoration: none;
}

.sai-platform-add:hover {
  background: #fffbeb;
}

.sai-schedule-caption {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--sai-border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

.sai-char-count {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--sai-muted);
}

.sai-schedule-note {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--sai-muted);
}

.sai-schedule-when-wrap[hidden] {
  display: none;
}

.sai-schedule-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sai-schedule-actions .sai-btn {
  flex: 1;
}

.sai-save-actions {
  margin-top: 20px;
}

.sai-save-actions .sai-btn {
  flex: 1;
  min-width: 0;
}

/* Hide brand kit on Step 2 (studio) */
body.sai-step-studio .sai-brand-anchor {
  display: none !important;
}

/* When sidebar is collapsed in studio, leave room for the open rail button */
body.sai-step-studio:not(.sai-projects-sidebar-open) #view-studio .sai-chat-header {
  padding-left: 56px;
}

#view-studio .sai-chat-header-title strong {
  font-size: 14px;
}

.sai-project-row.is-draft .sai-project-date {
  color: var(--brand-primary);
  font-weight: 500;
}

/* ── Overlays ── */
.sai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* JSON / registry viewer must sit ABOVE the Processing Status drawer (1100) */
#trace-json-modal.sai-overlay {
  z-index: 1300;
}

/* ── TESTING ONLY — Processing Status drawer (remove before production) ── */
.sai-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
}
.sai-drawer-overlay[hidden] { display: none !important; }
.sai-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.sai-drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(520px, 92vw);
  background: var(--sai-surface, #fff);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  animation: sai-drawer-in 0.22s ease;
}
@keyframes sai-drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.sai-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 8px;
}
.sai-drawer-head h2 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sai-drawer-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 7px;
  border-radius: 999px;
}
.sai-drawer-sub {
  margin: 0 20px 10px;
  color: var(--sai-muted, #6b7280);
  font-size: 0.8rem;
}
.sai-drawer-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--sai-muted, #6b7280);
}
.sai-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 24px;
}
.sai-trace-item {
  border: 1px solid var(--sai-border, #e5e7eb);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fafafa;
}
.sai-trace-head-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.sai-trace-head {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: transparent;
  padding: 12px 8px 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #111827;
}
.sai-trace-info {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: 10px 12px 10px 0;
  border-radius: 50%;
  border: 1.5px solid #9ca3af;
  background: #fff;
  color: #4b5563;
  font-size: 0.75rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sai-trace-info:hover,
.sai-trace-info.is-open {
  border-color: var(--sai-accent, #e8731c);
  color: var(--sai-accent, #e8731c);
  background: #fff7ed;
}
.sai-trace-info-panel {
  margin: 0 14px 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #374151;
}
.sai-trace-info-panel strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9a3412;
  margin-bottom: 4px;
}
.sai-trace-info-panel p {
  margin: 0;
}
.sai-trace-head .sai-trace-chevron {
  transition: transform 0.18s ease;
  color: var(--sai-muted, #6b7280);
}
.sai-trace-item.is-open .sai-trace-chevron { transform: rotate(90deg); }
.sai-trace-body {
  padding: 0 14px 14px;
  display: none;
}
.sai-trace-item.is-open .sai-trace-body { display: block; }
.sai-trace-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 4px;
}
.sai-trace-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sai-muted, #6b7280);
  margin: 0;
}
.sai-trace-copy {
  border: 1px solid var(--sai-border, #e5e7eb);
  background: #fff;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.72rem;
  line-height: 1.4;
  cursor: pointer;
  color: var(--sai-muted, #6b7280);
  flex-shrink: 0;
}
.sai-trace-copy:hover { color: #111827; border-color: #c4c4c4; }
.sai-trace-copy.is-copied { color: #15803d; border-color: #86efac; }
.sai-trace-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--sai-border, #e5e7eb);
  border-radius: 8px;
  padding: 10px;
  margin: 0;
  max-height: 320px;
  overflow: auto;
}
.sai-trace-img {
  max-width: 160px;
  border-radius: 8px;
  border: 1px solid var(--sai-border, #e5e7eb);
  margin-top: 4px;
  cursor: zoom-in;
  display: block;
}
.sai-trace-img:hover { outline: 2px solid var(--sai-accent, #e8731c); outline-offset: 2px; }
.sai-trace-api {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  margin-bottom: 4px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--sai-border, #e5e7eb);
  border-radius: 8px;
}
.sai-trace-api code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  word-break: break-all;
}
.sai-trace-api-method {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #111827;
  color: #fff;
}
.sai-trace-attach {
  margin-bottom: 4px;
}
.sai-trace-attach-summary {
  margin: 0 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--sai-muted, #6b7280);
  white-space: pre-wrap;
  word-break: break-word;
}
.sai-trace-attach-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sai-trace-attach-card {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--sai-border, #e5e7eb);
  border-radius: 8px;
}
.sai-trace-attach-card.is-empty {
  opacity: 0.55;
}
.sai-trace-attach-card.is-attached {
  border-color: #fdba74;
  background: #fff7ed;
}
.sai-trace-attach-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--sai-border, #e5e7eb);
  flex-shrink: 0;
  cursor: zoom-in;
  background: #f3f4f6;
}
.sai-trace-attach-thumb.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 0.75rem;
  cursor: default;
}
.sai-trace-attach-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sai-trace-attach-meta strong {
  font-size: 0.78rem;
  color: #111827;
}
.sai-trace-attach-meta span {
  font-size: 0.72rem;
  color: var(--sai-muted, #6b7280);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sai-trace-empty {
  color: var(--sai-muted, #6b7280);
  font-size: 0.85rem;
  text-align: center;
  padding: 40px 20px;
}
.sai-trace-registry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.sai-trace-ref-group {
  padding: 8px 10px;
  border: 1px solid #e6e8ec;
  border-radius: 10px;
  background: #fafbfc;
}
.sai-trace-ref-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sai-muted, #6b7280);
  margin-bottom: 6px;
}
.sai-trace-ref-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.8rem;
  color: var(--sai-text, #111827);
  line-height: 1.45;
}
.sai-trace-ref-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef1f5;
  color: #4b5563;
  font-size: 0.68rem;
  font-weight: 600;
}
.sai-trace-registry-note {
  margin: 0 0 4px;
  font-size: 0.76rem;
  color: var(--sai-muted, #6b7280);
  line-height: 1.4;
}
.sai-trace-registry-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--sai-border, #e5e7eb);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #111827;
}
.sai-trace-registry-link:hover {
  border-color: var(--sai-accent, #e8731c);
  background: #fffaf5;
}
.sai-trace-registry-icon {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sai-muted, #6b7280);
  flex-shrink: 0;
}
.sai-trace-registry-path {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--sai-muted, #6b7280);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45%;
}
.sai-trace-ref-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.sai-trace-ref-thumb-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border: 1px solid #e6e8ec;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}
.sai-trace-ref-thumb-card:hover {
  border-color: var(--sai-accent, #e8731c);
}
.sai-trace-ref-thumb {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: #f3f4f6;
}
.sai-trace-ref-thumb-card .sai-trace-ref-badge {
  margin: 0 6px 6px;
  align-self: flex-start;
}
.sai-trace-registry-link-img {
  align-items: center;
}
.sai-trace-registry-thumb {
  width: 44px;
  height: 55px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #f3f4f6;
}
.sai-trace-json-modal { max-width: 720px; max-height: 85vh; display: flex; flex-direction: column; }
.sai-trace-json-view { max-height: 60vh; }

.sai-overlay[hidden] {
  display: none !important;
}

.sai-modal {
  background: var(--sai-surface);
  border-radius: var(--sai-radius);
  padding: 28px;
  max-width: 850px;
  width: 100%;
  box-shadow: var(--sai-shadow);
}

.sai-modal-sm {
  max-width: 380px;
}

.sai-update-info-modal {
  max-width: 420px;
}

.sai-update-info-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin: 0 0 18px;
  max-height: min(50vh, 360px);
  overflow-y: auto;
}

.sai-update-info-fields .sai-field-full {
  grid-column: 1 / -1;
}

.sai-update-info-fields .sai-field label {
  font-size: 0.75rem;
}

.sai-update-info-fields .sai-field input,
.sai-update-info-fields .sai-field textarea {
  font-size: 0.88rem;
  padding: 8px 10px;
}

.sai-share-modal {
  max-width: 560px;
  width: min(560px, calc(100vw - 32px));
}

.sai-share-body {
  margin: 0 0 16px;
  min-height: 200px;
}

.sai-share-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 200px;
  color: var(--sai-muted, #6b7280);
  font-size: 0.88rem;
}

.sai-share-loading .sai-spinner {
  width: 28px;
  height: 28px;
  border-width: 2.5px;
  border-color: rgba(15, 23, 42, 0.12);
  border-top-color: var(--brand-primary, #e8731c);
}

.sai-share-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 10px;
  margin: 0 0 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.sai-share-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 8px 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: #fafaf9;
  color: var(--sai-text, #1c1917);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.sai-share-tab:hover {
  border-color: rgba(15, 23, 42, 0.18);
}

.sai-share-tab.is-active {
  background: #1c1917;
  border-color: #1c1917;
  color: #fff;
}

.sai-share-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-share-tab-count {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.7;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 1.25rem;
  text-align: center;
}

.sai-share-tab.is-active .sai-share-tab-count {
  background: rgba(255, 255, 255, 0.18);
  opacity: 1;
}

.sai-share-panels {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #fff;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}

.sai-share-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}

.sai-share-panel.is-active {
  display: flex;
}

.sai-share-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--sai-muted, #6b7280);
  margin-bottom: 2px;
  cursor: pointer;
}

.sai-share-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.sai-share-member:hover {
  background: rgba(15, 23, 42, 0.04);
}

.sai-share-member input {
  margin: 0;
  accent-color: #0f172a;
}

.sai-share-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e7e5e4;
  color: #1c1917;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sai-share-member-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sai-share-member-name {
  font-size: 0.88rem;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-share-member-email {
  font-size: 0.72rem;
  color: var(--sai-muted, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sai-share-empty {
  margin: 12px 4px;
  font-size: 0.88rem;
  color: var(--sai-muted, #6b7280);
  text-align: center;
  line-height: 1.4;
}

.sai-share-empty--sm {
  margin: 4px 0;
  font-size: 0.8rem;
  text-align: left;
}

.sai-chat-update-info {
  margin: 0 0 10px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  background: #fafaf9;
}

.sai-chat-update-info-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sai-chat-update-info-head strong {
  display: block;
  font-size: 0.92rem;
}

.sai-chat-update-info-head p {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--sai-muted, #6b7280);
  line-height: 1.35;
}

.sai-chat-update-info-close {
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #78716c;
  padding: 0 2px;
}

.sai-chat-update-info-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 12px;
}

.sai-chat-update-info-fields .sai-field-full {
  grid-column: 1 / -1;
}

.sai-chat-update-info-fields .sai-field label {
  font-size: 0.72rem;
}

.sai-chat-update-info-fields .sai-field input,
.sai-chat-update-info-fields .sai-field textarea {
  font-size: 0.86rem;
  padding: 7px 9px;
}

@media (max-width: 560px) {
  .sai-chat-update-info-fields {
    grid-template-columns: 1fr;
  }
}

.sai-modal-wide {
  max-width: 640px;
}

.sai-modal h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

#ratio-modal-msg{
  font-size: 14px;
}

.sai-modal-desc {
  color: var(--sai-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0 0 18px;
}

.sai-modal-tag {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sai-muted);
  margin: 10px 0 8px;
}

.sai-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sai-modal-actions .sai-btn {
  flex: 1;
}

.sai-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sai-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--sai-muted);
}

.sai-fm-tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 12px;
  background: #f0f1f3;
  border: 1px solid var(--sai-border);
}

.sai-fm-tabs button {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--sai-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.sai-fm-tabs button:hover {
  color: var(--sai-text);
}

.sai-fm-tabs button.active {
  background: #fff;
  color: var(--sai-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sai-fm-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 280px;
  height: 100%;
  padding: 28px 20px;
  border: 1.5px dashed #d5d8de;
  border-radius: 14px;
  background: linear-gradient(180deg, #fcfcfd 0%, #f6f7f9 100%);
  cursor: pointer;
  color: var(--sai-muted);
  transition: border-color 0.15s, background 0.15s;
}

.sai-fm-drop:hover {
  border-color: #c4c9d1;
  background: #f8f9fb;
}

.sai-fm-drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--sai-border);
  font-size: 1.1rem;
  color: #6b7280;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sai-fm-drop-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--sai-text);
}

.sai-fm-drop-sub {
  font-size: 0.78rem;
  color: var(--sai-muted);
}

.sai-fm-placeholder {
  font-size: 0.88rem;
  color: var(--sai-muted);
}

/* ── Loading ── */
.sai-loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.sai-loading[hidden] {
  display: none !important;
}

.sai-loading p {
  color: #fff;
  font-size: 0.92rem;
}

.sai-loading-gif {
  width: 120px;
  height: auto;
}

.sai-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--sai-accent);
  border-radius: 50%;
  animation: saiSpin 0.8s linear infinite;
}

@keyframes saiSpin {
  to { transform: rotate(360deg); }
}

.sai-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.sai-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sai-toast.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.sai-toast.success {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* ── Responsive ── */
@media (max-width: 800px) {
  .sai-studio-layout {
    grid-template-columns: 1fr;
  }

  .sai-preview-col {
    border-right: none;
    border-bottom: 1px solid var(--sai-border);
  }

  .sai-dynamic-fields {
    grid-template-columns: 1fr;
  }

  .sai-view-launch {
    padding: 100px 16px 32px;
  }

  .sai-launch-inner {
    max-width: 100%;
  }

  /* Keep brand anchor fixed at top */
  .sai-brand-anchor {
    position: fixed;
    top: 56px;
    right: 12px;
    left: auto;
    z-index: 250;
  }

  .sai-brand-toggle {
    max-width: calc(50vw - 20px);
    font-size: 0.75rem;
    padding: 7px 12px;
  }

  #brand-toggle-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 110px;
  }

  /* Mobile: sidebar overlays content (no layout push) */
  body.sai-projects-sidebar-open .sai-view-launch,
  body.sai-projects-sidebar-open .sai-view-studio {
    margin-left: 0;
    width: 100%;
  }

  .sai-projects-sidebar {
    top: var(--sai-site-header-h);
    height: calc(100vh - var(--sai-site-header-h));
    width: min(280px, 86vw);
    z-index: 260;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
  }

  .sai-projects-rail-btn {
    top: calc(var(--sai-site-header-h) + 12px);
    left: 12px;
    z-index: 250;
  }

  .sai-brand-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 270px;
    max-height: min(65vh, 480px);
    z-index: 260;
    overflow: hidden;
  }

  .sai-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 240;
    background: rgba(0, 0, 0, 0.35);
  }

  .sai-mobile-backdrop[hidden] {
    display: none !important;
  }

  .sai-composer-actions-row {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #launch-composer .sai-composer-send {
    flex: 1 1 120px;
    max-width: 160px;
  }

  .sai-composer-wrap {
    padding: 12px;
  }

  .sai-attach-chip {
    width: 64px;
    height: 64px;
  }

  .sai-optional-card {
    padding: 14px;
  }

  .sai-chip-row {
    gap: 6px;
  }

  #view-studio .sai-chat-header {
    padding: 10px 12px;
    background: #fff;
  }

  #view-studio .sai-chat-scroll {
    padding: 58px 12px 16px;
  }

  #view-studio .sai-composer-dock {
    padding: 8px 12px 12px;
  }

  #view-studio .sai-chat-header-title strong {
    font-size: 13px;
  }

  #view-studio .sai-chat-header-title p {
    max-width: min(52vw, 220px);
  }
}

/* Mobile only: + → plug → References / Opponent / Player / Background dropdown */
@media (max-width: 767px) {
  .sai-mobile-attach-plus {
    display: inline-flex;
  }

  .sai-projects-rail-btn{
    top: calc(var(--sai-site-header-h) + 5px);
  }

  .sai-projects-sidebar{
    top: 49px;
  }

  .sai-slot-menu {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 40;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 190px;
    padding: 8px;
    border: 1px solid var(--sai-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  }

  .sai-slot-menu.is-open {
    display: flex;
  }

  .sai-slot-menu .sai-slot-btn {
    width: 100%;
    justify-content: flex-start;
    height: 38px;
    border-radius: 10px;
    background: #f7f8fa;
  }

  .sai-composer-left {
    max-width: none;
    overflow: visible;
  }

  /* Studio chat composer: keep + near the input actions */
  #view-studio .sai-composer-bottom {
    flex: 0 0 auto;
  }
}

@media (max-width: 480px) {

  .side-navbar-wrapper.navdrawer {
    top: 50px;
  }
  .maincontent-2{
    height: 94vh;
  }
  .sai-view-launch {
    padding-top: 60px;
  }

  #view-studio .sai-chat-header {
    padding: 8px 10px;
    background: #eeeeeee8;
  }

  #view-studio .sai-chat-scroll {
    padding: 54px 10px 12px;
  }

  #view-studio .sai-composer-dock {
    padding: 6px 10px 10px;
  }

  #view-studio .sai-chat-header-title p {
    max-width: min(48vw, 160px);
  }

  #launch-composer .sai-composer-send-legacy {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  #launch-composer .sai-composer-send {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .sai-brand-panel {
    position: fixed;
    top: 96px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 108px);
  }
}

/* ── Sideline AI full-screen preview (unique namespace) ── */
.sideline-ai-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sideline-ai-preview-modal[hidden] {
  display: flex !important;
}

.sideline-ai-preview-modal--active {
  opacity: 1;
  visibility: visible;
}

.sideline-ai-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  cursor: pointer;
}

.sideline-ai-preview-content {
  position: relative;
  z-index: 10001;
  max-width: 95%;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sideline-ai-preview-modal--active .sideline-ai-preview-content {
  transform: scale(1);
}

.sideline-ai-preview-content .sai-img-protect-wrap {
  display: block;
  max-width: 100%;
  max-height: 95vh;
  line-height: 0;
}

.sideline-ai-preview-image {
  max-width: 100%;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sideline-ai-preview-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10002;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sideline-ai-preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: rotate(90deg);
}


