/* ── Warp Overlay ────────────────────────────────────────── */
#warp-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 14, 0.85); /* Darker overlay for warp */
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 100;
  text-align: center;
}

body.light #warp-overlay {
  background: rgba(245, 244, 239, 0.85);
}

#warp-overlay.active {
  display: flex;
}

#warp-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--border-mid);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#warp-stats h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--text);
  letter-spacing: 0.05em;
}

#warp-stats p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0;
}

#warp-stats span {
  color: var(--text);
  font-weight: bold;
}

#stopWarp {
  padding: 10px 24px;
  font-size: 13px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.2s;
}

#stopWarp:hover {
  opacity: 0.8;
}

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

/* ── Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:          #0f0f0e;
  --bg2:         #1a1a18;
  --bg3:         #222220;
  --border:      rgba(255,255,255,0.08);
  --border-mid:  rgba(255,255,255,0.14);
  --text:        #d4d2c8;
  --text-muted:  #6e6d68;
  --text-dim:    #3d3d3a;
  --green:       #97C459;
  --green-dark:  #3B6D11;
  --blue:        #378ADD;
  --red:         #E24B4A;
  --accent:      #378ADD;
  --mono:        'SF Mono', 'Fira Code', 'Consolas', monospace;
  --radius:      8px;
}

body.light {
  --bg:         #f5f4ef;
  --bg2:        #eceae3;
  --bg3:        #e2e0d8;
  --border:     rgba(0,0,0,0.08);
  --border-mid: rgba(0,0,0,0.14);
  --text:       #1a1a18;
  --text-muted: #6e6d68;
  --text-dim:   #b0aea6;
  --green:      #3B6D11;
  --green-dark: #97C459;
  --blue:       #185FA5;
  --red:        #A32D2D;
  --accent:     #185FA5;
}

/* ── Layout ─────────────────────────────────────────────────────── */
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); overflow: hidden; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1600px; /* Wider for sidebar */
  margin: 0 auto;
}

#main-view {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
#nn-sidebar {
  width: 320px;
  background: var(--bg2);
  border-left: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
}

#nn-sidebar.hidden {
  width: 0;
  overflow: hidden;
  border-left: none;
}

.sidebar-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px;
  border-bottom: 0.5px solid var(--border);
  text-align: center;
}

/* ── Load Display ─────────────────────────────────────────── */
#load-container {
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.load-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#load-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#load-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease-out, background-color 0.3s;
}

#load-pct {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--mono);
}

#nnCanvas {
  width: 100%;
  height: 40%; /* Fixed height to make room for thoughts */
  flex-shrink: 0;
}

#thought-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
}

#thought-log {
  flex: 1;
  padding: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-muted);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  mask-image: linear-gradient(to bottom, transparent, black 15%);
}

.thought-item {
  animation: slideIn 0.3s ease-out forwards;
  opacity: 0.8;
}

.thought-item.action { color: var(--accent); font-weight: 500; }
.thought-item.bio    { color: var(--green); }
.thought-item.social { color: var(--red); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 0.8; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────────── */
#header {
  padding: 14px 20px 10px;
  border-bottom: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#header-left { display: flex; align-items: center; gap: 16px; }
#header-right { display: flex; align-items: center; gap: 12px; }

#header h2 { font-size: 12px; font-weight: 500; letter-spacing: 0.1em; color: var(--text-muted); text-transform: uppercase; }

#status-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }

button {
  font-size: 11px; padding: 6px 12px; border-radius: var(--radius);
  border: 0.5px solid var(--border-mid);
  background: var(--bg2); color: var(--text);
  cursor: pointer; font-family: var(--mono); letter-spacing: 0.03em;
  transition: background .15s, border-color .15s;
}
button:hover { background: var(--bg3); border-color: var(--text-dim); }
#pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green-dark);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.75)} }

/* ── Mode tabs ──────────────────────────────────────────────────── */
#mode-tabs { display: flex; }
.tab {
  font-size: 11px; padding: 4px 10px; cursor: pointer;
  border: 0.5px solid var(--border-mid);
  border-radius: 0;
  background: transparent; color: var(--text-muted);
  font-family: var(--mono); letter-spacing: 0.03em;
  transition: background .15s, color .15s;
}
.tab:first-of-type { border-radius: var(--radius) 0 0 var(--radius); }
.tab:last-of-type  { border-radius: 0 var(--radius) var(--radius) 0; }
.tab:not(:first-of-type) { border-left: none; }
.tab.active { background: var(--bg3); color: var(--text); border-color: var(--border-mid); }
.tab:hover:not(.active) { background: var(--bg2); color: var(--text); }

/* ── Canvas ─────────────────────────────────────────────────────── */
#canvas-wrap { flex: 1; position: relative; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; }

/* ── Controls ───────────────────────────────────────────────────── */
#controls {
  padding: 12px 20px;
  border-top: 0.5px solid var(--border);
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  flex-shrink: 0;
}
.ctrl-group { display: flex; flex-direction: column; gap: 5px; }
.ctrl-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.ctrl-row   { display: flex; align-items: center; gap: 8px; }
.ctrl-val   { font-size: 13px; font-weight: 500; color: var(--text); min-width: 20px; }
.ctrl-unit  { font-size: 11px; color: var(--text-dim); }

input[type="range"] {
  flex: 1; -webkit-appearance: none; height: 2px;
  background: var(--border-mid); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--green); cursor: pointer;
  border: 2px solid var(--bg);
}

/* ── Stats ──────────────────────────────────────────────────────── */
#stats { margin-left: auto; display: flex; gap: 20px; }
.stat  { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.stat-val { font-size: 14px; font-weight: 500; color: var(--text); }

/* ── Import Brain Overlay (Synced with Warp Style) ────────── */
.glass-overlay {
  position: absolute; /* Changed to absolute to fit canvas-wrap or inset:0 */
  inset: 0;
  background: rgba(15, 15, 14, 0.85); 
  backdrop-filter: blur(12px);
  display: flex; 
  align-items: center; 
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

body.light .glass-overlay {
  background: rgba(245, 244, 239, 0.85);
}

.modal-card {
  background: var(--bg2);
  width: 90%; 
  max-width: 550px;
  border: 0.5px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  overflow: hidden;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px; 
  display: flex; 
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg);
}

.header-titles h3 { 
  font-size: 14px; 
  text-transform: uppercase; 
  letter-spacing: 0.1em; 
  color: var(--accent); 
  margin: 0;
}

.header-titles p { 
  margin: 6px 0 0; 
  font-size: 10px; 
  color: var(--text-muted); 
  text-transform: uppercase;
}

.close-x { 
  background: transparent; 
  border: none; 
  color: var(--text-muted); 
  font-size: 20px; 
  cursor: pointer; 
  padding: 0 5px;
  line-height: 1;
}
.close-x:hover { color: var(--red); }

.table-scroll { 
  max-height: 280px; 
  overflow-y: auto; 
  background: var(--bg2);
}

.brain-table { 
  width: 100%; 
  border-collapse: collapse; 
  text-align: left; 
}

.brain-table th { 
  padding: 10px 20px; 
  font-size: 9px; 
  text-transform: uppercase; 
  color: var(--text-dim); 
  background: var(--bg);
  position: sticky;
  top: 0;
}

.brain-table td { 
  padding: 12px 20px; 
  border-bottom: 0.5px solid var(--border); 
  font-size: 12px; 
  color: var(--text-muted);
}

.brain-tag { 
  font-family: var(--mono); 
  color: var(--text); 
  font-weight: 500;
}

.load-btn { 
  background: var(--bg3); 
  color: var(--text); 
  border: 0.5px solid var(--border-mid); 
  padding: 4px 10px; 
  border-radius: 4px; 
  font-size: 10px;
}

.load-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.modal-content {
  padding: 20px;
  background: var(--bg);
}

.neural-divider {
  border: 0;
  height: 1px;
  /* Increased opacity to 0.5 and added a subtle blue/cyan tint for a "tech" feel */
  background: linear-gradient(
    to right, 
    transparent, 
    rgba(255, 255, 255, 0.5) 20%, 
    rgba(0, 255, 255, 0.3) 50%, 
    rgba(255, 255, 255, 0.5) 80%, 
    transparent
  );
  margin: 25px 5%; /* Narrower width makes it look cleaner */
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.1); /* Very soft glow */
}

.modal-footer { 
  padding: 20px; 
  background: var(--bg); 
  border-top: 0.5px solid var(--border);
  text-align: center; 
}

.primary-btn { 
  background: var(--green-dark); 
  color: white; 
  border: none; 
  padding: 10px 20px; 
  border-radius: var(--radius); 
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer; 
}

.primary-btn:hover { background: var(--green); }

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