@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg-color: #0f0c14;
  --panel-color: #1c1924;
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f1e7ff;
  --text-muted: #c5b8d9;
  --accent-color: #c0267a;
  --accent-hover: #d63d8f;
  --bubble-user: #8b1a5a;
  --bubble-peer: #211d2b;
  --gold: #d4af77;
  --ok: #7dcea0;
  --font: 'Inter', system-ui, sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 1.25rem;
}

.top {
  width: 100%;
  max-width: 880px;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand img {
  height: 42px;
  width: auto;
  border-radius: 10px;
  object-fit: contain;
}

.brand strong {
  font-family: var(--serif);
  font-size: 1.05rem;
  display: block;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--accent-color);
}

.chat-container {
  width: 100%;
  max-width: 800px;
  height: min(78vh, 720px);
  background-color: var(--panel-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -18px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(15, 12, 20, 0.55);
}

.chat-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--serif);
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-pill {
  font-size: 0.72rem;
  color: var(--gold);
  border: 1px solid rgba(212, 175, 119, 0.35);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.nick-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nick-input {
  width: 120px;
  padding: 0.4rem 0.55rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-main);
  font: inherit;
  font-size: 0.85rem;
}

.nick-input:focus {
  outline: none;
  border-color: rgba(192, 38, 122, 0.55);
}

.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--ok);
  border-radius: 50%;
  margin-right: 8px;
  box-shadow: 0 0 8px var(--ok);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.message {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.94rem;
  line-height: 1.45;
  word-wrap: break-word;
}

.message .msg-meta {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  opacity: 0.75;
}

.message .msg-time {
  display: block;
  font-size: 0.68rem;
  opacity: 0.55;
  margin-top: 0.4rem;
  text-align: right;
}

.message.user {
  background-color: var(--bubble-user);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.message.user .msg-meta {
  color: #ffd6ec;
}

.message.peer {
  background-color: var(--bubble-peer);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.message.system {
  max-width: 100%;
  align-self: stretch;
  background: rgba(192, 38, 122, 0.08);
  border-color: rgba(192, 38, 122, 0.25);
  color: var(--text-muted);
  font-size: 0.88rem;
}

.chat-input-area {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 12, 20, 0.55);
  display: flex;
  gap: 10px;
}

.chat-input-area input {
  flex: 1;
  padding: 12px 14px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-area input:focus {
  border-color: rgba(192, 38, 122, 0.55);
  box-shadow: 0 0 0 3px rgba(192, 38, 122, 0.15);
}

.chat-input-area button {
  padding: 0 1.25rem;
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
}

.chat-input-area button:hover {
  filter: brightness(1.08);
}

.chat-input-area button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.foot-note {
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.foot-note a {
  color: var(--accent-color);
  text-decoration: none;
}

.foot-note a:hover {
  color: #ffb3d9;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

@media (max-width: 640px) {
  .chat-container {
    height: min(72vh, 640px);
  }
  .message {
    max-width: 90%;
  }
  .nick-input {
    width: 100px;
  }
}

/* ---- Multiusuario layout ---- */
.chat-layout {
  width: 100%;
  max-width: 1080px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: stretch;
  min-height: min(78vh, 720px);
}

.online-panel {
  background: var(--panel-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  max-height: min(78vh, 720px);
}

.online-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.online-head h3 {
  font-size: 0.95rem;
  font-family: var(--serif);
  letter-spacing: -0.02em;
}

.online-count {
  min-width: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ok);
  background: rgba(125, 206, 160, 0.12);
  border: 1px solid rgba(125, 206, 160, 0.35);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.online-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.online-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.online-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  padding: 0.35rem 0.4rem;
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.03);
}

.online-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  flex-shrink: 0;
}

.online-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-item .tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: auto;
}

.online-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.5rem 0.25rem;
}

.online-rules {
  border-top: 1px solid var(--border-color);
  padding-top: 0.65rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.online-rules strong {
  display: block;
  color: var(--gold);
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
}

.online-rules ul {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.45;
}

.chat-layout .chat-container {
  max-width: none;
  height: min(78vh, 720px);
  width: 100%;
}

.chat-anon-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: rgba(241, 231, 255, 0.7);
  flex-wrap: wrap;
}

.anon-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.identity-hint {
  opacity: 0.85;
  font-size: 0.78rem;
}

.mod-status {
  margin: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  color: #e8a094;
  background: rgba(232, 160, 148, 0.08);
  border-top: 1px solid rgba(232, 160, 148, 0.25);
}

.mod-status.is-error {
  color: #ffb3a8;
}

.cloud-banner {
  width: 100%;
  max-width: 1080px;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(232, 160, 148, 0.1);
  border: 1px solid rgba(232, 160, 148, 0.35);
  color: #e8a094;
  font-size: 0.85rem;
  line-height: 1.45;
}

.cloud-banner code {
  font-size: 0.8em;
  color: #ffd4c8;
}

.mode-pill.is-cloud {
  color: var(--ok);
  border-color: rgba(125, 206, 160, 0.45);
}

.mode-pill.is-offline {
  color: #e8a094;
  border-color: rgba(232, 160, 148, 0.45);
}

.message.system .msg-body a {
  color: #ffb3d9;
}

@media (max-width: 820px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
  .online-panel {
    max-height: none;
    order: 2;
  }
  .chat-layout .chat-container {
    order: 1;
    height: min(70vh, 640px);
  }
}
