/* --- Design System & Custom Properties --- */
:root {
  --bg-deep: hsl(230, 25%, 5%);
  --bg-surface: hsla(230, 20%, 10%, 0.6);
  --bg-surface-hover: hsla(230, 20%, 15%, 0.8);
  --border-light: hsla(220, 30%, 40%, 0.15);
  --border-glow: hsla(180, 80%, 50%, 0.3);
  
  --color-text-main: hsl(220, 15%, 90%);
  --color-text-muted: hsl(220, 10%, 60%);
  --color-text-accent: hsl(175, 90%, 55%);
  
  /* Accent HSL codes (for dynamic variations) */
  --accent-cyan: 175, 90%, 55%;
  --accent-violet: 275, 85%, 65%;
  --accent-amber: 35, 95%, 55%;
  --accent-rose: 345, 85%, 60%;
  
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', monospace;
  
  --shadow-glow: 0 0 20px hsla(175, 90%, 55%, 0.25);
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Base Styles --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-deep);
  color: var(--color-text-main);
  font-family: var(--font-display);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Ambient glow backdrop */
.glow-backdrop {
  position: absolute;
  top: 10%;
  left: 30%;
  width: 60vw;
  height: 60vh;
  background: radial-gradient(circle, hsla(275, 85%, 65%, 0.08) 0%, hsla(175, 90%, 55%, 0.04) 50%, transparent 100%);
  z-index: 0;
  pointer-events: none;
  filter: blur(80px);
}

/* --- Header --- */
header {
  height: 70px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  background: hsla(230, 25%, 4%, 0.8);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  font-family: var(--font-display);
  background: linear-gradient(135deg, hsl(175, 90%, 55%), hsl(275, 85%, 65%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo .version {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: hsla(175, 90%, 55%, 0.1);
  color: hsl(175, 90%, 55%);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid hsla(175, 90%, 55%, 0.25);
  font-weight: bold;
}

.pulse {
  width: 8px;
  height: 8px;
  background-color: hsl(175, 90%, 55%);
  border-radius: 50%;
  box-shadow: 0 0 10px hsl(175, 90%, 55%);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 8px hsl(175, 90%, 55%);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.5;
    box-shadow: 0 0 18px hsl(175, 90%, 55%);
  }
}

.system-status {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-status .label {
  color: var(--color-text-muted);
}

.system-status .status-value {
  color: hsl(175, 90%, 55%);
  font-weight: bold;
}

.system-status .status-value::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: hsl(175, 90%, 55%);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* --- Main Layout --- */
main {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* Canvas Container */
.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, hsla(230, 20%, 8%, 0.4) 0%, hsla(230, 25%, 3%, 0.8) 100%);
  overflow: hidden;
}

#latent-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-overlay {
  position: absolute;
  bottom: 20px;
  left: 20px;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.tip-toast {
  background: hsla(230, 20%, 5%, 0.7);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
}

/* --- Cognitive Console (Sidebar) --- */
.cognitive-console {
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: 360px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: hsla(230, 25%, 4%, 0.55);
  backdrop-filter: blur(16px);
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 25px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Scrollbar styles for the sidebar */
.cognitive-console::-webkit-scrollbar {
  width: 6px;
}
.cognitive-console::-webkit-scrollbar-track {
  background: transparent;
}
.cognitive-console::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
.cognitive-console::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.console-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.console-section h2 {
  font-size: 0.9rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

/* Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-header label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-main);
}

.control-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-accent);
  background: hsla(175, 90%, 55%, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid hsla(175, 90%, 55%, 0.15);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border-light);
  outline: none;
  margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-text-accent);
  cursor: pointer;
  box-shadow: 0 0 10px hsla(175, 90%, 55%, 0.5);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.control-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

/* Stimulus Input */
.prompt-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#prompt-input {
  width: 100%;
  background: hsla(230, 20%, 5%, 0.6);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px 45px 12px 16px;
  color: var(--color-text-main);
  font-family: var(--font-display);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

#prompt-input:focus {
  border-color: var(--color-text-accent);
  box-shadow: var(--shadow-glow);
  background: hsla(230, 20%, 5%, 0.8);
}

#btn-inject {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  border-radius: 6px;
}

#btn-inject:hover {
  color: var(--color-text-accent);
  background: hsla(175, 90%, 55%, 0.1);
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: hsla(220, 15%, 20%, 0.4);
  border: 1px solid var(--border-light);
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
  color: var(--color-text-muted);
}

.tag:hover {
  background: hsla(175, 90%, 55%, 0.1);
  border-color: hsla(175, 90%, 55%, 0.3);
  color: var(--color-text-main);
  transform: translateY(-1px);
}

/* Audio Control Button */
.audio-control {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
}

.audio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.audio-header h2 {
  border-bottom: none;
  padding-bottom: 0;
}

.audio-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, hsl(275, 85%, 65%), hsl(175, 90%, 55%));
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px hsla(275, 85%, 65%, 0.3);
}

.audio-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px hsla(175, 90%, 55%, 0.4);
}

.audio-toggle.muted {
  background: hsla(220, 10%, 15%, 0.6);
  border: 1px solid var(--border-light);
  color: var(--color-text-muted);
  box-shadow: none;
}

.audio-toggle.muted:hover {
  background: hsla(220, 10%, 20%, 0.8);
  color: var(--color-text-main);
  border-color: var(--color-text-muted);
}

.audio-toggle .icon-play { display: inline-flex; }
.audio-toggle .icon-mute { display: none; }

.audio-toggle.muted .icon-play { display: none; }
.audio-toggle.muted .icon-mute { display: inline-flex; }

.audio-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* --- Footer (Thought Stream Panel) --- */
footer {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 400px;
  height: 170px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: hsla(230, 25%, 3%, 0.55);
  backdrop-filter: blur(16px);
  padding: 20px 30px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.thought-stream-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-header h2 {
  font-size: 0.9rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-text-muted);
}

.thought-pulse {
  background-color: hsl(275, 85%, 65%);
  box-shadow: 0 0 10px hsl(275, 85%, 65%);
}

.entropy-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.entropy-label span {
  color: hsl(35, 95%, 55%);
}

.thought-scroll-container {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 10px;
}

.thought-scroll-container::-webkit-scrollbar {
  width: 4px;
}
.thought-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}
.thought-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

.thought-line {
  line-height: 1.4;
  word-break: break-all;
  border-left: 2px solid transparent;
  padding-left: 10px;
  animation: line-fade-in 0.25s ease-out;
}

@keyframes line-fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.system-line {
  color: var(--color-text-muted);
  border-left-color: var(--border-light);
}

.cognitive-line {
  color: var(--color-text-main);
  border-left-color: hsl(175, 90%, 55%);
}

.monologue-line {
  color: hsl(275, 85%, 65%);
  font-style: italic;
  border-left-color: hsl(275, 85%, 65%);
}

.code-line {
  color: hsl(35, 95%, 55%);
  background: hsla(35, 95%, 55%, 0.04);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid hsla(35, 95%, 55%, 0.1);
  border-left: 2px solid hsl(35, 95%, 55%);
  white-space: pre-wrap;
}

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
  .cognitive-console {
    top: auto;
    left: 20px;
    right: 20px;
    bottom: 20px;
    width: auto;
    height: 260px;
    border: 1px solid var(--border-light);
  }
  
  footer {
    left: 20px;
    right: 20px;
    bottom: 300px;
    width: auto;
    height: 140px;
  }
}
