:root {
  --bg: #0d1117;
  --bg-tool: #161b22;
  --text: #c9d1d9;
  --text-dim: #6e7681;
  --text-bright: #f0f6fc;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --cyan: #39c5cf;
  --border: #30363d;
  --font: 'Cascadia Code', 'SF Mono', 'Fira Code', 'Menlo', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Header — minimal status bar */
header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tool);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
}
#status-indicator { font-size: 10px; }
#status-indicator.online { color: var(--green); }
#status-indicator.offline { color: var(--red); }
#status-indicator.connecting { color: var(--yellow); }
#status-text { color: var(--text-dim); }

/* Terminal area (legacy) */
#terminal {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  scroll-behavior: smooth;
}

/* xterm.js container */
#terminal-container {
  flex: 1;
  overflow: hidden;
}
#terminal-container .xterm {
  height: 100%;
  padding: 4px;
}

/* System messages */
.sys { color: var(--text-dim); font-style: italic; }

/* User input echo */
.user-input { color: var(--blue); }
.user-input::before { content: '❯ '; color: var(--green); }

/* Agent text */
.agent-text { color: var(--text); }

/* Streaming cursor */
.cursor { 
  display: inline-block; 
  width: 7px; height: 14px; 
  background: var(--text); 
  animation: blink 0.7s infinite; 
  vertical-align: text-bottom;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Tool calls */
.tool-call {
  margin: 4px 0;
  border-left: 2px solid var(--blue);
  padding: 2px 0 2px 8px;
  color: var(--text-dim);
  font-size: 12px;
}
.tool-call.completed { border-left-color: var(--green); }
.tool-call.failed { border-left-color: var(--red); }
.tool-call .tool-icon { margin-right: 4px; }
.tool-call .tool-name { color: var(--cyan); }
.tool-call .tool-status { margin-left: 8px; }
.tool-call .tool-status.completed { color: var(--green); }
.tool-call .tool-status.failed { color: var(--red); }
.tool-call .tool-status.in_progress { color: var(--yellow); }

/* Tool call content (expandable) */
.tool-body { display: none; margin-top: 4px; }
.tool-call.expanded .tool-body { display: block; }

/* Diff blocks */
.diff { margin: 4px 0; font-size: 12px; }
.diff-header { color: var(--text-dim); }
.diff-add { color: var(--green); }
.diff-add::before { content: '+ '; }
.diff-del { color: var(--red); }
.diff-del::before { content: '- '; }

/* Code blocks */
.code-block {
  background: var(--bg-tool);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 4px 0;
  overflow-x: auto;
  font-size: 12px;
}
.code-header { color: var(--text-dim); font-size: 11px; margin-bottom: 2px; }

/* Permission dialog */
#permission-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 60px;
  z-index: 100;
}
#permission-overlay.hidden { display: none; }
.perm-dialog {
  background: var(--bg-tool);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  padding: 12px;
  width: calc(100% - 24px);
  max-width: 400px;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
}
.perm-dialog h3 { color: var(--yellow); font-size: 14px; margin-bottom: 6px; flex-shrink: 0; }
.perm-dialog p { font-size: 12px; color: var(--text); margin-bottom: 10px; overflow-y: auto; flex: 1; min-height: 0; }
.perm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; padding-top: 4px; }
.perm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.perm-actions button {
  padding: 6px 16px; border: none; border-radius: 4px;
  cursor: pointer; font-size: 13px; font-family: var(--font);
}
.btn-approve { background: var(--green); color: #000; }
.btn-deny { background: var(--red); color: #fff; }

/* Input area */
#input-area {
  padding: 4px 8px 6px;
  background: var(--bg-tool);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#key-bar {
  display: flex;
  gap: 4px;
  padding: 4px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#key-bar button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 36px;
  -webkit-tap-highlight-color: transparent;
}
#key-bar button:active { background: var(--blue); color: #000; }
#input-form {
  display: flex;
  align-items: center;
  gap: 4px;
}
.prompt { color: var(--green); font-weight: bold; }
#input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-bright);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  caret-color: var(--green);
}
#input::placeholder { color: var(--text-dim); }

.hidden { display: none !important; }

/* Dashboard */
#dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.session-card {
  background: var(--bg-tool);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.session-card:hover { border-color: var(--blue); }
.session-card .status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.session-card .status-dot.online { background: var(--green); }
.session-card .status-dot.offline { background: var(--text-dim); }
.session-card .info { flex: 1; min-width: 0; }
.session-card .repo { color: var(--blue); font-weight: bold; font-size: 13px; }
.session-card .branch { color: var(--text-dim); font-size: 11px; }
.session-card .machine { color: var(--text-dim); font-size: 11px; }
.session-card .arrow { color: var(--text-dim); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
