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

:root {
  --bg: #0d1117;
  --bg-light: #161b22;
  --bg-hover: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #7d8590;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --cyan: #39d353;
  --sidebar-width: 260px;
}

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-light);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.2s;
}

.sidebar.hidden {
  margin-left: calc(-1 * var(--sidebar-width));
}

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

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}

.sidebar-header button {
  background: var(--bg);
  color: var(--green);
  border: 1px solid var(--border);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sidebar-header button:hover {
  border-color: var(--green);
  background: rgba(63, 185, 80, 0.1);
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.session-item:hover {
  background: var(--bg-hover);
}

.session-item.active {
  background: var(--bg);
  border: 1px solid var(--border);
}

.session-item .session-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item .session-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  color: var(--green);
  font-size: 14px;
}

.title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.status.online {
  color: var(--green);
  background: rgba(63, 185, 80, 0.15);
}

.status.offline {
  color: var(--red);
  background: rgba(248, 81, 73, 0.15);
}

header button {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

header button:hover {
  color: var(--text);
  border-color: var(--accent);
}

#btn-sidebar {
  font-size: 14px;
  padding: 4px 8px;
}

#btn-delete-session {
  color: var(--red);
}

#btn-delete-session:hover {
  border-color: var(--red);
}

/* Terminal output */
#terminal {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

#output {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.msg {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  background: var(--bg-light);
  border-left: 3px solid var(--accent);
}

.msg.user .label {
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 4px;
}

.msg.assistant {
  background: transparent;
  border-left: 3px solid var(--green);
}

.msg.assistant .label {
  color: var(--green);
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 4px;
}

.msg.system {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  border: none;
  padding: 4px;
}

.msg.error {
  color: var(--red);
  border-left: 3px solid var(--red);
  background: rgba(248, 81, 73, 0.08);
}

.msg.error .label {
  color: var(--red);
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 4px;
}

.msg .duration {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 4px;
}

.tool-call {
  color: var(--cyan);
  font-size: 12px;
  margin: 4px 0;
  padding: 2px 0;
  border-left: 2px solid var(--cyan);
  padding-left: 8px;
  white-space: pre-wrap;
}

/* Input bar */
#input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-light);
}

.prompt-symbol {
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
  padding-bottom: 4px;
}

#input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

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

#btn-send {
  background: var(--accent);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

#btn-send:hover {
  opacity: 0.85;
}

#btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Question UI */
.question-container {
  background: var(--bg-light);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
}

.question-title {
  color: var(--yellow);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 10px;
}

.question-item {
  margin-bottom: 12px;
}

.question-header {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-option {
  background: var(--bg);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.question-option:hover {
  border-color: var(--accent);
  color: var(--text);
}

.question-option.selected {
  border-color: var(--green);
  color: var(--green);
  background: rgba(63, 185, 80, 0.1);
}

.question-option .opt-desc {
  color: var(--text-dim);
  font-size: 11px;
}

.question-submit {
  margin-top: 10px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.question-submit:hover {
  opacity: 0.85;
}

.question-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Scrollbar */
#terminal::-webkit-scrollbar,
.session-list::-webkit-scrollbar {
  width: 6px;
}

#terminal::-webkit-scrollbar-track,
.session-list::-webkit-scrollbar-track {
  background: transparent;
}

#terminal::-webkit-scrollbar-thumb,
.session-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }
  .sidebar.hidden {
    margin-left: calc(-1 * var(--sidebar-width));
  }
  #main {
    width: 100%;
  }
}
