/* ============ Design tokens — Supernatural OS brand system ============ */
:root {
  --bg: #050505;
  --bg-2: #101010;
  --surface: #161616;
  --surface-2: #1E1E1E;
  --border: rgba(244, 243, 238, 0.10);
  --border-strong: rgba(244, 243, 238, 0.22);
  --text: #F4F3EE;
  --text-muted: #93969C;
  --body-text: #D7D6D0;
  --accent: #FCF354;
  --accent-ink: #111111;
  --accent-dim: rgba(252, 243, 84, 0.28);
  --accent-tint: rgba(252, 243, 84, 0.06);
  --danger: #FF6B6B;
  --danger-soft: rgba(255, 107, 107, 0.12);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Space Mono', monospace;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

[data-theme="light"] {
  --bg: #F7F6F1;
  --bg-2: #EFEEE9;
  --surface: #FFFFFF;
  --surface-2: #F1F0EA;
  --border: rgba(20, 20, 20, 0.12);
  --border-strong: rgba(20, 20, 20, 0.28);
  --text: #161616;
  --text-muted: #68686D;
  --body-text: #3B3B3B;
  --accent: #161616;
  --accent-ink: #FFFFFF;
  --accent-dim: rgba(20, 20, 20, 0.18);
  --accent-tint: rgba(20, 20, 20, 0.045);
  --danger: #C13F3F;
  --danger-soft: rgba(193, 63, 63, 0.10);
}

* { box-sizing: border-box; }
img, svg, canvas, video { max-width: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

body {
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button { font-family: var(--font-body); cursor: pointer; }
input { font-family: var(--font-body); }
a { color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ============ Utility ============ */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.mono { font-family: var(--font-mono); }

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-display);
  transition: border-color 0.15s ease, background 0.15s ease, filter 0.15s ease;
}
.btn:hover { border-color: var(--border-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary,
.btn-gold {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover,
.btn-gold:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); }
.btn-ghost.btn-danger { color: var(--danger); }
.btn-ghost.btn-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.field input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.field input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.field select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
}
.field select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.field input[type="file"] {
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.field textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
  resize: vertical;
}
.field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.error-banner {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.inline-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  font: inherit;
  padding: 0;
  cursor: pointer;
}
.inline-link-btn:hover { opacity: 0.85; }

.notice-banner {
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.auth-card .error-banner { margin-bottom: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 0;
}

/* ============ Brand mark ============ */
.brand-logo { height: 70px; width: auto; display: block; color: var(--text); }
.brandst0 { fill: currentColor; }
.brandst1 { fill: var(--accent); }
[data-theme="light"] .brandst1 { fill: var(--text); }

.logo-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  display: block;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.15s ease;
}
.logo-btn:hover { opacity: 0.8; }
.logo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ============ Auth screen ============ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-x: hidden;
}

.auth-card { width: 100%; max-width: 400px; padding: 40px 32px; }

.dashboard { max-width: 880px; margin: 0 auto; padding: 20px 20px calc(56px + env(safe-area-inset-bottom) + 24px); overflow-x: hidden; }

.auth-card .brand-logo { margin: 0 auto 14px; }

.auth-tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin: 0 0 28px;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-switch button {
  background: none; border: none; color: var(--accent);
  font-weight: 600; font-size: 13px; padding: 0;
}

/* ============ Dashboard shell ============ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 14px;
  padding: 14px 4px 28px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* Hamburger nav is used at every screen size now, not just mobile — the
   icon row stays hidden and .icon-btn.mobile-nav-toggle (two classes, so
   it always wins over the single-class .icon-btn rule below regardless of
   source order) keeps the toggle visible. */
.topbar-icons { display: none; }
.icon-btn.mobile-nav-toggle { display: flex; }

.greeting { font-size: 13px; color: var(--text-muted); font-family: var(--font-mono); min-width: 0; }
.greeting strong { color: var(--text); font-weight: 700; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }

.grid { display: grid; gap: 16px; }

/* ============ Bottom tab bar ============ */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  max-width: 880px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  padding-left: calc(8px + env(safe-area-inset-left));
  padding-right: calc(8px + env(safe-area-inset-right));
}
.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
}
.tab-bar-item svg { width: 22px; height: 22px; }
.tab-bar-item span { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
.tab-bar-item.active { color: var(--accent); }

/* ============ Mobile hamburger nav ============ */
.mobile-nav-panel {
  display: none;
  margin: 0 0 16px;
}
.mobile-nav-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
}
.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
}
.mobile-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-muted); }
.mobile-nav-item:hover { background: var(--bg-2); }
.mobile-nav-item:active { background: var(--accent-tint); }

.announcement-banner {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
}

/* ============ Hero / rank card ============ */
.hero-card {
  padding: 28px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 24px;
  align-items: center;
}

.rank-sigil-wrap {
  width: 70px; height: 70px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-sigil { width: 34px; height: 34px; color: var(--accent); }

.rank-info { min-width: 0; }
.rank-info .eyebrow { margin-bottom: 4px; }
.rank-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
  overflow-wrap: break-word;
}

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
}
.progress-caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: var(--font-mono);
  overflow-wrap: break-word;
}

.total-xp { text-align: right; min-width: 0; }
.total-xp .num {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.total-xp .label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
  font-family: var(--font-mono);
}

.credits-balance { text-align: right; min-width: 0; padding-left: 20px; border-left: 1px solid var(--border); }
.credits-balance .num {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.credits-balance .label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ============ Streak / constellation ============ */
.streak-card { padding: 26px 28px 22px; }
.streak-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 8px;
}
.streak-count { display: flex; align-items: baseline; gap: 8px; }
.streak-count .num { font-family: var(--font-mono); font-size: 30px; font-weight: 700; }
.streak-count .unit { color: var(--text-muted); font-size: 13px; }
.longest-note { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.constellation {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  overflow-x: auto;
  max-width: 100%;
  padding: 8px 2px 4px;
}

.constellation-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: 40px;
  position: relative;
}

.constellation-link {
  position: absolute;
  top: 12px;
  right: 100%;
  width: 4px;
  height: 1.5px;
  background: var(--border);
}
.constellation-link.lit { background: var(--accent); }

.star {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.4s ease;
}
.star.lit {
  border-color: var(--accent);
  background: var(--accent);
}
.star.today-empty { border-style: dashed; border-color: var(--border-strong); }
.star svg { width: 11px; height: 11px; color: var(--accent-ink); opacity: 0; }
.star.lit svg { opacity: 1; }

.day-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ============ Log XP form ============ */
.log-card { padding: 24px 28px; }
.log-card h2, .rewards-card h2, .activity-card h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 4px;
}
.section-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 18px; line-height: 1.4em; }
.daily-cap-note {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  margin: -10px 0 18px;
}
.daily-cap-note.at-cap { color: var(--danger); }

.log-form {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 12px;
  align-items: end;
}

.checkbox-field {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============ Daily Quest ============ */
.quest-card {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.quest-form {
  grid-template-columns: 1fr;
  align-items: stretch;
}
.quest-form .btn { justify-self: start; }
.quest-completed-banner { margin-bottom: 4px; }
.quest-submitted-details {
  color: var(--body-text);
  font-size: 13.5px;
  margin: 8px 0 0;
  overflow-wrap: break-word;
}

/* ============ Rewards ============ */
.rewards-card { padding: 24px 28px; }
.reward-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }

/* ============ Store ============ */
.store-balance-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.store-balance-pill {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-muted);
}
.store-balance-pill .store-balance-value { color: var(--accent); font-weight: 700; }
.store-equipped-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.store-list { display: flex; flex-direction: column; gap: 12px; }
.store-category-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 2px;
}
.store-category-heading:first-child { margin-top: 0; }
.store-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  background: var(--bg-2);
}
.store-item.premium-quest-item { grid-template-columns: auto 1fr auto; }
.store-item-thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
}
.store-item-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.store-item-name { font-weight: 600; font-size: 14px; }
.store-item-cost { font-family: var(--font-mono); color: var(--accent); font-size: 12px; margin-top: 2px; }
.store-item-description { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.premium-quest-play-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.premium-quest-resource-link { font-size: 12.5px; color: var(--accent); text-decoration: underline; cursor: pointer; width: fit-content; }

/* ============ Community quests ============ */
.cq-detail-header { display: flex; gap: 16px; align-items: flex-start; margin-top: 6px; }
.cq-detail-thumb { width: 72px; height: 72px; border-radius: var(--radius-md); }
.cq-days-list { display: flex; flex-direction: column; gap: 10px; }
.cq-day-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  background: var(--bg-2);
}
.cq-day-card.is-today { border-color: var(--accent); background: var(--accent-tint); }
.cq-day-card.is-completed { opacity: 0.6; }
.cq-day-card.is-locked { opacity: 0.45; }
.cq-day-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cq-day-title { font-weight: 600; font-size: 14px; margin-top: 2px; }
.cq-day-description { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.cq-day-complete-panel {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cq-board-posts { display: flex; flex-direction: column; gap: 12px; }
.cq-board-post { display: flex; gap: 10px; align-items: flex-start; }
.cq-board-post-body { flex: 1; min-width: 0; }
.cq-board-post-header { display: flex; align-items: baseline; gap: 8px; }
.cq-board-post-name { font-weight: 600; font-size: 13px; }
.cq-board-post-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.cq-board-post-message { font-size: 13px; color: var(--body-text); margin-top: 2px; overflow-wrap: break-word; }
.cq-board-post-actions { flex-shrink: 0; }
.store-item.owned { border-color: var(--accent); background: var(--accent-tint); }

.reward-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  background: var(--bg-2);
}
.reward-item > div:first-child { min-width: 0; }
.reward-item.claimed { opacity: 0.5; }
.reward-item.unlocked:not(.claimed) {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.reward-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.reward-title { font-weight: 600; font-size: 14.5px; overflow-wrap: break-word; }
.reward-title.claimed-text { text-decoration: line-through; }
.reward-target { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.reward-progress { grid-column: 1 / -1; }
.reward-progress .progress-track { height: 3px; }

.badge-claimed {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.new-reward-form {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.admin-add-form { grid-template-columns: 1fr 1fr 1fr auto; }

.users-page-header { margin-bottom: 4px; }
.users-page-header .btn { padding-left: 4px; margin-bottom: 15px; }

.account-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 4px;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 18px 0 4px;
}
.avatar-upload-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 16px 0 18px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}
.search-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.filter-tab {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}
.filter-tab:hover { border-color: var(--border-strong); color: var(--text); }
.filter-tab.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}

.user-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-2);
  flex-wrap: wrap;
}
.user-item.inactive { opacity: 0.55; }
.user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-name-row { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; font-size: 14px; }
.user-email { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.user-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.reset-password-form {
  flex-basis: 100%;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.reset-password-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.reset-password-form input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.role-pill, .status-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
}
.status-pill.active { border-color: var(--accent); color: var(--text); background: var(--accent-tint); }
.status-pill.warn { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.role-pill.flair-pill { border-color: var(--accent); color: var(--accent-ink, var(--text)); background: var(--accent); }

/* ============ Avatars ============ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 700;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 88px; height: 88px; font-size: 32px; }

/* ============ User profile view ============ */
.user-profile-header { display: flex; gap: 18px; align-items: center; margin-top: 6px; }
.user-profile-header .section-sub { margin: 2px 0 0; }
.user-profile-header .flair-pill { margin: 4px 0; display: inline-block; }
.user-profile-bio { font-size: 13.5px; line-height: 1.6; margin-top: 18px; white-space: pre-wrap; overflow-wrap: break-word; }
.user-name-link, .user-avatar-link { cursor: pointer; }

/* ============ Leaderboard ============ */
.leaderboard-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-2);
}
.leaderboard-row.self { border-color: var(--accent); background: var(--accent-tint); }
.leaderboard-rank {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}
.leaderboard-row:nth-child(1) .leaderboard-rank { color: var(--accent); font-size: 17px; }
.leaderboard-row:nth-child(2) .leaderboard-rank,
.leaderboard-row:nth-child(3) .leaderboard-rank { color: var(--text); }
.leaderboard-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; overflow-wrap: break-word; }
.leaderboard-name .role-pill { margin-left: 6px; }
.leaderboard-xp { font-family: var(--font-mono); font-weight: 700; color: var(--accent); flex-shrink: 0; }

.empty-state {
  color: var(--text-muted);
  font-size: 13.5px;
  text-align: center;
  padding: 18px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

/* ============ Activity list ============ */
.activity-card { padding: 24px 28px; }
.activity-filter-tabs { margin: 2px 0 14px; }
.activity-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; overflow-x: hidden; }
.activity-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  gap: 10px;
}
.activity-row:last-child { border-bottom: none; }
.activity-row.self { background: var(--accent-tint); margin: 0 -14px; padding: 11px 14px; border-radius: var(--radius-sm); border-bottom-color: transparent; }
.activity-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding-left: 10px; padding-right: 10px; }
.activity-person { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.activity-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-name { font-weight: 600; font-size: 13px; }
.activity-note { color: var(--text-muted); font-size: 12px; overflow-wrap: break-word; }
.activity-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.activity-amount { font-family: var(--font-mono); color: var(--accent); font-weight: 700; flex-shrink: 0; padding-left: 10px; padding-right: 10px; }

/* ============ Ranks legend ============ */
.rank-ladder { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.rank-pill-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: currentColor;
  object-fit: contain;
  border-radius: 3px;
}
.rank-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.rank-pill.reached { border-color: var(--accent); color: var(--text); background: var(--accent-tint); }

/* ============ Admin: rank management ============ */
.rank-manage-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.cq-subquests-panel {
  margin: -4px 0 12px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.rank-edit-form,
.rank-manage-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-2);
}

.rank-manage-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.rank-manage-icon svg { width: 26px; height: 26px; color: var(--accent); }
.rank-manage-icon img { width: 100%; height: 100%; object-fit: cover; }

.rank-manage-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.rank-manage-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.rank-manage-actions .btn { white-space: nowrap; }

.rank-add-heading {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 22px 0 12px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}

@media (max-width: 620px) {
  .rank-edit-form,
  .rank-manage-item {
    grid-template-columns: 1fr;
  }
  .rank-manage-icon { width: 44px; height: 44px; }
  .rank-manage-fields { grid-template-columns: 1fr; }
  .rank-manage-actions { flex-direction: row; }
}

/* ============ Admin: quest scheduling ============ */
.quest-manage-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }

.quest-edit-form,
.quest-manage-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-2);
}
.quest-manage-item.is-today { border-color: var(--accent); background: var(--accent-tint); }

.quest-today-badge {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.quest-pool-badge { color: var(--text-muted); }

.quest-manage-fields {
  display: grid;
  grid-template-columns: 140px 1fr 110px;
  gap: 12px;
  min-width: 0;
}
.quest-manage-fields .field:last-child { grid-column: 1 / -1; }

.quest-manage-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.quest-manage-actions .btn { white-space: nowrap; }

@media (max-width: 620px) {
  .quest-edit-form,
  .quest-manage-item { grid-template-columns: 1fr; }
  .quest-manage-fields { grid-template-columns: 1fr; }
  .quest-manage-fields .field:last-child { grid-column: auto; }
  .quest-manage-actions { flex-direction: row; }
}

/* ============ Toast ============ */
#toast {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 24px;
  width: fit-content;
  margin: 0 auto;
  box-sizing: border-box;
  overflow-wrap: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-family: var(--font-mono);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ============ Rank-up celebration ============ */
/* Hardcoded dark/space colors here on purpose, independent of the
   light/dark theme toggle — a hyperspace jump doesn't make sense in
   cream-and-ink light mode, and this is a brief full-screen "event"
   rather than a themed surface. */
.rankup-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.rankup-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.rankup-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 0 24px;
  animation: rankupIn 0.5s ease 0.4s both;
}
.rankup-eyebrow {
  text-shadow: 0 0 16px var(--accent);
}
.rankup-icon-wrap {
  width: 88px;
  height: 88px;
  margin: 16px auto;
  border-radius: 50%;
  background: #161616;
  border: 1px solid var(--accent);
  box-shadow: 0 0 50px rgba(252, 243, 84, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.rankup-sigil { width: 42px; height: 42px; color: var(--accent); }
.rankup-sigil-img { width: 100%; height: 100%; object-fit: cover; }
.rankup-name {
  font-family: var(--font-display);
  font-size: 40px;
  margin: 4px 0 0;
  color: #F4F3EE;
  text-shadow: 0 0 30px rgba(252, 243, 84, 0.5);
}
.rankup-hint {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #93969C;
  letter-spacing: 0.04em;
}
@keyframes rankupIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
@media (max-width: 620px) {
  .rankup-name { font-size: 30px; }
  .rankup-icon-wrap { width: 72px; height: 72px; }
  .rankup-sigil { width: 34px; height: 34px; }
}

/* ============ Responsive ============ */
@media (max-width: 620px) {
  .dashboard { padding: 16px 14px 60px; }
  .hero-card { grid-template-columns: 1fr; text-align: center; gap: 14px; padding: 22px; }
  .credits-balance { padding-left: 0; border-left: none; padding-top: 10px; border-top: 1px solid var(--border); }
  .rank-sigil-wrap { margin: 0 auto; }
  .total-xp { text-align: center; }
  .log-form { grid-template-columns: 1fr; }
  .log-form button, .new-reward-form button { width: 100%; }
  .new-reward-form { grid-template-columns: 1fr; }
  .admin-add-form { grid-template-columns: 1fr; }
  .user-item { flex-direction: column; align-items: flex-start; }
  .user-toolbar { flex-direction: column; align-items: stretch; }
  .filter-tabs { justify-content: stretch; }
  .filter-tab { flex: 1; }
  .reward-actions { justify-self: start; }
  .log-card, .rewards-card, .activity-card, .streak-card, .admin-card { padding: 20px; }
  .topbar-right { width: 100%; gap: 6px; }
  .greeting { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .icon-btn { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
