:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --bubble-user: #2563eb;
  --bubble-user-fg: #ffffff;
  --bubble-agent: #f3f4f6;
  --bubble-agent-fg: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --fg: #f3f4f6;
    --muted: #9ca3af;
    --border: #374151;
    --bubble-agent: #1f2937;
    --bubble-agent-fg: #f3f4f6;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

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

header h1 { font-size: 1.1rem; margin: 0; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.9rem;
}

#renewalBtn {
  background: transparent;
  color: var(--fg);
}

main#chatLog {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.msg {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  white-space: pre-wrap;
  line-height: 1.4;
}

.msg.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-fg);
}

.msg.agent {
  align-self: flex-start;
  background: var(--bubble-agent);
  color: var(--bubble-agent-fg);
}

.msg.pending { opacity: 0.6; }

#chatForm {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

#chatInput {
  flex: 1;
  font: inherit;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}
