/* ==========================================================================
   VISION STUDIO - MODERN DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #07090e;
  --bg-secondary: #0e131f;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 35, 54, 0.85);
  --bg-input: rgba(10, 14, 24, 0.8);
  --bg-glass: rgba(15, 22, 36, 0.65);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.35);
  --border-active: rgba(99, 102, 241, 0.6);

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #030712;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.25);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Background Ambient Lighting */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.05) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  right: 15%;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, rgba(6, 182, 212, 0.04) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */

.top-navbar {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(14, 19, 31, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

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

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
}

.brand-title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title span {
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

/* Status Pill */
.ollama-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.ollama-status-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
  animation: pulse-dot 2s infinite;
}

.status-dot.offline {
  background: var(--accent-rose);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.8);
}

.status-dot.warning {
  background: var(--accent-amber);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.status-label {
  font-weight: 500;
  color: var(--text-primary);
}

.status-latency {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Model Selector */
.model-selector-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 6px 4px 10px;
  gap: 6px;
  transition: var(--transition-fast);
}

.model-selector-wrapper:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.select-icon {
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
}

.model-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 8px 4px 2px;
  outline: none;
  cursor: pointer;
  min-width: 150px;
}

.model-select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

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

.nav-action-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.nav-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.history-count-badge {
  background: var(--accent-indigo);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   MAIN SPLIT WORKSPACE
   ========================================================================== */

.main-workspace {
  display: grid;
  grid-template-columns: 460px 1fr;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 64px);
  gap: 16px;
  padding: 16px 20px;
}

@media (max-width: 1024px) {
  .main-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    overflow-y: auto;
    height: auto;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-normal);
}

.panel:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.panel-header {
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  color: #fff;
}

.panel-title svg {
  color: var(--accent-cyan);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-body::-webkit-scrollbar {
  width: 6px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   LEFT PANEL (INPUTS)
   ========================================================================== */

/* Sample Images Drawer */
.sample-drawer {
  background: rgba(10, 14, 25, 0.95);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  animation: slideDown 0.2s ease-out;
}

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

.sample-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

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

.sample-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.sample-card:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.sample-card img {
  width: 100%;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.sample-card span {
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
}

/* Upload Container */
.upload-container {
  position: relative;
}

.file-input-hidden {
  display: none;
}

.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(10, 14, 24, 0.5);
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.drop-zone:hover {
  border-color: var(--accent-blue);
  background: rgba(59, 130, 246, 0.04);
}

.drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px;
  gap: 8px;
}

.upload-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  transition: transform var(--transition-fast);
}

.drop-zone:hover .upload-icon-wrapper {
  transform: translateY(-2px) scale(1.05);
}

.drop-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.highlight-text {
  color: var(--accent-cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drop-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
}

kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-primary);
}

/* Image Preview */
.preview-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.preview-img-container {
  position: relative;
  width: 100%;
  max-height: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-img-container img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.preview-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: var(--transition-fast);
}

.preview-img-container:hover .preview-overlay {
  opacity: 1;
}

.preview-action-btn {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-color);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preview-action-btn:hover {
  background: rgba(59, 130, 246, 0.9);
}

.preview-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.9);
}

.image-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.meta-separator {
  color: var(--text-muted);
}

.change-img-link {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.change-img-link:hover {
  text-decoration: underline;
}

/* Presets */
.preset-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.hint-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-radius: var(--radius-full);
}

.preset-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  padding: 5px 11px;
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.preset-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.preset-pill.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--accent-blue);
  color: #93c5fd;
  font-weight: 600;
}

/* Prompt Input */
.prompt-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shortcut-tip {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.prompt-input-wrapper {
  position: relative;
}

textarea#promptInput {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.45;
  padding: 10px 36px 10px 12px;
  resize: vertical;
  min-height: 90px;
  max-height: 250px;
  outline: none;
  transition: var(--transition-fast);
}

textarea#promptInput:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.clear-prompt-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

.clear-prompt-btn:hover {
  color: var(--text-primary);
}

/* Parameters Accordion */
.params-accordion {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  overflow: hidden;
}

.params-toggle-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition-fast);
}

.params-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

.params-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chevron-icon {
  transition: transform var(--transition-fast);
}

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

.params-content {
  padding: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(8, 11, 20, 0.7);
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.param-group label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.param-group input[type="text"],
.param-group input[type="number"] {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  outline: none;
}

.param-group input[type="text"]:focus,
.param-group input[type="number"]:focus {
  border-color: var(--accent-blue);
}

.param-row {
  display: flex;
  gap: 14px;
}

.param-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-val {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-cyan);
}

input[type="range"] {
  accent-color: var(--accent-blue);
  cursor: pointer;
}

/* Switch */
.switch-group {
  align-items: flex-start;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.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.15);
  transition: .3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
}

input:checked + .slider {
  background-color: var(--accent-blue);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Panel Footer Actions */
.panel-footer {
  height: 60px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-color);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
  outline: none;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #6d28d9);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 1);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   RIGHT PANEL (OUTPUT & TELEMETRY)
   ========================================================================== */

.output-panel {
  display: flex;
  flex-direction: column;
}

.status-indicator-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-indicator-pill.idle {
  background: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
}

.status-indicator-pill.generating {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  animation: pulse-dot 1.5s infinite;
}

.status-indicator-pill.completed {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-indicator-pill.error {
  background: rgba(244, 63, 94, 0.2);
  color: #f87171;
}

.output-tab-group {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

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

/* Telemetry Bar */
.telemetry-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
}

.stat-val.highlight {
  color: var(--accent-cyan);
}

/* Output Toolbar */
.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--border-color);
}

.model-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #c084fc;
  background: rgba(139, 92, 246, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

/* Output Body Area */
.output-body {
  position: relative;
  background: rgba(9, 12, 20, 0.6);
  flex: 1;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  gap: 12px;
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  margin-bottom: 6px;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.empty-state p {
  max-width: 380px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.empty-features {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.feat-item {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

/* Markdown Stream Rendering */
.markdown-output {
  font-size: 0.92rem;
  line-height: 1.7;
  color: #e5e7eb;
  padding: 10px;
  user-select: text;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3,
.markdown-output h4 {
  color: #fff;
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.markdown-output h1 { font-size: 1.4rem; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.markdown-output h2 { font-size: 1.2rem; }
.markdown-output h3 { font-size: 1.05rem; }

.markdown-output p {
  margin-bottom: 12px;
}

.markdown-output ul, .markdown-output ol {
  margin-left: 20px;
  margin-bottom: 14px;
}

.markdown-output li {
  margin-bottom: 4px;
}

.markdown-output code:not(pre code) {
  background: rgba(255, 255, 255, 0.08);
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.84em;
  padding: 2px 6px;
  border-radius: 4px;
}

.markdown-output pre {
  background: #0f1422;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  overflow-x: auto;
  margin: 14px 0;
  position: relative;
}

.markdown-output pre code {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.5;
}

.markdown-output blockquote {
  border-left: 3px solid var(--accent-blue);
  padding-left: 14px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 12px 0;
}

.markdown-output table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.85rem;
}

.markdown-output th, .markdown-output td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.markdown-output th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
  color: #fff;
}

/* Typing cursor */
.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 17px;
  background: var(--accent-cyan);
  vertical-align: text-bottom;
  margin-left: 3px;
  border-radius: 1px;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Raw Output */
textarea.raw-output {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  padding: 10px;
}

/* Error & Warning Card in Output */
.error-card-box {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 10px 0;
}

.error-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fda4af;
  margin-bottom: 8px;
}

.error-card-message {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(244, 63, 94, 0.2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #fecdd3;
  word-break: break-word;
  margin-bottom: 12px;
}

.error-card-help {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.error-card-help ul {
  margin-left: 18px;
  margin-top: 6px;
}

.error-card-help code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  color: #38bdf8;
}

/* ==========================================================================
   HISTORY DRAWER & MODALS
   ========================================================================== */

.history-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: 380px;
  background: rgba(14, 19, 31, 0.95);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.history-drawer.open {
  transform: translateX(0);
}

.history-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.text-btn.danger {
  color: var(--accent-rose);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.history-item-card:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--accent-blue);
  transform: translateX(-2px);
}

.history-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: #000;
}

.history-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-prompt-preview {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-stats-preview {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Lightbox Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

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

.modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

.modal-close-btn {
  position: absolute;
  top: -36px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s ease-out;
}

.toast.success { border-color: rgba(16, 185, 129, 0.5); }
.toast.error { border-color: rgba(244, 63, 94, 0.5); }
.toast.info { border-color: rgba(59, 130, 246, 0.5); }

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

/* Debug Inspector Styles */
.debug-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.debug-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.debug-actions {
  display: flex;
  gap: 6px;
}

.debug-pre {
  flex: 1;
  background: #090c14;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-all;
}

.debug-pre code {
  color: inherit;
}

/* Computing status banner */
.computing-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #93c5fd;
  font-weight: 600;
  font-size: 0.84rem;
  margin-bottom: 12px;
  animation: pulse-dot 2s infinite;
}

/* Thinking / Reasoning Accordion Box */
.thinking-box {
  background: rgba(139, 92, 246, 0.07);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  transition: var(--transition-fast);
}

.thinking-box[open] {
  border-color: rgba(139, 92, 246, 0.45);
}

.thinking-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(139, 92, 246, 0.12);
  font-size: 0.8rem;
  font-weight: 600;
  color: #c084fc;
  cursor: pointer;
  user-select: none;
}

.thinking-summary:hover {
  background: rgba(139, 92, 246, 0.18);
}

.thinking-content {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: #d8b4fe;
  background: rgba(0, 0, 0, 0.25);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid rgba(139, 92, 246, 0.15);
}



