@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0c0c0e;
  --bg-surface: #161618;
  --bg-elevated: #1c1c1f;
  --accent: #007aff;
  --accent-hover: #0056b3;
  --text-primary: #ffffff;
  --text-secondary: #c7c7cc;
  --text-muted: #a1a1a6;
  --border: #38383a;
  --border-muted: #2c2c2e;
  --success: #30d158;
  --warning: #ff9f0a;
  --error: #ff3b30;
  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(12, 12, 14, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 0;
  height: 64px;
  display: flex;
  align-items: center;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--text-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  opacity: 1;
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  opacity: 1;
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 64px;
  position: relative;
}

.hero-content {
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
  padding: 4rem 0;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-buttons .btn {
  padding: 0.625rem 1.25rem;
}

/* Features */
.features {
  padding: 5rem 0;
  background: var(--bg-surface);
}

.section-title {
  text-align: center;
  margin-bottom: 3rem;
}

.section-title h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.section-title p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.feature-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s ease;
}

.feature-card:hover {
  border-color: var(--text-muted);
}

.feature-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

.feature-card code {
  background: var(--bg-surface);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent);
}

/* How It Works */
.how-it-works {
  padding: 5rem 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 2.5rem;
}

.step {
  text-align: center;
}

.step-number {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 auto 1rem;
  color: white;
  font-family: 'IBM Plex Mono', monospace;
}

.step h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.step p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Architecture */
.architecture {
  padding: 5rem 0;
  background: var(--bg-surface);
}

.architecture-diagram {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-top: 2rem;
  overflow-x: auto;
}

.diagram-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 700px;
}

.diagram-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  text-align: center;
  min-width: 100px;
  transition: border-color 0.2s ease;
}

.diagram-box:hover {
  border-color: var(--accent);
}

.diagram-box.highlight {
  border-color: var(--accent);
  background: rgba(0, 122, 255, 0.1);
}

.diagram-box .icon {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.diagram-box .label {
  font-weight: 600;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
}

.diagram-arrow {
  color: var(--accent);
  font-size: 1.25rem;
  font-family: 'IBM Plex Mono', monospace;
}

/* Commands */
.commands {
  padding: 5rem 0;
}

.commands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.command-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.command-card .cmd {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.command-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Footer */
footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

footer p {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

footer .links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

footer .links a {
  color: var(--text-muted);
  font-size: 0.875rem;
}

footer .links a:hover {
  color: var(--text-primary);
}

/* ========================
   CHAT INTERFACE
   ======================== */

.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'IBM Plex Mono', monospace;
}

.chat-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}

.chat-header .logo {
  font-size: 1rem;
}

.header-stats {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.disconnected {
  background: var(--error);
}

.badge {
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-persistent {
  background: rgba(48, 209, 88, 0.15);
  color: var(--success);
}

.badge-ephemeral {
  background: rgba(255, 159, 10, 0.15);
  color: var(--warning);
}

.chat-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.conversation-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

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

.message {
  max-width: 75%;
  font-size: 0.875rem;
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.message.user .message-time {
  text-align: right;
}

.message.assistant .message-time {
  text-align: left;
}

/* Search Results */
.search-result {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin: 0.5rem 0;
  align-self: flex-start;
  max-width: 75%;
}

.search-result-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

/* Memory Panel */
.memory-panel {
  width: 300px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.memory-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.memory-header h3 {
  font-size: 0.8125rem;
  font-weight: 600;
}

.memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.memory-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.memory-content {
  margin-bottom: 0.5rem;
  line-height: 1.4;
  word-break: break-word;
}

.memory-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.memory-type {
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.625rem;
  text-transform: uppercase;
}

.memory-type.explicit {
  background: rgba(0, 122, 255, 0.15);
  color: var(--accent);
}

.memory-type.reflection {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.memory-stars {
  color: var(--warning);
  font-size: 0.625rem;
  letter-spacing: 1px;
}

.empty-memories {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* Input */
.chat-input-area {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.chat-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input-container {
  flex: 1;
  position: relative;
}

.chat-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.875rem;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s ease;
}

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

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

.input-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.input-hint kbd {
  background: var(--bg-primary);
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-family: inherit;
  margin: 0 0.125rem;
}

.send-btn {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover {
  background: var(--accent-hover);
}

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

/* Command Bar */
.command-bar {
  padding: 0.625rem 1.5rem;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

.command-bar span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.command-bar code {
  background: var(--bg-elevated);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: inherit;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90%;
  max-width: 380px;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}

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

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8125rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group select {
  cursor: pointer;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: white;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Confirm Dialog */
.confirm-dialog {
  text-align: center;
}

.confirm-dialog p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  opacity: 1;
}

/* Mobile */
.mobile-warning {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.mobile-warning .icon {
  font-size: 3rem;
  margin-bottom: 1.25rem;
}

.mobile-warning h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.mobile-warning p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.25rem;
  }
  
  .hero p {
    font-size: 1rem;
  }
  
  .steps {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .features-grid {
    grid-template-columns: 1fr;
  }
  
  .memory-panel {
    display: none;
  }
  
  .mobile-warning {
    display: flex;
    flex-direction: column;
  }
  
  .chat-container {
    display: none;
  }
  
  .nav-links {
    display: none;
  }
}
