/* BoozeBuddy: mobile-first (§1). Base = 320-430px phone; min-width queries only,
   additive. Token structure borrowed from tallyme; layout is our own.
   100dvh not 100vh; env(safe-area-inset-*); transform/opacity only on the card. */

:root {
  --bg: #0f0f14; --surface: #1a1a22; --surface-2: #24242e;
  --text: #f2f2f5; --muted: #9a9aa8; --line: #33333f;
  --accent: #ff5a5f; --like: #4ade80; --danger: #ff5a5f;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-1: 8px; --r-2: 12px; --r-3: 20px; --z-toast: 100;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: var(--sp-4); }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 var(--sp-3); line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); }

/* buttons + inputs */
button { font: inherit; cursor: pointer; border: none; border-radius: var(--r-2); }
.primary, .send { background: var(--accent); color: #fff; padding: var(--sp-3) var(--sp-4); font-weight: 600; }
.secondary { background: var(--surface-2); color: var(--text); padding: var(--sp-3) var(--sp-4); }
.full { width: 100%; margin-top: var(--sp-3); }
.navbtn { background: transparent; color: var(--text); padding: var(--sp-2) var(--sp-3); }
.navbtn.danger { color: var(--danger); }
input, textarea, select {
  width: 100%; padding: var(--sp-3); background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-1); font: inherit;
}
label { display: block; margin-bottom: var(--sp-3); font-size: 14px; color: var(--muted); }
label input, label textarea, label select { margin-top: var(--sp-1); }
.stack > * { margin-bottom: var(--sp-3); }

/* cards */
.card { background: var(--surface); border-radius: var(--r-3); padding: var(--sp-5); }
.auth-card { max-width: 420px; margin: auto; width: 100%; text-align: center; }
.brand { color: var(--accent); font-size: 32px; }
.brand-sm { font-weight: 700; }
.link-safety { display: block; text-align: center; margin-top: var(--sp-4); }

/* toast + spinner */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--surface-2); color: var(--text);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-2); z-index: var(--z-toast);
  max-width: 90%; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.spinner { width: 32px; height: 32px; margin: auto; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* topbar */
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) var(--sp-4); padding: var(--sp-4); padding-top: calc(var(--sp-3) + env(safe-area-inset-top)); }
.topbar nav { display: flex; gap: var(--sp-2); }

/* deck */
.deck-stack { position: relative; flex: 1; min-height: 0; }
.deck-card {
  position: absolute; inset: 0; background: var(--surface); border-radius: var(--r-3);
  overflow: hidden; touch-action: none; display: flex; flex-direction: column;
  box-shadow: 0 8px 30px rgba(0,0,0,.45); will-change: transform;
}
.deck-card .photo { flex: 1; min-height: 0; background: var(--surface-2); }
.deck-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.deck-card .noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); }
.deck-card .meta { padding: var(--sp-4); }
.tags, .chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag { background: var(--surface-2); padding: 2px var(--sp-2); border-radius: var(--r-1); font-size: 12px; }
.chip { background: var(--surface-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-2); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.chip input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-1); margin: 0 0 var(--sp-3); }
legend { color: var(--muted); font-size: 13px; }
.deck-actions { display: flex; justify-content: center; gap: var(--sp-6); padding: var(--sp-4) 0 calc(var(--sp-2) + env(safe-area-inset-bottom)); }
.round { width: 60px; height: 60px; border-radius: 50%; font-size: 24px; background: var(--surface-2); color: var(--text); box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.round.like { color: var(--like); }
.round.pass { color: var(--muted); }
.empty { text-align: center; color: var(--muted); margin: auto; padding: var(--sp-6); }

/* matches list */
.list { flex: 1; min-height: 0; overflow-y: auto; }
.match-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  background: transparent; color: var(--text); padding: var(--sp-3); border-bottom: 1px solid var(--line); text-align: left; }
.avatar { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: var(--surface-2); flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.match-name { display: flex; flex-direction: column; }

/* chat */
.chat-menu { display: flex; gap: var(--sp-1); }
.nudge { background: var(--surface-2); color: var(--muted); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); font-size: 13px; margin-bottom: var(--sp-2); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2) 0; }
.bubble { max-width: 78%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-2); word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: #fff; }
.bubble.theirs { align-self: flex-start; background: var(--surface-2); }
.chat-form { display: flex; gap: var(--sp-2); padding-bottom: env(safe-area-inset-bottom); }
.chat-form input { flex: 1; }

.photo-btn { display: block; background: var(--surface-2); padding: var(--sp-3); border-radius: var(--r-2); text-align: center; margin-top: var(--sp-4); color: var(--text); }

/* static docs (safety centre) */
.doc { max-width: 640px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom)); }
.doc h2 { margin-top: var(--sp-5); }
.doc ul { padding-left: var(--sp-5); }
.doc li { margin-bottom: var(--sp-2); }

@media (min-width: 640px) {
  .screen { max-width: 520px; margin: 0 auto; width: 100%; }
  .deck-stack { min-height: 60vh; }
}
