/* One stylesheet, no build step, no framework. Mobile-first; dark and light via prefers-color-scheme.
   Accessibility floor: visible focus rings, 4.5:1 body contrast, real labels, 44px touch targets. */
:root {
  --bg: #0f0f12; --surface: #18181d; --surface-2: #202027; --text: #f2f2f5; --muted: #a9a9b8;
  --accent: #ff5c8a; --accent-text: #1a0a10; --ok: #4ade80; --border: #2c2c36;
  --radius: 16px; --tap: 44px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafafc; --surface: #ffffff; --surface-2: #f2f2f6; --text: #16161a; --muted: #5b5b6b;
    --accent: #d9285a; --accent-text: #ffffff; --ok: #15803d; --border: #e3e3ea;
    --shadow: 0 8px 30px rgba(20,20,40,.12);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
/* Wordmark: the product name, used on auth screens and in the top bar. */
.wordmark { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: var(--tap); padding: 12px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;            /* brand row above nav row when the screen is narrow */
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1 1 auto; min-width: 0; }
.topbar h1.wordmark { font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  white-space: nowrap; flex: 0 1 auto; }
/* The nav must never wrap: a wrapped "Sign out" reads as two buttons. */
.topbar nav a, .topbar button.ghost { white-space: nowrap; }
.topbar nav { display: flex; gap: 8px; flex-wrap: nowrap; flex: 0 0 auto; }
/* Narrow screens: let the nav drop to its own row instead of clipping "Sign out". */
@media (max-width: 430px) {
  .topbar { row-gap: 6px; }
  .topbar h1, .topbar h1.wordmark { flex: 1 1 100%; }
  .topbar nav { flex: 1 1 100%; justify-content: space-between; }
  .topbar nav a { padding: 8px 10px; }
}
.topbar nav a {
  color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 999px; min-height: var(--tap);
  display: inline-flex; align-items: center;
}
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--muted); }
input[type=email], input[type=password], input[type=date], input[type=text], input[type=number], select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.error { color: #ff7a90; font-size: 14px; min-height: 1.2em; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }

/* ---------- browse / swipe ---------- */
.deck { position: relative; height: min(62vh, 520px); }
.pcard {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; touch-action: pan-y; will-change: transform;
}
.pcard .photo {
  flex: 1; min-height: 180px; display: grid; place-items: center; font-size: 64px; font-weight: 700;
  background: linear-gradient(135deg, var(--surface-2), var(--surface)); color: var(--muted);
}
.pcard .photo img { width: 100%; height: 100%; object-fit: cover; }
.pcard .body { padding: 14px 16px; }
.pcard h2 { margin: 0 0 2px; font-size: 22px; }
.pcard .bio { margin: 8px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.actions { display: flex; gap: 12px; margin-top: 16px; }
.actions button { flex: 1; }
.pcard.dragging { transition: none; }
.pcard.snap { transition: transform .2s ease-out; }
.stamp {
  position: absolute; top: 18px; padding: 6px 12px; border-radius: 8px; font-weight: 800; letter-spacing: .08em;
  border: 3px solid currentColor; opacity: 0; pointer-events: none;
}
.stamp.like { right: 18px; color: var(--ok); transform: rotate(12deg); }
.stamp.pass { left: 18px; color: #ff6b6b; transform: rotate(-12deg); }
.empty { text-align: center; padding: 48px 16px; }

/* ---------- matches ---------- */
.mlist { display: grid; gap: 10px; }
.mrow {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit;
  min-height: var(--tap);
}
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 700; color: var(--muted);
}
.mrow .meta { flex: 1; min-width: 0; }
.mrow .name { font-weight: 600; }
.mrow .preview { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- chat ---------- */
.chat-shell { display: flex; flex-direction: column; height: 100dvh; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 14px 8px; scroll-behavior: smooth; }
.bubbles { display: flex; flex-direction: column; gap: 8px; max-width: 640px; margin: 0 auto; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.bubble.pending { opacity: .7; }
.bubble.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; }
.bubble .tools { margin-top: 6px; display: flex; justify-content: flex-end; }
.bubble .tools button { min-height: 32px; padding: 4px 10px; font-size: 12px; background: transparent; color: var(--muted); border-color: transparent; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
.composer-inner { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 120px; min-height: var(--tap); border-radius: 22px; }
.ai-footer {
  text-align: center; font-size: 12px; color: var(--muted); padding: 6px 14px 12px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.reminder { margin: 12px auto; max-width: 640px; font-size: 13px; color: var(--muted); text-align: center; }
.usage-note { font-size: 12px; color: var(--muted); text-align: right; padding: 0 14px 4px; }

@media (prefers-reduced-motion: reduce) {
  .pcard.snap { transition: none; } .typing i { animation: none; } .chat-scroll { scroll-behavior: auto; }
}
