/* ============================================================
   Aletho — CSS
   "Not who you seek. What you seek."
   ============================================================ */

:root {
  --bg:          #07091a;
  --bg-surface:  #0d1225;
  --bg-card:     #111c35;
  --bg-hover:    #162040;
  --gold:        #f59e0b;
  --gold-dim:    rgba(245,158,11,.18);
  --gold-border: rgba(245,158,11,.35);
  --emerald:     #10b981;
  --violet:      #8b5cf6;
  --rose:        #f43f5e;
  --cyan:        #06b6d4;
  --text:        #dce8ff;
  --text-muted:  #6b82a8;
  --text-dim:    #3a4f72;
  --border:      rgba(255,255,255,.07);
  --border-gold: rgba(245,158,11,.4);
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Starfield background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 15%  10%, rgba(255,255,255,.6)  0%, transparent 100%),
    radial-gradient(1px 1px at 42%  28%, rgba(255,255,255,.4)  0%, transparent 100%),
    radial-gradient(1px 1px at 67%   5%, rgba(255,255,255,.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 85%  40%, rgba(255,255,255,.35) 0%, transparent 100%),
    radial-gradient(1px 1px at  8%  62%, rgba(255,255,255,.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 30%  75%, rgba(255,255,255,.5)  0%, transparent 100%),
    radial-gradient(1px 1px at 55%  88%, rgba(255,255,255,.3)  0%, transparent 100%),
    radial-gradient(1px 1px at 78%  70%, rgba(255,255,255,.4)  0%, transparent 100%),
    radial-gradient(1px 1px at 93%  85%, rgba(255,255,255,.5)  0%, transparent 100%),
    radial-gradient(1px 1px at 20%  45%, rgba(255,255,255,.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 72%  52%, rgba(255,255,255,.45) 0%, transparent 100%),
    radial-gradient(2px 2px at 50%  20%, rgba(245,200,100,.2)  0%, transparent 100%),
    radial-gradient(2px 2px at 10%  90%, rgba(140,100,240,.2)  0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

main, header, footer, nav, section, .container { position: relative; z-index: 1; }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-dim); filter: brightness(1.3); }

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
}

img { max-width: 100%; display: block; }
textarea, input, select, button { font-family: inherit; font-size: 1rem; }

/* ── Layout ───────────────────────────────────────────────── */
.container  { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container-sm { max-width: 680px; margin: 0 auto; padding: 0 1.25rem; }
.page-wrap   { padding: 2.5rem 0 5rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── Navigation ───────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,9,26,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .9rem 0;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-logo {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -.04em;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.nav-logo .logo-glyph { font-size: 1.6rem; }
.nav-logo:hover { color: var(--gold); filter: brightness(1.2); }

.nav-links {
  display: flex;
  align-items: center;
  gap: .2rem;
  list-style: none;
}
.nav-links a {
  color: var(--text-muted);
  padding: .4rem .75rem;
  border-radius: 6px;
  font-size: .92rem;
  transition: background .2s, color .2s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--gold-dim);
  color: var(--gold);
}
.nav-links .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rose);
  color: #fff;
  border-radius: 99px;
  font-size: .7rem;
  width: 1.1rem;
  height: 1.1rem;
  margin-left: .25rem;
  font-weight: 700;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn-primary {
  background: var(--gold);
  color: #09100a;
  border-color: var(--gold);
}
.btn-primary:hover { background: #fcd34d; color: #09100a; filter: none; }

.btn-outline {
  background: transparent;
  color: var(--gold);
  border-color: var(--gold-border);
}
.btn-outline:hover { background: var(--gold-dim); color: var(--gold); filter: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); filter: none; }

.btn-emerald {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}
.btn-emerald:hover { background: #0ea572; filter: none; }

.btn-sm { padding: .38rem .9rem; font-size: .85rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1.1rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  transition: border-color .25s, transform .2s;
}
.card:hover { border-color: var(--border-gold); }
.card-glow { box-shadow: 0 0 0 1px var(--gold-border), var(--shadow); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  margin-bottom: .45rem;
  font-size: .9rem;
  color: var(--text-muted);
  font-weight: 500;
}
.form-label em { color: var(--text-dim); font-style: normal; font-size: .82rem; }

.form-control {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .65rem .95rem;
  transition: border-color .2s, box-shadow .2s;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--gold-border);
  box-shadow: 0 0 0 3px rgba(245,158,11,.1);
}
.form-control::placeholder { color: var(--text-dim); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b82a8' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .85rem center; padding-right: 2.5rem; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .82rem; color: var(--text-dim); margin-top: .35rem; }

/* Checkbox values grid */
.values-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: .5rem;
}
.values-grid label {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text-muted);
  transition: all .2s;
}
.values-grid label:hover { border-color: var(--gold-border); color: var(--text); }
.values-grid input[type=checkbox]:checked + span { color: var(--gold); }
.values-grid label:has(input:checked) { border-color: var(--gold-border); background: var(--gold-dim); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: .8rem 1.1rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  font-size: .93rem;
  margin-bottom: 1.25rem;
}
.alert-error   { background: rgba(244,63,94,.1);  border-color: var(--rose);    color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border-color: var(--emerald); color: #6ee7b7; }
.alert-info    { background: rgba(6,182,212,.1);  border-color: var(--cyan);    color: #a5f3fc; }

/* ── Tags / Badges ────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .65rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.tag-domain   { background: rgba(139,92,246,.18); color: var(--violet);  border: 1px solid rgba(139,92,246,.3); }
.tag-approach { background: rgba(6,182,212,.15);  color: var(--cyan);    border: 1px solid rgba(6,182,212,.3); }
.tag-urgency  { background: rgba(245,158,11,.15); color: var(--gold);    border: 1px solid var(--gold-border); }
.tag-value    { background: rgba(16,185,129,.12); color: var(--emerald); border: 1px solid rgba(16,185,129,.3); }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.1);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.avatar-sm { width: 2rem;  height: 2rem;  font-size: .8rem; }
.avatar-md { width: 2.8rem;height: 2.8rem;font-size: 1.1rem; }
.avatar-lg { width: 4rem;  height: 4rem;  font-size: 1.6rem; }
.avatar-xl { width: 5.5rem;height: 5.5rem;font-size: 2rem; }

/* ── Score pill ───────────────────────────────────────────── */
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  border-radius: 99px;
  padding: .2rem .65rem;
  font-size: .82rem;
  font-weight: 700;
}

/* ── Page hero ────────────────────────────────────────────── */
.hero {
  padding: 6rem 0 5rem;
  text-align: center;
  position: relative;
}
.hero-eyebrow {
  font-size: .82rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  color: #fff;
  margin-bottom: 1.25rem;
  line-height: 1.15;
}
.hero h1 .accent { color: var(--gold); }
.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 2.5rem;
}
.hero-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-55%);
  width: 700px;
  height: 500px;
  background: radial-gradient(ellipse at center,
    rgba(245,158,11,.08) 0%,
    rgba(139,92,246,.05) 40%,
    transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Section headers ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.section-header h2 { font-size: 1.35rem; color: var(--text); }

/* ── Purpose card ─────────────────────────────────────────── */
.purpose-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  transition: all .25s;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.purpose-card:hover { border-color: var(--border-gold); transform: translateY(-2px); }
.purpose-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.purpose-card-desc {
  font-size: .9rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.purpose-card-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.purpose-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .83rem;
  color: var(--text-dim);
}
.purpose-card-creator { display: flex; align-items: center; gap: .5rem; }

/* ── User card ────────────────────────────────────────────── */
.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  transition: all .25s;
}
.user-card:hover { border-color: var(--border-gold); transform: translateY(-2px); }
.user-card-header { display: flex; align-items: center; gap: .9rem; }
.user-card-name { font-weight: 700; color: #fff; font-size: 1rem; }
.user-card-username { font-size: .82rem; color: var(--text-dim); }
.user-card-score { font-size: .85rem; }

/* ── Stats bar ────────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stat-val { font-size: 1.8rem; font-weight: 800; color: var(--gold); line-height: 1; }
.stat-lbl { font-size: .78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-top: .2rem; }

/* ── Messages ─────────────────────────────────────────────── */
.thread-list { display: flex; flex-direction: column; gap: .5rem; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  color: inherit;
}
.thread-item:hover { border-color: var(--border-gold); background: var(--bg-hover); color: inherit; filter: none; }
.thread-info { flex: 1; min-width: 0; }
.thread-name { font-weight: 600; color: #fff; font-size: .95rem; }
.thread-preview { font-size: .83rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-unread { background: var(--gold); color: #000; border-radius: 99px; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; }

.message-bubble {
  max-width: 72%;
  padding: .65rem 1rem;
  border-radius: 16px;
  font-size: .93rem;
  line-height: 1.55;
}
.message-bubble.mine { background: var(--gold-dim); border: 1px solid var(--gold-border); color: var(--text); align-self: flex-end; border-bottom-right-radius: 4px; }
.message-bubble.theirs { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.message-time { font-size: .72rem; color: var(--text-dim); margin-top: .25rem; }

.messages-wrap { display: flex; flex-direction: column; gap: .8rem; padding: 1.25rem 0; }

/* ── Captcha block ────────────────────────────────────────── */
.captcha-block {
  background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(6,182,212,.05));
  border: 1px solid rgba(139,92,246,.3);
  border-radius: 12px;
  padding: 1.25rem 1.4rem;
}
.captcha-block .captcha-label {
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--violet);
  font-weight: 700;
  margin-bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.captcha-block .captcha-question {
  color: var(--text);
  font-size: .95rem;
  margin-bottom: .85rem;
  line-height: 1.6;
}
.captcha-block .captcha-hint { font-size: .8rem; color: var(--text-dim); margin-bottom: .65rem; }

/* ── How it works ─────────────────────────────────────────── */
.how-step {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
}
.how-step-num {
  width: 2.2rem;
  height: 2.2rem;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 800;
  font-size: .9rem;
  flex-shrink: 0;
}
.how-step-body h3 { font-size: 1rem; color: #fff; margin-bottom: .3rem; }
.how-step-body p  { font-size: .9rem; color: var(--text-muted); }

/* ── Manifesto ────────────────────────────────────────────── */
.manifesto {
  border-left: 3px solid var(--gold-border);
  padding: 1rem 1.5rem;
  margin: 2rem 0;
  background: var(--gold-dim);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.75;
}

/* ── Profile page ─────────────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.profile-meta h1 { font-size: 1.75rem; color: #fff; margin-bottom: .2rem; }
.profile-meta .username { color: var(--text-dim); font-size: .93rem; }
.profile-meta .location { color: var(--text-muted); font-size: .9rem; display: flex; align-items: center; gap: .3rem; margin-top: .4rem; }

.section-title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  align-items: center;
}
.filter-bar select.form-control { width: auto; min-width: 160px; }
.filter-bar .form-control { padding: .5rem .9rem; font-size: .88rem; }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1.15rem; color: var(--text); margin-bottom: .5rem; }
.empty-state p  { font-size: .9rem; max-width: 400px; margin: 0 auto 1.5rem; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 2rem 0; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  color: var(--text-dim);
  font-size: .84rem;
  text-align: center;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--gold); }
.site-footer .motto {
  color: var(--text-muted);
  font-style: italic;
  margin-top: .5rem;
  font-size: .9rem;
}

/* ── Auth pages ───────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .logo-text {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -.04em;
}
.auth-logo .logo-tagline {
  font-size: .84rem;
  color: var(--text-dim);
  margin-top: .25rem;
}
.auth-footer-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .9rem;
  color: var(--text-muted);
}

/* ── Dashboard ────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 860px) { .dashboard-grid { grid-template-columns: 1fr; } }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  position: sticky;
  top: 80px;
}

/* ── Endurance bar ────────────────────────────────────────── */
.endurance-bar-wrap { margin: .5rem 0 .25rem; }
.endurance-bar-track {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.endurance-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--violet));
  border-radius: 99px;
  transition: width .6s ease;
}

/* ── Misc utils ───────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.gap-3  { gap: 1.5rem; }
.mt-1   { margin-top: .5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-1   { margin-bottom: .5rem; }
.mb-2   { margin-bottom: 1rem; }
.mb-3   { margin-bottom: 1.5rem; }
.text-muted   { color: var(--text-muted); }
.text-dim     { color: var(--text-dim); }
.text-gold    { color: var(--gold); }
.text-emerald { color: var(--emerald); }
.text-violet  { color: var(--violet); }
.text-sm { font-size: .88rem; }
.text-xs { font-size: .78rem; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Align section on purpose view */
.align-box {
  background: linear-gradient(135deg, rgba(16,185,129,.06), rgba(6,182,212,.04));
  border: 1px solid rgba(16,185,129,.25);
  border-radius: 12px;
  padding: 1.4rem;
}

/* Convergence highlight */
.convergence-card {
  border-color: var(--gold-border) !important;
  background: linear-gradient(135deg, rgba(245,158,11,.05), rgba(139,92,246,.04));
}

/* Purpose detail */
.purpose-detail-header { margin-bottom: 2rem; }
.purpose-detail-header h1 { font-size: 1.9rem; color: #fff; margin-bottom: .75rem; }
.purpose-detail-body { font-size: 1rem; line-height: 1.8; color: var(--text-muted); }

/* Responsive nav */
@media (max-width: 640px) {
  .nav-links a span { display: none; }
  .nav-links { gap: 0; }
}

/* ============================================================
   RESPONSIVE & AVATAR ADDITIONS
   ============================================================ */

/* ── Avatar image support ─────────────────────────────────── */
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Clickable upload wrapper */
.avatar-upload-wrap {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}
.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.58);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  pointer-events: none;
}
.avatar-upload-wrap:hover .avatar-upload-overlay { opacity: 1; }

/* Avatar upload row in form */
.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}
.avatar-upload-row input[type=file] { font-size: .88rem; }

/* ── Profile page layout ──────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.profile-body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.profile-col-left, .profile-col-right { min-width: 0; }

/* ── Hamburger nav ────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: .45rem .5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-mobile-only { display: none; }

/* ── Tablet (≤900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .sidebar-card   { position: static; }

  .profile-body-grid { grid-template-columns: 1fr; }

  .grid-3 { grid-template-columns: repeat(2,1fr); }
}

/* ── Mobile (≤640px) ──────────────────────────────────────── */
@media (max-width: 640px) {
  /* Container */
  .container, .container-sm { padding: 0 .9rem; }
  .page-wrap { padding: 1.25rem 0 3rem; }

  /* Nav hamburger */
  .nav-hamburger   { display: flex; }
  .nav-mobile-only { display: list-item; }
  .nav { position: relative; }
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 0;
    right: 0;
    background: rgba(7,9,26,.98);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: .6rem .75rem .9rem;
    gap: .15rem;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
  }
  .nav-links.open { display: flex; }
  .nav-links li    { width: 100%; }
  .nav-links a     { display: block; padding: .65rem .85rem; font-size: 1rem; border-radius: 8px; }
  .nav-links a span { display: inline !important; }
  /* Hide avatar-only link on mobile, show text instead */
  .nav-links li:has(.avatar) a::after { content: ' My Profile'; font-size: .95rem; color: var(--text-muted); }

  /* Auth */
  .auth-card { padding: 1.5rem 1.1rem; border-radius: 12px; }
  .auth-logo .logo-text { font-size: 1.6rem; }

  /* Profile hero stacks */
  .profile-hero         { flex-direction: column; gap: 1rem; }
  .profile-actions      { flex-direction: row; align-items: flex-start; flex-wrap: wrap; flex-shrink: unset; width: 100%; }
  .profile-meta h1      { font-size: 1.3rem; }
  .profile-body-grid    { grid-template-columns: 1fr; }

  /* Grids */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 1rem .9rem; }

  /* Purpose detail header */
  .purpose-detail-header h1 { font-size: 1.25rem; }

  /* Message bubbles */
  .message-bubble { max-width: 90%; }

  /* Hero */
  .hero { padding: 3rem 0 2.5rem; }
  .hero h1 { font-size: clamp(1.8rem, 7vw, 3rem); }
  .hero p  { font-size: .95rem; }

  /* Filter bar */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select.form-control,
  .filter-bar .form-control { width: 100%; min-width: unset; }

  /* Manifesto */
  .manifesto { padding: .85rem 1rem; font-size: .9rem; }

  /* Section header */
  .section-header { flex-direction: column; align-items: flex-start; gap: .6rem; }

  /* Values grid */
  .values-grid { grid-template-columns: 1fr; }

  /* How-it-works steps */
  .how-step-body h3 { font-size: .95rem; }

  /* Dashboard sidebar nav links */
  .sidebar-card nav { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }

  /* Admin stat grid */
  .stat-card .val { font-size: 1.5rem; }

  /* Buttons */
  .btn-lg { padding: .7rem 1.4rem; font-size: 1rem; }
}

/* ── Extra small (≤400px) ─────────────────────────────────── */
@media (max-width: 400px) {
  .nav-logo   { font-size: 1.1rem; }
  .auth-card  { padding: 1.25rem .9rem; }
  .page-wrap  { padding: 1rem 0 2.5rem; }
}

/* ── Admin table overflow on mobile ───────────────────────── */
@media (max-width: 900px) {
  .card table  { font-size: .82rem; }
  td, th       { padding: .45rem .55rem; }
}
@media (max-width: 640px) {
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-layout     { grid-template-columns: 1fr; }
  .admin-nav        { position: static; }
}

/* ── Messages layout mobile ───────────────────────────────── */
@media (max-width: 720px) {
  .messages-layout { grid-template-columns: 1fr !important; }
}

/* ── Convergence card responsive ─────────────────────────── */
@media (max-width: 640px) {
  .user-card-header { flex-wrap: wrap; }
  .score-pill       { margin-left: 0 !important; }
}

/* ── Print styles (profile handout) ──────────────────────── */
.print-only { display: none; }

@media print {
  /* ── Page setup ── */
  @page {
    size: letter portrait;
    margin: 0.55cm 0.75cm;
  }

  /* ── Hide screen-only chrome ── */
  .no-print,
  .nav,
  .site-footer,
  .section-header a,
  .purpose-card-footer,
  .btn,
  .align-box,
  .alert { display: none !important; }

  .print-only { display: block !important; }

  /* ── Base ── */
  html { font-size: 7.5pt; }
  body {
    background: #fff !important;
    color: #111 !important;
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.35;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ── Wrappers ── */
  .page-wrap, .container {
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* ── Profile hero ── */
  .profile-hero {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.6rem !important;
    padding-bottom: 0.4rem !important;
    margin-bottom: 0.5rem !important;
    border-bottom: 1.5pt solid #222 !important;
    flex-wrap: nowrap !important;
  }
  .profile-avatar-wrap { flex-shrink: 0; }
  .avatar.avatar-xl {
    width: 52px !important;
    height: 52px !important;
    font-size: 22px !important;
    line-height: 52px !important;
    border-radius: 50% !important;
    border: none !important;
  }
  .profile-meta { flex: 1; min-width: 0; }
  .profile-meta h1 {
    font-size: 13pt !important;
    color: #000 !important;
    margin: 0 0 0.1rem !important;
    line-height: 1.2 !important;
  }
  .username  { font-size: 8pt !important; color: #555 !important; }
  .location  { font-size: 7.5pt !important; color: #555 !important; }

  /* ── Tags ── */
  .tag {
    display: inline-block;
    border: 0.5pt solid #999 !important;
    color: #333 !important;
    background: #f2f2f2 !important;
    font-size: 6.5pt !important;
    padding: 0.05rem 0.3rem !important;
    border-radius: 2px !important;
    margin: 0.1rem 0.15rem 0.1rem 0 !important;
  }
  .flex.gap-1 { gap: 0.2rem !important; }

  /* ── Body grid: keep two columns ── */
  .profile-body-grid {
    display: grid !important;
    grid-template-columns: 38% 60% !important;
    gap: 0.55rem !important;
    align-items: start !important;
  }
  .profile-col-left, .profile-col-right { min-width: 0; }

  /* ── Cards ── */
  .card {
    background: #fff !important;
    border: 0.5pt solid #ccc !important;
    border-radius: 2px !important;
    padding: 0.25rem 0.4rem !important;
    margin-bottom: 0.35rem !important;
    box-shadow: none !important;
  }
  .mb-2 { margin-bottom: 0.35rem !important; }

  .section-title {
    font-size: 6pt !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    color: #888 !important;
    margin-bottom: 0.2rem !important;
    font-family: Arial, sans-serif !important;
  }

  /* Truncate bio text blocks to 3 lines */
  .card p {
    color: #222 !important;
    line-height: 1.35 !important;
    margin: 0 !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 3 !important;
    overflow: hidden !important;
  }

  /* ── Purposes column: 2-column mini-grid ── */
  .profile-col-right .section-header {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    margin-bottom: 0.3rem;
  }
  .profile-col-right .section-header h2 {
    font-size: 8pt !important;
    color: #000 !important;
    margin: 0 !important;
  }
  .profile-col-right > div[style*="flex-direction:column"],
  .profile-col-right > div[style*="flex-direction: column"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.35rem !important;
  }

  /* ── Purpose cards ── */
  .purpose-card {
    border: 0.5pt solid #ccc !important;
    background: #fff !important;
    padding: 0.25rem 0.35rem !important;
    margin: 0 !important;
    border-radius: 2px !important;
    box-shadow: none !important;
  }
  .purpose-card-title {
    font-size: 7pt !important;
    font-weight: bold !important;
    color: #000 !important;
    line-height: 1.3 !important;
    margin-bottom: 0.2rem !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    overflow: hidden !important;
  }
  /* Hide description text — title + tags is enough for a handout */
  .purpose-card-desc { display: none !important; }
  .purpose-card-meta { margin-top: 0.15rem !important; }

  /* ── Empty states ── */
  .empty-state { display: none !important; }

  /* ── Print footer ── */
  .print-footer {
    display: block !important;
    margin-top: 0.4rem;
  }
  .print-footer > div {
    border-top: 0.5pt solid #bbb !important;
    padding-top: 0.3rem !important;
    font-size: 6.5pt !important;
    color: #777 !important;
    font-family: Arial, sans-serif !important;
  }
}
