:root {
  --ink: #12151b;
  --panel: #191d25;
  --panel-raised: #20242e;
  --border: #2a2f3a;
  --text: #eceef2;
  --text-dim: #8a92a3;
  --accent: #e8a33d;
  --accent-dim: #7a5a2c;
  --danger: #e0645a;
  --online: #5fbf8f;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

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

.screen {
  height: 100vh;
  width: 100%;
}

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--accent);
  transform: rotate(45deg);
  display: inline-block;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

/* ---------- Auth screen ---------- */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(232, 163, 61, 0.08), transparent 40%),
    var(--ink);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 360px;
}

.brand-sub {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0.5rem 0 2rem;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.field input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus {
  border-color: var(--accent);
}

.field input::placeholder {
  color: #545b6b;
}

.btn-primary {
  margin-top: 0.4rem;
  background: var(--accent);
  color: #1a1408;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.auth-error {
  background: rgba(224, 100, 90, 0.12);
  border: 1px solid rgba(224, 100, 90, 0.35);
  color: #f2a49d;
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font-size: 0.82rem;
  margin: 0;
}

.auth-toggle {
  margin-top: 1.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.4rem;
}

.auth-toggle button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.4rem 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease;
}

.btn-google:hover { border-color: var(--text-dim); filter: brightness(1.08); }
.btn-google:disabled { opacity: 0.6; cursor: default; }


/* ---------- Private messaging ---------- */

.dm-tools {
  min-width: 0;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 0.55rem 0.25rem;
}

.user-search {
  display: flex;
  gap: 0.35rem;
}

.user-search input {
  min-width: 0;
  width: 100%;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.55rem 0.6rem;
  color: var(--text);
  outline: none;
  font-size: 0.74rem;
}

.user-search input:focus {
  border-color: var(--accent);
}

.btn-small {
  margin-top: 0;
  padding: 0.45rem 0.55rem;
  font-size: 0.72rem;
}

.search-status {
  color: var(--text-dim);
  font-size: 0.7rem;
  line-height: 1.35;
  margin: 0.5rem 0.25rem;
}

.search-results,
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.user-result,
.conversation-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.45rem;
  color: var(--text);
  cursor: pointer;
}

.user-result:hover,
.conversation-item:hover,
.conversation-item.active {
  background: var(--panel-raised);
  border-color: var(--border);
}

.result-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  color: #f2d8b0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
}

.user-result span:last-child,
.conversation-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.user-result strong,
.conversation-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
}

.user-result small,
.conversation-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 0.62rem;
}

.conversations-label {
  margin-top: 1.15rem;
}

.conversation-empty {
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 0.25rem;
}

.btn-notifications {
  width: 100%;
  margin-bottom: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-dim);
  padding: 0.48rem 0.55rem;
  font-size: 0.7rem;
  cursor: pointer;
}

.btn-notifications:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn-notifications.enabled {
  border-color: rgba(95, 191, 143, 0.5);
  color: var(--online);
}

.chat-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 0.8rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--ink);
}

.chat-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.chat-subtitle {
  color: var(--text-dim);
  font-size: 0.72rem;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---------- Chat screen ---------- */

#chat-screen {
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
}

.sidebar-top { margin-bottom: 1.75rem; }

.room-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.5rem;
  border-radius: 8px;
  background: var(--panel-raised);
}

.room-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(95, 191, 143, 0.15);
}

.room-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.room-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.sidebar-spacer { flex: 1; }

.me {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.me-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #f2d8b0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-display);
  flex-shrink: 0;
  text-transform: uppercase;
}

.me-email {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-ghost:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.chat-pane {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.msg {
  max-width: 62ch;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.msg-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.msg.is-me .msg-author { color: #7fd6c0; }

.msg-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}

.msg-body {
  font-size: 0.94rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg-empty {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: auto;
  text-align: center;
}

.composer {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0.7rem 1.1rem;
  color: var(--text);
  font-size: 0.94rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s ease;
}

.composer input:focus { border-color: var(--accent); }

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #1a1408;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s ease;
}

.btn-send:hover { filter: brightness(1.08); }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  #chat-screen { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 1rem;
  }
  .sidebar-top { margin-bottom: 0; }
  .room-info { display: none; }
  .dm-tools { flex: 1; }
  .user-search { display: none; }
  .section-label, .search-results, .conversations-label, .conversation-list { display: none; }
  .btn-notifications { width: auto; margin: 0; padding: 0.4rem; }
  .chat-header { padding: 0.7rem 1rem; }
  .sidebar-spacer { display: none; }
  .me { border-top: none; padding-top: 0; }
  .me-email { display: none; }
  .messages { padding: 1rem 1rem 0.5rem; }
  .composer { padding: 0.8rem 1rem 1.1rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Admin / moderation ---------- */
.admin-tools {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.admin-change-form { margin-top: .5rem; }
.admin-user-result { margin-top: .45rem; }
.admin-user-card {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-raised);
}
.admin-user-card strong { font-size: .72rem; overflow-wrap: anywhere; }
.admin-user-card small { color: var(--text-dim); font-size: .62rem; }
.admin-actions { display: flex; gap: .35rem; margin-top: .25rem; }
.admin-action { font-size: .65rem; padding: .3rem .45rem; }
.admin-messages-label { margin-top: .9rem; }
.admin-messages {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.admin-message-row {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-raised);
}
.admin-message-row > div { min-width: 0; }
.admin-message-row strong { font-size: .66rem; overflow-wrap: anywhere; }
.admin-message-row small { display: block; color: var(--text-dim); font-size: .57rem; }
.admin-message-row p { margin: .3rem 0 0; font-size: .67rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-block { margin-left: auto; }
.deleted { color: var(--text-dim); font-style: italic; }
.blocked-notice {
  padding: .45rem 2rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: .72rem;
}
