/* ── Bhutan National Soil Intelligence Portal ── */
/* Spy-movie green aesthetic — matches SoilScope landing + app */

:root {
  --bg-deep: #060d06;
  --bg-panel: rgba(10, 18, 10, 0.88);
  --border: rgba(76, 175, 80, 0.15);
  --border-hover: rgba(76, 175, 80, 0.30);
  --accent: #4caf50;
  --accent-dim: #388e3c;
  --accent-green: #4caf50;
  --text: #e8ede8;
  --text-dim: #9aaa9a;
  --text-label: #6a8a6a;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", monospace;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

#cesiumContainer {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── Top bar ── */
#topBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 100;
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-brand img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.top-brand h1 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.top-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

/* .layer-pills replaced by .layer-groups */

.layer-pill {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.layer-pill:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.layer-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(76, 175, 80, 0.08);
}

/* ── Overlay Toggles ── */
.overlay-toggles {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.overlay-toggle {
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.overlay-toggle:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text);
}

.overlay-toggle .overlay-icon {
  font-size: 12px;
  line-height: 1;
}

/* Weather = blue */
.overlay-toggle[data-overlay="weather"].active {
  border-color: #64b5f6;
  color: #64b5f6;
  background: rgba(100, 181, 246, 0.1);
  box-shadow: 0 0 8px rgba(100, 181, 246, 0.15);
}

.overlay-toggle[data-overlay="weather"].active .overlay-icon { color: #64b5f6; }

/* ── Layer Group Dropdowns ── */
.layer-groups {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.layer-group {
  position: relative;
}

.layer-group-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.layer-group-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.layer-group-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(76, 175, 80, 0.08);
}

.group-icon { font-size: 10px; line-height: 1; }
.group-arrow { font-size: 8px; opacity: 0.6; transition: transform 0.2s; }
.layer-group.open .group-arrow { transform: rotate(180deg); }

.layer-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 150px;
  padding: 6px;
  background: rgba(10, 18, 10, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  z-index: 110;
  display: none;
  flex-direction: column;
  gap: 3px;
}

.layer-group.open .layer-dropdown { display: flex; }

.layer-dropdown .layer-pill {
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: 4px;
}

/* ── Metric bar (bottom) ── */
#metricBar {
  position: fixed;
  bottom: 12px; left: 16px; right: 16px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(76, 175, 80, 0.15);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 100;
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  text-align: center;
  gap: 2px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-label);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-shadow: 0 0 12px rgba(76, 175, 80, 0.15);
}

/* ── District panel (left) ── */
#districtPanel {
  position: fixed;
  top: 60px;
  left: 12px;
  bottom: 76px;
  width: 256px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  overflow-y: auto;
  z-index: 90;
  padding: 12px 0;
}

#districtPanel::-webkit-scrollbar { width: 4px; }
#districtPanel::-webkit-scrollbar-track { background: transparent; }
#districtPanel::-webkit-scrollbar-thumb { background: rgba(76, 175, 80, 0.2); border-radius: 2px; }

#districtPanel {
  transition: width 0.3s ease, padding 0.3s ease;
}
#districtPanel.collapsed {
  width: 36px;
  padding: 8px 0 0;
  overflow: hidden;
}
#districtPanel.collapsed #districtList { display: none; }
#districtPanel.collapsed .panel-title span { display: none; }
#districtPanel.collapsed .panel-title {
  justify-content: center;
  border-bottom: none;
  padding: 4px 0;
}
#districtPanel.collapsed #districtToggle {
  transform: rotate(180deg);
  margin-left: 0;
}
#districtToggle {
  transition: transform 0.3s ease;
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 0 14px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}

.dzongkhag-row {
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 2px solid transparent;
}

.dzongkhag-row:hover { background: rgba(76, 175, 80, 0.04); }
.dzongkhag-row.expanded { border-left-color: var(--accent); background: rgba(76, 175, 80, 0.04); }

.dzongkhag-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dzongkhag-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.gewog-list {
  display: none;
  padding: 4px 0 4px 12px;
}

.dzongkhag-row.expanded .gewog-list { display: block; }

.gewog-item {
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gewog-item:hover { color: var(--text); background: rgba(76, 175, 80, 0.06); }
.gewog-item.active { color: var(--accent); background: rgba(76, 175, 80, 0.08); }

.gewog-badge {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
}

.gewog-badge.no-data { background: var(--text-label); }

/* ── Research panel (right) ── */
#researchPanel {
  position: fixed;
  top: 60px;
  right: 12px;
  bottom: 76px;
  width: 340px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 90;
  display: none;
  flex-direction: column;
}

#researchPanel.visible { display: flex; }

.research-header {
  padding: 12px 14px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.research-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.research-subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.research-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.research-close:hover { color: var(--text); }

.research-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.research-tab {
  flex: 1;
  padding: 8px 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.research-tab:hover { color: var(--text); }
.research-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.research-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}

.research-body::-webkit-scrollbar { width: 4px; }
.research-body::-webkit-scrollbar-thumb { background: rgba(76, 175, 80, 0.2); border-radius: 2px; }

.research-body h1, .research-body h2, .research-body h3 {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0 6px;
}

.research-body p { margin-bottom: 8px; }
.research-body ul { padding-left: 16px; margin-bottom: 8px; }
.research-body strong { color: var(--text); }
.research-body a { color: var(--accent-dim); text-decoration: none; }
.research-body a:hover { color: var(--accent); text-decoration: underline; }

.research-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-label);
  font-size: 12px;
}

/* ── Chat (bottom of research panel) ── */
.research-chat {
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.research-chat input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.research-chat input:focus { border-color: var(--border-hover); }
.research-chat input::placeholder { color: var(--text-label); }

.research-chat button {
  padding: 7px 14px;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  background: rgba(76, 175, 80, 0.1);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.research-chat button:hover { background: rgba(76, 175, 80, 0.2); }

/* ── Soil probe (floating card) ── */
#soilProbe {
  position: fixed;
  display: none;
  width: 220px;
  padding: 10px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  z-index: 95;
  pointer-events: none;
}

#soilProbe.visible { display: block; }

.probe-layer {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 4px;
}

.probe-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
}

.probe-unit {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 4px;
}

.probe-coords {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-label);
  margin-top: 4px;
}

/* ── HUD overlay ── */
.bhutan-hud {
  position: fixed;
  bottom: 60px;
  right: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-label);
  z-index: 80;
  pointer-events: none;
  text-align: right;
}

/* ── Welcome overlay ── */
#welcomeOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(6, 13, 6, 0.85);
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

#welcomeOverlay.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* ── Living background layers (landing page palette) ── */
.welcome-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.welcome-bg__layer {
  position: absolute;
  width: 220%;
  height: 220%;
  will-change: transform;
}

.welcome-bg__layer--1 {
  background: radial-gradient(ellipse 70% 55% at 25% 35%, rgba(20,100,40,0.65), rgba(15,70,30,0.3), transparent);
  animation: drift1 45s ease-in-out infinite;
}

.welcome-bg__layer--2 {
  background: radial-gradient(ellipse 55% 70% at 75% 65%, rgba(141,110,85,0.45), rgba(100,75,55,0.2), transparent);
  animation: drift2 55s ease-in-out infinite;
}

.welcome-bg__layer--3 {
  background: radial-gradient(ellipse 45% 45% at 50% 45%, rgba(76,175,80,0.35), rgba(56,142,60,0.15), transparent);
  animation: bg-breathe 16s ease-in-out infinite;
}

.welcome-bg__layer--4 {
  background: radial-gradient(ellipse 40% 50% at 60% 30%, rgba(0,105,92,0.3), rgba(0,77,64,0.1), transparent);
  animation: drift3 60s ease-in-out infinite;
}

.welcome-bg__layer--5 {
  background: radial-gradient(ellipse 50% 35% at 40% 80%, rgba(160,120,60,0.25), rgba(120,85,40,0.1), transparent);
  animation: drift4 70s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(4%, -2%) scale(1.04); }
  50% { transform: translate(2%, 3%) scale(1.02); }
  75% { transform: translate(-3%, 1%) scale(0.97); }
}

@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  33% { transform: translate(-5%, 3%) rotate(2deg) scale(1.03); }
  66% { transform: translate(3%, -2%) rotate(-1deg) scale(0.98); }
}

@keyframes bg-breathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.8; }
  50% { transform: translate(-6%, 4%) scale(1.06); opacity: 1; }
}

@keyframes drift4 {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  40% { transform: translate(3%, -3%) scale(1.05); opacity: 1; }
  70% { transform: translate(-2%, 2%) scale(0.98); opacity: 0.7; }
}

/* ── Organic Particles Canvas ── */
#welcomeOverlay .organic-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ── Grain Texture ── */
#welcomeOverlay .grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  opacity: 0.025;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px;
}

/* ── Welcome content (frameless — floats on living background) ── */
.welcome-inner {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 640px;
  padding: 80px 48px 100px;
  background: transparent;
  border: none;
  margin: 0 auto;
}

/* ── Staggered fadeUp cascade ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.welcome-eyebrow,
.welcome-inner h2,
.welcome-desc,
.welcome-divider,
.welcome-stats,
.welcome-cta,
.welcome-brand {
  opacity: 0;
  animation: fadeUp 1s ease forwards;
}

.welcome-eyebrow    { animation-delay: 0.3s; }
.welcome-inner h2   { animation-delay: 0.5s; }
.welcome-desc       { animation-delay: 0.7s; }
.welcome-divider    { animation-delay: 0.9s; }
.welcome-stats      { animation-delay: 1.1s; }
.welcome-cta        { animation-delay: 1.3s; }
.welcome-brand      { animation-delay: 1.5s; }

/* ── Eyebrow ── */
.welcome-eyebrow {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #81c784;
  margin-bottom: 24px;
  text-shadow: 0 0 30px rgba(76,175,80,0.4);
}

/* ── Headline ── */
.welcome-inner h2 {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 20px;
}

.welcome-inner h2 em {
  font-style: italic;
  color: #81c784;
  position: relative;
  display: inline-block;
}

.welcome-inner h2 em::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #4caf50;
  animation: breathe-line 8s ease-in-out infinite;
}

@keyframes breathe-line {
  0%, 100% { opacity: 0.2; transform: scaleX(0.95); }
  50%      { opacity: 0.6; transform: scaleX(1); }
}

/* ── Description ── */
.welcome-desc {
  font-size: 1.2rem;
  line-height: 2.1;
  color: rgba(232, 237, 232, 0.72);
  max-width: 660px;
  margin: 0 auto 12px;
  font-weight: 300;
}

/* ── Breathing divider ── */
.welcome-divider {
  width: 60%;
  height: 1px;
  margin: 0 auto 28px;
  background: linear-gradient(90deg, transparent, rgba(76,175,80,0.08), rgba(76,175,80,0.25), rgba(76,175,80,0.08), transparent);
  animation: divider-breathe 8s ease-in-out infinite;
}

@keyframes divider-breathe {
  0%, 100% { opacity: 0.4; transform: scaleX(0.95); }
  50%      { opacity: 1; transform: scaleX(1); }
}

/* ── Stats row ── */
.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.welcome-stat {
  text-align: center;
  min-width: 70px;
}

.welcome-stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  color: #4caf50;
  display: block;
  text-shadow: 0 0 16px rgba(76, 175, 80, 0.25);
}

.welcome-stat-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  display: block;
}

/* ── CTA button ── */
.welcome-cta {
  padding: 14px 36px;
  border: 1px solid #4caf50;
  border-radius: 8px;
  background: #4caf50;
  color: #0a0f0a;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: btn-breathe 8s ease-in-out infinite, fadeUp 1s ease 1.3s forwards;
  opacity: 0;
}

@keyframes btn-breathe {
  0%, 100% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.15); }
  50%      { box-shadow: 0 0 40px rgba(76, 175, 80, 0.3); }
}

.welcome-cta:hover {
  background: #81c784;
  transform: translateY(-2px);
  box-shadow: 0 0 50px rgba(76, 175, 80, 0.35);
}

/* ── Brand line ── */
.welcome-brand {
  margin-top: 28px;
  font-size: 11px;
  color: var(--text-label);
  letter-spacing: 0.02em;
}

/* ── Loading spinner ── */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Scrollbar base ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(76, 175, 80, 0.15); border-radius: 2px; }

/* ── Telescope HUD Overlay ── */
.telescope-hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.hud-crosshair-h, .hud-crosshair-v {
  position: absolute;
  background: rgba(76, 175, 80, 0.08);
}

.hud-crosshair-h {
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
}

.hud-crosshair-v {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
}

.hud-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px solid rgba(76, 175, 80, 0.06);
  transform: translate(-50%, -50%);
}

.hud-ring-1 {
  width: 200px;
  height: 200px;
}

.hud-ring-2 {
  width: 400px;
  height: 400px;
}

.hud-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: rgba(76, 175, 80, 0.15);
  border-style: solid;
  border-width: 0;
}

.hud-corner-tl { top: 12px; left: 12px; border-top-width: 1px; border-left-width: 1px; }
.hud-corner-tr { top: 12px; right: 12px; border-top-width: 1px; border-right-width: 1px; }
.hud-corner-bl { bottom: 12px; left: 12px; border-bottom-width: 1px; border-left-width: 1px; }
.hud-corner-br { bottom: 12px; right: 12px; border-bottom-width: 1px; border-right-width: 1px; }

.hud-scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.04), transparent);
  animation: scanline 8s linear infinite;
}

@keyframes scanline {
  0% { top: 0; }
  100% { top: 100%; }
}

.hud-coords {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  color: rgba(76, 175, 80, 0.5);
  letter-spacing: 1px;
  text-align: center;
  white-space: nowrap;
}

/* ── Soil Spirit ── */
.soil-spirit {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  pointer-events: none;
}

.soil-spirit.hidden { display: none; }

.soil-spirit.visible {
  display: block;
  animation: spiritBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.spirit-bubble {
  position: relative;
  max-width: 380px;
  padding: 14px 20px;
  background: rgba(10, 18, 10, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(76, 175, 80, 0.25);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(76, 175, 80, 0.08);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  text-align: center;
}

.spirit-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(10, 18, 10, 0.92);
}

@keyframes spiritBounceIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.8); }
  60% { opacity: 1; transform: translateX(-50%) translateY(-8px) scale(1.03); }
  80% { transform: translateX(-50%) translateY(3px) scale(0.99); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes spiritFadeOut {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

.soil-spirit.fading {
  animation: spiritFadeOut 0.4s ease forwards;
}

/* ── Soil Toast ── */
.soil-toast {
  position: fixed;
  z-index: 115;
  padding: 8px 16px;
  background: rgba(10, 18, 10, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.soil-toast.hidden { display: none; }

.soil-toast.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.soil-toast.fading {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* ── AI Chat Panel ── */
.ai-chat-panel {
  position: fixed;
  top: 60px;
  right: 12px;
  bottom: 76px;
  width: 380px;
  background: rgba(10, 18, 10, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 95;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.ai-chat-panel.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-header span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.chat-header button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.chat-header button:hover { color: var(--text); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(76, 175, 80, 0.2); border-radius: 2px; }

.chat-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.15);
  color: var(--text);
}

.chat-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.chat-msg.bot strong { color: var(--text); }
.chat-msg.bot a { color: var(--accent-dim); text-decoration: none; }
.chat-msg.bot a:hover { color: var(--accent); text-decoration: underline; }
.chat-msg.bot h1, .chat-msg.bot h2, .chat-msg.bot h3 { color: var(--text); font-size: 12px; font-weight: 600; margin: 8px 0 4px; }
.chat-msg.bot p { margin-bottom: 6px; }
.chat-msg.bot ul { padding-left: 14px; margin-bottom: 6px; }

.chat-msg.typing {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingPulse 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.chat-input-row {
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-row input:focus { border-color: var(--border-hover); }
.chat-input-row input::placeholder { color: var(--text-label); }

.chat-input-row button {
  padding: 8px 16px;
  border: 1px solid var(--accent-dim);
  border-radius: 6px;
  background: rgba(76, 175, 80, 0.1);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-input-row button:hover { background: rgba(76, 175, 80, 0.2); }

/* When AI chat panel is open, shift research panel left */
#researchPanel.visible ~ .ai-chat-panel:not(.hidden),
.ai-chat-panel:not(.hidden) ~ #researchPanel.visible {
  /* Both panels can coexist — research panel is 340px on right, chat panel overlaps */
}

/* On smaller screens, chat panel takes priority */
@media (max-width: 800px) {
  .ai-chat-panel { width: 320px; right: 8px; }
}

/* ── Valuation Breakdown Panel ── */
.valuation-panel {
  position: fixed;
  bottom: 76px;
  right: 16px;
  width: 380px;
  max-height: 70vh;
  background: rgba(10, 18, 10, 0.95);
  border: 1px solid rgba(76, 175, 80, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: valSlideUp 0.3s ease-out;
}
.valuation-panel.hidden { display: none; }

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

.val-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(76, 175, 80, 0.15);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.val-header button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.val-header button:hover { color: #fff; }

.val-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

.val-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.val-row:last-child { border-bottom: none; }

.val-row-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.val-row-value {
  font-weight: 500;
  color: var(--text-main);
}
.val-row-factor {
  font-size: 11px;
  color: var(--accent);
  margin-left: 6px;
}

.val-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0 8px;
  margin-top: 8px;
  border-top: 1px solid rgba(76, 175, 80, 0.3);
}
.val-total-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.val-total-value {
  font-size: 22px;
  font-weight: 600;
  color: #81c784;
}

.val-diff {
  text-align: right;
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0 0;
}
.val-diff.positive { color: #81c784; }
.val-diff.negative { color: #ef9a9a; }

.val-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(76, 175, 80, 0.1);
  background: rgba(76, 175, 80, 0.03);
}
.val-soildao {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}
.val-soildao strong {
  color: var(--text-main);
  display: block;
  margin-bottom: 6px;
}
.val-soildao p {
  margin: 0 0 8px;
}
.val-cta {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 14px;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 6px;
  color: #81c784;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
.val-cta:hover {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.5);
}

#metCarbonItem:hover .metric-value {
  color: #81c784;
  text-decoration: underline;
}
