:root {
  /* Apple 2026 / Glassmorphism Design System */
  --bg-color: #030712;
  --glass-bg: rgba(17, 24, 39, 0.45);
  --glass-bg-solid: rgba(11, 17, 33, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.12);
  --glass-blur: blur(40px);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  /* Vibrant Node Colors */
  --color-planner: #fbbf24; /* Amber */
  --color-planner-bg: rgba(245, 158, 11, 0.08);
  --color-tool: #38bdf8; /* Cyan/Light Blue */
  --color-tool-bg: rgba(56, 189, 248, 0.08);
  --color-finish: #34d399; /* Emerald */
  --color-finish-bg: rgba(52, 211, 153, 0.08);

  --accent-primary: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --accent-danger: #ef4444;
  
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-y: auto; /* Natural document scroll */
  -webkit-font-smoothing: antialiased;
}

/* --- Ambient Orbs (Background) - Fixed position for parallax effect --- */
.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.5;
  animation: floatOrb 25s infinite alternate ease-in-out;
  pointer-events: none;
}
.orb-1 {
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(59,130,246,0.35) 0%, transparent 70%);
  top: -200px; left: -150px;
}
.orb-2 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(139,92,246,0.25) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  animation-delay: -5s;
}
.orb-3 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(16,185,129,0.15) 0%, transparent 70%);
  top: 30%; left: 30%;
  animation-delay: -10s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
  100% { transform: translate(-40px, 90px) scale(0.9); }
}

/* --- App Layout --- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px;
  gap: 24px;
  max-width: 1920px;
  margin: 0 auto;
}

.glass-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-icon {
  width: 32px; height: 32px;
  color: var(--accent-primary);
}
.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.3s ease;
}
.status-indicator.active .status-dot {
  background: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: pulse 1.5s infinite;
}
.status-indicator.error .status-dot {
  background: var(--accent-danger);
  box-shadow: 0 0 10px var(--accent-danger);
}
.status-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* --- Split Workspaces --- */
.top-workspace {
  display: grid;
  grid-template-columns: 450px 1fr;
  gap: 24px;
  align-items: start; /* Let panels grow to their natural height */
}

/* --- Left Panel: Controls --- */
.control-section {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.search-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glass-input {
  width: 100%;
  height: 140px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 18px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  resize: vertical;
  outline: none;
  transition: all 0.3s var(--ease-smooth);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}
.glass-input:focus {
  border-color: rgba(59, 130, 246, 0.6);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-toolbar {
  display: flex;
  gap: 12px;
}

button {
  cursor: pointer;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s var(--ease-spring);
}

.btn-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(1);
}
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary, .btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.btn-secondary:hover, .btn-icon:hover {
  background: rgba(255,255,255,0.15);
}
.btn-secondary svg, .btn-icon svg { width: 20px; height: 20px; }

.btn-small {
  padding: 8px 12px;
  font-size: 0.85rem;
  gap: 6px;
  border-radius: 8px;
}
.btn-small svg { width: 16px; height: 16px; }

.samples-wrapper {
  margin-top: auto;
  padding-top: 16px;
}
.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 16px;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.sample-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s var(--ease-smooth);
}
.sample-chip:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text-main);
  border-color: var(--glass-highlight);
  transform: translateY(-1px);
}

/* --- Top Right Panel: Final Results --- */
.results-panel {
  position: relative;
  display: flex;
  flex-direction: column;
}

.results-content {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.answer-card {
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.15), rgba(0,0,0,0.3));
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius-lg);
  padding: 28px;
  animation: scaleIn 0.5s var(--ease-spring);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}
.icon-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-title svg { width: 24px; height: 24px; color: var(--accent-primary); }
.icon-title h2 { font-size: 1.3rem; font-weight: 600; margin: 0;}

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

.answer-body {
  font-size: 1.1rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.95);
}

.result-groups {
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.tool-group {
  animation: slideUpFade 0.6s var(--ease-smooth) forwards;
}
.tool-group-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
}
.tool-group-header h3 {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-main);
  text-transform: capitalize;
}
.tool-count {
  background: rgba(255,255,255,0.1);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.movie-card {
  display: flex;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s var(--ease-spring);
  height: 140px;
}
.movie-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 16px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
  background: rgba(255,255,255,0.08);
}

.movie-poster {
  width: 95px;
  flex-shrink: 0;
  background: #111;
  position: relative;
  overflow: hidden;
}
.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.movie-card:hover .movie-poster img { transform: scale(1.05); }

.poster-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(45deg, #1e293b, #0f172a);
  font-size: 1.8rem;
  font-weight: 700;
  color: rgba(255,255,255,0.2);
}

.movie-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.movie-info h4 {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.movie-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.movie-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.genre-tag {
  font-size: 0.7rem;
  padding: 3px 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #cbd5e1;
}

.generic-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.generic-item {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}
.generic-item strong { font-size: 1rem; color: var(--text-main); }
.generic-item span { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; line-height: 1.4;}

/* --- Bottom Panel: Trace Console --- */
.trace-panel {
  display: flex;
  flex-direction: column;
  margin-top: 16px;
}
.trace-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(0,0,0,0.4);
  border-bottom: 1px solid var(--glass-border);
}
.trace-header-bar h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-main);
}
.badge {
  background: rgba(255,255,255,0.15);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

.trace-content-area {
  padding: 32px;
  display: flex;
  flex-direction: column;
}

.trace-timeline {
  display: flex;
  flex-direction: column;
  gap: 32px; /* Expansive gaps between steps */
}

/* Verbose Trace Cards */
.trace-card {
  display: grid;
  grid-template-columns: 320px 1fr 1fr;
  gap: 24px;
  background: var(--glass-bg-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
  animation: slideUpFade 0.4s var(--ease-spring) forwards;
  align-items: start; /* Let columns dictate their own height naturally */
}

/* Node Types Styling */
.trace-card.type-decide {
  border-left: 6px solid var(--color-planner);
  background: linear-gradient(90deg, var(--color-planner-bg) 0%, rgba(11, 17, 33, 0.8) 15%, rgba(11, 17, 33, 0.6) 100%);
}
.trace-card.type-tool {
  border-left: 6px solid var(--color-tool);
  background: linear-gradient(90deg, var(--color-tool-bg) 0%, rgba(11, 17, 33, 0.8) 15%, rgba(11, 17, 33, 0.6) 100%);
}
.trace-card.type-finish {
  border-left: 6px solid var(--color-finish);
  background: linear-gradient(90deg, var(--color-finish-bg) 0%, rgba(11, 17, 33, 0.8) 15%, rgba(11, 17, 33, 0.6) 100%);
}

/* Trace Column 1: Meta/Story */
.trace-meta {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 24px;
  border-right: 1px solid rgba(255,255,255,0.05);
  height: 100%;
}
.trace-meta-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-pill {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  letter-spacing: 0.05em;
  color: #fff;
}
.node-type {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.type-decide .node-type { color: var(--color-planner); }
.type-tool .node-type { color: var(--color-tool); }
.type-finish .node-type { color: var(--color-finish); }

.trace-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}
.trace-action-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #cbd5e1;
  background: rgba(0,0,0,0.4);
  padding: 6px 12px;
  border-radius: 6px;
  align-self: flex-start;
  word-break: break-all;
  border: 1px solid rgba(255,255,255,0.1);
}
.trace-story {
  margin-top: auto;
  font-size: 1.05rem;
  font-style: italic;
  color: rgba(255,255,255,0.9);
  border-left: 3px solid rgba(255,255,255,0.3);
  padding-left: 16px;
  line-height: 1.5;
  padding-top: 4px;
  padding-bottom: 4px;
}
.type-decide .trace-story { border-color: var(--color-planner); }
.type-tool .trace-story { border-color: var(--color-tool); }
.type-finish .trace-story { border-color: var(--color-finish); }

/* Trace Columns 2 & 3: I/O */
.trace-io-block {
  display: flex;
  flex-direction: column;
  background: rgba(4, 8, 16, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.io-header {
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid var(--glass-border);
}
.io-content {
  margin: 0;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #a6accd;
  /* Expansive blocks: no max-height, no overflow-y: hidden. Let it grow! */
  overflow-x: auto; /* Keep horizontal scroll for extremely long unbreakable strings */
  white-space: pre; 
}

/* Syntax Highlighting */
.json-key { color: #82aaff; font-weight: 500; }
.json-string { color: #c3e88d; }
.json-number { color: #f78c6c; }
.json-boolean { color: #ffcb6b; font-style: italic; }

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.empty-state p { font-size: 1.05rem; margin-top: 16px; max-width: 400px; line-height: 1.5;}
.large-empty svg { width: 80px; height: 80px; opacity: 0.4;}
.large-empty h3 { color: var(--text-main); margin-bottom: 12px; font-weight: 600; font-size: 1.4rem; }

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s ease;
  border-radius: var(--radius-lg);
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }

.loader-rings {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 32px;
}
.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}
.ring:nth-child(1) { border-top-color: var(--accent-primary); animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite; }
.ring:nth-child(2) { inset: 12px; border-right-color: #8b5cf6; animation: spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse; }
.ring:nth-child(3) { inset: 24px; border-bottom-color: #10b981; animation: spin 1.8s cubic-bezier(0.5, 0, 0.5, 1) infinite; }

.loading-text {
  font-size: 1.4rem;
  font-weight: 600;
  background: linear-gradient(90deg, #fff, #94a3b8, #fff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2s linear infinite;
}
.loading-subtext { color: var(--text-muted); font-size: 1rem; margin-top: 12px; }

/* Glass Modal */
.glass-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.glass-modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.glass-modal-content {
  background: var(--glass-bg-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1200px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: translateY(0) scale(1);
  transition: transform 0.3s var(--ease-spring);
}
.glass-modal.hidden .glass-modal-content {
  transform: translateY(20px) scale(0.98);
}
.glass-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.2);
}
.glass-modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}
.glass-modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}
.glass-modal-body pre {
  margin: 0;
}

/* Custom Scrollbar for whole page & horizontal areas */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Animations */
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(1.2); } 100% { opacity: 1; transform: scale(1); } }
@keyframes shimmer { to { background-position: 200% center; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.hidden { display: none !important; }

/* Responsive Adjustments */
@media (max-width: 1400px) {
  .top-workspace {
    grid-template-columns: 400px 1fr;
  }
  .trace-card {
    grid-template-columns: 260px 1fr 1fr;
  }
}

@media (max-width: 1100px) {
  .top-workspace {
    grid-template-columns: 1fr; /* Stack controls and results */
  }
  .trace-card {
    grid-template-columns: 1fr; /* Stack Meta, Input, Output vertically */
  }
  .trace-meta {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-right: 0;
    padding-bottom: 24px;
    margin-bottom: 8px;
  }
  .trace-story {
    margin-top: 16px;
  }
}

@media (max-width: 600px) {
  .app-container { padding: 12px; gap: 16px; }
  .glass-nav { padding: 12px 16px; flex-direction: column; gap: 16px; align-items: flex-start;}
  .trace-header-bar { padding: 12px 16px; }
  .trace-content-area { padding: 16px; }
  .trace-timeline { gap: 16px; }
  .trace-card { padding: 16px; gap: 16px; }
  .io-content { font-size: 0.75rem; padding: 12px; }
}
