:root {
  --bg: #090d16;
  --bg-card: rgba(18, 25, 41, 0.75);
  --bg-input: #0b1120;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(59, 130, 246, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(139, 92, 246, 0.1) 0%, transparent 45%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  padding: 24px 16px;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.shop-badge {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 8px 16px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.shop-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  transform: translateY(-1px);
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
}

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

.card-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title-wrap h2, .card h3 {
  font-size: 16px;
  font-weight: 700;
}

/* Badges */
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-pending {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Key Row */
.key-input-row {
  display: flex;
  gap: 12px;
}

.input-wrap {
  flex: 1;
}

input[type="text"], textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

#api-key-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
}

/* Key details box */
.key-details {
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(11, 17, 32, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.text-highlight {
  color: #38bdf8;
  font-weight: 700;
  font-size: 14px;
}

.key-error {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  color: #fca5a5;
  font-size: 13.5px;
}

/* Tabs */
.studio-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 20px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Studio Grid Layout */
.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.form-group {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.chip-label {
  font-size: 11.5px;
  color: var(--text-muted);
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Radio Pill Group */
.radio-pill-group, .ratio-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-pill {
  cursor: pointer;
  display: inline-flex;
}

.radio-pill input {
  display: none;
}

.radio-pill span {
  display: block;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.radio-pill input:checked + span {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--primary);
  color: #93c5fd;
  font-weight: 600;
}

/* File Upload Box */
.file-upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  position: relative;
  background: rgba(11, 17, 32, 0.4);
  transition: all 0.2s ease;
}

.file-upload-box:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.04);
}

.file-upload-box input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.upload-preview {
  position: relative;
  display: inline-block;
  max-width: 160px;
}

.upload-preview img {
  max-width: 100%;
  max-height: 100px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
}

.btn-remove-file {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ef4444;
  color: #fff;
  border: none;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  z-index: 10;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.btn-success:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-large {
  padding: 14px 24px;
  font-size: 15px;
  margin-top: 20px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Preview / Output Card */
.preview-card {
  display: flex;
  flex-direction: column;
}

.idle-placeholder {
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  margin-top: 16px;
}

.placeholder-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.7;
}

/* Progress Box */
.progress-box {
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 16px;
  padding: 32px 16px;
  background: rgba(11, 17, 32, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 16px;
}

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

.progress-bar-wrap {
  width: 100%;
  max-width: 380px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #a855f7);
  transition: width 0.4s ease;
}

.progress-meta {
  width: 100%;
  max-width: 380px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.progress-tip {
  margin-top: 18px;
  font-size: 12.5px;
  color: #94a3b8;
  max-width: 400px;
}

/* Result Box */
.result-box {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#video-player {
  width: 100%;
  max-height: 380px;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.img-display-wrap {
  width: 100%;
  max-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

#image-display {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.gallery-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-media-wrap {
  height: 160px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gallery-media-wrap img, .gallery-media-wrap video {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.gallery-meta {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-prompt {
  font-size: 12px;
  color: #cbd5e1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* Footer */
.studio-footer {
  text-align: center;
  font-size: 12px;
  color: #64748b;
  margin-top: 24px;
}

/* Quota & Storage Styles */
.badge-quota {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.badge-quota.full {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
  animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.quota-warning-banner {
  margin-top: 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fca5a5;
  font-size: 13px;
  font-weight: 600;
}

.quota-mini-tag {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
}

.quota-mini-tag.full {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

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

.card-header-inner h3 {
  margin-bottom: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: #cbd5e1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-subtext {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.gallery-stats-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-stats-pill .sep {
  color: #64748b;
}

.btn-delete-item {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-delete-item:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.6);
}

.gallery-footer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modal-box {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.modal-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.config-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-item label, .config-row label {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
}

.field-hint {
  font-size: 11px;
  color: #64748b;
}

.active-status-box {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: #93c5fd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-msg {
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.config-msg.success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.config-msg.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
}

/* Toast Notify */
.toast-notify {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.hidden {
  display: none !important;
}

