.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.v5-form-mount { min-width: 0; }
.v5-form-mount > form { display: block; min-width: 0; }
.v5-form-mount > form > [data-form-body="basic"] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  margin: 0; }
.v5-form-mount > form > [data-form-body="basic"] > * { margin: 0 !important; }

.v5-form-mount > form > details:not(:has([data-id])) { display: none; }

.v5-form-mount > form > [data-form-body="basic"] > div { display: flex; flex-direction: column; }

.v5-form-mount > form > [data-form-body="basic"] [data-help-trigger] { color: hsl(var(--muted-foreground)); }

.v5-form-mount [aria-haspopup="dialog"],
.v5-form-mount [data-component="visual-picker"] [role="button"] {
  white-space: normal;
}
.v5-form-mount [data-component="visual-picker"] {
  border-radius: 16px;
}

.v5-form-mount textarea {
  min-height: 96px;
  resize: none;
  border-radius: 14px;
}

.v5-form-mount select,
.v5-form-mount input[type="number"],
.v5-form-mount input[type="text"]:not([type="file"]) {
  height: 44px;
  border-radius: 12px;
}

.v5-form-mount .dropzone-empty,
.v5-form-mount [data-media-field] {
  min-height: 120px;
  border-radius: 16px;
}

.v5-form-mount .file-drop-zone ~ .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.v5-form-mount .file-drop-zone ~ .grid :is(img, video, .h-20) { height: auto; aspect-ratio: 1 / 1; }

.v5-form-mount.v5-form-ready > div.animate-pulse { display: none; }

.v5-advanced-row {
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  gap: 6px;
}
.v5-advanced-row:empty { display: none; }
.v5-form-mount > form > .v5-advanced-row { margin: 12px 0 0; }
.v5-advanced-row::-webkit-scrollbar { height: 4px; }
.v5-advanced-row::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 9999px; }
.v5-advanced-row > * { margin: 0; min-width: 0; flex: 0 0 auto; }

.v5-advanced-row .mb-1\.5,
.v5-advanced-row .mb-2,
.v5-advanced-row label[for]:not(:empty),
.v5-advanced-row [data-help-trigger],
.v5-advanced-row [role="alert"]:empty { display: none !important; }

.v5-advanced-row button,
.v5-advanced-row select,
.v5-advanced-row input[type="text"]:not([type="file"]),
.v5-advanced-row input[type="number"] {
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 14px !important;
  font-size: 12px !important;
  line-height: 36px !important;
  border-radius: 9999px !important;
  background: var(--panel-input) !important;
  border: 1px solid transparent !important;
  color: hsl(var(--foreground)) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
.v5-advanced-row button:hover,
.v5-advanced-row select:hover { background: var(--panel-hover) !important; }
.v5-advanced-row button svg { display: none !important; }
.v5-advanced-row button .shrink-0.ml-2 { display: none !important; }

.v5-advanced-row .dropzone-empty,
.v5-advanced-row [data-media-field] {
  min-height: 36px !important;
  max-width: 140px !important;
  padding: 2px 10px !important;
  border-radius: 9999px !important;
}
.v5-advanced-row .dropzone-empty * { font-size: 12px !important; }
.v5-advanced-row [role="radio"],
.v5-advanced-row [role="radiogroup"] > button {
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 12px !important;
  font-size: 12px !important;
  border-radius: 9999px !important;
}
.v5-advanced-row [role="radiogroup"].grid {
  display: inline-flex !important;
  gap: 4px !important;
  flex-wrap: nowrap !important;
}

.v5-generate-btn {
  background: linear-gradient(90deg, #9335EC 0%, #7C3AED 100%);
  box-shadow: 0 8px 24px -10px rgba(147, 53, 236, 0.6);
}
.v5-generate-btn:hover:not(:disabled) {
  background: linear-gradient(90deg, #8a2fe0 0%, #6d28d9 100%);
}
.v5-generate-btn { position: relative; }
.v5-generate-btn .ml-2 {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.v5-studio { display: flex; flex-direction: column; gap: 12px; }
.v5-studio.hidden { display: none !important; }
.v5-panel { display: flex; flex-direction: column; gap: 16px; padding: 20px 20px 0; }
.v5-panel-foot {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex; flex-direction: column; gap: 8px;
  margin-top: -16px; padding: 16px 0 18px;
  background: linear-gradient(to bottom, transparent 0%, var(--panel) 30%);
}

.v5-canvas {
  position: relative;
  order: -1;
  min-height: 380px;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(rgba(0,0,0,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    #F3F4F7;
}
.dark .v5-canvas {
  background:
    radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    #0B0B0D;
}

@media (min-width: 1024px) {
  .v5-studio:not(.hidden) {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }
  .v5-panel {
    position: sticky;
    top: 84px;
    max-height: calc(100dvh - 14rem);
    overflow-y: auto;
    scrollbar-width: none;
  }
  .v5-panel::-webkit-scrollbar { display: none; }
  .v5-canvas { order: 0; align-self: stretch; min-height: min(560px, calc(100dvh - 14rem)); contain: size; }
  .v5-intro-card { max-height: 100%; }
  .v5-intro-media { aspect-ratio: auto; flex: 0 1 231px; min-height: 0; }
  .v5-canvas .v5-intro-card { width: min(340px, 100%); }
  .v5-canvas .v5-intro-title { font-size: 24px; }
  .v5-canvas .v5-intro-desc { font-size: 14px; }
  .v5-canvas .v5-upload-btn { height: 46px; margin-top: 10px; font-size: 15px; }
  .v5-canvas .v5-upload-btn svg { width: 18px; height: 18px; }
  .v5-intro-card > :not(.v5-intro-media) { flex-shrink: 0; }
}
@media (min-width: 1024px) and (max-height: 820px) {
  .v5-intro-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}

.v5-intro { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 24px; }
.v5-intro-card {
  width: min(400px, 100%);
  padding: 16px 16px 20px;
  border-radius: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 24px 60px -30px rgba(0,0,0,0.25);
}
.dark .v5-intro-card { background: #141416; border-color: rgba(255,255,255,0.06); box-shadow: 0 24px 60px -30px rgba(0,0,0,0.8); }
.v5-intro-media {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.9) 50%, transparent 70%) 0 0 / 200% 100% #E9E9EC;
  animation: v5-shimmer 1.4s ease-in-out 6;
}
.dark .v5-intro-media { background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.1) 50%, transparent 70%) 0 0 / 200% 100% #1C1C1F; }
.v5-intro-media > :is(img, video) { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 1 !important; }
@keyframes v5-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.v5-intro-title { font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: 0.01em; text-transform: uppercase; }
.v5-intro-desc { max-width: 340px; font-size: 15px; line-height: 1.45; color: var(--form-hint); }
.v5-upload-btn {
  margin-top: 14px;
  width: 100%;
  height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 16px; font-weight: 600;
  background: transparent; color: #0D0D0D;
  border: 1px solid rgba(0,0,0,0.14);
  transition: background 0.15s ease;
}
.dark .v5-upload-btn { color: #FFFFFF; border-color: rgba(255,255,255,0.16); }
.v5-upload-btn { padding: 0 16px; }
.v5-upload-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v5-upload-btn svg { flex: none; }
.v5-upload-btn:hover { background: rgba(0,0,0,0.04); }
.dark .v5-upload-btn:hover { background: rgba(255,255,255,0.06); }
.v5-upload-btn svg { width: 20px; height: 20px; }
.v5-rate-link { margin-top: 4px; font-size: 12px; color: var(--form-hint); }
.v5-rate-link:hover { color: hsl(var(--foreground)); }

.v5-upload-preview { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 48px; container-type: size; }
.v5-upload-preview[hidden] { display: none; }
.v5-preview-frame { position: relative; display: flex; }
.v5-upload-preview [hidden] { display: none; }
.v5-upload-preview :is(img, video) {
  max-width: 100cqw;
  max-height: 100cqh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,0.6);
}
.v5-replace-btn {
  position: absolute; top: 12px; right: 12px;
  height: 34px; padding: 0 14px; border-radius: 9999px;
  font-size: 13px; font-weight: 600;
  background: rgba(0,0,0,0.55); color: #FFFFFF;
  backdrop-filter: blur(8px);
}
.v5-replace-btn:hover { background: rgba(0,0,0,0.7); }

.v5-stage { position: absolute; inset: 0; padding: 48px; display: none; }
.v5-stage > img,
.v5-stage > video,
.v5-stage :is(img, video):not(.ait-slider *) { width: 100%; height: 100%; object-fit: contain; display: block; }
.v5-stage .v5-stage-mirror { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 20px; aspect-ratio: auto; }
.v5-stage .v5-stage-mirror :is(img, video) { object-fit: contain; padding: 48px; box-sizing: border-box; background: transparent; }

.v5-canvas[data-v5-state="image"] .v5-intro,
.v5-canvas[data-v5-state="run"] .v5-intro,
.v5-canvas[data-v5-state="run"] .v5-upload-preview { display: none; }
.v5-canvas[data-v5-state="run"] .v5-stage { display: flex; align-items: center; justify-content: center; }

.v5-drop-hint {
  position: absolute; inset: 12px;
  display: none; align-items: center; justify-content: center;
  border: 2px dashed hsl(var(--primary));
  border-radius: 16px;
  background: rgba(147, 53, 236, 0.08);
  font-size: 15px; font-weight: 600; color: hsl(var(--foreground));
  pointer-events: none;
}
.v5-canvas.is-dragover .v5-drop-hint { display: flex; }

#remix-area.hidden { display: none !important; }

.prose-guide { color: #898A8B; font-size: 16px; line-height: 24px; }
.prose-guide :is(h1, h2, h3, strong, dt) { color: hsl(var(--foreground)); font-weight: 600; }
.prose-guide :is(h1, h2) { font-size: 16px; line-height: 21px; margin: 24px 0 10px; }
.prose-guide h3 { font-size: 14px; line-height: 20px; margin: 12px 0 4px; }
.prose-guide h3 + p { margin-bottom: 10px; }
.prose-guide dt { font-size: 14px; }
.prose-guide :is(p, ul, dd) { margin-bottom: 14px; }
.prose-guide ul { padding-left: 22px; list-style: disc; }
.prose-guide > :first-child { margin-top: 0; }

.size-slider { -webkit-appearance: none; appearance: none; width: 100px; height: 4px; background: #404040; border-radius: 9999px; cursor: pointer; outline: none; }
.size-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #9335EC; cursor: pointer; border: none; box-shadow: 0 2px 8px rgba(147, 53, 236, 0.5); margin-top: 0; }
.size-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #9335EC; cursor: pointer; border: none; box-shadow: 0 2px 8px rgba(147, 53, 236, 0.5); }
.size-slider::-moz-range-track { background: #404040; height: 4px; border-radius: 9999px; }

.view-toggle-container { display: flex; align-items: center; width: 94px; padding: 5px; background: #262626; border-radius: 24px; gap: 2px; }
.view-toggle-btn { flex: 1; height: 30px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: #737373; background: transparent; border: none; cursor: pointer; transition: all 0.15s ease; }
.view-toggle-btn:hover { color: #a3a3a3; }
.view-toggle-btn.active { background: #404040; color: #ffffff; }

:root:not(.dark) .size-slider { background: #D9D9D9; }
:root:not(.dark) .size-slider::-moz-range-track { background: #D9D9D9; }
:root:not(.dark) .view-toggle-container { background: #DFE4EC; }
:root:not(.dark) .view-toggle-btn { color: #898A8B; }
:root:not(.dark) .view-toggle-btn:hover { color: #0D0D0D; }
:root:not(.dark) .view-toggle-btn.active { background: #ffffff; color: #0D0D0D; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

@media (min-width: 1024px) {
  .history-list-card { max-width: 100%; }
  .history-list-media { flex: var(--list-media-flex, 1) 1 var(--list-media-basis, 0); min-width: 0; overflow: hidden; }
  .history-list-info { flex: var(--list-info-flex, 0) 0 var(--list-info-basis, 280px); max-width: var(--list-info-basis, 280px); overflow: hidden; }
}
.history-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; justify-content: start; align-content: start; align-items: start; width: 100%; }
.history-grid.cols-4 { --cols: 4; }
.history-grid.cols-3 { --cols: 3; }
.history-grid.cols-2 { --cols: 2; }

.history-card { position: relative; width: 100%; border-radius: 16px; overflow: hidden; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); }
.history-grid .history-card { align-self: start; height: 0; padding-bottom: 73.75%; }
.history-card-media { position: absolute; inset: 0; background: hsl(var(--secondary)); }
.history-card-media-el { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.history-media-video { object-fit: cover; }
.history-media-image { object-fit: contain; background: rgba(0,0,0,0.04); }
.history-media-placeholder { background: hsl(var(--secondary)); }
.history-card > img, .history-card > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.history-card-overlay { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.8) 100%); opacity: 0; transition: opacity 0.2s; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; }
.history-card:hover .history-card-overlay, .history-card.show-overlay .history-card-overlay { opacity: 1; }
.history-card-actions { display: flex; gap: 8px; }
.history-card-action { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.15); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; color: white; border: none; cursor: pointer; transition: background 0.2s; }
.history-card-action:hover { background: rgba(255,255,255,0.25); }
.history-card-text { color: white; font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.history-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.history-card-badge { padding: 6px 10px; border-radius: 10px; font-size: 12px; line-height: 1; background: rgba(255,255,255,0.15); color: white; backdrop-filter: blur(8px); }

.history-list .history-card { aspect-ratio: auto; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; padding: 12px; border-radius: 16px; align-items: start; }
.history-list .history-card-media { position: relative; inset: auto; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: hsl(var(--secondary)); }
.history-list .history-card-media-el { position: absolute; inset: 0; }
.history-list .history-card-overlay { position: static; opacity: 1; background: none; padding: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.history-list .history-card-text { color: hsl(var(--foreground)); -webkit-line-clamp: 8; }
.history-list .history-card-actions { justify-content: flex-end; gap: 8px; }
.history-list .history-card-badge { background: hsl(var(--secondary)); color: hsl(var(--foreground)); backdrop-filter: none; }
.history-list .history-card.history-card-text-only { grid-template-columns: 1fr; }
.history-list .history-card.history-card-text-only .history-card-media { display: none; }
.history-list .history-card.history-card-text-only .history-card-text { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; -webkit-line-clamp: 6; }
[data-v5-upload][hidden] { display: none !important; }

/* Clear the fixed bottom tab bar. */
@media (max-width: 1023.98px) {
  body.has-bottom-tabs .v5-panel-foot { bottom: calc(61px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 1023.98px) {
  .v5-canvas[data-v5-state="intro"] { min-height: 0; }
  .v5-intro { padding: 12px; }
  .v5-intro-card { padding: 10px 10px 12px; gap: 4px; }
  .v5-intro-media { aspect-ratio: auto; height: 140px; margin-bottom: 6px; }
  .v5-intro-title { font-size: 20px; }
  .v5-intro-desc,
  .v5-intro-card .v5-upload-btn { display: none; }
  .v5-panel-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
