:root {
  --bg: #0e0f13;
  --bg-2: #16181f;
  --bg-3: #1e212b;
  --text: #e8e6e1;
  --text-dim: #9a978f;
  --orange: #FF9300;
  --line: #2a2d38;
  --user-bubble: #232733;
  --radius: 14px;
  font-size: 16px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

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

/* ---------- sidebar ---------- */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 16px;
}

#brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 10px; border-bottom: 1px solid var(--line); }
.brand-mark { font-size: 28px; color: var(--orange); }
.brand-name { font-weight: 700; letter-spacing: 0.04em; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

#agent-list { display: flex; flex-direction: column; gap: 6px; }

.agent-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.agent-card:hover { background: var(--bg-3); }
.agent-card.active { background: var(--bg-3); border-color: var(--accent, var(--orange)); }
.agent-glyph {
  font-size: 20px; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent, var(--orange));
  flex-shrink: 0;
}
.agent-name { font-weight: 600; font-size: 14px; }
.agent-tagline { font-size: 11px; color: var(--text-dim); line-height: 1.3; }

#conv-section { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.conv-header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; padding: 0 6px 8px; }
#new-conv {
  background: none; border: 1px solid var(--line); color: var(--text);
  width: 24px; height: 24px; border-radius: 6px; cursor: pointer; font-size: 15px;
}
#new-conv:hover { border-color: var(--orange); color: var(--orange); }
.conv-item {
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--bg-3); color: var(--text); }
.conv-item.active { background: var(--bg-3); color: var(--text); }
.conv-glyph { margin-right: 6px; }

#status-bar { font-size: 11px; color: var(--text-dim); padding: 8px 6px 0; border-top: 1px solid var(--line); }
#status-bar .warn { color: #e8c547; }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; height: 100vh; }

#chat-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
#chat-agent-glyph {
  font-size: 24px; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg);
  color: var(--orange);
}
#chat-agent-name { font-weight: 700; font-size: 17px; }
#chat-agent-tagline { font-size: 12.5px; color: var(--text-dim); }

#messages {
  flex: 1; overflow-y: auto;
  padding: 28px 0;
  display: flex; flex-direction: column; gap: 18px;
}
.msg { max-width: 760px; width: calc(100% - 96px); margin: 0 auto; display: flex; gap: 14px; }
.msg .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; background: var(--bg-3);
}
.msg.user .avatar { background: var(--user-bubble); color: var(--text-dim); }
.msg.agent .avatar { color: var(--accent, var(--orange)); }
.msg .body { flex: 1; line-height: 1.65; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; padding-top: 5px; }
.msg.user .body { color: var(--text); opacity: 0.92; }
.msg .speak-btn {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px;
  align-self: flex-start; margin-top: 4px;
}
.msg .speak-btn:hover { color: var(--orange); background: var(--bg-3); }
.msg .speak-btn.playing { color: var(--orange); }

.error-note { color: #f87171; font-size: 13px; text-align: center; padding: 8px; }

#composer {
  display: flex; gap: 12px; align-items: flex-end;
  padding: 18px 48px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}
#input {
  flex: 1; resize: none;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; font-size: 15px; font-family: inherit;
  line-height: 1.5; outline: none;
}
#input:focus { border-color: var(--orange); }
#send {
  background: var(--orange); color: #1a1206;
  border: none; border-radius: var(--radius);
  padding: 12px 22px; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
#send:disabled { opacity: 0.4; cursor: default; }

.thinking { color: var(--text-dim); font-style: italic; }
