/* Bound on the web: phone-first, styled to feel like the iPhone app. */

:root {
  --accent: #f46652;
  --brand: linear-gradient(135deg, #fa8c54, #e6456b);
  --bg: #ffffff;
  --card: #f2f2f7;
  --text: #111114;
  --secondary: #6c6c72;
  --tertiary: #b4b4ba;
  --line: #e3e3e8;
  --fill: rgba(120, 120, 128, 0.12);
  --accent-soft: rgba(244, 102, 82, 0.14);
  --danger: #e5383b;
  --bar: rgba(255, 255, 255, 0.86);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  --radius: 20px;
  --tabbar: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --secondary: #9a9aa1;
    --tertiary: #55555b;
    --line: #2c2c2e;
    --fill: rgba(120, 120, 128, 0.24);
    --accent-soft: rgba(244, 102, 82, 0.22);
    --bar: rgba(22, 22, 24, 0.86);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
img { display: block; }
.icon { flex: none; }

.secondary { color: var(--secondary); }
.caption { color: var(--secondary); font-size: 13px; }
.caption.error, .form-error { color: var(--danger); font-size: 14px; }
.form-notice { color: var(--accent); font-size: 14px; }
.accent { color: var(--accent); font-weight: 500; }
.bold { font-weight: 600; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; }
.gap { gap: 14px; }
.center { align-self: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ─── Layout ─────────────────────────────────────────────────────────────────────────── */

.shell main { max-width: 600px; margin: 0 auto; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px); }
.shell.full main { padding-bottom: 0; }
.page { display: flex; flex-direction: column; gap: 16px; padding: 16px 16px 24px; }
.page.has-footer { padding-bottom: 110px; }
.page-title { display: flex; align-items: baseline; justify-content: space-between; padding-top: 8px; }
.page-title h1 { font-size: 34px; }
.center-page { min-height: 70vh; display: grid; place-content: center; gap: 16px; text-align: center; padding: 24px; }

.splash { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--fill); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
}
.tabbar a {
  flex: 0 1 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--secondary); font-size: 11px; font-weight: 500;
}
.tabbar a.active { color: var(--accent); }

.backbar { display: flex; align-items: center; justify-content: space-between; margin: -8px -8px 0; }
.icon-button {
  width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none;
  color: var(--accent); border-radius: 50%; cursor: pointer;
}
.icon-button:hover { background: var(--fill); }

/* ─── Controls ───────────────────────────────────────────────────────────────────────── */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
.button:hover { filter: brightness(1.06); }
.button:disabled { opacity: 0.4; cursor: default; filter: none; }
.button.wide { width: 100%; }
.button.large { min-height: 52px; font-size: 17px; }
.button.pill { border-radius: 999px; padding: 8px 20px; }
.button.secondary { background: var(--fill); color: var(--accent); }
.button.danger { background: var(--danger); color: #fff; }
.button.secondary.danger { background: var(--fill); color: var(--danger); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 0; font-size: 17px; }
.link.small { font-size: 15px; }
.link:disabled { opacity: 0.4; cursor: default; }
.link.danger, .danger { color: var(--danger); }

.segmented { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; }
.segmented button {
  flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.segmented button.on { background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented button.on { background: #636366; } }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--secondary); }
.field input, .field select, .field textarea, .composer {
  width: 100%; padding: 12px 14px; border: 1px solid transparent; border-radius: 12px;
  background: var(--card); font-size: 16px; outline: none; resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus, .composer:focus { border-color: var(--accent); }
.field.prefix { flex-direction: row; align-items: center; gap: 0; background: var(--card); border-radius: 12px; padding-left: 14px; }
.field.prefix span { color: var(--secondary); font-size: 16px; }
.field.prefix input { padding-left: 2px; }
.toggle { display: flex; justify-content: space-between; align-items: center; font-weight: 500; cursor: pointer; }
.toggle input {
  appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--fill);
  position: relative; cursor: pointer; transition: background 0.2s; margin: 0;
}
.toggle input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s;
}
.toggle input:checked { background: #34c759; }
.toggle input:checked::after { transform: translateX(20px); }

.chips, .tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags { gap: 6px; }
.chip {
  display: inline-block; padding: 7px 12px; border-radius: 999px; border: 0;
  background: var(--fill); font-size: 15px; white-space: nowrap;
}
button.chip { cursor: pointer; }
.chip.selected { background: var(--accent); color: #fff; }
.chip.highlighted { background: var(--accent-soft); }
.tag { padding: 4px 8px; border-radius: 999px; background: var(--fill); font-size: 12px; font-weight: 500; }

/* ─── Cards and avatars ──────────────────────────────────────────────────────────────── */

.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card p { line-height: 1.45; }

.avatar {
  position: relative; flex: none; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; color: #fff; font-weight: 700;
  font-family: ui-rounded, -apple-system, sans-serif;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-stack { display: flex; }
.avatar-stack > * { margin-right: calc(var(--size) * -0.3); box-shadow: 0 0 0 2px var(--card); }
.avatar.more { background: var(--fill); color: var(--text); font-size: 12px; font-weight: 700; }

.banner {
  background: var(--brand); color: #fff; border-radius: 22px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.banner .eyebrow { font-size: 12px; font-weight: 700; opacity: 0.85; letter-spacing: 0.03em; }
.banner-route { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banner hr { border: 0; border-top: 1px solid rgba(255, 255, 255, 0.4); width: 100%; margin: 6px 0; }

.crew { flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
.crew > div { display: flex; flex-direction: column; gap: 8px; }

.match { flex-direction: row; align-items: flex-start; gap: 14px; color: inherit; transition: transform 0.1s; }
.match:active { transform: scale(0.99); }
.match-body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.match-name { display: flex; justify-content: space-between; font-size: 17px; }
.chevron { color: var(--tertiary); font-size: 22px; line-height: 1; }

.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.profile-head h1 { margin-top: 4px; }

.journey { display: flex; flex-direction: column; gap: 12px; }
.journey-row { display: flex; gap: 12px; align-items: flex-start; color: var(--accent); }
.journey-title { color: var(--text); font-weight: 500; font-size: 15px; }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reasons li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.reasons .icon { color: var(--accent); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--fill); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile.add { display: grid; place-items: center; border: 1.5px dashed var(--tertiary); background: none; color: var(--accent); cursor: pointer; }
.tile-remove {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, 0.6); color: #fff; display: grid; place-items: center; cursor: pointer;
}

.links a { font-size: 15px; }
.account-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 8px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; z-index: 20; min-width: 220px; padding: 6px;
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); border: 0.5px solid var(--line);
}
.menu button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; font-size: 16px;
}
.menu button:hover { background: var(--fill); }

.footer-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 5;
  padding: 12px 16px; background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.footer-bar .button { max-width: 568px; margin: 0 auto; display: flex; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 40px 16px; color: var(--secondary); }
.empty h3 { color: var(--text); }
.empty p { font-size: 15px; max-width: 340px; }
.empty .button { margin-top: 8px; }

/* ─── Sheets ─────────────────────────────────────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.25s ease-out;
}
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; box-shadow: var(--shadow); }
}
.sheet-header {
  position: sticky; top: 0; background: var(--bg); z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 16px; border-bottom: 0.5px solid var(--line);
}
.sheet-header h2 { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-header > :first-child { justify-self: start; }
.sheet-actions { justify-self: end; }
.sheet-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.starter {
  text-align: left; border: 0; border-radius: 12px; padding: 12px; background: var(--accent-soft);
  font-size: 15px; cursor: pointer;
}
.choices { display: flex; flex-direction: column; gap: 2px; }
.choice { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 0.5px solid var(--line); cursor: pointer; }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 100;
  width: min(92vw, 480px); padding: 12px 16px; border-radius: 14px;
  background: var(--danger); color: #fff; font-size: 15px; box-shadow: var(--shadow); cursor: pointer;
}

/* ─── Welcome and forms ──────────────────────────────────────────────────────────────── */

.welcome {
  max-width: 440px; margin: 0 auto; min-height: 100vh; padding: 48px 20px 32px;
  display: flex; flex-direction: column; gap: 22px; justify-content: center;
}
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero-icon { border-radius: 22px; box-shadow: 0 8px 24px rgba(230, 69, 107, 0.3); }
.hero h1 { font-size: 40px; }
.hero p { color: var(--secondary); font-size: 17px; max-width: 320px; }
.auth-card { gap: 16px; padding: 18px; }
.auth-card .field input { background: var(--bg); }
.fine-print { font-size: 13px; color: var(--secondary); text-align: center; line-height: 1.5; }

.form-page { gap: 22px; }
.topbar {
  position: sticky; top: 0; z-index: 5; margin: -16px -16px 0; padding: 10px 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 0.5px solid var(--line);
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar > :last-child { justify-self: end; }
.lead { color: var(--secondary); }
.group { display: flex; flex-direction: column; gap: 12px; }
.group h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--secondary); }

/* ─── Chats ──────────────────────────────────────────────────────────────────────────── */

.convo-list { list-style: none; margin: 0 -16px; padding: 0; }
.convo-row { display: flex; gap: 12px; align-items: center; padding: 10px 16px; color: inherit; }
.convo-row:hover { background: var(--fill); }
.convo-body { flex: 1; min-width: 0; border-bottom: 0.5px solid var(--line); padding-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.convo-top { display: flex; justify-content: space-between; gap: 8px; }
.convo-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-badge { width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }

.chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 600px; margin: 0 auto; }
.chat-bar {
  margin: 0; padding: 4px 8px; border-bottom: 0.5px solid var(--line);
  background: var(--bar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-bottom: 12px; }
.chat-head p { max-width: 300px; }
.bubble-row { display: flex; align-items: flex-end; gap: 8px; padding-right: 50px; }
.bubble-row.mine { justify-content: flex-end; padding: 0 0 0 50px; }
.bubble {
  padding: 9px 14px; border-radius: 18px; background: var(--fill);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35;
}
.bubble-row.mine .bubble { background: var(--brand); color: #fff; }
.composer-bar {
  display: flex; align-items: flex-end; gap: 10px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--line); background: var(--bar);
}
.composer-bar textarea {
  flex: 1; resize: none; max-height: 140px; field-sizing: content; padding: 9px 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--card); font-size: 16px; outline: none;
}
.send {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; cursor: pointer; flex: none; margin-bottom: 2px;
}
.send:disabled { opacity: 0.35; cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spacer { width: 44px; flex: none; }

/* ─── Plans and Housing ──────────────────────────────────────────────────────────────── */

.section-title { font-size: 20px; font-weight: 700; }
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { font-size: 15px; }
.plan-card { flex-direction: row; align-items: flex-start; gap: 14px; color: inherit; }
.date-badge {
  flex: none; width: 52px; height: 56px; border-radius: 12px; background: var(--accent-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.date-badge span { font-size: 11px; font-weight: 700; color: var(--accent); }
.date-badge strong { font-size: 22px; line-height: 1.1; }
.status-tag {
  flex: none; align-self: flex-start; padding: 2px 7px; border-radius: 999px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700;
}
.match-name { gap: 8px; }
.plan-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-meta .avatar-stack { margin-right: 6px; }
.accent-tag { background: var(--accent-soft); }

.detail-head { display: flex; flex-direction: column; gap: 6px; }
.big-emoji { font-size: 44px; line-height: 1.1; }
.rent { font-size: 20px; font-weight: 600; }
.facts > div { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.facts .icon { color: var(--accent); }
.person-row { display: flex; flex-direction: row; align-items: center; gap: 12px; color: inherit; }
.person-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 3px; border-radius: 999px;
  background: var(--fill); color: inherit; font-size: 15px;
}

.filter-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { flex: none; color: var(--text); }
.filter-row .chip.selected { color: #fff; }
.warning { display: flex; gap: 6px; align-items: flex-start; }

.thumb { flex: none; width: 84px; height: 84px; aspect-ratio: auto; }
.placeholder, .banner-placeholder { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.banner-placeholder { aspect-ratio: auto; height: 140px; }
.listing-body { gap: 3px; }
.kind-label { display: flex; align-items: center; gap: 5px; color: var(--accent); font-size: 13px; font-weight: 600; }
.poster { display: flex; align-items: center; gap: 6px; }
.gallery { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.gallery img { flex: none; width: 240px; height: 240px; object-fit: cover; border-radius: 12px; }
.sheet-body .group + .group { margin-top: 8px; }

/* Five tabs fit a phone; labels stay on one line. */
.tabbar { gap: 0; }
.tabbar a { flex: 1 1 0; max-width: 120px; min-width: 0; }

/* Short confirmations sit mid-screen, and sheets stay inside the visible area on iPhone Safari. */
.sheet-backdrop { height: 100dvh; bottom: auto; padding-bottom: env(safe-area-inset-bottom); }
.sheet-backdrop.center { align-items: center; padding: 16px; }
.sheet-backdrop.center .sheet { border-radius: 18px; box-shadow: var(--shadow); }
.sheet { max-height: 92dvh; }
button, a, label { touch-action: manipulation; }

.more-button { background: var(--accent-soft); }
.more-button:hover { background: var(--accent-soft); filter: brightness(0.96); }
