:root {
  color-scheme: light dark;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: 
    radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3), transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2), transparent 50%),
    linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  background-attachment: fixed;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.75rem 3rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.brand-mark {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-tagline {
  margin: 0;
  color: rgba(148, 163, 184, 0.9);
  font-size: 0.95rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.5rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(51, 65, 85, 0.6) 100%);
  backdrop-filter: blur(20px);
  box-shadow: 
    0 20px 40px -15px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-actions {
  display: flex;
  gap: 0.75rem;
}

.user-name {
  font-weight: 600;
  font-size: 1rem;
}

.user-role {
  color: rgba(148, 163, 184, 0.9);
  font-size: 0.9rem;
}

.user-status {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.85);
}

.ghost-button {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.ghost-button:hover {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.25) 0%, rgba(168, 85, 247, 0.25) 100%);
  color: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 10px 25px -10px rgba(96, 165, 250, 0.4);
}

.ghost-button:active {
  transform: translateY(0);
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 240px;
  padding: 2.5rem 2rem;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(18px);
}

.sidebar h2 {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.85);
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}

.sidebar a {
  color: rgba(226, 232, 240, 0.85);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  display: block;
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(96, 165, 250, 0.18);
  color: #f8fafc;
}

.sidebar a.disabled {
  color: rgba(148, 163, 184, 0.5);
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-user {
  padding: 1.5rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  margin-bottom: 1.5rem;
  display: none;
}

.sidebar-user-info {
  margin-bottom: 1rem;
}

.sidebar-user-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: rgba(248, 250, 252, 0.9);
  margin-bottom: 0.25rem;
}

.sidebar-user-email {
  display: block;
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.8);
}

.sidebar-button {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.sidebar-button:hover {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.25) 0%, rgba(168, 85, 247, 0.25) 100%);
  color: #f8fafc;
}

.content {
  flex: 1;
  padding: 3rem 3rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 900px;
  margin: 0 auto;
}

#generate-section {
  max-width: 600px;
  margin: 0 auto;
}

.panel {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.8) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 2.5rem;
  backdrop-filter: blur(20px);
  box-shadow: 
    0 32px 64px -12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

h1,
 h2 {
  margin-top: 0;
}

.lead {
  margin-bottom: 2rem;
  color: rgba(226, 232, 240, 0.85);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

fieldset {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  padding: 1.5rem;
}

legend {
  padding: 0 0.5rem;
  color: rgba(248, 250, 252, 0.9);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

select,
 textarea,
 input[type='file'] {
  box-sizing: border-box;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.6);
  color: inherit;
  font-size: 1rem;
}

textarea {
  resize: vertical;
}

.cta {
  border: none;
  border-radius: 999px;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 10px 30px -10px rgba(99, 102, 241, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 20px 40px -15px rgba(99, 102, 241, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.cta:hover::before {
  left: 100%;
}

.cta:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.results-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

#results dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.75rem 1.25rem;
  margin: 0;
}

#results dt {
  font-weight: 600;
  color: rgba(248, 250, 252, 0.9);
}

#results dd {
  margin: 0;
  font-family: 'IBM Plex Mono', 'SFMono-Regular', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(148, 163, 184, 0.9);
}

.image-gallery {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.image-gallery figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.image-gallery img {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 20px 45px -25px rgba(15, 23, 42, 0.8);
}

.image-gallery figcaption {
  font-size: 0.85rem;
  color: rgba(226, 232, 240, 0.7);
}

#toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(248, 250, 252, 0.18);
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  box-shadow: 0 25px 50px -20px rgba(15, 23, 42, 0.75);
}

.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  gap: 0.25rem;
}

.mobile-menu-toggle span {
  width: 24px;
  height: 2px;
  background: #e2e8f0;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}



@media (max-width: 1024px) {
  .app-header {
    padding: 1.5rem 2rem;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    left: 0;
  }

  .content {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 1rem 1.5rem;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .brand {
    flex: 1;
  }

  .brand-tagline {
    display: none;
  }

  .user-card {
    display: none;
  }

  .mobile-menu-toggle {
    order: -1;
  }

  .sidebar {
    padding: 2rem 1.5rem;
  }

  .sidebar-user {
    display: block;
  }

  .content {
    padding: 1.5rem 1rem 5rem;
  }

  .panel {
    padding: 1.5rem;
  }

  #generate-section {
    max-width: none;
  }

  .ghost-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .sample-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .sample-image {
    height: 80px;
  }

  #toast {
    bottom: 5rem;
    right: 1rem;
    left: 1rem;
  }

  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(20px);
    padding: 1rem;
    z-index: 999;
  }

  .mobile-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-around;
    gap: 1rem;
  }

  .mobile-nav a {
    color: rgba(226, 232, 240, 0.85);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 8px;
    text-align: center;
    min-width: 60px;
  }

  .mobile-nav a.active {
    background: rgba(96, 165, 250, 0.18);
    color: #f8fafc;
  }

  .mobile-nav a.disabled {
    color: rgba(148, 163, 184, 0.5);
    pointer-events: none;
  }
}

.image-placeholder {
  font-size: 0.9rem;
  color: rgba(148, 163, 184, 0.7);
}

.loading-message {
  text-align: center;
  color: rgba(148, 163, 184, 0.8);
  font-style: italic;
  padding: 2rem;
}

.history-item {
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(30, 41, 59, 0.3);
  backdrop-filter: blur(10px);
}

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

.history-header h3 {
  margin: 0;
  color: rgba(248, 250, 252, 0.9);
  font-size: 1.1rem;
}

.history-date {
  color: rgba(148, 163, 184, 0.7);
  font-size: 0.85rem;
}

.history-prompt {
  color: rgba(226, 232, 240, 0.8);
  line-height: 1.5;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.history-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.history-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history-image:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 1s ease-in-out infinite;
  margin-right: 8px;
}

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

.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.lightbox.show {
  display: flex;
}

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

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 1001;
}

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

#lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

.comparison-item {
  text-align: center;
}

.comparison-item h4 {
  margin: 0 0 1rem;
  color: rgba(248, 250, 252, 0.9);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comparison-item img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s ease;
}

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

@media (max-width: 768px) {
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.image-source-options {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-button {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(30, 41, 59, 0.5);
  color: rgba(226, 232, 240, 0.8);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.tab-button.active {
  background: rgba(96, 165, 250, 0.2);
  border-color: rgba(96, 165, 250, 0.5);
  color: #f8fafc;
}

.tab-button:hover {
  background: rgba(96, 165, 250, 0.15);
  color: #f8fafc;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.3);
}

.sample-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sample-image:hover {
  border-color: rgba(96, 165, 250, 0.5);
  transform: scale(1.05);
}

.sample-image.selected {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}
