:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-yellow: #d29922;
  --accent-purple: #a371f7;
  --hal-red: #ff0000;
  --border-color: #30363d;
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.1) 2px,
      rgba(0, 0, 0, 0.1) 4px
    );
  pointer-events: none;
  z-index: 1000;
  opacity: 0.3;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

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

.header-titles h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--hal-red), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-titles .subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-style: italic;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* HAL Eye */
.hal-eye {
  width: 50px;
  height: 50px;
  cursor: pointer;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.hal-eye:hover {
  transform: scale(1.1);
}

.hal-outer {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 0 10px rgba(255, 0, 0, 0.3),
    inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.hal-inner {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hal-red) 0%, #8b0000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: hal-pulse 2s ease-in-out infinite;
}

.hal-eye.thinking .hal-inner {
  animation: hal-think 0.5s ease-in-out infinite;
}

.hal-eye.meltdown .hal-inner {
  animation: hal-meltdown 0.1s ease-in-out infinite;
}

.hal-core {
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--hal-red) 100%);
}

@keyframes hal-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--hal-red); }
  50% { box-shadow: 0 0 25px var(--hal-red), 0 0 50px rgba(255, 0, 0, 0.5); }
}

@keyframes hal-think {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes hal-meltdown {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.2) rotate(5deg); }
  50% { transform: scale(0.9) rotate(-5deg); }
  75% { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  border-radius: 20px;
  font-size: 0.875rem;
}

.status-emoji {
  font-size: 0.75rem;
}

.secret-claude-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

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

/* Chaos Meter */
.chaos-bar-container {
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.chaos-meter {
  max-width: 100%;
}

.chaos-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.chaos-value {
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.chaos-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.chaos-fill {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.5s ease, background 0.3s ease;
  border-radius: 4px;
}

.chaos-fill.warning {
  background: var(--accent-yellow);
}

.chaos-fill.critical {
  background: var(--accent-red);
  animation: chaos-pulse 0.5s ease-in-out infinite;
}

@keyframes chaos-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Main Workspace */
.main-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

/* Code Editor */
.editor-panel {
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 250px;
  overflow: hidden;
}

@media (max-width: 900px) {
  .editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    min-height: 200px;
  }
}

.code-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.editor-dots {
  display: flex;
  gap: 0.5rem;
}

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

.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }

.editor-title {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: 'JetBrains Mono', monospace;
}

.editor-content {
  flex: 1;
  overflow: auto;
  padding: 1rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  background: var(--bg-primary);
}

.code-line {
  display: flex;
  padding: 0 1rem;
  transition: background 0.3s ease;
}

.code-line.changed {
  background: rgba(63, 185, 80, 0.15);
  animation: line-flash 2s ease-out;
}

@keyframes line-flash {
  0% { background: rgba(63, 185, 80, 0.4); }
  100% { background: transparent; }
}

.line-number {
  min-width: 2.5rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 1rem;
  user-select: none;
  flex-shrink: 0;
}

.line-content {
  flex: 1;
  white-space: pre;
  overflow-x: auto;
}

.syntax-keyword { color: var(--accent-purple); }
.syntax-string { color: var(--accent-green); }
.syntax-comment { color: var(--text-muted); font-style: italic; }

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  min-height: 250px;
  overflow: hidden;
}

@media (max-width: 900px) {
  .chat-panel {
    min-height: 200px;
  }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-empty {
  color: var(--text-secondary);
  text-align: center;
  padding: 2rem 1rem;
}

.chat-empty p {
  margin-bottom: 0.5rem;
}

.chat-message {
  display: flex;
  gap: 0.75rem;
  animation: message-in 0.3s ease-out;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.ai .message-content {
  background: var(--bg-tertiary);
  border-bottom-left-radius: 4px;
}

.chat-message.user .message-content {
  background: var(--accent-blue);
  color: white;
  border-bottom-right-radius: 4px;
}

.typing-indicator {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.quick-action-btn {
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.7rem;
  font-family: 'Space Grotesk', sans-serif;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-action-btn:hover:not(:disabled) {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

.quick-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat Input */
.chat-input-form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9rem;
  min-width: 0;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  padding: 0.75rem 1.25rem;
  background: var(--accent-blue);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: #4a90e2;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error Console */
.error-console {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  max-height: 120px;
  flex-shrink: 0;
}

.console-header {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--bg-tertiary);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}

.error-count {
  color: var(--accent-red);
  font-weight: 600;
}

.console-content {
  padding: 0.5rem 1rem;
  overflow-y: auto;
  max-height: 70px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

.console-line {
  padding: 0.25rem 0;
  animation: error-in 0.3s ease-out;
  word-wrap: break-word;
}

@keyframes error-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.console-line.warning { color: var(--accent-yellow); }
.console-line.error { color: var(--accent-red); }
.console-line.critical { 
  color: var(--accent-red); 
  font-weight: 700;
  animation: critical-flash 0.5s ease-in-out infinite;
}

@keyframes critical-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Footer */
.app-footer {
  padding: 1rem;
  text-align: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

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

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

.footer-small {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Meltdown Overlay */
.meltdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: glitch-bg 0.1s infinite;
  padding: 1rem;
}

@keyframes glitch-bg {
  0% { background-position: 0 0; }
  20% { background-position: -2px 2px; }
  40% { background-position: 2px -2px; }
  60% { background-position: -2px -2px; }
  80% { background-position: 2px 2px; }
  100% { background-position: 0 0; }
}

.glitch-container {
  text-align: center;
  animation: container-glitch 0.5s infinite;
  max-width: 100%;
}

@keyframes container-glitch {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-2px, 2px); }
  50% { transform: translate(2px, -2px); }
  75% { transform: translate(-2px, -2px); }
}

.meltdown-hal {
  margin-bottom: 2rem;
}

.meltdown-hal .hal-eye {
  width: 100px;
  height: 100px;
  margin: 0 auto;
}

.daisy-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  color: var(--hal-red);
  margin-bottom: 2rem;
  min-height: 150px;
}

.daisy-text p {
  margin-bottom: 0.5rem;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.daisy-text p.current {
  opacity: 1;
  animation: daisy-current 1s ease-in-out infinite;
}

@keyframes daisy-current {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.reset-button {
  padding: 1rem 2rem;
  background: var(--accent-red);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 1.1rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto;
  animation: reset-pulse 1s ease-in-out infinite;
}

@keyframes reset-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(248, 81, 73, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(248, 81, 73, 0.8); }
}

.reset-icon {
  font-size: 1.25rem;
}

/* Can't do that message */
.cant-do-that {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: var(--hal-red);
  padding: 1.5rem 2rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-family: 'JetBrains Mono', monospace;
  z-index: 3000;
  border: 2px solid var(--hal-red);
  animation: cant-do-that 0.5s ease-out;
  text-align: center;
  max-width: 90%;
}

@keyframes cant-do-that {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .app-header {
    padding: 0.75rem 1rem;
  }
  
  .header-titles h1 {
    font-size: 1.1rem;
  }
  
  .header-titles .subtitle {
    font-size: 0.7rem;
  }
  
  .hal-eye {
    width: 36px;
    height: 36px;
  }
  
  .status-indicator {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
  }
  
  .status-text {
    display: none;
  }
  
  .secret-claude-btn {
    display: none;
  }
  
  .quick-actions {
    padding: 0.5rem;
    gap: 0.375rem;
  }
  
  .quick-action-btn {
    font-size: 0.65rem;
    padding: 0.375rem 0.5rem;
  }
  
  .editor-content {
    font-size: 0.65rem;
  }
  
  .line-number {
    min-width: 2rem;
    padding-right: 0.5rem;
  }
  
  .daisy-text {
    font-size: 1rem;
  }
  
  .reset-button {
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
  }
  
  .meltdown-hal .hal-eye {
    width: 80px;
    height: 80px;
  }
  
  .chat-input {
    font-size: 0.8rem;
    padding: 0.625rem 0.75rem;
  }
  
  .chat-input::placeholder {
    font-size: 0.75rem;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}