:root {
  --bg: #0a0e14;
  --bg-surface: #0d1117;
  --bg-elevated: #161b22;
  --border: #21262d;
  --border-focus: #58a6ff;
  --text: #e6edf3;
  --text-dim: #7d8590;
  --text-muted: #484f58;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --radius: 6px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* HEADER */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  height: 40px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.logo { font-weight: 700; font-size: 14px; color: var(--accent); }

.badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.model { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange);
}
.status-dot.ok { background: var(--green); }
.status-dot.error { background: var(--red); }
.status-dot.loading { animation: pulse 1s infinite; }
.status-text { color: var(--text-dim); font-size: 11px; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.header-right { display: flex; gap: 6px; }
.header-right button {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
}
.header-right button:hover { color: var(--text); border-color: var(--border-focus); }

/* BOOT SCREEN */
#boot-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px;
}

#boot-screen.hidden { display: none; }

.boot-robot pre {
  color: var(--accent);
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
}

#boot-log {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.boot-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.boot-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}

#boot-steps {
  text-align: left;
  font-size: 12px;
  line-height: 2;
  color: var(--text-dim);
}

.step-ok { color: var(--green); }
.step-ok::before { content: '✓ '; }
.step-fail { color: var(--red); }
.step-fail::before { content: '✗ '; }
.step-loading { color: var(--orange); }
.step-loading::before { content: '⟳ '; }

#boot-progress {
  margin-top: 16px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

#boot-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.4s ease;
}

#boot-error {
  margin-top: 12px;
  padding: 12px;
  background: rgba(248,81,73,0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 12px;
  text-align: left;
}

#boot-config {
  margin-top: 20px;
  text-align: left;
}

#boot-config label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

#boot-config input {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
}

#boot-config input:focus { border-color: var(--border-focus); }

#btn-save-key {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}
#btn-save-key:hover { background: var(--accent); }

#boot-config .note {
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.hidden { display: none !important; }

/* MAIN TERMINAL */
#main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#terminal-container {
  flex: 1;
  padding: 4px;
}

#terminal-container .xterm {
  height: 100%;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  width: 440px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 { font-size: 15px; margin-bottom: 16px; color: var(--accent); }

.modal-content label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.modal-content input {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px;
  outline: none;
}

.modal-content pre {
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
  overflow-x: auto;
}

.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions button {
  padding: 7px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  color: var(--text-dim);
}
#btn-cfg-save { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
