/* ==========================================================================
   AuraFlow Studio - Core Design System & Stylesheet
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
  --bg-color: #060913;
  --panel-bg: rgba(13, 20, 38, 0.65);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-border-glow: rgba(191, 90, 242, 0.15);
  
  /* Primary Gradients */
  --primary-glow: linear-gradient(135deg, #bf5af2 0%, #0a84ff 100%);
  --accent-cyan: #5ac8fa;
  --accent-purple: #bf5af2;
  --accent-blue: #0a84ff;
  --accent-pink: #ff2d55;
  --accent-green: #30d158;

  /* Text Colors */
  --text-main: #f5f6fa;
  --text-muted: #8a94a6;
  --text-dark: #4e5d78;

  /* Font Families */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --neon-shadow-purple: 0 0 20px rgba(191, 90, 242, 0.35);
  --neon-shadow-cyan: 0 0 20px rgba(90, 200, 250, 0.35);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Reset & Global Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* Background Glowing Orbs */
.glow-orb {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  transition: all var(--transition-slow);
}
.orb-1 {
  background: #bf5af2;
  top: -100px;
  right: -50px;
}
.orb-2 {
  background: #0a84ff;
  bottom: 10%;
  left: -100px;
}
.orb-3 {
  background: #ff2d55;
  top: 40%;
  right: 25%;
  width: 350px;
  height: 350px;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(191, 90, 242, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(191, 90, 242, 0.45);
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  gap: 1.5rem;
}

/* Glassmorphism Panel Helper */
.card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow);
  transition: border var(--transition-normal), box-shadow var(--transition-normal);
}
.card:hover {
  border-color: rgba(191, 90, 242, 0.18);
}

/* App Header Layout */
.app-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: rgba(13, 20, 38, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  gap: 1.5rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.logo-icon svg {
  filter: drop-shadow(0 0 8px rgba(191, 90, 242, 0.3));
}
.logo-text h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #bf5af2, #0a84ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}
.logo-text span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
}

.nav-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  gap: 0.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}
.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}
.tab-btn.active {
  color: var(--text-main);
  background: var(--primary-glow);
  box-shadow: 0 4px 15px rgba(191, 90, 242, 0.25);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(48, 209, 88, 0.08);
  padding: 0.4rem 0.85rem;
  border-radius: 30px;
  border: 1px solid rgba(48, 209, 88, 0.18);
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulse-green 2s infinite;
}
.status-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-green);
}

@keyframes pulse-green {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 14px var(--accent-green); }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* App Main Workspace */
.app-workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Configuration Sidebar */
.config-sidebar {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sidebar-header h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
}
.sidebar-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Forms & Parameter Styling */
.param-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.param-group label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
}

.custom-select-wrapper {
  position: relative;
}
.custom-select {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-main);
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  appearance: none;
}
.custom-select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px rgba(191, 90, 242, 0.15);
}
.custom-select-wrapper::after {
  content: '▼';
  font-size: 0.65rem;
  color: var(--text-muted);
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.field-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.15rem;
}

/* Aspect Ratio / Dimensions Selector */
.aspect-ratio-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}
.aspect-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.5rem 0.25rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.aspect-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}
.aspect-btn.active {
  background: rgba(10, 132, 255, 0.12);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.resolution-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.res-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
}
.res-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.res-field input {
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  width: 100%;
  margin-top: 0.05rem;
}
.res-divider {
  color: var(--text-muted);
  font-weight: 700;
}

/* Switch styling */
.toggle-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
}
.toggle-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
input:checked + .slider {
  background-color: var(--accent-purple);
}
input:checked + .slider:before {
  transform: translateX(20px);
}

/* Accordion Settings Section */
.accordion-section {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 1rem;
  margin-top: 0.5rem;
}
.accordion-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.accordion-toggle .chevron {
  transition: transform var(--transition-fast);
}
.accordion-toggle.active .chevron {
  transform: rotate(180deg);
}
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal) ease-out;
}
.accordion-content.open {
  max-height: 250px;
  margin-top: 1rem;
}

/* General Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.75rem 1.4rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-primary {
  background: var(--primary-glow);
  color: var(--text-main);
  box-shadow: var(--neon-shadow-purple);
}
.btn-primary:hover {
  opacity: 0.93;
  transform: translateY(-1px);
  box-shadow: 0 0 26px rgba(191, 90, 242, 0.5);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.15);
}
.btn-danger-link {
  background: transparent;
  border: none;
  color: var(--accent-pink);
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  opacity: 0.8;
  font-size: 0.85rem;
}
.btn-danger-link:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Workspace Area Layout */
.workspace-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Upload Panel */
.upload-container {
  padding: 1.5rem;
}
.upload-wrapper {
  background: rgba(0, 0, 0, 0.18);
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 2.2rem 1.5rem;
  text-align: center;
  transition: all var(--transition-normal);
  position: relative;
}
.upload-wrapper.dragover {
  border-color: var(--accent-cyan);
  background: rgba(90, 200, 250, 0.03);
  box-shadow: var(--neon-shadow-cyan);
}
.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.upload-prompt svg {
  color: var(--text-muted);
  opacity: 0.7;
}
.upload-prompt h3 {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.05rem;
}
.upload-prompt p {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.upload-prompt .btn {
  margin-top: 0.35rem;
}

/* Upload Preview State */
.upload-preview {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-align: left;
  gap: 1.25rem;
}
.preview-img-wrapper {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #000;
  flex-shrink: 0;
}
.preview-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.remove-preview-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.remove-preview-btn:hover {
  background: var(--accent-pink);
  border-color: transparent;
}
.preview-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
}
.preview-status .filename {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-status .filesize {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin: 0.2rem 0;
}
.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--primary-glow);
  border-radius: 10px;
  transition: width 0.2s ease-out;
}
.upload-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-cyan);
}
.upload-badge.success {
  color: var(--accent-green);
}

/* Prompt Container */
.prompt-container {
  padding: 1rem;
}
.prompt-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.5rem;
  gap: 0.5rem;
}
.prompt-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  height: 96px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.4rem 0.6rem;
}
.prompt-input-wrapper textarea::placeholder {
  color: var(--text-dark);
}
.prompt-input-wrapper .btn-primary {
  align-self: stretch;
  padding: 0 1.6rem;
  flex-shrink: 0;
}

/* Viewport Container (Preview Output) */
.viewport-container {
  min-height: 480px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewport-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  max-width: 380px;
  padding: 2rem;
  color: var(--text-muted);
  margin: auto;
}
.stars-icon {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-purple);
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 10px rgba(191, 90, 242, 0.1));
}
.viewport-placeholder h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text-main);
}
.viewport-placeholder p {
  font-size: 0.82rem;
  line-height: 1.5;
}

/* Loader Styling */
.viewport-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  text-align: center;
  padding: 3rem;
  z-index: 10;
  margin: auto;
}
.loader-ripple {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
}
.loader-ripple div {
  position: absolute;
  border: 4px solid var(--accent-purple);
  opacity: 1;
  border-radius: 50%;
  animation: loader-ripple 1.4s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
.loader-ripple div:nth-child(2) {
  animation-delay: -0.7s;
  border-color: var(--accent-blue);
}
@keyframes loader-ripple {
  0% { top: 36px; left: 36px; width: 0; height: 0; opacity: 0; }
  4.9% { top: 36px; left: 36px; width: 0; height: 0; opacity: 0; }
  5% { top: 36px; left: 36px; width: 0; height: 0; opacity: 1; }
  100% { top: 0px; left: 0px; width: 72px; height: 72px; opacity: 0; }
}

.viewport-loading h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
}
.viewport-loading p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.loading-sub {
  font-size: 0.72rem !important;
  color: var(--accent-cyan) !important;
  font-weight: 600;
}

/* Generation Output Viewport */
.viewport-output {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.output-media-container {
  flex: 1;
  background: #020408;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.output-media-container img,
.output-media-container video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
}

.output-actions {
  background: rgba(8, 14, 27, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.actions-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.output-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}
.output-seed {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.actions-right {
  display: flex;
  gap: 0.6rem;
}
.actions-right .btn {
  padding: 0.6rem 1.1rem;
}

/* My Studio Gallery / History */
.app-history {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.85rem;
}
.header-left h2 {
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 1.25rem;
}
.header-left p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  min-height: 120px;
  align-items: start;
}
.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* History Card */
.history-card {
  background: #020408;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: all var(--transition-fast);
  aspect-ratio: 1 / 1;
  box-shadow: var(--glass-shadow);
}
.history-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-purple);
  box-shadow: 0 6px 20px rgba(191, 90, 242, 0.15);
}

.history-media-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #020408;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  overflow: hidden;
  z-index: 1;
}
.history-media-wrapper img,
.history-media-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal);
}
.history-card:hover .history-media-wrapper img,
.history-card:hover .history-media-wrapper video {
  transform: scale(1.05);
}

.history-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  display: flex;
  flex-direction: column;
  z-index: 2;
  pointer-events: none; /* Let click pass through to mediaWrapper */
}

.history-card-info {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  pointer-events: auto; /* Allow selecting text if needed */
}
.history-card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 1px 2px rgba(0, 0, 0, 0.85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;  
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
.history-card-model {
  font-size: 0.62rem;
  color: var(--accent-cyan);
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.history-card-type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.5px;
  color: #fff;
  text-transform: uppercase;
  z-index: 3;
  pointer-events: none;
}

/* History Card Actions - Top Left */
.history-card-overlay .history-card-actions {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 5px;
  margin-top: 0;
  pointer-events: auto; /* Clickable */
}
.history-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50% !important;
  background: rgba(13, 20, 38, 0.75) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #fff;
  cursor: pointer;
  transition: all var(--transition-fast) !important;
  padding: 0 !important;
  flex: none !important;
}
.history-action-btn:hover {
  background: var(--primary-glow) !important;
  border-color: transparent !important;
  box-shadow: 0 2px 8px rgba(191, 90, 242, 0.4);
}
.history-action-btn.delete-btn {
  background: rgba(255, 45, 85, 0.08);
  border-color: rgba(255, 45, 85, 0.15);
  color: var(--accent-pink) !important;
  border-color: rgba(255, 45, 85, 0.25) !important;
}
.history-action-btn.delete-btn:hover {
  background: var(--accent-pink) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(255, 45, 85, 0.4);
}

/* Modal / Lightbox Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal.show {
  display: flex;
}
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.modal-content {
  position: relative;
  width: 90vw;
  max-width: 1100px;
  height: 85vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10001;
  padding: 0;
  border-color: rgba(191, 90, 242, 0.25);
  animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modal-enter {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.modal-close-btn:hover {
  background: var(--accent-pink);
  border-color: transparent;
  transform: rotate(90deg);
}

.modal-zoom-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(13, 20, 38, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.85rem;
  border-radius: 30px;
  z-index: 10005;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.zoom-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  transition: all var(--transition-fast);
}
.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}
.zoom-btn.reset {
  width: auto;
  border-radius: 20px;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.zoom-level {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-cyan);
  min-width: 48px;
  text-align: center;
}

.modal-body {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #020408;
}
.modal-media-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: auto;
  cursor: grab;
}
.modal-media-wrapper:active {
  cursor: grabbing;
}
.modal-media-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.15s ease-out;
  transform-origin: center center;
}
.modal-media-wrapper video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Notification Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(13, 20, 38, 0.95);
  backdrop-filter: blur(8px);
  border-left: 4px solid var(--accent-purple);
  border-top: 1px solid var(--panel-border);
  border-bottom: 1px solid var(--panel-border);
  border-right: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  color: var(--text-main);
  font-weight: 500;
  font-family: var(--font-display);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 9999;
  transform: translateY(120px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: none;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Responsive & Adaptive Grid System
   ========================================================================== */

@media (max-width: 1024px) {
  .app-workspace {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: 1rem;
  }
  .logo-area {
    justify-content: center;
  }
  .nav-tabs {
    justify-content: center;
    overflow-x: auto;
  }
  .status-indicator {
    align-self: center;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }
  .app-container {
    padding: 0.75rem;
    gap: 1rem;
  }
  .app-header {
    border-radius: 12px;
  }
  .nav-tabs {
    flex-direction: column;
    background: transparent;
    border: none;
    gap: 0.4rem;
    padding: 0;
  }
  .tab-btn {
    justify-content: center;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
  }
  .prompt-input-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .prompt-input-wrapper textarea {
    height: 120px !important;
  }
  .prompt-input-wrapper .btn-primary {
    padding: 0.75rem;
  }
  .output-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    text-align: center;
  }
  .actions-right {
    justify-content: center;
  }
  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }
}

/* ==========================================================================
   Overlay Studio Layout
   ========================================================================== */
.app-workspace.full-width {
  grid-template-columns: 1fr;
}
.app-workspace.full-width .config-sidebar {
  display: none;
}

.overlay-studio-panel {
  width: 100%;
}
.overlay-grid-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.overlay-controls-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.overlay-control-card {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.overlay-control-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

/* Background Thumbnails selection grid */
.overlay-gen-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: #020408;
  transition: all var(--transition-fast);
  position: relative;
}
.overlay-gen-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.overlay-gen-thumb:hover {
  transform: scale(1.04);
}
.overlay-gen-thumb.active {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(191, 90, 242, 0.4);
}

/* Mobile responsive for overlay grid */
@media (max-width: 768px) {
  .overlay-grid-layout {
    grid-template-columns: 1fr;
  }
}
