:root {
  --bg-dark: #080c10;
  --panel-bg: #0e151d;
  --panel-border: #1a2533;
  --card-bg: #141e2b;
  --card-hover: #1c2b3d;
  --primary-emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Space Grotesk', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary-emerald);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-family: var(--font-mono);
}

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

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--primary-emerald);
  font-family: var(--font-mono);
  background: rgba(16, 185, 129, 0.08);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary-emerald);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.api-key-btn {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.api-key-btn:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
}

/* Main Container */
.main-container {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Persona Section */
.persona-section {
  margin-bottom: 1.5rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.section-title-row h2 {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-heading);
}

.section-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--panel-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
}

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

.persona-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.persona-card:hover {
  background: var(--card-bg);
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
}

.persona-card.active {
  background: var(--card-bg);
  border-color: var(--primary-emerald);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
}

.persona-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.persona-avatar {
  font-size: 1.8rem;
}

.persona-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.persona-origin {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.persona-condition {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 0.6rem;
}

.persona-flavor-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.persona-flavor-tags span {
  font-size: 0.7rem;
  background: var(--bg-dark);
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.25rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h3 {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-heading);
}

.badge-accent {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-weight: 600;
}

/* Radar Canvas */
.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 0;
}

.flavor-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.user-dot { background-color: #06b6d4; }
.qloo-dot { background-color: #10b981; }

/* Sliders */
.tuning-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--panel-border);
}

.tuning-section h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.65rem;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-main);
}

.slider-row label span {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.slider {
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--card-bg);
  border-radius: 3px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-emerald);
  cursor: pointer;
  box-shadow: 0 0 10px var(--emerald-glow);
}

/* Recommendations Panel */
.btn-secondary {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--text-muted);
}

.agent-synthesis-card {
  display: flex;
  gap: 0.75rem;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.agent-icon {
  font-size: 1.4rem;
}

.agent-text {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.4;
}

/* Top Match Card */
.top-match-card {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}

.top-match-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #06b6d4);
}

.match-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--primary-emerald);
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.entity-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.entity-title-row h4 {
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-heading);
}

.entity-category {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.composite-score {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--primary-emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.nutrient-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .nutrient-chips {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chip {
  background: var(--bg-dark);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chip-label {
  font-size: 0.7rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  font-weight: 600;
}

.chip-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.entity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.entity-tags span {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  background: rgba(6, 182, 212, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Adaptations List */
.adaptations-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.15rem;
}

.adaptations-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.adapt-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.adaptations-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.adapt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
}

.orig-food {
  font-weight: 600;
  color: #f87171;
  text-decoration: line-through;
  flex: 1;
}

.arrow-icon {
  color: var(--text-muted);
  margin: 0 0.75rem;
}

.sub-food {
  font-weight: 600;
  color: var(--primary-emerald);
  flex: 2;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  width: 90%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-heading);
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.modal-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-hint code {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.text-input {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}

.text-input:focus {
  border-color: var(--primary-emerald);
}

.radio-toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 0 15px var(--emerald-glow);
}

.btn-primary:hover {
  opacity: 0.95;
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 1rem 2rem;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}
