:root {
  --bg: #f4f6fb;
  --surface: #fff;
  --border: #dce1ec;
  --text: #1b1f2a;
  --text-muted: #596278;
  --primary: #3455d8;
  --primary-hover: #2946b9;
  --primary-soft: #edf0ff;
  --danger: #b4232b;
  --radius: 14px;
  --shadow: 0 3px 12px rgba(20, 24, 40, .07);
  color-scheme: light;
  accent-color: var(--primary);
  scrollbar-color: #9ba6bd var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101219;
    --surface: #191e2b;
    --border: #384156;
    --text: #e8eaf2;
    --text-muted: #adb6ca;
    --primary: #4868e6;
    --primary-hover: #3c5ddc;
    --primary-soft: #232e50;
    --danger: #b93039;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .58; cursor: wait; }
a { color: var(--primary); text-underline-offset: .2em; }
button, input, textarea, select { caret-color: var(--primary); }
::selection { background: var(--primary); color: #fff; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.2; letter-spacing: -.025em; margin: 0 0 16px; }
h2 { font-size: 20px; line-height: 1.35; margin: 0 0 12px; }
p { margin: 0 0 16px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: inline-block; width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -80px; left: 16px; padding: 12px 20px; background: var(--surface); color: var(--text); z-index: 100; }
.skip-link:focus { top: 10px; }
#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: calc(env(safe-area-inset-top, 0px) + 12px) max(20px, calc((100% - 1160px) / 2)) 12px; background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 23px; font-weight: 750; letter-spacing: -.025em; text-decoration: none; line-height: 1.1; }
.brand > .icon { color: var(--primary); width: 32px; height: 32px; }
.brand-domain { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--text-muted); }
.topbar-title { color: var(--text-muted); font-size: 14px; margin-inline-start: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; background: transparent; color: var(--text); border: 0; border-radius: 12px; }
.icon-btn:hover { background: var(--bg); }
.screen { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; padding: 28px max(20px, calc((100% - 1160px) / 2)) calc(108px + env(safe-area-inset-bottom, 0px)); scroll-padding-block: 16px 90px; }
.screen:focus { outline: none; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: clamp(8px, 5vw, 80px); background: var(--surface); border-top: 1px solid var(--border); padding: 8px 8px calc(env(safe-area-inset-bottom, 0px) + 8px); z-index: 10; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 6px 12px; min-width: 64px; min-height: 56px; border: none; border-radius: 10px; color: var(--text-muted); background: none; font-size: 12px; }
.nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.nav-item:hover { background: var(--bg); }
.home-intro { margin: 4px 0 24px; }
.home-intro h1 { font-size: clamp(30px, 4vw, 42px); letter-spacing: -.03em; margin-bottom: 10px; }
.home-intro p { max-width: 65ch; color: var(--text-muted); margin: 0; }
.mobile-break { display: none; }
.search-input-wrap { display: flex; gap: 10px; margin-bottom: 18px; max-width: 760px; }
.search-input-wrap input { flex: 1; min-width: 0; padding: 13px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; }
.filter-divider { height: 24px; width: 1px; background: var(--border); margin-inline: 4px; }
.chip { padding: 9px 14px; min-height: 42px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; white-space: nowrap; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:hover:not(.active) { background: var(--primary-soft); }
.listing-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.listing-card { position: relative; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-width: 0; }
.cover { display: block; width: 100%; aspect-ratio: 4/3; padding: 0; margin: 0; border: 0; background: var(--border); color: var(--text-muted); }
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.no-image { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; height: 100%; color: var(--text-muted); font-size: 13px; }
.no-image .icon { width: 36px; height: 36px; }
.fav-btn { position: absolute; top: 10px; right: 10px; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.fav-btn.is-favorite { color: var(--primary); }
.fav-btn.is-favorite .icon { fill: currentColor; }
.boosted-badge { position: absolute; top: 12px; left: 10px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 8px; }
.info { padding: 16px; }
.listing-kind { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.price { font-weight: 750; font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding: 0; border: 0; text-align: start; background: none; color: var(--text); font-weight: 550; font-size: 16px; margin: 5px 0 8px; line-height: 1.4; overflow-wrap: anywhere; }
.title:hover, .my-listing-title:hover { color: var(--primary); }
.meta { font-size: 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.section-title { margin: 36px 0 18px; }
.empty-state, .loading-text { grid-column: 1 / -1; text-align: center; padding: 56px 24px; color: var(--text-muted); }
.empty-state h2 { color: var(--text); }
.empty-state p { max-width: 54ch; margin-inline: auto; }
.load-more { display: flex; justify-content: center; margin-top: 24px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 12px 18px; border: 1px solid transparent; border-radius: 12px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; text-align: center; line-height: 1.35; }
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 9px 13px; font-size: 14px; min-height: 42px; }
.muted, .field-hint { color: var(--text-muted); font-size: 14px; line-height: 1.6; }
.back-button { margin-bottom: 18px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 32px; align-items: start; }
.detail-content { min-width: 0; }
.detail-gallery { display: flex; overflow-x: auto; gap: 12px; margin-bottom: 20px; border-radius: var(--radius); scroll-snap-type: x mandatory; }
.detail-gallery img { display: block; flex: 0 0 100%; min-width: 0; width: 100%; max-height: 460px; object-fit: contain; background: var(--border); border-radius: var(--radius); scroll-snap-align: start; }
.gallery-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; width: 100%; min-height: 220px; background: var(--border); color: var(--text-muted); }
.gallery-empty .icon { width: 40px; height: 40px; }
.detail-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail-heading > div { min-width: 0; }
.detail-price { font-size: clamp(24px, 3vw, 32px); font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.detail-title { font-size: 24px; margin-top: 8px; margin-bottom: 12px; }
.detail-favorite { position: static; flex-shrink: 0; box-shadow: none; border: 1px solid var(--border); }
.detail-meta-row { display: flex; gap: 8px 20px; flex-wrap: wrap; margin: 12px 0; color: var(--text-muted); font-size: 14px; }
.detail-desc { white-space: pre-wrap; max-width: 70ch; line-height: 1.7; margin-top: 22px; }
.contact-card { position: sticky; top: 0; padding: 24px; margin-top: 60px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.contact-card .muted { margin: 16px 0 0; }
.phone-link { display: flex; align-items: center; gap: 8px; margin: 20px 0; font-size: 19px; font-weight: 650; text-decoration: none; overflow-wrap: anywhere; }
.amenity-pills, .amenity-check-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-block: 12px; }
.pill { padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; }
.form-container, .narrow-content { max-width: 720px; margin-inline: auto; }
.form-container > .muted { margin-bottom: 24px; }
.toggle-group { display: flex; gap: 10px; margin-bottom: 16px; }
.toggle-group button { flex: 1; min-height: 48px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 16px; }
.toggle-group button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
#createForm { margin-top: 28px; }
.form-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; min-width: 0; }
.form-field label, .amenities-fieldset legend { font-size: 14px; font-weight: 600; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); font-size: 16px; }
.form-field textarea { resize: vertical; }
.form-field select:disabled { opacity: .7; }
.form-row { display: flex; gap: 16px; }
.form-row .form-field { flex: 1; }
.field-hint { margin-top: -8px; margin-bottom: 20px; }
.form-field .field-hint { margin: 0; }
.amenities-fieldset { padding: 0; border: 0; margin: 8px 0 24px; }
.amenity-check { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 14px; cursor: pointer; }
.amenity-check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.amenity-check input { width: 18px; height: 18px; }
.image-upload-row { display: flex; gap: 14px; flex-wrap: wrap; padding-top: 8px; }
.image-thumb-wrap { position: relative; }
.image-thumb { display: block; width: 86px; height: 86px; border-radius: 10px; object-fit: cover; }
.image-thumb-remove { position: absolute; top: -8px; right: -8px; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 6px; border: 2px solid var(--surface); border-radius: 50%; color: #fff; background: var(--danger); }
.image-thumb-remove .icon { width: 18px; height: 18px; }
.form-error { color: var(--danger); font-size: 15px; font-weight: 550; margin: 10px 0 18px; }
.conversation-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: start; }
.avatar-circle { display: flex; justify-content: center; align-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; }
.conv-info { display: block; flex: 1; min-width: 0; }
.conv-name, .conv-last { display: block; }
.conv-name { font-weight: 650; }
.conv-last { color: var(--text-muted); font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: 2px; }
.unread-dot { min-width: 24px; border-radius: 999px; padding: 2px 7px; background: var(--primary); color: #fff; font-size: 12px; text-align: center; }
.chat-container { display: flex; flex-direction: column; max-width: 800px; min-height: 100%; margin-inline: auto; }
.chat-container .back-button { align-self: flex-start; }
.chat-messages { display: flex; flex-direction: column; flex: 1; gap: 10px; padding-bottom: 24px; }
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble.mine { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input-bar { display: flex; position: sticky; bottom: -16px; gap: 10px; padding: 14px 0; background: var(--bg); }
.chat-input-bar input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: var(--surface); }
.profile-card { padding: 28px 24px; text-align: center; background: var(--surface); border-radius: var(--radius); margin-bottom: 20px; }
.profile-card h1 { font-size: 24px; margin-bottom: 8px; }
.profile-card .avatar-circle { width: 64px; height: 64px; margin: 0 auto 16px; font-size: 24px; }
.profile-balance { margin: 16px 0; font-size: 26px; font-weight: 750; }
.stat-row { display: flex; margin: 0 0 24px; padding: 14px 0; border-block: 1px solid var(--border); }
.stat-box { flex: 1; text-align: center; min-width: 0; }
.stat-box .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-box .label { color: var(--text-muted); font-size: 14px; }
.menu-list { display: flex; flex-direction: column; gap: 10px; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; text-align: start; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.menu-item span { overflow-wrap: anywhere; }
.my-listing { margin-bottom: 20px; padding: 22px; background: var(--surface); border-radius: var(--radius); }
.my-listing-title { padding: 0; margin-bottom: 8px; border: 0; color: var(--text); background: none; font-weight: 650; font-size: 18px; text-align: start; overflow-wrap: anywhere; }
.my-listing .muted { margin-top: 8px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.payment-row { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.payment-row > * { min-width: 0; overflow-wrap: anywhere; }
.login-prompt { max-width: 540px; margin: 40px auto; text-align: center; }
.login-prompt p { margin-bottom: 24px; }
.login-prompt .muted { margin-top: 22px; }
.modal-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,12,20,.55); z-index: 60; padding: 20px; }
.modal-sheet { width: 100%; max-width: 480px; max-height: 90dvh; overflow-y: auto; padding: 24px; border-radius: 16px; background: var(--surface); box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.modal-heading h2 { margin: 0; }
.modal-sheet .login-prompt { margin: 0; }
.modal-sheet .login-prompt h2 { display: none; }
.notice { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: max-content; max-width: min(520px, calc(100% - 32px)); padding: 14px 18px; background: var(--text); color: var(--surface); border-radius: 12px; box-shadow: 0 5px 20px rgba(0,0,0,.18); z-index: 80; font-size: 14px; overflow-wrap: anywhere; }
#topupResult { margin-top: 18px; }
@media (max-width: 1000px) { .listing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 740px) {
  .screen { padding: 22px 16px calc(100px + env(safe-area-inset-bottom, 0px)); }
  .topbar { padding-inline: 16px; }
  .listing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .detail-layout { grid-template-columns: 1fr; gap: 12px; }
  .contact-card { position: static; margin-top: 0; padding: 20px; }
  .detail-gallery img { max-height: 340px; }
  .detail-title { font-size: 22px; }
  .home-intro { margin-bottom: 22px; }
  .filter-divider { display: none; }
  .filter-bar { gap: 7px; }
  .bottom-nav { gap: 0; justify-content: space-around; }
  .nav-item { padding: 6px; min-width: 0; flex: 1; font-size: 11px; }
  .info { padding: 12px; }
  .price { font-size: 16px; }
  .title { font-size: 15px; }
  .meta { font-size: 13px; }
}
@media (max-width: 420px) {
  .brand { font-size: 21px; }
  .topbar-title { display: none; }
  .screen { padding-inline: 12px; }
  .home-intro h1 { font-size: 30px; }
  .home-intro p { font-size: 15px; }
  .mobile-break { display: initial; }
  .search-input-wrap { gap: 7px; }
  .search-input-wrap input { padding: 12px; }
  .search-input-wrap .btn { padding-inline: 12px; }
  .chip { padding: 8px 12px; }
  .listing-grid { gap: 10px; }
  .fav-btn { width: 38px; height: 38px; top: 7px; right: 7px; }
  .no-image span { font-size: 11px; }
  .listing-kind { font-size: 11px; }
  .form-row { gap: 10px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-sheet { max-height: 90dvh; border-radius: 16px 16px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
  .form-container h1 { font-size: 25px; }
  .toggle-group { gap: 8px; }
  .toggle-group button { font-size: 15px; padding: 10px; }
  .chat-bubble { max-width: 88%; }
}
@media (max-width: 330px) {
  .listing-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .search-input-wrap { flex-wrap: wrap; }
  .search-input-wrap input { flex-basis: 100%; }
  .nav-item span { font-size: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .home-intro { animation: intro 320ms cubic-bezier(.16,1,.3,1); }
  @keyframes intro { from { transform: translateY(6px); opacity: .65; } to { transform: translateY(0); opacity: 1; } }
}
@media (forced-colors: active) { .listing-card, .btn, .nav-item.active, .fav-btn { border: 1px solid ButtonText; } }
