/* Trang chợ. Dùng chung token với styles.css. */

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: auto;
}
.tabs a {
  color: #d5d8f0;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}
.tabs a[aria-current='page'] { background: #fff; color: #1d2140; }

.m-head {
  background: linear-gradient(180deg, var(--sky-top) 0%, #22275a 100%);
  color: #fff;
  padding: max(14px, env(safe-area-inset-top)) 16px 20px;
}
.m-wrap { max-width: 1048px; margin: 0 auto; } /* = .m-main trừ padding, để thẳng hàng */
.m-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.m-top .brand { color: #fff; text-decoration: none; }
.m-head .tabs { display: flex; width: fit-content; margin-top: 14px; }
.m-head h1 {
  font-size: clamp(30px, 8vw, 44px);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-top: 18px;
  margin-bottom: 0;
}
.m-lede { color: #d5d8f0; margin-top: 6px; margin-bottom: 0; max-width: 34em; }
.search { margin-top: 16px; }
.search input {
  width: 100%;
  max-width: 520px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 0;
  font-size: 16px;
  background: #fff;
  color: #1d2140;
}

.m-main { max-width: 1080px; margin: 0 auto; padding: 14px 16px 120px; }
.m-main h2 { font-size: 19px; font-weight: 800; margin: 22px 0 10px; }

.kinds {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 6px;
  margin: 0 -16px;
  scrollbar-width: none;
}
.kinds::-webkit-scrollbar { display: none; }
.kinds button {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.kinds button[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.grid {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px 12px;
}
.item { min-width: 0; }
.item button {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.item button:focus-visible { outline: 3px solid var(--window); outline-offset: 3px; }
.thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.icon {
  display: grid;
  place-items: center;
  font-size: 44px;
  background: color-mix(in srgb, var(--k) 22%, var(--surface));
}
.badge {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 19, 42, 0.78);
  color: #fff;
}
.item .price { font-weight: 800; font-size: 16px; margin: 8px 0 0; }
.item .price.soft { font-weight: 600; color: var(--muted); }
.item .title {
  margin: 2px 0 0;
  font-size: 15px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.item .meta { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.item.fresh .thumb { animation: flash 1.6s ease-out; }

.mine { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mine li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.mine .m-text { flex: 1; min-width: 0; }
.mine .m-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine .m-text span { font-size: 13px; color: var(--muted); }
.mine button, .small-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  min-height: 38px;
  white-space: nowrap;
}

/* chi tiết tin */
.sheet.tall { max-height: 94vh; }
/* Mở thẳng từ link (chưa có dữ liệu): mở sẵn ở chiều cao lớn, không bật từ một dải nhỏ lên. */
.sheet.tall.is-loading { min-height: 70vh; }
.skel { display: block; background: var(--line); opacity: 0.7; }
.skel-btn { width: 128px; height: 43px; margin: 6px 0 12px; border-radius: 999px; }
.skel-line { width: 55%; height: 16px; margin: 6px 0 7px; border-radius: 6px; }
.joins .skel-line { margin: 2px 0; height: 13px; }
.skel-input { width: 76px; height: 42px; border-radius: var(--radius-sm); }
.skel-input.grow { flex: 1; width: auto; }
.skel-cta { height: 50px; margin-top: 16px; border-radius: 999px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet-body { padding: 18px 16px max(22px, env(safe-area-inset-bottom)); }
.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 12px -16px 0;
  padding: 0 16px;
  scrollbar-width: none;
}
.gallery img {
  flex: none;
  width: min(86%, 420px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-sm);
  scroll-snap-align: center;
  background: var(--surface);
}
.gallery img:only-child { width: 100%; }
.d-kind { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.d-title { font-size: 22px; font-weight: 800; line-height: 1.2; margin: 2px 0 0; overflow-wrap: anywhere; }
.d-price { font-size: 20px; font-weight: 800; margin: 6px 0 0; }
.d-body { white-space: pre-line; margin: 12px 0 0; overflow-wrap: anywhere; }
.d-meta { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.box {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 14px;
}
.box h3 { font-size: 15px; margin: 0 0 4px; }
.box p { margin: 0; color: var(--ink) !important; overflow-wrap: anywhere; }
.box a { color: inherit; font-weight: 600; }
.box.locked p { color: var(--muted) !important; }
.joins { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.joins li { padding: 6px 0; border-top: 1px solid var(--line); }
.joins li:first-child { border-top: 0; }
.join-row { display: flex; gap: 8px; margin-top: 10px; }
.join-row input { width: 76px; }
.join-row .grow { flex: 1; width: auto; }
.join-row input, .join-row .grow {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 16px;
}
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.d-actions .danger { color: var(--danger); border-color: currentColor; }

/* form đăng tin */
.kind-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.kind-pick button {
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}
.kind-pick button[aria-pressed='true'] { border-color: var(--k); box-shadow: inset 0 0 0 1px var(--k); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-style: normal; font-weight: 400; }
.photo-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-pick .ph, .add-photo {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
.photo-pick .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick .ph.busy img { opacity: 0.4; }
.photo-pick .ph.busy::after {
  content: '';
  position: absolute;
  inset: 26px;
  border: 3px solid var(--window);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.photo-pick .ph button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: rgba(16, 19, 42, 0.8);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}
.add-photo {
  display: grid;
  place-items: center;
  border: 2px dashed var(--line);
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
}
.add-photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 980px) {
  .m-head { padding-top: 22px; padding-bottom: 28px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px 18px; }
}

/* nút Nhắn Zalo + công tắc trong form */
.zalo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: #0a68ff;
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
  min-height: 42px;
}
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: #0a68ff; }
.item .meta .ava { margin-right: 5px; }
.d-meta { display: flex; align-items: center; gap: 8px; }

/* ---------- trang Lịch tiện ích ---------- */
.ev-day h2 { font-size: 17px; margin: 22px 0 8px; }
.ev-day h2 small { font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 6px; }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.ev-time { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; line-height: 1.35; }
.ev-time small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.ev-body { min-width: 0; }
.ev-body b { font-size: 16px; }
.ev-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ev-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.ev-tag.booked { color: var(--ok); border-color: currentColor; }
.ev-tag.overlap { color: var(--danger); border-color: currentColor; }
.ev-who { margin: 6px 0 0; font-size: 14px; overflow-wrap: anywhere; white-space: pre-line; }
.ev-who span { color: var(--muted); }
.ev-actions { grid-column: 2; display: flex; gap: 8px; margin-top: 6px; }
.ev-when { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.seg#ev-status button { font-size: 14px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }
.ev-locked { margin-top: 12px; }
#ev-amenity button[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 600; }

/* ---------- trang Cài đặt ---------- */
a.small-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
.set-main { max-width: 640px; }
.set-main [hidden] { display: none !important; }
.set-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 14px;
}
.set-main .set-card h2 { margin: 0 0 6px; font-size: 18px; }
.set-card p { margin: 0; }
.set-card fieldset { margin-top: 12px; }
.set-status { color: var(--muted); }
.set-card .notify-guide { margin-top: 10px; background: var(--paper); }
.set-install { margin-top: 12px; }
.set-steps { margin: 8px 0 0; padding-left: 22px; }
.set-steps li { margin-top: 6px; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; }
.set-grid .check { margin-top: 8px; }
.set-tag { display: block; font-size: 12px; font-weight: 600; color: var(--danger); }
.set-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.set-quick .small-btn { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.set-switch { align-items: flex-start; }
.set-switch input { margin-top: 2px; flex: none; }
.set-switch b { display: block; }
.set-switch small { display: block; margin-top: 2px; }
.set-note { margin: 14px 4px 0; }
.set-hint { margin-top: 8px !important; }
.set-card .seg { display: flex; }
.set-card .seg button { flex: 1; }
.set-save {
  position: sticky;
  bottom: 0;
  margin: 16px -16px 0;
  padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 30%);
}
.set-save .form-error:empty { display: none; }
