:root {
  color-scheme: dark;
  --nova-bg: #0f131b;
  --nova-surface: #171d28;
  --nova-surface-alt: #1f2735;
  --nova-border: #273044;
  --nova-accent: #7c5cff;
  --nova-accent-soft: rgba(124, 92, 255, 0.24);
  --nova-text: #e6e9f5;
  --nova-text-muted: #9aa6c4;
  --nova-danger: #ff6b81;
}

#nova-ai-root {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--nova-text);
  background: radial-gradient(circle at top, rgba(124, 92, 255, 0.12), transparent 60%), var(--nova-bg);
  padding: 2.5rem 1.5rem;
}

#nova-ai-root .nova-shell {
  max-width: 960px;
  margin: 0 auto;
  background: var(--nova-surface);
  border-radius: 24px;
  border: 1px solid var(--nova-border);
  box-shadow: 0 28px 80px rgba(12, 14, 22, 0.45);
  overflow: hidden;
}

.nova-header {
  padding: 2.2rem 2.4rem 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.15), transparent);
}

.nova-title {
  font-size: 1.8rem;
  font-weight: 700;
}

.nova-subtitle {
  margin-top: 0.45rem;
  color: var(--nova-text-muted);
  font-size: 0.95rem;
}

.nova-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.8rem 0.9rem;
  background: var(--nova-surface);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nova-tabs button {
  flex: 1 1 0;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--nova-text-muted);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nova-tabs button:hover,
.nova-tabs button:focus-visible {
  background: rgba(124, 92, 255, 0.12);
  color: var(--nova-text);
  outline: none;
}

.nova-tabs button.active {
  background: var(--nova-accent);
  color: #fff;
  box-shadow: 0 12px 30px rgba(124, 92, 255, 0.45);
  transform: translateY(-2px);
}

.nova-panel {
  display: none;
  padding: 1.8rem 2.4rem 2.4rem;
  background: var(--nova-surface);
}

.nova-panel.active {
  display: block;
  animation: fadeIn 220ms ease;
}

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

.form {
  display: grid;
  gap: 1.2rem;
}

.form-row {
  display: grid;
  gap: 0.45rem;
}

.form-row label {
  font-weight: 600;
  color: var(--nova-text-muted);
}

.form-row textarea,
.form-row input,
.form-row select {
  appearance: none;
  background: var(--nova-surface-alt);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  color: var(--nova-text);
  font-size: 0.95rem;
  transition: border 160ms ease, box-shadow 160ms ease;
}

.form-row textarea:focus,
.form-row input:focus,
.form-row select:focus {
  border-color: var(--nova-accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
  outline: none;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 0.75rem 1.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--nova-surface-alt);
  color: var(--nova-text);
  transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
}

.btn:hover,
.btn:focus-visible {
  background: rgba(124, 92, 255, 0.16);
  outline: none;
}

.btn.primary {
  background: linear-gradient(135deg, #8e6bff, #5d3bff);
  box-shadow: 0 16px 30px rgba(112, 98, 255, 0.4);
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: linear-gradient(135deg, #9c77ff, #6f49ff);
}

.btn.secondary {
  background: rgba(124, 92, 255, 0.12);
  color: #d7dcff;
  box-shadow: 0 12px 24px rgba(124, 92, 255, 0.22);
}

.btn.secondary:hover,
.btn.secondary:focus-visible {
  background: rgba(124, 92, 255, 0.22);
}

.chat-transcript {
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
  background: var(--nova-surface-alt);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 1rem;
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  max-width: 78%;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: 0.015em;
  box-shadow: 0 8px 18px rgba(5, 8, 18, 0.32);
  animation: bubbleIn 180ms ease;
}

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

.bubble.user {
  justify-self: end;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(124, 92, 255, 0.15));
  border: 1px solid rgba(124, 92, 255, 0.35);
}

.bubble.assistant {
  justify-self: start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bubble.streaming::after {
  content: '▌';
  display: inline-block;
  margin-left: 0.25rem;
  animation: blink 900ms steps(2, start) infinite;
}

@keyframes blink {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.bubble.error {
  border-color: rgba(255, 107, 129, 0.4);
  background: rgba(255, 107, 129, 0.15);
  color: #ffd9e0;
}

.bubble.warning {
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.12);
  color: #fde68a;
}

.vision-result,
.image-result {
  margin-top: 1.6rem;
  background: var(--nova-surface-alt);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1.2rem 1.4rem;
  min-height: 120px;
  font-size: 0.98rem;
  color: var(--nova-text-muted);
  line-height: 1.6;
}

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

.image-card {
  margin: 0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(8, 10, 20, 0.4);
}

.image-card img {
  display: block;
  width: 100%;
  height: auto;
}

.image-card .download-link {
  display: block;
  width: calc(100% - 1.5rem);
  margin: 0.75rem;
  text-align: center;
}

.image-card .download-link:active {
  transform: translateY(0);
  background: rgba(124, 92, 255, 0.3);
}

.loader {
  padding: 1rem;
  text-align: center;
  color: var(--nova-text-muted);
}

.is-loading {
  position: relative;
}

.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 22, 0.55);
  backdrop-filter: blur(2px);
  border-radius: 24px;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    opacity: 0.25;
  }
}

@media (max-width: 768px) {
  #nova-ai-root {
    padding: 1.5rem 1rem;
  }

  #nova-ai-root .nova-shell {
    border-radius: 20px;
  }

  .nova-panel {
    padding: 1.5rem;
  }

  .chat-transcript {
    max-height: 360px;
  }

  .bubble {
    max-width: 88%;
  }
}

.field-hint {
  font-size: 0.8rem;
  color: var(--nova-text-muted);
  margin-top: -0.3rem;
}

.field-note {
  font-size: 0.8rem;
  color: var(--nova-text-muted);
  margin-top: 0.4rem;
}

.nova-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  background: #333;
  color: white;
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  z-index: 10000;
  animation: slideIn 0.3s ease;
}

.nova-notification.success {
  background: #28a745;
}

.nova-notification.warning {
  background: #ffc107;
  color: #333;
}

.nova-notification.error {
  background: #dc3545;
}

.nova-notification.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.bubble.error {
  background-color: #fee;
  border-left: 4px solid #dc3545;
}
