:root {
  --bg: #0f0f10;
  --bg-elev: #1a1a1c;
  --bg-input: #1f1f22;
  --border: #2a2a2e;
  --text: #ececec;
  --text-dim: #9a9a9f;
  --accent: #3b82f6;
  --user-bg: #2a2a2e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  flex-shrink: 0;
}
.brand {
  font-weight: 600;
  letter-spacing: 2px;
  font-size: 15px;
  color: var(--text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.session-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.session-timer.warning { color: #d2a96d; border-color: #d2a96d44; }
.session-timer.danger { color: #ff6b6b; border-color: #ff6b6b44; }

.topbar button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.topbar button:hover {
  color: var(--text);
  border-color: #3a3a3e;
}

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #2a2a2e; border-radius: 4px; }
.messages::-webkit-scrollbar-track { background: transparent; }

.msg-wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
}
.msg-wrap.user { justify-content: flex-end; }
.msg-wrap.assistant { justify-content: flex-start; }

.msg {
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.6;
}

.msg.user {
  background: var(--user-bg);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 18px;
  max-width: 80%;
}

.msg.assistant {
  background: transparent;
  color: var(--text);
  padding: 0;
  max-width: 100%;
  width: 100%;
}

.msg.system-note {
  background: transparent;
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  width: 100%;
  padding: 8px 0;
}

/* Composer */
.composer {
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
  background: var(--bg);
  flex-shrink: 0;
}
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.composer textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  padding: 11px 14px;
  resize: none;
  max-height: 220px;
  outline: none;
  transition: border-color 0.15s;
}
.composer textarea:focus { border-color: #3a3a3e; }
.composer textarea::placeholder { color: var(--text-dim); }
.composer textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.composer button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s;
}
.composer button:hover { opacity: 0.9; }
.composer button:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--text-dim);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 600px) {
  .messages { padding: 16px 12px; }
  .composer { padding: 10px 12px 14px; }
}
