/* GK Yard Chat — reuses the main site's design tokens so the subdomain
   feels native, not bolted on. */

:root {
  --bg: #fafaf8;
  --card: #ffffff;
  --border: #e8e4dc;
  --text: #111111;
  --text2: #444444;
  --muted: #787878;
  --accent: #e63329;
  --accent-dark: #c02920;
  --accent2: #1a1a6e;
  --tag-bg: #f0ede6;
  --danger: #c02920;
  --success: #1a7a4a;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --card: #181818;
  --border: #2e2e2e;
  --text: #f0f0f0;
  --text2: #c0c0c0;
  --muted: #888888;
  --accent: #ff4d42;
  --accent-dark: #e63329;
  --accent2: #3a3aae;
  --tag-bg: #202020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, sans-serif;
  min-height: 100vh;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 20;
}

.chat-header .brand {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}
.chat-header .brand span { color: var(--accent); }

.chat-header .back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  min-height: calc(100vh - 60px);
}

.room-sidebar {
  width: 220px;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}

.room-sidebar h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 16px;
  margin: 16px 0 8px;
}

.room-link {
  display: block;
  padding: 8px 16px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.room-link:hover { background: var(--tag-bg); }
.room-link.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--tag-bg);
  font-weight: 600;
}

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

.room-title-bar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.room-title-bar h2 { margin: 0 0 4px; font-family: 'Playfair Display', serif; font-size: 18px; }
.pinned-note {
  font-size: 12px;
  color: var(--accent2);
  background: var(--tag-bg);
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 6px;
}

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

.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
}

.online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2ecc71;
  border: 2px solid var(--card);
}

.msg-body { min-width: 0; }
.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.msg-name { font-weight: 600; font-size: 13px; }
.msg-name.role-mod { color: var(--accent2); }
.msg-name.role-admin { color: var(--accent); }
.msg-time { font-size: 11px; color: var(--muted); }
.edited-tag { font-size: 10px; color: var(--muted); font-style: italic; }

.mention { color: var(--accent2); font-weight: 600; background: var(--tag-bg); padding: 0 3px; border-radius: 4px; }
.mention-me { color: #fff; background: var(--accent); }

.edit-form { margin-top: 4px; }
.edit-textarea {
  width: 100%;
  min-height: 50px;
  resize: vertical;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
}
.edit-form-actions { display: flex; gap: 6px; margin-top: 4px; }
.edit-form-actions button {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}
.edit-form-actions .edit-save { background: var(--accent); color: #fff; border-color: var(--accent); }
.msg-content {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg-content.deleted { font-style: italic; color: var(--muted); }

.reply-quote {
  border-left: 3px solid var(--accent2);
  padding: 4px 10px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  background: var(--tag-bg);
  border-radius: 0 6px 6px 0;
}
.reply-quote-name { font-weight: 600; color: var(--accent2); margin-right: 6px; }

.msg-attachment {
  max-width: 260px;
  max-height: 260px;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
  cursor: pointer;
}

.reaction-bar { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.react-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text2);
  line-height: 1.6;
}
.react-btn:hover { border-color: var(--accent); }
.react-btn.reacted { border-color: var(--accent); background: var(--tag-bg); }
.react-add { font-weight: 700; color: var(--muted); }
.react-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
  display: flex;
  gap: 2px;
  z-index: 30;
}
.react-picker-emoji {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
}
.react-picker-emoji:hover { background: var(--tag-bg); }
.react-count { font-size: 11px; color: var(--muted); }

.loading-older { text-align: center; font-size: 12px; color: var(--muted); padding: 8px; }

.msg-actions { display: flex; gap: 6px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted);
  padding: 2px 6px;
}
.msg-actions button:hover { color: var(--accent); }

.composer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  background: var(--card);
  color: var(--text);
  max-height: 120px;
}
.composer button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}
.composer button:hover { background: var(--accent-dark); }
.composer button:disabled { opacity: .5; cursor: not-allowed; }

.char-count { font-size: 11px; color: var(--muted); text-align: right; }

.guest-banner {
  padding: 10px 20px;
  background: var(--tag-bg);
  border-top: 1px solid var(--border);
  font-size: 13px;
  text-align: center;
  color: var(--text2);
}
.guest-banner a { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ── Auth forms ───────────────────────────────────────────── */
.auth-wrap {
  max-width: 380px;
  margin: 60px auto;
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.auth-wrap h2 { font-family: 'Playfair Display', serif; margin-top: 0; }
.auth-wrap label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.auth-wrap input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.auth-wrap button[type="submit"] {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.form-error {
  background: #fdeceb;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
  display: none;
}
[data-theme="dark"] .form-error { background: #3a1a18; }

.avatar-swatch { transition: transform .1s; }
.avatar-swatch:hover { transform: scale(1.1); }

@media (max-width: 700px) {
  .room-sidebar { display: none; }

  .chat-header {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .chat-header .back-link span,
  .chat-header .back-link { font-size: 12px; }
  .chat-header .brand { font-size: 17px; }

  .room-title-bar { padding: 10px 14px; }
  .messages-pane { padding: 12px 14px; gap: 12px; }
  .msg { max-width: 92%; }

  .composer { padding: 10px 12px; }

  /* Reaction/report/delete buttons are hover-revealed on desktop, which
     doesn't exist on touch — show them plainly and give them a real tap
     target (44px is the standard minimum touch target size). */
  .msg-actions { opacity: 1; }
  .msg-actions button {
    padding: 6px 10px;
    min-height: 32px;
  }
  .react-btn { padding: 5px 10px; min-height: 30px; }

  .auth-wrap { margin: 20px 16px; padding: 22px; }

  .admin-wrap table { display: block; overflow-x: auto; white-space: nowrap; }
}
