/* MoolBhau — warm, chat-first marketplace UI */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface2: #f4eee3;
  --ink: #26211b;
  --ink2: #6d6459;
  --ink3: #a59c8e;
  --brand: #c2410c;
  --brand-deep: #9a3412;
  --brand-grad: linear-gradient(135deg, #f59e0b, #ea580c);
  --good: #047857;
  --good-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;
  --line: #eae2d4;
  --chip: #f1e9da;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(38, 33, 27, .06), 0 6px 20px rgba(38, 33, 27, .07);
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
button { font: inherit; }
a { color: var(--brand); text-decoration: none; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px calc(10px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; color: var(--ink); }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-grad); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 6px rgba(234, 88, 12, .35);
}
.logo-word { font-weight: 700; font-size: 17px; letter-spacing: -.01em; display: flex; flex-direction: column; line-height: 1.05; }
.logo-word small { font-weight: 500; font-size: 10.5px; color: var(--ink3); letter-spacing: .01em; }

main {
  max-width: 560px; margin: 0 auto;
  padding: 14px 14px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  min-height: 70vh;
}
@media (min-width: 720px) { main { padding-top: 20px; } }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink3); font-size: 11px; font-weight: 600;
  padding: 4px 14px; border-radius: 10px;
}
.tabbar a svg { width: 22px; height: 22px; fill: currentColor; }
.tabbar a.active { color: var(--brand); }
.tabbar em {
  position: absolute; top: 0; right: 6px;
  background: var(--brand); color: #fff; font-style: normal;
  font-size: 10px; font-weight: 700; border-radius: 999px;
  min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px;
}
.tabbar em[hidden] { display: none; }

/* ---------- primitives ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; cursor: pointer;
  border-radius: 11px; padding: 11px 18px;
  font-weight: 700; font-size: 14.5px;
  background: var(--brand-grad); color: #fff;
  box-shadow: 0 2px 8px rgba(234, 88, 12, .3);
  transition: transform .06s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ghost {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: none;
}
.btn.subtle { background: var(--chip); color: var(--brand-deep); box-shadow: none; }
.btn.danger { background: var(--danger-bg); color: var(--danger); box-shadow: none; }
.btn.good { background: var(--good); box-shadow: 0 2px 8px rgba(4, 120, 87, .3); }
.btn.small { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }

input, select, textarea {
  width: 100%;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
label.field { display: block; margin: 12px 0 0; font-size: 12.5px; font-weight: 700; color: var(--ink2); }
label.field input, label.field select, label.field textarea { margin-top: 5px; font-weight: 500; }
label.field .hint { font-weight: 500; color: var(--ink3); font-size: 11.5px; margin-top: 4px; display: block; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--ink2); }
.tiny { font-size: 12px; }
.center { text-align: center; }
h2 { font-size: 19px; letter-spacing: -.015em; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

/* ---------- chips & search ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.kind-toggle {
  display: flex; background: var(--chip); border-radius: 11px; padding: 3px; margin-bottom: 12px;
}
.kind-toggle button {
  flex: 1; border: none; background: transparent; padding: 8px;
  border-radius: 9px; font-weight: 700; color: var(--ink2); cursor: pointer;
}
.kind-toggle button.active { background: var(--surface); color: var(--brand-deep); box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.chip.active { background: var(--brand-grad); border-color: transparent; color: #fff; }
.chip .n { color: var(--ink3); font-weight: 600; font-size: 11.5px; }
.chip.active .n { color: rgba(255,255,255,.85); }

/* ---------- listing cards ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.listing-card { display: flex; gap: 12px; cursor: pointer; }
.listing-emoji {
  flex: 0 0 46px; width: 46px; height: 46px;
  border-radius: 12px; background: var(--surface2);
  display: grid; place-items: center; font-size: 22px;
}
.listing-main { min-width: 0; flex: 1; }
.listing-title { font-weight: 700; font-size: 14.5px; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-sub { color: var(--ink2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.price { font-weight: 800; color: var(--good); font-size: 13.5px; }
.tag {
  background: var(--chip); color: var(--ink2);
  font-size: 11px; font-weight: 700; padding: 2.5px 8px; border-radius: 999px;
}
.tag.b2b { background: #ede9fe; color: #5b21b6; }
.alias-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink2); }
.avatar {
  width: 20px; height: 20px; border-radius: 999px; color: #fff;
  display: inline-grid; place-items: center; font-size: 10px; font-weight: 800;
}

/* ---------- detail ---------- */
.detail-head { display: flex; gap: 12px; align-items: flex-start; }
.privacy-note {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--surface2); border-radius: var(--radius-s);
  padding: 10px 12px; font-size: 12.5px; color: var(--ink2); margin-top: 12px;
}

/* ---------- chat ---------- */
.thread-list .card { cursor: pointer; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.badge.pending { background: var(--warn-bg); color: var(--warn-ink); }
.badge.accepted { background: var(--good-bg); color: var(--good); }
.badge.declined, .badge.closed { background: var(--surface2); color: var(--ink3); }

.chat-screen { display: flex; flex-direction: column; min-height: calc(100vh - 220px); }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 14.5px; }
.chat-head .who span { font-size: 12px; color: var(--ink2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: grid; place-items: center;
}
.iconbtn svg { width: 20px; height: 20px; fill: var(--brand); }

.msgs { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 4px 0 12px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: linear-gradient(135deg, #fde9d2, #fddcc3); border-bottom-right-radius: 5px; }
.msg.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.system {
  align-self: center; background: var(--surface2); color: var(--ink2);
  font-size: 12px; border-radius: 999px; padding: 6px 14px; text-align: center; max-width: 95%;
}
.msg time { display: block; font-size: 10px; color: var(--ink3); margin-top: 3px; text-align: right; }
.redact-note { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--warn-ink); margin-top: 3px; }

.offer-card {
  align-self: center; width: 92%;
  border: 1.5px dashed #f0b27a; background: #fffaf3;
  border-radius: var(--radius); padding: 12px 14px;
}
.offer-amount { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.offer-split { font-size: 11.5px; color: var(--ink2); margin-top: 3px; }
.offer-actions { display: flex; gap: 8px; margin-top: 10px; }
.offer-status { font-size: 11px; font-weight: 800; }
.offer-status.paid { color: var(--good); }

.composer {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; gap: 8px; padding: 8px 0 4px; background: var(--bg);
}
.composer textarea { resize: none; height: 44px; border-radius: 14px; }
.composer .btn { border-radius: 14px; padding: 0 16px; }

.pii-banner {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: var(--radius-s); padding: 9px 12px; font-size: 12.5px; margin: 8px 0;
}

/* ---------- request gate ---------- */
.request-gate { text-align: center; padding: 18px 10px; }
.request-gate .big { font-size: 34px; }

/* ---------- wallet (stat tiles per dataviz spec) ---------- */
.hero-tile { padding: 20px 16px; }
.hero-tile .label { font-size: 13px; font-weight: 600; color: var(--ink2); }
.hero-tile .value {
  font-size: 48px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px;
}
.tile-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.stat-tile { padding: 13px 14px; }
.stat-tile .label { font-size: 12.5px; font-weight: 600; color: var(--ink2); }
.stat-tile .value { font-size: 24px; font-weight: 600; letter-spacing: -.015em; margin-top: 2px; }
.txns { margin-top: 14px; }
.txn { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.txn:last-child { border-bottom: none; }
.txn .amt { font-variant-numeric: tabular-nums; font-weight: 700; }
.txn .amt.credit { color: var(--good); }
.txn .amt.debit { color: var(--ink2); }
.txn .memo { color: var(--ink2); }

/* ---------- profile ---------- */
.role-toggles { display: flex; gap: 10px; margin: 10px 0 2px; }
.role-card {
  flex: 1; cursor: pointer; user-select: none;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 12px; text-align: center;
}
.role-card.on { border-color: #f59e0b; background: #fff8ec; box-shadow: 0 0 0 3px rgba(245, 158, 11, .12); }
.role-card .em { font-size: 22px; }
.role-card b { display: block; font-size: 13.5px; margin-top: 3px; }
.role-card span { font-size: 11px; color: var(--ink2); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(30, 24, 16, .45);
  display: grid; place-items: end center;
  animation: fade .15s ease;
}
@media (min-width: 560px) { .modal-backdrop { place-items: center; } }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 18px 26px;
}
@media (min-width: 560px) { .modal { border-radius: 20px; } }
.modal h2 { margin-top: 0; }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast ---------- */
#toast-root { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 16px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 10px 16px; border-radius: 999px; max-width: 92%;
  box-shadow: var(--shadow); animation: pop .18s ease;
}
.toast.warn { background: var(--warn-ink); }
.toast.good { background: var(--good); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- video call ---------- */
.call-overlay {
  position: fixed; inset: 0; z-index: 70; background: #17120c;
  display: flex; flex-direction: column;
}
.call-videos { position: relative; flex: 1; }
.call-videos video.remote { width: 100%; height: 100%; object-fit: cover; background: #241c12; }
.call-videos video.local {
  position: absolute; right: 14px; top: 14px;
  width: 108px; aspect-ratio: 3/4; object-fit: cover;
  border-radius: 12px; border: 2px solid rgba(255,255,255,.5); background: #000;
}
.call-status { position: absolute; left: 0; right: 0; top: 16px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.call-controls { display: flex; justify-content: center; gap: 16px; padding: 18px 0 calc(22px + env(safe-area-inset-bottom)); }
.call-controls button {
  width: 56px; height: 56px; border-radius: 999px; border: none; cursor: pointer;
  display: grid; place-items: center; background: rgba(255,255,255,.14);
}
.call-controls button svg { width: 24px; height: 24px; fill: #fff; }
.call-controls button.off { background: rgba(255,255,255,.85); }
.call-controls button.off svg { fill: #26211b; }
.call-controls button.end { background: #dc2626; }
.incoming-banner {
  position: fixed; z-index: 65; left: 12px; right: 12px; top: 12px;
  background: var(--ink); color: #fff; border-radius: 16px;
  padding: 13px 15px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: pop .2s ease;
}
.incoming-banner .grow { flex: 1; }
.incoming-banner b { display: block; }
.incoming-banner span { font-size: 12px; opacity: .8; }

/* ---------- AI concierge ---------- */
#fab-ai {
  position: fixed; z-index: 45;
  right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--brand-grad); font-size: 24px;
  box-shadow: 0 4px 14px rgba(234, 88, 12, .45);
  transition: transform .1s;
}
#fab-ai:active { transform: scale(.92); }
.ai-msgs { display: flex; flex-direction: column; gap: 7px; max-height: 46vh; overflow-y: auto; padding: 4px 0; }
.ai-quick { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0 2px; }
.ai-card {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 10px; margin-top: 6px;
}
.ai-card .em { font-size: 18px; }
.ai-card b { font-size: 12.5px; display: block; }
.ai-card span { font-size: 11px; color: var(--ink2); }
.ai-compose { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--ink2); padding: 34px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.section-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--ink3); margin: 18px 0 8px; }
.how-step { display: flex; gap: 12px; margin-bottom: 14px; }
.how-step .n {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 999px;
  background: var(--brand-grad); color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 14px;
}
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--surface2), #fff, var(--surface2)); background-size: 200% 100%; animation: sk 1.1s linear infinite; height: 72px; }
@keyframes sk { to { background-position: -200% 0; } }
