body {
  font-family: 'Inter', sans-serif;
  background: #0b0b0b;
  color: #e0e0e0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  /* Added overflow: hidden to prevent scrollbars from the main page */
  overflow: hidden;
}

body.chat-active {
  align-items: normal;
  justify-content: normal;
}

body.chat-active .container {
  height: 100vh;
  max-height: 100vh;
  padding-top: 60px;
  padding-bottom: 20px;
  box-sizing: border-box;
  justify-content: normal;
  margin: 0 auto;
  width: 90%;
}

.welcome-message {
  display: block;
  text-align: center;
  font-weight: 500;
  margin-bottom: 24px;
}
body.chat-active .welcome-message {
  display: none;
}

#prompt-display {
  font-size: 1.5rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.5;
  color: #777;
  min-height: 3em;
}

.chat-box {
  display: none;
  flex: 1;
  overflow-y: auto;
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 12px;
  width: 100%;
  max-width: 740px;
  margin-left: auto;
  margin-right: auto;
  min-height: 0;
  
  /* --- NEW: Discreet Scrollbar --- */
  scrollbar-width: thin;
  scrollbar-color: #333 #0b0b0b;
}

/* --- NEW: Webkit (Chrome, Safari) Scrollbar --- */
.chat-box::-webkit-scrollbar {
  width: 8px;
}
.chat-box::-webkit-scrollbar-track {
  background: #111;
  border-radius: 4px;
}
.chat-box::-webkit-scrollbar-thumb {
  background-color: #333;
  border-radius: 4px;
  border: 2px solid #111;
}

body.chat-active .chat-box {
  display: flex;
  flex-direction: column;
}

.user,
.assistant {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.user {
  background: #00f0b5;
  color: #000;
  align-self: flex-end;
  /* Ensure user bubbles don't get too wide */
  max-width: 80%;
  overflow-wrap: break-word;
  text-align: right; /* <-- ADDED */
}

.assistant {
  background: #222222;
  color: #e0e0e0;
  align-self: flex-start;
  /* Ensure assistant bubbles don't get too wide */
  max-width: 80%;
  overflow-wrap: break-word;
  text-align: left; /* <-- ADDED */
}

/* --- FIX: Loading bubble styles --- */
.assistant-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px; /* Approx height of one line of text */
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #555;
  border-top-color: #00f0b5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
/* --- End of fix --- */

.input-area {
  display: flex;
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  position: relative;
}

#user-input {
  flex: 1;
  padding: 16px 60px 16px 20px;
  border-radius: 24px;
  background: #222;
  border: 1px solid #333;
  color: #e0e0e0;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  resize: none;
  overflow-y: hidden;
  line-height: 1.4;
  max-height: 200px;
}

#user-input:focus {
  border-color: #00f0b5;
  outline: none;
  box-shadow: 0 0 10px rgba(0, 240, 181, 0.3);
}

#reflect-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);

  background: #00f0b5;
  color: #000;
  border: none;
  border-radius: 12px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#reflect-btn:hover {
  background: #f44336;
  color: #fff;
}

/* --- Markdown styles (no change) --- */
.assistant strong {
  color: #ffffff;
}
.assistant em {
  font-style: italic;
  color: #aaaaaa;
}
.assistant blockquote {
  border-left: 3px solid #00f0b5;
  padding-left: 1rem;
  margin: 0.5rem 0;
  color: #aaaaaa;
  font-style: italic;
}
.assistant ul,
.assistant ol {
  margin: 0.5rem 0 0.5rem 1.5rem;
  padding: 0 0 0 0.5rem;
}
.assistant li {
  margin-bottom: 0.25rem;
}
.assistant p {
  margin-block-start: 0;
  margin-block-end: 0;
  margin-bottom: 0.5em;
}
.assistant p:last-child {
  margin-bottom: 0;
}


/* --- About Panel styles (no change) --- */
#panel-dimmer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1999;
  display: none;
}
#about-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: 90%;
  background: #111111;
  border-right: 1px solid #333;
  box-shadow: 4px 0px 15px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  padding: 2rem;
  box-sizing: border-box;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease-in-out;
}
#about-panel.about-panel-open {
  transform: translateX(0);
}
#close-panel-btn {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  color: #aaaaaa;
  cursor: pointer;
}
#close-panel-btn:hover {
  color: #ffffff;
}
#about-panel h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
  color: #e0e0e0;
}
#about-panel p {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #aaaaaa;
}

/* --- Container for chat/welcome message --- */
.container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh; /* keeps everything vertically centered */
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

.welcome-message,
#chat-box,
.input-area {
  position: relative;
  z-index: 2;
}

/* --- THIS IS THE FIX: Lattice Panel Overlay --- */
.lattice-overlay {
  position: fixed;
  inset: 0;
  background: #0b0b0b;
  display: flex; /* This centers the content */
  justify-content: center; /* This centers the content */
  align-items: center; /* This centers the content */
  z-index: 999;
}
.lattice-overlay.hidden {
  display: none;
}

/* --- THIS IS THE FIX: Close button for lattice --- */
.close-btn {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  font-size: 1.5rem;
  background: none;
  color: #48e6b8;
  border: none;
  cursor: pointer;
  z-index: 1001; /* Ensure it's above the canvas */
}

/* --- Nav bar styles --- */
.nav-bar {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100; /* Ensure nav is above other content */
}

.nav-link {
  color: #aaa;
  font-size: 0.9rem;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-link:hover {
  color: #ffffff;
}

.logo-btn {
  color: #b3f5cc;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.3s ease;
  padding: 8px;
  font-size: 0.9rem;
}
.logo-btn:hover {
  opacity: 0.8;
}

/* --- Decorative seed orb --- */
#lattice-seed {
  position: fixed;
  bottom: 4rem;
  right: 5rem;
  opacity: 0.8;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 0 20px rgba(120, 255, 210, 0.6));
}

/* --- THIS IS THE FIX: Lattice Canvas --- */
#lattice-viewer {
  /* Removed all position: fixed, right, bottom rules */
  /* It will now be centered by its parent, .lattice-overlay */
  background: radial-gradient(circle at center, #0a0a0a, #000);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  z-index: 1000; /* Below the close button */
}

/* --- Lattice Grid Label Fix --- */
.lattice-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  fill: #aaa;               /* for SVG text */
  color: #aaa;              /* fallback */
  text-transform: lowercase;
}

.lattice-label-row {
  text-anchor: end;
  dominant-baseline: middle;
}

.lattice-label-col {
  text-anchor: middle;
  dominant-baseline: hanging;
}

/* Add extra space so labels don't overlap */
#lattice-viewer {
  padding: 40px;
}