:root {
  --bg: #0f1115;
  --panel: #161a21;
  --panel-2: #1d222b;
  --text: #e6e8eb;
  --muted: #8c95a3;
  --accent: #4c8bf5;
  --accent-text: #ffffff;
  --them: #232934;
  --you: #2d6cdf;
  --border: #242a35;
  --error: #ff6b6b;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --text: #15171a;
    --muted: #6a7280;
    --them: #eef0f3;
    --you: #2d6cdf;
    --border: #e3e6eb;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

#app {
  height: 100dvh;
  display: flex;
  justify-content: center;
}

.view {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

/* --- Login --- */

#login-view {
  justify-content: center;
  align-items: center;
  padding: 24px;
}

#login-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form h1 {
  margin: 0 0 8px;
  font-size: 22px;
  text-align: center;
}

#login-form input,
#login-form button {
  font: inherit;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

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

#login-form button {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
  cursor: pointer;
  font-weight: 600;
}

.error {
  color: var(--error);
  font-size: 13px;
  margin: 0;
  text-align: center;
}

/* --- Chat --- */

#chat-view {
  height: 100dvh;
}

#chat-view header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

#chat-view header .title {
  font-weight: 600;
  flex: 1;
}

#chat-view header button {
  font: inherit;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}

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

.msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.msg.them {
  align-self: flex-start;
  background: var(--them);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg.you {
  align-self: flex-end;
  background: var(--you);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg .time {
  display: block;
  font-size: 11px;
  opacity: 0.65;
  margin-top: 2px;
}

#send-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  align-items: end;
}

#text {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  outline: none;
}

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

#send-btn {
  font: inherit;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 600;
}

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