:root {
  --bg-darkest: #080605;
  --bg-base: #100c0a;
  --bg-card: #18130d;
  --bg-input: #1f1a13;
  --bg-bubble-in: #1f1a13;
  --bg-bubble-out: #2a2218;
  --gold-light: #d4b87e;
  --gold-mid: #b89058;
  --gold-dark: #8b6a3c;
  --text-primary: #f0ebe0;
  --text-secondary: #a89878;
  --text-tertiary: #6e6450;
  --border-subtle: #2a2218;
  --shadow-card: 0 8px 32px rgba(0,0,0,0.6);
  --error: #d56565;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg-darkest);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ===== Login screen ===== */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(ellipse at center, rgba(212,184,126,0.04) 0%, var(--bg-darkest) 70%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-card);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}
.login-brand p {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-mid);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus {
  border-color: var(--gold-light);
}
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(180deg, #d8b67a 0%, #9b7a48 100%);
  color: #100c0a;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.error {
  background: rgba(213,101,101,0.1);
  color: var(--error);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid rgba(213,101,101,0.3);
}
.muted-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ===== Chat screen ===== */
.chat-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg-base);
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-dark) 100%);
  color: #100c0a;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}
.chat-title {
  flex: 1;
  min-width: 0;
}
.chat-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.chat-title p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chat-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4caf50;
}
.chat-status.disconnected { background: var(--error); }
.chat-actions { display: flex; gap: 6px; }
.chat-actions button {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-actions button:hover { border-color: var(--gold-mid); color: var(--gold-light); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.in {
  align-self: flex-end;
  background: var(--bg-bubble-out);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-right-radius: 4px;
}
.msg.out {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--gold-mid);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.day-divider {
  align-self: center;
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: var(--bg-card);
  padding: 4px 12px;
  border-radius: 12px;
  margin: 8px 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  letter-spacing: 0.05em;
}

.chat-composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
}
.chat-composer textarea {
  flex: 1;
  resize: none;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  max-height: 140px;
  min-height: 42px;
  outline: none;
}
.chat-composer textarea:focus { border-color: var(--gold-light); }
.chat-composer .btn {
  width: auto;
  padding: 0 22px;
  flex-shrink: 0;
}

.typing {
  font-size: 12px;
  color: var(--gold-mid);
  padding: 0 22px 8px;
  font-style: italic;
}

/* Force-change-password dialog */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 32px 28px;
}
.modal h3 {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-weight: 500;
  font-size: 18px;
}
.modal p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px;
}
