:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --panel: #f5f5f7;
  --border: #e2e2e6;
  --text: #1c1c1f;
  --muted: #6b6b73;
  --accent: #c96442;
  --accent-fg: #ffffff;
  --bubble-user: #eef1f4;
  --bubble-assistant: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --panel: #212121;
    --border: #333333;
    --text: #ececec;
    --muted: #9a9a9a;
    --bubble-user: #2a2a2a;
    --bubble-assistant: #191919;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* Auth screen */
.auth-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-card h1 {
  font-size: 1.3rem;
  margin: 0;
}

.auth-card .hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.auth-card input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.auth-card button {
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.95rem;
  cursor: pointer;
}

.auth-card button:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-message {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

/* App layout */
.app-screen {
  height: 100%;
  display: flex;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 12px;
}

.sidebar-header button {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

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

.conversation-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.conversation-item:hover {
  background: var(--bubble-user);
}

.conversation-item.active {
  background: var(--bubble-user);
  font-weight: 600;
}

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

.user-email {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  text-decoration: underline;
  padding: 0;
  flex-shrink: 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  max-width: 720px;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.95rem;
}

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

.msg.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--border);
}

.msg.pending {
  color: var(--muted);
}

.empty-state {
  margin: auto;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.chat-input-row button {
  padding: 0 20px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  font-size: 0.9rem;
}

.chat-input-row button:disabled {
  opacity: 0.6;
  cursor: default;
}
