/* ============================================================
   style.css - fal Studio Dark Glassmorphism Theme
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 32, 0.8);
  --bg-card-hover: rgba(30, 30, 48, 0.9);
  --bg-input: rgba(15, 15, 25, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(139, 92, 246, 0.5);

  --text-primary: #f0f0f5;
  --text-secondary: #9898b0;
  --text-muted: #5a5a72;
  --text-hint: #4a4a60;

  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #06b6d4);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;

  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);

  --transition: 0.2s ease;
  --transition-slow: 0.35s ease;
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  color: white;
  flex-shrink: 0;
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
  font-family: inherit;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.gallery-count {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border-color);
}

.nav-item-sm {
  font-size: 0.82rem;
  padding: 10px 14px;
  color: var(--text-muted);
}

.nav-item-sm:hover {
  color: var(--error);
}

/* ============ MOBILE HEADER ============ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 200;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ---- Tab Panels ---- */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Panel Grid (2 columns) ---- */
.panel-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 28px;
  align-items: start;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.card-title svg {
  color: var(--accent);
  flex-shrink: 0;
}

.output-card {
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

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

.output-header .card-title {
  margin-bottom: 0;
}

/* ============ FORM ELEMENTS ============ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.form-select,
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition);
  outline: none;
  line-height: 1.5;
}

.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-textarea::placeholder,
.form-input::placeholder {
  color: var(--text-hint);
}

/* ---- Range Slider ---- */
.form-range {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px var(--accent-glow);
}

.range-value {
  float: right;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
}

/* ============ SETTINGS TOGGLE ============ */
.settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  user-select: none;
  margin-bottom: 4px;
}

.settings-toggle:hover {
  color: var(--text-primary);
}

.settings-toggle .chevron {
  margin-left: auto;
  transition: transform var(--transition);
}

.settings-toggle.open .chevron {
  transform: rotate(180deg);
}

.settings-panel {
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.25);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

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

.btn-generate {
  width: 100%;
  padding: 14px 24px;
  font-size: 0.95rem;
  justify-content: center;
  margin-top: 8px;
}

/* ============ DROPZONE ============ */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.05);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.dropzone-content svg {
  color: var(--text-hint);
}

.dropzone-content p {
  font-size: 0.85rem;
}

.dropzone-link {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.dropzone-hint {
  font-size: 0.75rem !important;
  color: var(--text-hint) !important;
}

.dropzone-preview {
  position: relative;
}

.dropzone-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-xs);
  object-fit: contain;
}

.dropzone-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.dropzone-remove:hover {
  background: var(--error);
}

/* Multi-image preview grid */
.dropzone-multi-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dropzone-multi-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg-input);
}

.dropzone-multi-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropzone-multi-item .dropzone-remove {
  width: 22px;
  height: 22px;
  font-size: 0.85rem;
  top: 2px;
  right: 2px;
}

.dropzone-multi-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============ GENERATION STATUS ============ */
.generation-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  text-align: center;
}

.status-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.status-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-timer {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.progress-bar {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
}

/* Indeterminate progress animation */
.progress-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease infinite;
}

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(450%); }
}

/* ============ OUTPUT EMPTY STATE ============ */
.output-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  text-align: center;
  flex: 1;
}

.output-empty svg {
  color: var(--text-hint);
  opacity: 0.5;
}

.output-empty p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.output-empty .hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============ OUTPUT GRID (Images) ============ */
.output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.output-grid.single {
  grid-template-columns: 1fr;
}

.output-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
  cursor: pointer;
  transition: transform var(--transition);
  animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.output-item:hover {
  transform: scale(1.02);
}

.output-item img {
  width: 100%;
  display: block;
}

.output-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.output-item:hover .output-item-overlay {
  opacity: 1;
}

.output-item-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.output-item-btn:hover {
  background: var(--accent);
}

/* ============ VIDEO OUTPUT ============ */
.output-video-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: scaleIn 0.4s ease;
}

.output-video-wrap video {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  background: black;
}

/* ============ GALLERY ============ */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-header .card-title {
  margin-bottom: 0;
}

.gallery-filters {
  display: flex;
  gap: 4px;
}

.gallery-filter.active {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent);
  border-color: rgba(139, 92, 246, 0.3);
}

/* Gallery toolbar */
.gallery-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.gallery-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
}

.gallery-search-wrap svg { color: var(--text-muted); flex-shrink: 0; }

.gallery-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  font-family: inherit;
}
.gallery-search::placeholder { color: var(--text-hint); }

.gallery-sort { flex-shrink: 0; }

/* Tag filter bar */
.gallery-tag-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.gallery-tag-chip {
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.gallery-tag-chip:hover, .gallery-tag-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 24px;
  text-align: center;
}

.gallery-empty svg {
  color: var(--text-hint);
  opacity: 0.4;
}

.gallery-empty p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.gallery-empty .hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
  cursor: pointer;
  aspect-ratio: 1;
  transition: transform var(--transition);
}

.gallery-item:hover {
  transform: scale(1.03);
}

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

.gallery-item-type {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: white;
}

.gallery-item-time {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  background: rgba(139, 92, 246, 0.7);
  backdrop-filter: blur(4px);
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: white;
  font-variant-numeric: tabular-nums;
}

.gallery-item-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition);
  z-index: 2;
}

.gallery-item:hover .gallery-item-delete {
  opacity: 1;
}

.gallery-item-delete:hover {
  background: var(--error);
  transform: scale(1.1);
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  opacity: 0;
  transition: opacity var(--transition);
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-prompt {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item-model {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

/* ============ LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 90vw;
  max-height: 75vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: -10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-info {
  text-align: center;
  max-width: 700px;
}

.lightbox-prompt {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.5;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-meta {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 500;
}

.lightbox-details {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
}

.lightbox-details span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lightbox-details .detail-label {
  color: var(--text-hint);
}

.lightbox-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.lightbox-delete-btn:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  color: var(--error) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  color: var(--text-primary);
  animation: toastIn 0.3s ease;
  max-width: 380px;
}

.toast.toast-exit {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 2px;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  /* Body & wrapper */
  body { display: block; min-height: 100vh; overflow-x: hidden; }
  #app-wrapper { display: block !important; min-height: 100vh; overflow-x: hidden; }

  /* Prevent width overflow */
  .controls-column, .output-column { min-width: 0; max-width: 100vw; overflow: hidden; }
  .card { min-width: 0; overflow: hidden; }

  /* Sidebar: slide-in overlay */
  .sidebar { transform: translateX(-100%); width: 260px; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mobile-header { display: flex; height: 50px; padding: 0 12px; }

  /* Main content */
  .main-content { margin-left: 0; padding: 58px 10px 20px; min-height: calc(100vh - 58px); }

  /* Cards */
  .card { padding: 14px; border-radius: 10px; }
  .card-title { font-size: 0.95rem; margin-bottom: 12px; gap: 8px; }
  .card-title svg { width: 18px; height: 18px; }

  /* Panel grid: single column, tight gap */
  .panel-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Output */
  .output-grid { grid-template-columns: 1fr; gap: 10px; }
  .output-card { min-height: 200px; padding: 12px; }
  .output-header { margin-bottom: 10px; }

  /* Model picker button */
  .model-picker-btn { padding: 10px 12px; max-width: 100%; box-sizing: border-box; }
  .model-picker-btn-info { overflow: hidden; }
  .model-picker-btn-name { font-size: 0.84rem; }
  .model-picker-btn-desc { font-size: 0.7rem; }

  /* Form elements */
  .form-group { margin-bottom: 12px; }
  .form-label { font-size: 0.72rem; margin-bottom: 5px; }
  .form-textarea { min-height: 60px; padding: 10px 12px; font-size: 0.85rem; }
  .form-input, .form-select { padding: 9px 12px; font-size: 0.85rem; }

  /* Chip groups */
  .chip-group { gap: 6px; }
  .chip { padding: 6px 12px; font-size: 0.76rem; }

  /* Dropzone: compact with visible content */
  .dropzone { padding: 14px 10px; }
  .dropzone-content { gap: 6px; }
  .dropzone-content svg { width: 28px; height: 28px; }
  .dropzone-content p { font-size: 0.78rem; }
  .dropzone-hint { font-size: 0.68rem !important; }

  /* Generate button: ensure visible and contained */
  .btn { white-space: normal; }
  .btn-generate { padding: 12px 16px; font-size: 0.88rem; border-radius: 8px; width: 100%; box-sizing: border-box; }

  /* Settings toggle */
  .settings-toggle { font-size: 0.8rem; padding: 8px 0; }

  /* Range sliders */
  .range-value { font-size: 0.78rem; }

  /* Gallery grid */
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .gallery-item { border-radius: 6px; }
  .gallery-item-type { font-size: 0.6rem; padding: 2px 5px; top: 4px; left: 4px; }
  .gallery-item-time { font-size: 0.58rem; padding: 2px 5px; top: 4px; right: 4px; }
  .gallery-item-delete { width: 22px; height: 22px; font-size: 0.8rem; }
  .gallery-item-vault { width: 22px; height: 22px; }
  .gallery-item-vault svg { width: 11px; height: 11px; }

  /* Gallery header: stack */
  .gallery-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .gallery-filters { flex-wrap: wrap; gap: 4px; }
  .gallery-filters .btn { font-size: 0.72rem; padding: 4px 8px; }

  /* Gallery toolbar: stack */
  .gallery-toolbar { flex-direction: column; gap: 6px; }
  .gallery-search-wrap { padding: 5px 10px; }
  .gallery-search { font-size: 0.78rem; }

  /* Lightbox: full screen */
  .lightbox { padding: 0; }
  .lightbox-content { max-width: 100vw; padding: 8px; }
  .lightbox-content img, .lightbox-content video { max-width: 100%; max-height: 55vh; border-radius: 6px; }
  .lightbox-close { top: 4px; right: 4px; width: 30px; height: 30px; position: fixed; z-index: 1010; }
  .lightbox-info { max-width: 100%; padding: 0 4px; }
  .lightbox-prompt { font-size: 0.78rem; max-height: 3em; }
  .lightbox-meta { font-size: 0.7rem; }
  .lightbox-details { font-size: 0.68rem; gap: 6px 10px; }
  .lightbox-actions { gap: 4px; flex-wrap: wrap; justify-content: center; }
  .lightbox-actions .btn { font-size: 0.68rem; padding: 5px 7px; gap: 3px; }
  .lightbox-actions .btn svg { width: 12px; height: 12px; }

  /* Status */
  .status-timer { font-size: 1.3rem; }
  .generation-status { padding: 30px 16px; gap: 12px; }
  .status-spinner { width: 36px; height: 36px; }

  /* Toasts */
  .toast-container { right: 6px; left: 6px; bottom: 6px; }
  .toast { max-width: 100%; font-size: 0.78rem; padding: 10px 12px; }

  /* Extend source */
  .extend-source { min-height: 60px; }
  .extend-empty { padding: 14px; }
  .extend-empty svg { width: 24px; height: 24px; }
  .extend-empty p { font-size: 0.76rem; }

  /* Sidebar user */
  .sidebar-user { padding: 10px 14px; }
  .sidebar-user-info { font-size: 0.78rem; }

  /* Video output */
  .output-video-wrap video { border-radius: 6px; }
}

@media (max-width: 480px) {
  .main-content { padding: 54px 6px 14px; }
  .card { padding: 12px; border-radius: 8px; }
  .card-title { font-size: 0.9rem; }
  .form-group { margin-bottom: 10px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .gallery-item { border-radius: 5px; }
  .lightbox-actions .btn { font-size: 0.65rem; padding: 4px 6px; }
  .pin-card { width: 280px; padding: 22px 18px 18px; }
  .pin-key { width: 52px; height: 44px; font-size: 1rem; border-radius: 10px; }
  .pin-grid { max-width: 190px; gap: 7px; }
  .pin-dots { gap: 12px; margin-bottom: 22px; }
  .pin-dot { width: 14px; height: 14px; }
}

/* ============ CHIP GROUP (duration/resolution selectors) ============ */
.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover {
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--text-primary);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ============ VAULT BUTTON ON GALLERY ITEMS ============ */
.gallery-item-vault {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition);
  z-index: 2;
}
.gallery-item:hover .gallery-item-vault { opacity: 1; }
.gallery-item-vault:hover { background: var(--accent); }
.gallery-item-vault.vault-restore { background: rgba(16, 185, 129, 0.7); }
.gallery-item-vault.vault-restore:hover { background: var(--success); }

.vault-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.vault-lock-btn {
  margin-left: auto;
  gap: 5px;
  color: var(--warning) !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}
.vault-lock-btn:hover {
  background: rgba(245, 158, 11, 0.15) !important;
}

.vault-count-badge {
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* ============ PIN PAD OVERLAY ============ */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

.pin-card {
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 32px 28px 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(139, 92, 246, 0.08);
}

.pin-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}
.pin-close:hover { color: var(--text-primary); }

.pin-lock-icon {
  color: var(--accent);
  margin-bottom: 12px;
}

.pin-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pin-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 28px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(139, 92, 246, 0.4);
  background: transparent;
  transition: all 0.2s ease;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.4);
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 240px;
  margin: 0 auto 20px;
}

.pin-key {
  width: 64px;
  height: 54px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-key:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
}

.pin-key:active {
  transform: scale(0.95);
  background: rgba(139, 92, 246, 0.25);
}

.pin-key-fn {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.pin-reset-link {
  background: none;
  border: none;
  color: var(--text-hint);
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition);
}
.pin-reset-link:hover { color: var(--error); }

/* Shake animation for wrong PIN */
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}
.pin-card.shake { animation: pinShake 0.5s ease; }

/* ============ GALLERY PICKER MODAL ============ */
.gp-overlay {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

.gp-modal {
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.gp-title {
  font-size: 1rem;
  font-weight: 700;
}

.gp-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
}

.gp-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.gp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.gp-item {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
}

.gp-item:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

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

.gp-item-type {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.6rem;
  padding: 2px 5px;
  background: rgba(0,0,0,0.6);
  border-radius: 3px;
  color: white;
  font-weight: 600;
}

.gp-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

@media (max-width: 480px) {
  .gp-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============ EXTEND VIDEO SOURCE ============ */
.extend-source {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 80px;
}

.extend-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
}

.extend-empty svg { color: var(--text-hint); }
.extend-empty p { font-size: 0.82rem; margin: 0; }

.extend-preview {
  position: relative;
}

.extend-preview video {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  display: block;
  background: black;
  border-radius: var(--radius-xs);
}

/* ============ MODEL PICKER BUTTON ============ */
.model-picker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
}

.model-picker-btn:hover {
  border-color: var(--border-focus);
  background: rgba(139, 92, 246, 0.04);
}

.model-picker-btn-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-picker-btn-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-picker-btn-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-picker-btn-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ============ MODEL PICKER MODAL ============ */
.mp-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

.mp-modal {
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.mp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.mp-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mp-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: auto;
}

.mp-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.mp-close:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

/* Search bar */
.mp-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.mp-search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.mp-search {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
}

.mp-search::placeholder {
  color: var(--text-hint);
}

/* Category tabs */
.mp-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
}

.mp-tabs::-webkit-scrollbar { height: 0; }

.mp-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}

.mp-tab:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.mp-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.mp-tab-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* Filters row */
.mp-filters-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.mp-filters-row .mp-tabs {
  flex: 1;
  border-bottom: none;
}

.mp-sort {
  padding: 0 16px 0 0;
  flex-shrink: 0;
}

.mp-sort-select {
  padding: 5px 28px 5px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* Favorite star on cards */
.mp-card-star {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition);
  z-index: 2;
}

.mp-card:hover .mp-card-star { opacity: 1; }
.mp-card-star.favorited { opacity: 1; color: #f59e0b; }
.mp-card-star:hover { background: rgba(0,0,0,0.7); color: #f59e0b; }

/* Grid container */
.mp-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.mp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.mp-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Model cards */
.mp-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  overflow: hidden;
  position: relative;
}

.mp-card:hover {
  border-color: rgba(139, 92, 246, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mp-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

.mp-card-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(6,182,212,0.15));
}

.mp-card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.mp-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-card-badge {
  font-size: 0.72rem;
  display: inline-block;
  margin-left: 4px;
}

.mp-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mp-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.mp-card-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent);
  font-weight: 500;
}

.mp-card-tag.uncensored-tag {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* Responsive */
@media (max-width: 768px) {
  .mp-overlay { padding: 0; }
  .mp-modal {
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    height: 100vh;
  }
  .mp-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .mp-card-thumb { height: 80px; }
  .mp-card-body { padding: 8px 10px 10px; }
  .mp-card-name { font-size: 0.78rem; }
  .mp-card-desc { font-size: 0.68rem; -webkit-line-clamp: 1; }
  .mp-tabs { gap: 4px; padding: 8px 12px; }
  .mp-tab { padding: 5px 10px; font-size: 0.72rem; }
  .mp-header { padding: 14px 14px 10px; }
  .mp-search-bar { padding: 8px 14px; }
  .mp-grid-wrap { padding: 10px 12px 16px; }
  .mp-filters-row { flex-wrap: wrap; }
  .mp-sort { padding: 0 12px 0 0; }

  /* Gallery picker */
  .gp-overlay { padding: 0; }
  .gp-modal { max-height: 100vh; max-width: 100vw; border-radius: 0; }
  .gp-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

@media (max-width: 480px) {
  .mp-grid { grid-template-columns: repeat(2, 1fr); }
  .gp-grid { grid-template-columns: repeat(2, 1fr); }
  }
}

/* ============ LOGIN SCREEN ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px 32px 32px;
  text-align: center;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg), 0 0 80px rgba(139, 92, 246, 0.06);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-field {
  text-align: left;
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-field input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.login-field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.login-field input::placeholder { color: var(--text-hint); }

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  color: var(--error);
  font-size: 0.82rem;
  margin-bottom: 16px;
  text-align: left;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  justify-content: center;
}

/* ============ SIDEBAR USER MENU ============ */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}

.sidebar-user-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-logout-btn:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ============ ADMIN PANEL ============ */
.admin-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
}

.admin-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
  flex: 1;
}

.admin-user-role {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.admin-user-role.role-admin {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent);
}

.admin-user-role.role-user {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-secondary);
}

/* ============ APP WRAPPER ============ */
#app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ============ MOBILE: Login + Admin ============ */
@media (max-width: 480px) {
  .login-card {
    width: 100%;
    max-width: 340px;
    padding: 28px 20px 24px;
    margin: 0 12px;
  }
  .login-field input { padding: 10px 12px; }
  .admin-create-user form { flex-direction: column; }
  .admin-create-user form .form-group { width: 100% !important; min-width: 0 !important; }
}

/* ============ UTILITY ============ */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
