/* ═══════════════════════════════════════════════════════════════
   TOPM ImageGen Home — Light Theme (aligned with seller/franchise)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --topm-primary: 15 23 42;
  --topm-accent: 59 130 246;
  --topm-secondary: 99 102 241;
  --topm-bglight: 248 250 252;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: rgb(51 65 85);
  background:
    radial-gradient(900px circle at 16% 6%, rgb(var(--topm-accent) / 0.10), transparent 60%),
    radial-gradient(900px circle at 85% 0%, rgb(var(--topm-secondary) / 0.10), transparent 60%),
    rgb(var(--topm-bglight));
  min-height: 100vh;
}

/* ─── Login / Register Page ──────────────────────────────────── */
body[data-page="login"] .container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: rgb(255 255 255 / 0.92);
  border: 1px solid rgb(226 232 240);
  border-radius: 18px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
  padding: 22px;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: rgb(var(--topm-primary));
}

.brand-badge {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgb(var(--topm-accent));
  color: white;
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 18px 0;
  font-size: 13px;
  color: rgb(100 116 139);
}

form {
  display: grid;
  gap: 12px;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: rgb(30 41 59);
}

input:not([type="checkbox"]) {
  width: 100%;
  border: 1px solid rgb(226 232 240);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:not([type="checkbox"]):focus {
  border-color: rgb(var(--topm-accent));
  box-shadow: 0 0 0 4px rgb(var(--topm-accent) / 0.12);
}

input::placeholder, textarea::placeholder { color: rgb(148 163 184); }

select {
  width: 100%;
  border: 1px solid rgb(226 232 240);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font-size: 14px;
  background: white;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: rgb(51 65 85);
}

select:focus {
  border-color: rgb(var(--topm-accent));
  box-shadow: 0 0 0 4px rgb(var(--topm-accent) / 0.12);
}

textarea {
  width: 100%;
  border: 1px solid rgb(226 232 240);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font-size: 14px;
  background: white;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: rgb(51 65 85);
  resize: vertical;
}

textarea:focus {
  border-color: rgb(var(--topm-accent));
  box-shadow: 0 0 0 4px rgb(var(--topm-accent) / 0.12);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 800;
  cursor: pointer;
  background: rgb(var(--topm-accent));
  color: white;
  font-family: inherit;
  font-size: 14px;
  transition: filter 0.15s ease;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-sm { width: auto; padding: 6px 16px; font-size: 13px; }
.btn-outline {
  background: transparent;
  border: 1px solid rgb(226 232 240);
  color: rgb(71 85 105);
  box-shadow: none;
}
.btn-outline:hover {
  border-color: rgb(var(--topm-accent));
  color: rgb(var(--topm-accent));
  background: rgb(var(--topm-accent) / 0.06);
}

.error {
  display: none;
  background: rgb(254 242 242);
  border: 1px solid rgb(254 202 202);
  color: rgb(185 28 28);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}
.error.show { display: block; }

.success-msg {
  display: none;
  background: rgb(240 253 244);
  border: 1px solid rgb(187 247 208);
  color: rgb(22 101 52);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}
.success-msg.show { display: block; }

.tab-switch {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgb(226 232 240);
}
.tab-switch button {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: rgb(100 116 139);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.tab-switch button.active {
  background: rgb(var(--topm-accent) / 0.1);
  color: rgb(var(--topm-accent));
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: rgb(100 116 139);
  text-align: center;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: rgb(var(--topm-accent));
}

.checkbox-row label {
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

/* ─── Main App Layout (Aibaokuan Style) ──────────────────────── */
body[data-page="app"] {
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent body scroll, handle scroll in main-content */
  background: rgb(var(--topm-bglight));
}

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar - Glassmorphism */
.sidebar {
  width: 80px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

.sidebar-top, .sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Brand Badge - Gradient */
.brand-badge {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 28px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Navigation Items */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: rgb(100 116 139);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 12px 8px;
  border-radius: 12px;
}

.nav-item:hover {
  color: rgb(var(--topm-primary));
  background: rgba(255, 255, 255, 0.6);
}

.nav-item.active {
  color: rgb(99, 102, 241);
  background: rgba(99, 102, 241, 0.1);
}

.nav-item.active .nav-icon {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
  color: rgb(99, 102, 241);
}

/* Navigation Icons - SVG */
.nav-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-icon svg {
  width: 22px;
  height: 22px;
}

.nav-item:hover .nav-icon {
  background: rgba(255, 255, 255, 0.6);
}

.nav-item.active:hover .nav-icon {
  background: rgba(99, 102, 241, 0.15);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

.user-menu:hover .btn-logout {
  display: block;
}

.btn-logout {
  display: none;
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 12px;
  background: white;
  border: 1px solid rgb(226 232 240);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgb(220 38 38);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgb(254 242 242);
}


/* Main Content Area - Modern Gradient Background */
.main-content {
  flex-grow: 1;
  overflow-y: auto;
  position: relative;
  padding: 32px 48px;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.bottom-spacer {
  height: 240px; /* Space for the floating bar (includes mode switch) */
}


/* Results Grid */
.results-area {
  min-height: 40vh;
}

/* Empty State - Modern Glass Card */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 40px;
  color: rgb(148 163 184);
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  border: 1px dashed rgba(226, 232, 240, 0.6);
  margin: 20px;
}
.empty-state .icon {
  font-size: 64px;
  margin-bottom: 24px;
  filter: grayscale(0.2);
}
.empty-state .title {
  font-size: 22px;
  font-weight: 700;
  color: rgb(51 65 85);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.empty-state .desc {
  font-size: 15px;
  color: rgb(100 116 139);
}


.results-grid, .history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.history-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px dashed rgb(203 213 225);
}

/* History Section - Modern Style */
.history-section {
  padding: 24px 32px;
  padding-bottom: 200px; /* Extra space at bottom to avoid being covered by floating bar */
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(226, 232, 240, 0.4);
}

.history-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-title {
  font-size: 20px;
  font-weight: 700;
  color: rgb(15, 23, 42);
  margin: 0;
  letter-spacing: -0.02em;
}

/* Chat-style History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Assets Section */
.assets-section {
  margin-top: 8px;
  padding: 24px 28px 180px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.assets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.assets-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: rgb(15 23 42);
}

.assets-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.assets-filters select,
.assets-filters input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgb(226 232 240);
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.85);
}

.assets-filters input {
  min-width: 220px;
}

.assets-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.asset-group-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 800;
  color: rgb(30 41 59);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.asset-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.asset-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgb(241 245 249);
  overflow: hidden;
  cursor: pointer;
}

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

.asset-video-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.asset-info {
  padding: 10px;
}

.asset-meta {
  margin: 0 0 6px;
  font-size: 12px;
  color: rgb(100 116 139);
}

.asset-prompt {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: rgb(51 65 85);
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.asset-actions {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.asset-time-inline {
  font-size: 12px;
  color: rgb(100 116 139);
}

.asset-icon-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.asset-icon-btn {
  border: 1px solid rgb(226 232 240);
  background: #fff;
  color: rgb(71 85 105);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  transition: all 0.2s ease;
}

.asset-icon-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.asset-icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgb(var(--topm-accent));
  color: rgb(var(--topm-accent));
}

.asset-icon-delete:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.assets-empty {
  margin-top: 20px;
}

/* Studio Section */
.studio-section {
  margin-top: 8px;
  padding: 24px 28px 180px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.studio-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: rgb(15 23 42);
}

.studio-tabs {
  display: flex;
  gap: 8px;
}

.studio-tab {
  border: 1px solid rgb(226 232 240);
  background: #fff;
  color: rgb(71 85 105);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}

.studio-tab.active {
  background: rgb(var(--topm-accent));
  color: #fff;
  border-color: rgb(var(--topm-accent));
}

.studio-panel {
  display: none;
}

.studio-panel.active {
  display: block;
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.studio-grid input,
.studio-grid select,
.studio-body textarea {
  width: 100%;
  border: 1px solid rgb(226 232 240);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: rgb(51 65 85);
}

.studio-body textarea {
  min-height: 90px;
  resize: vertical;
  margin-bottom: 10px;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.studio-shot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.studio-shot-card {
  border: 1px solid rgb(226 232 240);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.9);
}

.studio-shot-card .shot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: rgb(71 85 105);
}

.studio-shot-card textarea {
  margin-bottom: 8px;
}

.studio-shot-assets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.studio-shot-assets img,
.studio-shot-assets video {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgb(226 232 240);
}

.studio-downloads {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-main-layout {
  display: grid;
  grid-template-columns: minmax(360px, 420px) 1fr;
  gap: 22px;
}

.studio-main-left,
.studio-main-right {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgb(226 232 240);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.studio-main-right {
  min-height: 560px;
}

.studio-block {
  margin-bottom: 18px;
}

.studio-block-title {
  font-size: 14px;
  font-weight: 700;
  color: rgb(30 41 59);
  margin-bottom: 10px;
}

.studio-upload-tip {
  margin-top: 8px;
  font-size: 12px;
  color: rgb(100 116 139);
}

#studio-main-upload-input {
  width: 100%;
  padding: 13px;
  border: 1px dashed rgb(191 219 254);
  border-radius: 12px;
  background: linear-gradient(180deg, rgb(248 250 252) 0%, rgb(241 245 249) 100%);
  color: rgb(71 85 105);
  font-size: 13px;
  transition: all 0.2s ease;
}

#studio-main-upload-input:hover {
  border-color: rgb(96 165 250);
  background: linear-gradient(180deg, rgb(239 246 255) 0%, rgb(224 242 254) 100%);
}

#studio-main-upload-input:focus {
  outline: none;
  border-color: rgb(59 130 246);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

#studio-main-upload-input::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, rgb(37 99 235) 0%, rgb(14 165 233) 100%);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

#studio-main-upload-input::file-selector-button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.studio-upload-preview {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.studio-upload-item {
  position: relative;
  width: 72px;
  height: 72px;
}

.studio-upload-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgb(226 232 240);
}

.studio-upload-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgb(239 68 68);
  color: #fff;
  font-size: 14px;
  line-height: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.24);
}

.studio-main-config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.studio-inline-actions {
  margin: 8px 0;
}

.studio-main-selling-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.studio-main-selling-head .studio-block-title {
  margin-bottom: 0;
}

.studio-ai-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.16);
  color: rgb(29 78 216);
}

.studio-ai-copy-btn:hover {
  background: rgba(59, 130, 246, 0.22);
}

.studio-ai-copy-logo {
  font-size: 12px;
  line-height: 1;
}

#studio-main-selling-points {
  min-height: 190px;
  line-height: 1.55;
}

.studio-style-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.studio-style-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgb(226 232 240);
  border-radius: 10px;
  background: rgb(248 250 252);
  font-size: 13px;
  color: rgb(51 65 85);
}

.studio-style-options label:hover {
  border-color: rgb(191 219 254);
  background: rgb(239 246 255);
}

.studio-result-head {
  font-size: 16px;
  font-weight: 700;
  color: rgb(30 41 59);
  margin-bottom: 14px;
}

.studio-main-results {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.studio-result-style-group {
  border: 1px solid rgb(226 232 240);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  flex: 0 0 calc((100% - 24px) / 3);
  max-width: calc((100% - 24px) / 3);
}

.studio-result-style-title {
  font-size: 13px;
  font-weight: 700;
  color: rgb(71 85 105);
  margin-bottom: 8px;
}

.studio-result-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.studio-result-card {
  border: 1px solid rgb(226 232 240);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  width: 100%;
}

.studio-result-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.studio-result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px;
  font-size: 12px;
  gap: 6px;
}

.studio-result-style-tag {
  color: rgb(30 64 175);
  background: rgb(239 246 255);
  border: 1px solid rgb(191 219 254);
  border-radius: 999px;
  padding: 2px 8px;
}

.studio-result-media {
  width: 100%;
  aspect-ratio: var(--studio-aspect-ratio, 1 / 1);
}

.studio-result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgb(100 116 139);
  background: linear-gradient(180deg, rgb(248 250 252) 0%, rgb(241 245 249) 100%);
}

.studio-result-failed {
  color: rgb(185 28 28);
  background: linear-gradient(180deg, rgb(254 242 242) 0%, rgb(254 226 226) 100%);
}

.studio-result-failed small {
  font-size: 11px;
  color: rgb(153 27 27);
  max-width: 90%;
  text-align: center;
  word-break: break-word;
}

.studio-failed-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgb(239 68 68);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.studio-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgb(191 219 254);
  border-top-color: rgb(37 99 235);
  border-radius: 999px;
  display: inline-block;
  animation: studio-spin 0.8s linear infinite;
}

.studio-result-waiting {
  color: rgb(148 163 184);
}

.studio-retry-btn {
  border: 1px solid rgb(191 219 254);
  background: rgb(239 246 255);
  color: rgb(30 64 175);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
}

.studio-retry-btn:hover {
  background: rgb(219 234 254);
}

@media (max-width: 1200px) {
  .studio-main-layout {
    grid-template-columns: 1fr;
  }

  .studio-main-right {
    min-height: 0;
  }

  .studio-result-style-group {
    flex: 0 0 calc((100% - 12px) / 2);
    max-width: calc((100% - 12px) / 2);
  }
}

@media (max-width: 760px) {
  .studio-result-style-group {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

@keyframes studio-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.studio-empty-hint {
  color: rgb(100 116 139);
  font-size: 13px;
}

/* Chat message item - Modern Card Style */
.chat-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  margin-bottom: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.chat-message.user {
  flex-direction: row-reverse;
}

/* Avatar - Gradient Circle */
.chat-message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.chat-message.user .chat-message-avatar {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Message Content - Glass Card */
.chat-message-content {
  max-width: 75%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 18px;
  padding: 14px 18px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.chat-message.user .chat-message-content {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
  border-color: rgba(99, 102, 241, 0.2);
}

/* Prompt Text */
.chat-message-prompt {
  font-size: 14px;
  color: rgb(51 65 85);
  margin-bottom: 10px;
  line-height: 1.6;
}

/* Reference images for img2img - Modern Style */
.chat-message-refer-images {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  background: rgba(248, 250, 252, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.4);
}

.chat-message-refer-images .refer-label {
  font-size: 12px;
  font-weight: 600;
  color: rgb(71 85 105);
  white-space: nowrap;
}

.chat-message-refer-images .refer-images-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-message-refer-images .refer-image {
  width: auto;
  height: 56px;
  max-width: 120px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.8);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message-refer-images .refer-image:hover {
  transform: scale(1.08) translateY(-2px);
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.2);
}

.chat-message-refer-images .refer-image-empty {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 2px dashed rgba(203, 213, 225, 0.6);
  background: rgba(248, 250, 252, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgb(148 163 184);
  font-size: 11px;
  font-weight: 500;
}

.chat-message-config {
  font-size: 12px;
  color: rgb(148 163 184);
  margin-bottom: 8px;
  line-height: 1.4;
}

.chat-message-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.chat-message-images img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-message-images img:hover {
  transform: scale(1.02);
}

.chat-message-time {
  font-size: 11px;
  color: rgb(148 163 184);
  margin-top: 8px;
}

/* Chat message action buttons */
.chat-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid rgb(226, 232, 240);
  border-radius: 4px;
  background: white;
  color: rgb(71, 85, 105);
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: rgb(248, 250, 252);
  border-color: rgb(203, 213, 225);
}

.action-btn.reedit-btn:hover {
  color: #3b82f6;
  border-color: #3b82f6;
}

.action-btn.regenerate-btn:hover {
  color: #10b981;
  border-color: #10b981;
}

.action-btn.delete-btn:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* Task pending state */
.task-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  color: #3b82f6;
  font-size: 14px;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Task failed state */
.task-failed {
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  color: #ef4444;
  font-size: 14px;
}


/* Shared Card Style for Generated Images */
.result-card, .history-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
  transition: all 0.3s ease;
  border: 1px solid transparent;
}
.result-card:hover, .history-card:hover { 
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  border-color: rgb(var(--topm-accent) / 0.2);
}

.result-card img, .history-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: rgb(241 245 249);
}

.card-info {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-meta {
  font-size: 12px;
  color: rgb(100 116 139);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.download-btn {
  background: rgb(var(--topm-accent) / 0.08);
  color: rgb(var(--topm-accent));
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.download-btn:hover {
  background: rgb(var(--topm-accent));
  color: white;
}


/* Floating Generation Bar */
.floating-gen-bar {
  position: fixed;
  bottom: 32px;
  left: calc(50% + 36px);
  transform: translateX(-50%);
  width: fit-content;
  min-width: min(92vw, 1100px);
  max-width: calc(100vw - 24px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Glassmorphism Effect for Floating Bar */
.chat-input-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.02),
    0 12px 32px -4px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  padding: 20px 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-container:hover {
  box-shadow:
    0 8px 12px -2px rgba(0, 0, 0, 0.04),
    0 20px 40px -8px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

/* Mode Switch - Modern Pill Style */
.mode-switch {
  display: flex;
  gap: 4px;
  background: rgba(248, 250, 252, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 4px;
  border-radius: 14px;
  width: fit-content;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

/* Inline mode switch in history header */
.mode-switch-inline {
  margin-left: auto;
}

/* Mode Button with SVG Icon */
.mode-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: rgb(100 116 139);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-btn svg {
  width: 18px;
  height: 18px;
}

.mode-btn:hover {
  color: rgb(30, 41, 59);
  background: rgba(255, 255, 255, 0.5);
}

.mode-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  box-shadow:
    0 2px 8px rgba(99, 102, 241, 0.4),
    0 0 0 1px rgba(139, 92, 246, 0.2) inset;
}

/* Reference Image Upload */
.ref-image-upload {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  border: 2px dashed rgb(203 213 225);
  border-radius: 16px;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  position: relative;
}

.ref-image-upload:hover {
  border-color: rgb(var(--topm-accent));
  background: rgb(var(--topm-accent) / 0.04);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgb(148 163 184);
}

.upload-icon {
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 4px;
}

.upload-text {
  font-size: 12px;
  font-weight: 600;
}

.upload-preview {
  position: absolute;
  inset: 0;
  background: #fff;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-img-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s;
}
.remove-img-btn:hover { background: rgba(0,0,0,0.8); }


/* Parameters Row - Modern Style */
.param-selectors {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.param-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(248, 250, 252, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.6);
  transition: all 0.2s ease;
}

.param-item:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(99, 102, 241, 0.3);
}

.param-item select {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  font-weight: 600;
  color: rgb(51 65 85);
  cursor: pointer;
  padding: 0;
  min-width: 80px;
}

/* Chat-style Input Wrapper - Glassmorphism */
.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(248, 250, 252, 0.6);
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 24px;
  padding: 8px 8px 8px 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-wrapper:focus-within {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), 0 4px 12px rgba(0, 0, 0, 0.04);
}

/* AI Icon - Gradient */
.chat-ai-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.chat-ai-icon svg {
  width: 18px;
  height: 18px;
}

/* Chat Textarea - Modern Style */
.chat-textarea {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: rgb(15, 23, 42);
  font-family: inherit;
  line-height: 1.6;
  resize: none;
  min-height: 24px;
  max-height: 120px;
  padding: 6px 0;
}

.chat-textarea::placeholder {
  color: rgb(148 163 184);
  font-weight: 400;
}

/* Send Button - Modern Gradient */
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.send-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.send-btn:active {
  transform: translateY(0) scale(0.98);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

/* Cost Display - Modern Pill */
.cost-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: rgb(99, 102, 241);
  background: rgba(99, 102, 241, 0.1);
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.cost-display .diamond-icon {
  font-size: 14px;
}

/* Mode Content Container */
.mode-content {
  display: none;
}
.mode-content.active {
  display: block;
}

/* Small Reference Image Upload (Image Mode) */
.ref-image-upload-small {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px dashed rgb(203 213 225);
  border-radius: 12px;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  position: relative;
}

.ref-image-upload-small:hover {
  border-color: rgb(var(--topm-accent));
  background: rgb(var(--topm-accent) / 0.04);
}

.ref-image-upload-small .upload-placeholder {
  color: rgb(148 163 184);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-image-upload-small .upload-preview {
  position: absolute;
  inset: 0;
  background: #fff;
}

.ref-image-upload-small .upload-preview img,
.ref-image-upload-small > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 11px;
}

.ref-image-upload-small.has-image {
  border-style: solid;
  border-color: rgb(var(--topm-accent));
}

/* Multiple Reference Images Container */
.ref-images-container {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ref-images-container .ref-image-upload-small {
  position: relative;
}

.ref-images-container .ref-image-upload-small .remove-img-btn {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

.ref-images-container .add-more {
  border-style: dashed;
}

.ref-images-container .add-more:hover {
  border-color: rgb(var(--topm-accent));
  background: rgb(var(--topm-accent) / 0.04);
}

/* Video Mode Layout */
.video-input-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

/* New Video Layout */
.video-new-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

/* Left: Frame Uploads Section */
.video-frames-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Right: Params + Prompt Section */
.video-right-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* Video Params - No Wrapping */
#video-params {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  margin-bottom: 8px;
  width: max-content;
  min-width: 100%;
}

#video-params .param-item {
  flex-shrink: 0;
  padding: 6px 12px;
}

/* Frame Uploads Container - Modern Style */
.frame-uploads {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(248, 250, 252, 0.5);
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.5);
}

.frame-upload-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.frame-label {
  font-size: 13px;
  font-weight: 600;
  color: rgb(71 85 105);
}

.frame-arrow {
  color: rgb(148 163 184);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.6;
  min-width: 24px;
}

.frame-upload {
  width: 80px;
  height: 80px;
  border-radius: 14px;
}

.frame-upload .upload-placeholder svg {
  width: 28px;
  height: 28px;
  color: rgb(148 163 184);
}

.frame-upload .upload-text {
  font-size: 10px;
}

/* Video Reference Image Upload - Enhanced */
.ref-image-upload-video {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.8) 0%, rgba(239, 246, 255, 0.8) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
}

.ref-image-upload-video:hover {
  border-color: rgba(99, 102, 241, 0.6);
  background: linear-gradient(135deg, rgba(224, 231, 255, 0.8) 0%, rgba(238, 242, 255, 0.8) 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
}

.ref-image-upload-video.has-image {
  border-style: solid;
  border-color: rgba(99, 102, 241, 0.4);
}

.ref-image-upload-video:hover {
  border-color: rgb(var(--topm-accent));
  background: rgb(var(--topm-accent) / 0.04);
}

.ref-image-upload-video .upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgb(148 163 184);
}

.ref-image-upload-video .upload-text {
  font-size: 11px;
  font-weight: 600;
}

.ref-image-upload-video .upload-preview {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-image-upload-video .upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 14px;
}

/* Video Prompt Area */
.video-prompt-area {
  flex-grow: 1;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.video-prompt-area .chat-textarea {
  flex-grow: 1;
  min-height: 80px;
  max-height: 200px;
  background: #F8FAFC;
  border: 1px solid rgb(226 232 240);
  border-radius: 16px;
  padding: 12px 16px;
  resize: vertical;
}

.video-prompt-area .chat-textarea:focus {
  border-color: rgb(var(--topm-accent));
  background: white;
  box-shadow: 0 0 0 4px rgb(var(--topm-accent) / 0.08);
}


/* Generating overlay - Glassmorphism */
.generating-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.generating-overlay.show { display: flex; }

/* Modern Spinner */
.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(226, 232, 240, 0.5);
  border-top-color: #6366f1;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  animation: spin 0.8s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

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

/* Video Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}

.video-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}

.modal-close:hover {
    color: #ccc;
}

.image-crop-modal-content {
    width: min(92vw, 760px);
    background: #111827;
    border-radius: 14px;
    padding: 16px;
    color: #f8fafc;
    position: relative;
}

.image-crop-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.image-crop-header .modal-close {
    position: static;
    font-size: 28px;
    line-height: 1;
}

.image-crop-title {
    font-size: 18px;
    font-weight: 700;
}

.image-crop-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: #cbd5e1;
}

.image-crop-canvas-wrap {
    width: 100%;
    background: #0b1220;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#image-crop-canvas {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: grab;
    touch-action: none;
}

#image-crop-canvas.dragging {
    cursor: grabbing;
}

.image-crop-controls {
    margin-top: 12px;
    display: grid;
    gap: 6px;
}

.image-crop-controls label {
    font-size: 13px;
    color: #cbd5e1;
}

#image-crop-zoom {
    width: 100%;
}

.image-crop-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.image-crop-actions button {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.image-crop-actions .btn-secondary {
    background: #334155;
    color: #f8fafc;
}

.image-crop-actions .btn-primary {
    background: #6366f1;
    color: #fff;
}

/* Video Preview Container */
.video-preview-container {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.video-preview-container video {
    display: block;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0.9;
}

.video-preview-container:hover .video-play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Larger video in history */
.chat-message-media .video-preview-container video {
    width: 280px;
    max-width: 100%;
}

.generating-overlay .text { 
  font-size: 16px; 
  color: rgb(var(--topm-primary)); 
  font-weight: 700; 
}

/* Toast */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-success { background: rgb(22 163 74); }
.toast-error { background: rgb(220 38 38); }
.toast-info { background: rgb(var(--topm-accent)); }

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -20px) scale(0.9); }
  to { opacity: 1; transform: translate(0, 0) scale(1); }
}

.load-more {
  margin: 32px auto 0;
  display: block;
}

