/* ============ RETRO THEME ============ */
:root {
  --bg: #0a0e1a;
  --bg-dark: #050810;
  --surface: #111827;
  --surface-light: #1a2332;
  --border: #2a3447;
  --fg: #c9d1d9;
  --fg-bright: #ffffff;
  --muted: #6b7280;
  --accent: #00ff88;
  --accent-2: #00d4ff;
  --warn: #ffaa00;
  --error: #ff3860;
  --amber: #ffbf00;
}

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

body.retro {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT scanlines */
.scanlines {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%,
    rgba(0, 0, 0, 0.25) 50%
  ),
  linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.06),
    rgba(0, 255, 0, 0.02),
    rgba(0, 0, 255, 0.06)
  );
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
  z-index: 1000;
  animation: scan 8s linear infinite;
}

@keyframes scan {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 0 100%, 100% 0; }
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.blink { animation: blink 1s step-end infinite; }

/* Main window */
.window {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Title bar */
.titlebar {
  background: linear-gradient(180deg, #1a2332 0%, #111827 100%);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.titlebar-left { display: flex; gap: 6px; }
.titlebar-title {
  flex: 1;
  text-align: center;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  letter-spacing: 2px;
  font-size: 13px;
}
.titlebar-right { color: var(--muted); font-size: 12px; }

.dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
}
.dot-red { background: #ff5f56; box-shadow: 0 0 6px #ff5f56; }
.dot-amber { background: #ffbd2e; box-shadow: 0 0 6px #ffbd2e; }
.dot-green { background: #27c93f; box-shadow: 0 0 6px #27c93f; }

/* Main layout */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  color: var(--accent-2);
  font-size: 11px;
  font-weight: bold;
  padding: 4px 16px;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--fg);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--surface-light);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item.active {
  background: var(--surface-light);
  color: var(--accent);
  border-left-color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
}

.nav-icon {
  color: var(--accent-2);
  width: 16px;
  text-align: center;
}

.status-box {
  padding: 8px 16px;
  font-size: 11px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: var(--fg);
}

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

.sidebar-footer {
  padding: 12px 16px;
  font-size: 10px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  margin-top: 12px;
}

.sidebar-footer div { padding: 2px 0; }

/* Content */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  min-width: 0;
}

.content h1 {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  font-size: 22px;
  margin-bottom: 16px;
  letter-spacing: 1px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}

.content h2 {
  color: var(--accent-2);
  font-size: 16px;
  margin: 20px 0 12px;
  letter-spacing: 1px;
}

.content h3 {
  color: var(--fg-bright);
  font-size: 14px;
  margin: 16px 0 8px;
}

/* Status bar */
.statusbar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 12px;
  display: flex;
  gap: 24px;
  font-size: 11px;
  color: var(--muted);
}

.statusbar span:first-child {
  color: var(--accent);
  font-weight: bold;
}

/* Cards / tiles */
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px;
  margin-bottom: 8px;
  position: relative;
}

.tile::before {
  content: '▐';
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.tile-title {
  color: var(--fg-bright);
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 13px;
}

.tile-meta {
  color: var(--muted);
  font-size: 11px;
  font-family: monospace;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

/* Tables (terminal style) */
.term-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}

.term-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1px;
}

.term-table td {
  padding: 6px 10px;
  border-bottom: 1px dotted var(--border);
  color: var(--fg);
}

.term-table tr:hover td {
  background: var(--surface-light);
  color: var(--accent);
}

.term-table a {
  color: var(--accent-2);
  text-decoration: none;
}

.term-table a:hover {
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent);
}

/* Buttons */
.btn {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 10px var(--accent);
}

.btn-secondary {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.btn-secondary:hover {
  background: var(--accent-2);
  color: var(--bg);
  box-shadow: 0 0 10px var(--accent-2);
}

.btn-warn {
  color: var(--warn);
  border-color: var(--warn);
}

.btn-warn:hover {
  background: var(--warn);
  color: var(--bg);
}

/* Form */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  color: var(--accent-2);
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  border: 1px solid;
  letter-spacing: 1px;
}

.badge-running {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.1);
}

.badge-stopped {
  color: var(--muted);
  border-color: var(--muted);
}

.badge-active {
  color: var(--warn);
  border-color: var(--warn);
  background: rgba(255, 170, 0, 0.1);
}

.badge-done {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

/* ASCII art / sections */
.section {
  border: 1px solid var(--border);
  margin: 16px 0;
  background: var(--surface);
}

.section-header {
  background: var(--surface-light);
  padding: 6px 12px;
  color: var(--accent-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}

.section-body { padding: 12px; }

/* Chat */
.chat-box {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 12px;
  height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 13px;
  user-select: text;
  -webkit-user-select: text;
}

.chat-msg {
  margin-bottom: 8px;
  padding: 6px 10px;
  border-left: 2px solid;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.chat-msg code,
.chat-msg pre,
.chat-msg img,
.chat-msg video,
.chat-msg audio {
  user-select: text;
  -webkit-user-select: text;
}

.chat-user {
  border-color: var(--accent-2);
  color: var(--fg);
}

.chat-agent {
  border-color: var(--accent);
  color: var(--fg-bright);
  background: var(--surface);
}

.chat-meta {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 2px;
  user-select: text;
  -webkit-user-select: text;
}

/* Markdown rendering for agent messages */
.msg-body { color: var(--fg); line-height: 1.55; }
.msg-body p { margin: 6px 0; }
.msg-body p:first-child { margin-top: 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { color: var(--accent-2); font-weight: 700; }
.msg-body em { color: var(--fg-bright); font-style: italic; }
.msg-body code {
  background: var(--bg-dark);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  border: 1px solid var(--border);
}
.msg-body pre {
  background: var(--bg-dark);
  color: var(--fg-bright);
  padding: 10px 12px;
  border-left: 3px solid var(--accent-2);
  border-radius: 3px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 1em;
}
.msg-body ul, .msg-body ol { margin: 6px 0; padding-left: 24px; }
.msg-body li { margin: 3px 0; }
.msg-body ul li { list-style: disc; }
.msg-body ol li { list-style: decimal; }
.msg-body blockquote {
  border-left: 3px solid var(--muted);
  padding: 2px 0 2px 12px;
  color: var(--muted);
  margin: 8px 0;
  font-style: italic;
}
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  margin: 14px 0 6px 0;
  color: var(--accent-2);
  font-weight: 700;
  line-height: 1.3;
}
.msg-body h1 { font-size: 1.3em; }
.msg-body h2 { font-size: 1.2em; }
.msg-body h3 { font-size: 1.1em; }
.msg-body h4 { font-size: 1.0em; }
.msg-body h1:first-child, .msg-body h2:first-child, .msg-body h3:first-child, .msg-body h4:first-child { margin-top: 0; }
.msg-body a { color: var(--accent-2); text-decoration: underline; }
.msg-body a:hover { color: var(--accent); }
.msg-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
.msg-body table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.9em;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.msg-body th { background: var(--bg-dark); color: var(--accent-2); }

/* Selection highlight inside chat */
.chat-box ::selection,
.chat-msg ::selection {
  background: var(--accent);
  color: var(--bg);
  -webkit-text-fill-color: var(--bg);
}

/* Obsidian list */
.file-list {
  list-style: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-bottom: 1px dotted var(--border);
  text-decoration: none;
  color: var(--fg);
}

.file-item:hover {
  background: var(--surface-light);
  color: var(--accent);
}

.file-icon {
  color: var(--accent-2);
  font-family: monospace;
}

.file-name { flex: 1; }
.file-size { color: var(--muted); font-size: 11px; }

/* Markdown viewer */
.markdown-view {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 20px;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--fg);
  overflow-x: auto;
}

/* Banner */
.banner {
  background: var(--surface);
  border: 1px dashed var(--accent);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}

.banner-ascii {
  color: var(--accent);
  font-size: 10px;
  line-height: 1.2;
  white-space: pre;
}

.banner-sub {
  color: var(--accent-2);
  font-size: 11px;
  margin-top: 8px;
  letter-spacing: 2px;
}

/* Mobile */
@media (max-width: 768px) {
  .main { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .sidebar-section { display: inline-block; padding: 0; border: none; }
  .sidebar-section:not(:last-child) { margin-right: 8px; }
  .sidebar-label, .sidebar-footer { display: none; }
  .nav-item { display: inline-flex; padding: 6px 10px; }
  .content { padding: 16px; }
}
