/* ---------- Theme tokens ---------- */
:root {
  --brand: #0e5a4a;
  --brand-2: #127a63;
  --brand-soft: #e3f1ec;
  --gold: #d4a63c;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --text: #1d2722;
  --muted: #5f6b66;
  --line: #e4ded3;
  --danger: #b4372f;
  --danger-soft: #fbeceb;
  --warn-soft: #fdf3dc;
  --male: #dbe8f5;
  --female: #f5e1e6;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #3fb393; --brand-2: #57c7a7; --brand-soft: #173a31; --gold: #e2b85a;
    --bg: #111614; --surface: #1a211e; --surface-2: #161c19; --text: #e7ece9; --muted: #9aa8a1;
    --line: #2b3531; --danger: #f07a70; --danger-soft: #3a1f1d; --warn-soft: #3a3120;
    --male: #22303d; --female: #3a2830; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #3fb393; --brand-2: #57c7a7; --brand-soft: #173a31; --gold: #e2b85a;
  --bg: #111614; --surface: #1a211e; --surface-2: #161c19; --text: #e7ece9; --muted: #9aa8a1;
  --line: #2b3531; --danger: #f07a70; --danger-soft: #3a1f1d; --warn-soft: #3a3120;
  --male: #22303d; --female: #3a2830; --shadow: none; color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .6em; }
img { max-width: 100%; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
blockquote { margin: .5em 0; padding: .5em .8em; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 0 8px 8px 0; font-style: italic; overflow-wrap: anywhere; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 20px; padding-bottom: 32px; outline: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 28px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.wrap-gap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.sm { gap: 8px; }
.narrow { max-width: 460px; margin: 16px auto; }
.narrow-l { max-width: 640px; }
.prose.narrow { max-width: 720px; }
.prose li { margin-bottom: .35em; }

/* ---------- Header / nav ---------- */
.demo { background: var(--warn-soft); color: var(--text); font-size: .85rem; padding: 6px 16px; text-align: center; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text); letter-spacing: .2px; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a:not(.btn) { display: flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; position: relative; }
.nav a:not(.btn):hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.ico { width: 20px; height: 20px; flex: none; }
.ico.lg { width: 30px; height: 30px; color: var(--brand); }
.badge { background: var(--danger); color: #fff; font-size: .7rem; border-radius: 999px; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; }
.tabbar { display: none; }
.footer { color: var(--muted); font-size: .85rem; padding-top: 16px; padding-bottom: 24px; border-top: 1px solid var(--line); }

@media (max-width: 759px) {
  body.has-tabbar .nav { display: none; }
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.has-tabbar .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: .7rem; color: var(--muted); text-decoration: none; position: relative; min-width: 0; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a.active { color: var(--brand); }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); }
  .nav a.btn.sm { padding: 6px 12px; }
  .nav a:not(.btn) { padding: 6px 8px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; line-height: 1.2; min-height: 42px;
  transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0b1512; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0b1512; } }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: .9rem; }
.btn.lg { padding: 13px 22px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn .ico { width: 18px; height: 18px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 4px; }
.file { cursor: pointer; }

/* ---------- Cards & forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin-bottom: .2em; }
fieldset.card { margin: 0; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; display: flex; gap: 6px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.lbl { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
input:disabled, select:disabled { opacity: .7; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin-top: 3px; flex: none; accent-color: var(--brand); }
.radios { margin-top: 12px; }
.tag { font-size: .72rem; background: var(--brand-soft); color: var(--brand); padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.grid2, .grid3 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr 1fr; }
}
.grid2.tight { grid-template-columns: 1fr 1fr; gap: 0 10px; }
.private { border-color: var(--gold); background: linear-gradient(var(--surface), var(--surface-2)); }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 18px 0 8px; }
body.has-tabbar .sticky-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { body.has-tabbar .sticky-actions { bottom: 0; } }
.photo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ---------- Notices, status ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--brand-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.notice.warn { background: var(--warn-soft); }
.notice .ico { color: var(--brand); margin-top: 2px; }
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.s-approved { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.s-pending { background: var(--warn-soft); border-color: transparent; }
.s-rejected { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.danger-zone { border-color: var(--danger-soft); }
.empty { padding: 32px 20px; }

/* ---------- Home ---------- */
.hero { padding: 28px 0 24px; max-width: 760px; }
.eyebrow { color: var(--gold); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; }
.hero h1 { font-size: clamp(1.8rem, 1.2rem + 2.6vw, 2.8rem); }
.lead { font-size: 1.1rem; color: var(--muted); margin-bottom: 1.2em; }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 12px 0 24px; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feat h3 { margin-top: 10px; }
.feat p { color: var(--muted); margin: 0; }
.steps { padding-left: 1.3em; }
.steps li { margin-bottom: .5em; }

/* ---------- Avatars ---------- */
.avatar {
  --s: 64px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; position: relative;
  display: grid; place-items: center; overflow: hidden; background: var(--male); color: var(--brand);
  font-weight: 700; font-size: calc(var(--s) * .4);
}
.avatar.g-female { background: var(--female); }
.avatar.sm { --s: 48px; }
.avatar.lg { --s: 72px; }
.avatar.xl { --s: 104px; }
.avatar.xxl { --s: 140px; margin: 0 auto 12px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.has-img .initial { visibility: hidden; }
.avatar .lock { position: absolute; right: 6%; bottom: 6%; background: var(--surface); border-radius: 50%; width: 30%; height: 30%; min-width: 18px; min-height: 18px; display: grid; place-items: center; box-shadow: var(--shadow); }
.avatar .lock .ico { width: 60%; height: 60%; color: var(--muted); }

/* ---------- Browse ---------- */
.browse { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) {
  .browse { grid-template-columns: 280px 1fr; }
  .filters { position: sticky; top: 80px; }
  .only-mobile { display: none; }
}
@media (max-width: 899px) {
  .filters { display: none; }
  body.filters-open .filters { display: block; }
}
.results { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.results > .loading, .results > .empty { grid-column: 1 / -1; }
.pcard { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; padding: 16px; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--brand); }
.pc-body { min-width: 0; }
.pc-body h3 { margin-bottom: 2px; }
.pc-body p { margin: 0 0 2px; font-size: .9rem; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px !important; }
.chip { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
#more { margin-top: 18px; }

/* ---------- Profile page ---------- */
.profile { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .profile { grid-template-columns: 340px 1fr; } .side { position: sticky; top: 80px; } }
.side { display: flex; flex-direction: column; gap: 16px; }
.pname { margin-bottom: 4px; }
.details { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.action h3 { display: flex; gap: 8px; align-items: center; }
.action.contact { border: 2px solid var(--brand); }
.action .details { margin-bottom: 12px; }

/* ---------- Interests ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.tab { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab b { font-size: .8rem; opacity: .85; }
.irow { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; flex-wrap: wrap; }
.iname { font-weight: 700; color: var(--text); text-decoration: none; }
.iact { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .iact { width: 100%; } .iact .btn { flex: 1; } }

/* ---------- Moderation ---------- */
.mod .details { margin: 14px 0; }
.mod h3 a { color: inherit; }

/* ---------- Loading, toasts, dialog ---------- */
.loading { display: grid; place-items: center; padding: 48px; }
.spin { width: 20px; height: 20px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
.loading .spin { color: var(--brand); width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
body.has-tabbar .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { body.has-tabbar .toasts { bottom: 24px; } }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.2); transition: opacity .4s, transform .4s; font-size: .95rem; }
.toast-err { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(92vw, 480px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 20, 15, .5); }
.dlg-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-body p { margin-bottom: .6em; }
