/* The Village — warm, dignity-first design. System fonts only (independent). */

:root {
  --cream: #faf5ec;
  --cream-deep: #f3ecdc;
  --card: #fffdf8;
  --ink: #4a4238;
  --ink-soft: #7a6f61;
  --sage: #7c8b6f;
  --sage-dark: #5f6f54;
  --sage-pale: #e9efe2;
  --terra: #c4704f;
  --terra-dark: #a85638;
  --terra-pale: #f7e8dd;
  --gold: #d9a441;
  --line: #e7ddc9;
  --danger: #b0492f;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(122, 96, 60, 0.10);
  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; color: var(--ink); }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 20% 10%, #fbf3e2 0%, var(--cream) 55%);
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%; max-width: 420px;
  text-align: center;
}
.logo-mark { font-size: 44px; }
.logo-mark.small { font-size: 22px; }
.auth-card h1 { margin: 8px 0 4px; font-size: 34px; }
.tagline { color: var(--ink-soft); margin: 0 0 12px; font-size: 15px; }
.auth-intro { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.auth-tabs { display: flex; gap: 8px; margin: 18px 0; }
.auth-tab {
  flex: 1; padding: 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--cream-deep); color: var(--ink-soft); font-size: 15px; cursor: pointer;
}
.auth-tab.active { background: var(--sage); border-color: var(--sage); color: #fff; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-form label { font-size: 13px; font-weight: 600; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px; }
.auth-form input, .row-form input, #report-modal input {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 16px; background: #fff; color: var(--ink); width: 100%;
}
.auth-form input:focus { outline: 2px solid var(--sage); border-color: var(--sage); }
.btn-primary {
  background: var(--terra); color: #fff; border: none; border-radius: 999px;
  padding: 13px 22px; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn-primary:hover { background: var(--terra-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary {
  background: var(--sage); color: #fff; border: none; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-secondary:hover { background: var(--sage-dark); }
.auth-hint { font-size: 12.5px; color: var(--ink-soft); text-align: center; margin: 4px 0 0; }
.auth-error { color: var(--danger); font-size: 14px; text-align: center; margin: 4px 0 0; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Chat layout ---------- */
#chat-view { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.channel-title-wrap { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.channel-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-count { font-size: 12.5px; color: var(--sage-dark); white-space: nowrap; }
.icon-btn {
  background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px 8px;
  border-radius: 10px; color: var(--ink);
}
.icon-btn:hover { background: var(--cream-deep); }
.help-btn {
  background: var(--terra-pale); color: var(--terra-dark); border: 1px solid var(--terra);
  border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.help-btn:hover { background: var(--terra); color: #fff; }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  padding: 16px 12px; overflow-y: auto;
}
.side-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 6px 8px 8px; }
.channel-list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.channel-list button {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 9px 10px; border-radius: 12px; font-size: 15px; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.channel-list button:hover { background: var(--cream-deep); }
.channel-list button.active { background: var(--sage-pale); font-weight: 700; }
.channel-list .lock { font-size: 12px; color: var(--ink-soft); }
.side-btn {
  width: 100%; text-align: left; background: var(--cream-deep); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 10px; font-size: 14px; cursor: pointer; margin-bottom: 6px; color: var(--ink);
}
.side-btn:hover { background: var(--line); }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; font-weight: 700; }
.side-foot { margin-top: 20px; font-size: 12px; color: var(--ink-soft); line-height: 1.5; padding: 0 8px; }
.scrim { position: fixed; inset: 0; background: rgba(74,66,56,.35); z-index: 25; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--cream); }
.pinned-bar {
  background: var(--sage-pale); border-bottom: 1px solid var(--line);
  padding: 8px 16px; font-size: 13px; color: var(--sage-dark);
  max-height: 76px; overflow-y: auto;
}
.messages { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.day-divider { text-align: center; font-size: 12px; color: var(--ink-soft); margin: 10px 0; }

.msg { display: flex; gap: 10px; padding: 7px 10px; border-radius: 14px; }
.msg:hover { background: rgba(255,255,255,.65); }
.msg.own { background: var(--terra-pale); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--sage); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; font-family: var(--font-display);
}
.avatar.bot { background: var(--gold); }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.nick { font-weight: 700; font-size: 14.5px; }
.role-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px; background: var(--cream-deep); color: var(--ink-soft);
}
.role-badge.moderator { background: var(--sage); color: #fff; }
.role-badge.admin { background: var(--terra); color: #fff; }
.role-badge.bot { background: var(--gold); color: #fff; }
.time { font-size: 11.5px; color: var(--ink-soft); }
.msg-text { font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.msg-actions { display: none; gap: 4px; margin-top: 6px; }
.msg:hover .msg-actions { display: flex; flex-wrap: wrap; }
.mini-btn {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; padding: 4px 10px; cursor: pointer; color: var(--ink-soft);
}
.mini-btn:hover { border-color: var(--sage); color: var(--ink); }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.pin-mark { font-size: 12px; color: var(--gold); }

.typing { padding: 4px 18px; font-size: 13px; color: var(--ink-soft); font-style: italic; min-height: 22px; }
.composer {
  display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; padding: 13px 16px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 16px; background: #fff; color: var(--ink);
}
.composer input:focus { outline: 2px solid var(--sage); border-color: var(--sage); }
.composer .send { width: 52px; height: 52px; padding: 0; font-size: 20px; flex-shrink: 0; }
.composer.disabled input, .composer.disabled .send { opacity: .5; pointer-events: none; }

.menu-pop {
  position: absolute; top: 58px; right: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 8px; z-index: 40; min-width: 200px;
}
.menu-nick { margin: 6px 10px 10px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.menu-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px; border-radius: 10px; font-size: 15px; cursor: pointer; color: var(--ink);
}
.menu-item:hover { background: var(--cream-deep); }

/* ---------- Modals ---------- */
[hidden] { display: none !important; }
.modal-wrap {
  position: fixed; inset: 0; background: rgba(74,66,56,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--card); border-radius: 24px; padding: 30px 28px; width: 100%; max-width: 440px;
  max-height: 88dvh; overflow-y: auto; position: relative; box-shadow: var(--shadow);
}
.modal.wide { max-width: 620px; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal h2 { margin-top: 0; font-size: 24px; }
.modal h3 { font-size: 18px; margin: 22px 0 10px; }
.modal p { color: var(--ink-soft); line-height: 1.6; font-size: 14.5px; }
.help-list { list-style: none; padding: 0; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.help-list li { background: var(--sage-pale); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; line-height: 1.5; }
.help-list li strong { display: block; margin-bottom: 2px; }
.help-note { font-size: 13px; }
.row-form { display: flex; gap: 8px; margin-bottom: 12px; }
.invite-list, .user-list, .queue-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.invite-list li, .user-list li, .queue-item {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px;
}
.invite-code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .06em; color: var(--terra-dark); }
.used-tag { color: var(--ink-soft); font-size: 12.5px; }
.user-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-list .grow { flex: 1; font-weight: 600; }
.queue-item .q-body { background: var(--cream-deep); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-style: italic; }
.queue-item .q-meta { font-size: 12.5px; color: var(--ink-soft); }
.queue-item .q-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.muted { color: var(--ink-soft); font-style: italic; }

/* ---------- Mobile ---------- */
#menu-btn { display: none; }
@media (max-width: 760px) {
  #menu-btn { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 26;
    transform: translateX(-105%); transition: transform .22s ease;
    width: 270px; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .brand-name { display: none; }
  .help-btn { padding: 8px 10px; font-size: 12.5px; }
}

/* ---------- Admin page (separate view) ---------- */
.admin-page { min-height: 100dvh; background: var(--cream); }
.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.admin-topbar .brand { margin-left: auto; }
.admin-body { max-width: 680px; margin: 0 auto; padding: 26px 18px 70px; }
.admin-body h2 { margin: 0 0 6px; font-size: 26px; }
.admin-body h3 { font-size: 18px; margin: 26px 0 10px; }
