/* SangBaz — stone marketplace. Mobile-first, English. */
:root {
  --bg: #f7f2ea;
  --card: #ffffff;
  --line: #eae1d1;
  --line2: #ddd1bc;
  --text: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --dark: #1c1917;
  --dark2: #292524;
  --amber: #b45309;
  --amber2: #d97706;
  --amber-soft: #fef3c7;
  --amber-line: #fde68a;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 2px 8px rgba(28, 25, 23, .05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; padding: 0; background: var(--bg) url('/img/grain.png'); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 15px; line-height: 1.45;
}
#app { max-width: 600px; margin: 0 auto; min-height: 100dvh; padding-bottom: 84px; }
a { color: var(--amber); text-decoration: none; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 60; color: #fff;
  background: var(--dark) url('/img/bar.jpg') center/cover;
  padding: 12px 14px 11px; display: flex; align-items: center; gap: 10px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.appbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: .2px; }
.appbar .brand .mark {
  width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(145deg, var(--amber2), #92400e);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.appbar .title { font-weight: 700; font-size: 17px; flex: 1; }
.appbar .back {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .12); border: 0;
  color: #fff; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.appbar .actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.appbar .iconbtn {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .12); border: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 15px;
}
.appbar .iconbtn svg, .appbar .back svg { width: 18px; height: 18px; fill: currentColor; }
.appbar .brand .mark svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- layout blocks ---------- */
.wrap { padding: 12px 12px 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 10px; }
.card.text { padding: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 4px 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; word-wrap: break-word; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line2); background: #fff; color: var(--text);
  padding: 11px 14px; border-radius: 12px; font-size: 15px; font-weight: 600;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: 0 0 18px; fill: currentColor; }
.btn.sm svg { width: 15px; height: 15px; flex-basis: 15px; }
.chat-composer #th-send { width: 46px; height: 44px; padding: 0; flex: 0 0 46px; }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.amber { background: var(--amber2); border-color: var(--amber2); color: #fff; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn.sm { padding: 7px 11px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line2); background: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted);
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }

/* ---------- chips / pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #f5f5f4; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.amber { background: var(--amber-soft); border-color: var(--amber-line); color: #92400e; }
.chip.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip.green { background: var(--green-soft); border-color: #bbf7d0; color: var(--green); }
.chip.red { background: var(--red-soft); border-color: #fecaca; color: var(--red); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dist { color: var(--faint); font-size: 12px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.dist svg { width: 11px; height: 11px; fill: currentColor; }
.ipin { display: inline-flex; align-items: center; vertical-align: -2px; margin-right: 3px; }
.ipin svg { width: 12px; height: 12px; fill: var(--faint); }
.rating { color: #b45309; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.rating .off { color: var(--faint); font-weight: 500; }

/* ---------- user chip rows ---------- */
.urow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.urow .uname { font-weight: 700; font-size: 14.5px; }
.urow .sub { color: var(--faint); font-size: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(145deg, #57534e, #292524);
}
.avatar.company { background: linear-gradient(145deg, var(--amber2), #92400e); }
.avatar.sm { width: 30px; height: 30px; flex: 0 0 30px; font-size: 12.5px; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
input[type=text], input[type=password], input[type=tel], input[type=number], textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line2); border-radius: var(--radius-s);
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: 2px solid #fcd34d; outline-offset: 0; border-color: #f59e0b; }
.input-row { display: flex; gap: 8px; }
.input-row > * { flex: 1; }
.seg { display: flex; gap: 8px; }
.seg .opt {
  flex: 1; border: 1.5px solid var(--line2); border-radius: var(--radius-s); padding: 11px 10px; text-align: center;
  cursor: pointer; background: #fff; font-weight: 600; font-size: 14px; color: var(--muted);
}
.seg .opt.on { border-color: var(--amber2); background: var(--amber-soft); color: #92400e; }
.seg .opt .desc { display: block; font-size: 11.5px; font-weight: 500; margin-top: 2px; color: var(--faint); }
.seg .opt.on .desc { color: #b45309; }

/* ---------- market feed ---------- */
.searchbar { padding: 10px 12px 0; }
.searchbar .box {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px; box-shadow: var(--shadow);
}
.searchbar input { border: 0; padding: 0; font-size: 15px; background: transparent; }
.searchbar input:focus { outline: none; }
.searchbar svg { width: 17px; height: 17px; fill: var(--faint); flex: 0 0 17px; }
.searchbar .fb {
  position: relative; border: 0; background: transparent; padding: 2px 0 2px 8px;
  display: inline-flex; align-items: center; color: var(--muted); cursor: pointer;
}
.searchbar .fb svg { width: 19px; height: 19px; flex: 0 0 19px; fill: currentColor; }
.searchbar .fb .fcount {
  position: absolute; top: -6px; right: -6px; background: var(--amber2); color: #fff;
  font-size: 10px; font-weight: 800; min-width: 16px; height: 16px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1px solid rgba(28,25,23,.18); flex: 0 0 9px; }
.chips-wrap { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-wrap .chip { cursor: pointer; padding: 5px 12px; font-size: 12.5px; }
.chips-wrap .chip.on { background: var(--dark); border-color: var(--dark); color: #fff; }
.stone-chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 2px; scrollbar-width: none; }
.stone-chips::-webkit-scrollbar { display: none; }
.stone-chips .chip { cursor: pointer; padding: 5px 12px; font-size: 12.5px; }
.stone-chips .chip.on { background: var(--dark); border-color: var(--dark); color: #fff; }
.adcard { margin-bottom: 12px; cursor: pointer; }
.adcard .imgwrap { position: relative; background: #eeece9; }
.adcard .imgwrap img { width: 100%; height: 195px; object-fit: cover; }
.adcard .imgwrap .noimg {
  height: 195px; display: flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, .9); font-size: 34px;
  background: linear-gradient(145deg, #e2d3b6, #c4ad84);
}
.noimg svg { width: 46px; height: 46px; fill: currentColor; }
.mini-ad .noimg svg { width: 30px; height: 30px; fill: currentColor; }
.adcard .body { padding: 11px 12px 12px; }
.adcard .title { font-weight: 700; font-size: 16px; margin-bottom: 2px; }
.adcard .price { font-weight: 800; color: var(--amber); font-size: 15.5px; }
.adcard .foot { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.adcard .nimg {
  position: absolute; right: 8px; bottom: 8px; background: rgba(28, 25, 23, .72); color: #fff;
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
}
.loadmore { text-align: center; padding: 6px 0 18px; }

/* ad detail */
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 100%; width: 100%; height: 260px; object-fit: cover; scroll-snap-align: start; }
.detail-body { padding: 14px; }
.detail-title { font-size: 19px; font-weight: 800; line-height: 1.25; }
.detail-price { font-size: 18px; font-weight: 800; color: var(--amber); margin-top: 4px; }
.kv { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); flex: 0 0 92px; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }

/* ---------- board ---------- */
.post { padding: 12px; }
.post .text { margin-top: 8px; font-size: 14.5px; }
.post .footline { margin-top: 8px; display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12.5px; }
.composer { padding: 12px; }
.composer textarea { min-height: 70px; }

/* ---------- chat ---------- */
.chat-item { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.chat-item:last-child { border-bottom: 0; }
.chat-item .middle { flex: 1; min-width: 0; }
.chat-item .lastmsg { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  background: var(--amber2); color: #fff; font-size: 11px; font-weight: 800; border-radius: 999px;
  min-width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.thread { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; position: relative; }
.msg .t { font-size: 10.5px; color: rgba(255,255,255,.65); margin-top: 3px; text-align: right; }
.msg.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.them .t { color: var(--faint); }
.msg.me { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 5px; }
.chat-composer {
  position: sticky; bottom: 0; background: var(--bg); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line);
}
.chat-composer textarea { min-height: 44px; max-height: 120px; }

/* ---------- profile ---------- */
.profile-head { padding: 16px; display: flex; gap: 12px; align-items: center; }
.profile-head .avatar { width: 54px; height: 54px; flex-basis: 54px; font-size: 21px; }
.profile-head .name { font-size: 18px; font-weight: 800; }
.stars-show { color: #f59e0b; font-size: 15px; letter-spacing: 1px; }
.rating-item { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.rating-item:last-child { border-bottom: 0; }
.ads-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-ad { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; }
.mini-ad img { width: 100%; height: 92px; object-fit: cover; }
.mini-ad .noimg { height: 92px; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); background: #ddcdae; font-size: 24px; }
.mini-ad .b { padding: 7px 8px 8px; }
.mini-ad .t { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: #fff;
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--faint); font-size: 10.5px; font-weight: 600; cursor: pointer; position: relative;
}
.nav .item svg { width: 22px; height: 22px; fill: currentColor; }
.nav .item.on { color: var(--amber); }
.nav .item .nbadge {
  position: absolute; top: 4px; right: calc(50% - 22px); background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; border-radius: 999px; min-width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- fab ---------- */
.fab {
  position: fixed; right: max(16px, calc(50% - 284px)); bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--amber2); color: #fff; border: 0;
  box-shadow: 0 6px 18px rgba(180, 83, 9, .45); font-size: 26px; font-weight: 300; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 65;
}
.fab svg { width: 24px; height: 24px; fill: #fff; }

/* ---------- modal / toast ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(28, 25, 23, .5); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; width: 100%; max-width: 600px; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto;
  animation: slideup .18s ease-out;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.mhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mhead h3 { margin: 0; }
.mx {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; border: 1px solid var(--line2);
  background: #fff; color: var(--muted); display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer;
}
.mx svg { width: 15px; height: 15px; fill: currentColor; }
.toast {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  z-index: 200; max-width: 88vw; text-align: center; box-shadow: 0 6px 22px rgba(0,0,0,.3);
  animation: fadein .15s ease-out;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* picker */
.picklist { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-top: 6px; }
.picklist .p { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; cursor: pointer; background: #fff; }
.picklist .p:last-child { border-bottom: 0; }
.picklist .p:hover { background: #fafaf9; }

/* map */
.map { height: 230px; border-radius: var(--radius-s); overflow: hidden; border: 1px solid var(--line2); z-index: 1; }
.leaflet-container { font: inherit !important; }

/* photo picker */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(28,25,23,.75); color: #fff; border: 0; font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.addphoto {
  width: 74px; height: 74px; border-radius: 10px; border: 1.5px dashed var(--line2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--faint); font-size: 11px; gap: 2px; cursor: pointer; background: #fff;
}
.addphoto svg { width: 20px; height: 20px; fill: var(--faint); }

/* stars input */
.stars-in { display: flex; gap: 6px; justify-content: center; padding: 6px 0 10px; }
.stars-in .s { font-size: 36px; cursor: pointer; color: #d6d3d1; line-height: 1; user-select: none; }
.stars-in .s.on { color: #f59e0b; }

/* auth hero */
.hero {
  padding: 44px 20px 30px; text-align: center;
  background: url('/img/hero.jpg') center/cover;
  border-radius: 0 0 24px 24px; margin-bottom: 14px;
  box-shadow: inset 0 -22px 26px -22px rgba(28, 25, 23, .3);
}
.hero .logo {
  width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 22px;
  background: linear-gradient(145deg, var(--amber2), #92400e); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(180, 83, 9, .35); font-size: 38px;
}
.hero .logo svg { width: 40px; height: 40px; fill: currentColor; }
.hero h1 { margin: 0; font-size: 27px; letter-spacing: .3px; color: #241d16; text-shadow: 0 1px 0 rgba(255, 255, 255, .45); }
.hero p { margin: 6px 0 0; color: #6b5a44; font-size: 14px; }
.authtabs { display: flex; background: #efe7d8; border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.authtabs .t { flex: 1; text-align: center; padding: 9px 0; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; }
.authtabs .t.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--line2); border-top-color: var(--amber2);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 22px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--amber); font-weight: 600; cursor: pointer; }
.danger-text { color: var(--red); font-weight: 600; cursor: pointer; }

/* ---------- language switch ---------- */
.langsw { display: flex; gap: 8px; justify-content: center; margin: 16px 0 2px; }
.langp {
  border: 1px solid rgba(36, 29, 22, .2); background: rgba(255, 255, 255, .78); color: #4b3f33;
  padding: 7px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.langp.on { background: #241d16; color: #fff; border-color: #241d16; }
.card .langsw { margin: 4px 0 0; justify-content: flex-start; }
.card .langp { border-color: var(--line2); background: #fff; color: var(--muted); }
.card .langp.on { background: var(--dark); color: #fff; border-color: var(--dark); }
/* English-only fields (username / password) stay LTR inside an RTL page */
input.ltr { direction: ltr; text-align: left; }

/* ---------- RTL mirroring ---------- */
[dir=rtl] .appbar .actions { margin-left: 0; margin-right: auto; }
[dir=rtl] .appbar .back svg { transform: scaleX(-1); }
[dir=rtl] .searchbar .fb { padding: 2px 8px 2px 0; }
[dir=rtl] .searchbar .fb .fcount { right: auto; left: -6px; }
[dir=rtl] .adcard .nimg { right: auto; left: 8px; }
[dir=rtl] .thumb .x { right: auto; left: 3px; }
[dir=rtl] .fab { right: auto; left: max(16px, calc(50% - 284px)); }
[dir=rtl] .nav .item .nbadge { right: auto; left: calc(50% - 22px); }
/* user-typed text keeps its own direction (Farsi right, Latin left) */
[dir=rtl] .pre, [dir=rtl] .price, [dir=rtl] .title, [dir=rtl] .name, [dir=rtl] .uname,
[dir=rtl] .detail-title, [dir=rtl] .detail-price, [dir=rtl] .kv .v, [dir=rtl] .lastmsg {
  unicode-bidi: plaintext;
}
