:root {
  /* ---------------- Premium Cream 色票（唯一色彩來源，其餘全部從這裡衍生） ---------------- */
  --bg: #F7F1E8;
  --surface: #FFFDFC;
  --surface-secondary: #EFE5D8;
  --text-primary: #302B27;
  --text-secondary: #776D64;
  --accent: #B8956A;
  --accent-strong: #8E6F4E;
  --border: #E4D8CA;
  --radius: 18px;
  --shadow-soft: 0 4px 14px rgba(142, 111, 78, 0.10);
  --shadow-mid: 0 12px 32px rgba(142, 111, 78, 0.12);
  --shadow-strong: 0 20px 48px rgba(142, 111, 78, 0.16);

  /* 向下相容別名——整份 CSS 其餘幾百處都是用這幾個舊名稱，統一在這裡
     指向新的奶油色票，不用逐一改每一處 var(--glass)/var(--blue) 等。 */
  --glass: var(--surface);
  --blue: var(--accent);
  --blue-light: var(--accent-strong);
  --yellow: var(--accent-strong);
  --text: var(--text-primary);
  --text-muted: var(--text-secondary);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.6;
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); /* 底部固定業務欄空間（含手機安全區域） */
}

a { color: inherit; text-decoration: none; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(247, 241, 232, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}
.brand .emoji { font-size: 22px; }
.brand .divider { color: var(--accent); }

.header-nav a {
  margin-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  transition: color .2s;
}
.header-nav a:hover { color: var(--accent-strong); }

/* ---------------- 狀態列（即時更新中 + 物件總量） ---------------- */
.status-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: rgba(247, 241, 232, 0.7);
  border-bottom: 1px solid var(--border);
}
.stat-badge strong { color: var(--accent-strong); font-weight: 700; }

/* ---------------- Hero ---------------- */
.hero {
  padding: 20px 24px 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(184, 149, 106, 0.08), transparent 60%);
}

/* ---------------- AI 智慧搜尋 ---------------- */
.ai-search-wrap {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  transition: border-color .2s, box-shadow .2s;
}
.ai-search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 149, 106, 0.15);
}
.ai-search-icon { font-size: 18px; flex-shrink: 0; }
.ai-search-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  padding: 10px 4px;
  min-width: 0;
}
.ai-search-wrap input::placeholder { color: var(--text-muted); }
.ai-search-wrap .btn { flex-shrink: 0; white-space: nowrap; }
.ai-search-status {
  max-width: 640px;
  margin: 8px auto 0;
  font-size: 13px;
  color: var(--accent-strong);
  min-height: 18px;
  white-space: pre-line;
  line-height: 1.6;
}

.advanced-toggle {
  display: inline-block;
  margin: 14px auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
}
.advanced-toggle:hover { color: var(--accent-strong); }

#advancedFilters { margin-top: 12px; }

.hero-badges {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}
.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 8px rgba(142, 111, 78, 0.5);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hero h1 .emoji { font-size: clamp(28px, 5vw, 42px); }
.hero h1 .accent { color: var(--accent-strong); }
.hero h1 .divider { color: var(--accent); font-weight: 400; }

.hero p.sub {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 28px;
  font-size: 15px;
}

/* ---------------- 搜尋列 ---------------- */
.search-bar {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 100%;
}

.search-bar input,
.search-bar select {
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  flex: 1 1 140px;
  min-width: 0;
}
.search-bar input:focus,
.search-bar select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:hover { background: var(--accent-strong); color: var(--surface); }
.btn:active { transform: scale(0.97); }
.btn.outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
}

/* ---------------- 房型分類卡片小標籤（套房／一房／兩房／三房／四房） ---------------- */
.card-matched-rooms {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------------- 特色篩選 dropdown ---------------- */
.tag-filter-wrap { position: relative; }
#tagFilterCount { color: var(--accent-strong); font-weight: 700; margin-left: 2px; }
.tag-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 320px;
  max-width: 88vw;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-mid);
}
.tag-filter-panel[hidden] { display: none; }
.feature-group { margin-bottom: 12px; }
.feature-group:last-child { margin-bottom: 0; }
.feature-group-title { font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; display: flex; align-items: center; gap: 4px; }
.feature-check-row { display: flex; flex-wrap: wrap; gap: 6px; }
.feature-check-row label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px 5px 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-secondary);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex: 0 0 auto;
  width: max-content;
  white-space: nowrap;
}
/* 原生 checkbox 完全隱藏（不同手機瀏覽器對 checkbox 的原生樣式處理差很多，乾脆不用），
   改用 label::before 畫一個假的勾選框，勾選狀態靠 JS 幫 label 加/移除 is-checked class 來控制 */
.feature-check-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.feature-check-row label::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: transparent;
  box-sizing: border-box;
}
.feature-check-row label.is-checked::before {
  background: currentColor;
}
.feature-check-row label.is-checked::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 4px;
  height: 7px;
  margin-top: -5px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* 每一組按分類上色，跟卡片上的特色標籤色系一致——這裡用的是「淺底深字」
   版本，確保在奶油色卡片/面板上文字仍然清楚可讀（深色系配色在暗色主
   題上原本用的是「淺字」，直接搬到淺色主題上對比度會太差，這裡是必要
   的可讀性調整，不是額外新增的視覺功能）。 */
.feature-group.cat-pet label       { border-color: rgba(47, 122, 60, 0.3); }
.feature-group.cat-pet label.is-checked       { background: rgba(47, 122, 60, 0.14); border-color: rgba(47, 122, 60, 0.5); color: #2F7A3C; }
.feature-group.cat-type label      { border-color: rgba(29, 111, 165, 0.3); }
.feature-group.cat-type label.is-checked      { background: rgba(29, 111, 165, 0.14); border-color: rgba(29, 111, 165, 0.5); color: #1D6FA5; }
.feature-group.cat-amenity label   { border-color: rgba(168, 99, 30, 0.3); }
.feature-group.cat-amenity label.is-checked   { background: rgba(168, 99, 30, 0.14); border-color: rgba(168, 99, 30, 0.5); color: #A8631E; }
.feature-group.cat-condition label { border-color: rgba(107, 79, 160, 0.3); }
.feature-group.cat-condition label.is-checked { background: rgba(107, 79, 160, 0.14); border-color: rgba(107, 79, 160, 0.5); color: #6B4FA0; }
.feature-group.cat-promo label     { border-color: rgba(193, 72, 61, 0.3); }
.feature-group.cat-promo label.is-checked     { background: rgba(193, 72, 61, 0.14); border-color: rgba(193, 72, 61, 0.5); color: #C1483D; }
.tag-filter-clear {
  display: block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ---------------- 分頁 ---------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 24px 0;
  flex-wrap: wrap;
  padding: 0 12px;
}
.pager button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
}
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager button:not(:disabled):hover { border-color: var(--accent); color: var(--accent-strong); }
.pager .pager-info { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* ---------------- 篩選 chips ---------------- */
.filter-chips {
  max-width: 920px;
  margin: 14px auto 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
}
.chip.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: rgba(184, 149, 106, 0.12);
}

/* ---------------- 物件卡片 grid ----------------
   Mobile（< 768px）跟 Tablet（768–1199px）都固定 2 欄，只有
   Desktop（>= 1200px）才變 3 欄——手機兩欄的欄寬完全交給 grid 自己算
   （minmax(0,1fr)），絕對不手動寫死任何可能超出 viewport 的 px 寬度。
------------------------------------------------- */
.listing-grid {
  max-width: 1320px;
  margin: 32px auto;
  padding: 0 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
}
@media (min-width: 768px) {
  .listing-grid {
    padding: 0 24px;
    gap: 20px;
    margin: 40px auto;
  }
}
@media (min-width: 1200px) {
  .listing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-mid);
}

.card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--surface-secondary);
}

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.price {
  font-size: 20px;
  font-weight: 800;
  margin-top: auto;
  overflow-wrap: break-word;
}
.price .sign { color: var(--accent-strong); font-size: 15px; margin-right: 2px; }
.price .num { color: var(--accent-strong); }
.price .unit { color: var(--text-muted); font-size: 13px; font-weight: 400; margin-left: 3px; }

/* Mobile compact card：手機兩欄空間有限，重新排優先順序（圖片本來就在
   card-body 外面永遠第一），card-body 改成用 order 把租金拉到最前面、
   標題其次，特色標籤最多顯示 2 個、房號數量這種次要資訊放最後——不是
   把 desktop 的內容全部硬塞進來，是同一批既有資訊重新排優先序，見
   M5.6 之外這輪 UI 需求的 mobile card 優先順序規格。 */
@media (max-width: 767.98px) {
  .listing-grid { gap: 8px; }
  .card { border-radius: 12px; }
  .card-body { padding: 10px 10px 12px; gap: 6px; }
  .price { order: 1; margin-top: 0; font-size: 17px; }
  .card-title { order: 2; font-size: 13.5px; }
  .card .tag-chips { order: 3; margin: 0; }
  .card-meta { order: 4; font-size: 11.5px; }
  /* 特色標籤在手機兩欄卡片最多顯示 2 個，避免撐寬卡片——只隱藏多出來
     的，不影響資料本身、也不影響桌機/平板顯示。 */
  .card .tag-chips > *:nth-child(n+3) { display: none; }
}

/* ---------------- 詳情頁 ---------------- */
.detail-wrap {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 24px;
  width: 100%;
}
/* ---------------- 房號照片：左右滑動 carousel ---------------- */
.unit-gallery-wrap { position: relative; margin-top: 12px; }
.unit-gallery {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  scrollbar-width: none;
}
.unit-gallery::-webkit-scrollbar { display: none; }
.unit-gallery img {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: start;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
  max-height: 320px;
  margin: 0;
  display: block;
}
.unit-gallery-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(48, 43, 39, 0.65);
  color: #FFFDFC;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  pointer-events: none;
}
.unit-gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(48, 43, 39, 0.5);
  color: #FFFDFC;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 2;
}
.unit-gallery-arrow.prev { left: 8px; }
.unit-gallery-arrow.next { right: 8px; }
.unit-gallery-arrow:disabled { opacity: 0.25; cursor: default; }

.detail-gallery { max-width: 100%; }
.detail-gallery img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  object-fit: cover;
  max-height: 480px;
  display: block;
}
.detail-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
  min-width: 0;
  max-width: 100%;
}
.detail-info h1 { margin: 0 0 12px; font-size: 24px; overflow-wrap: break-word; }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.detail-tags span {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(184, 149, 106, 0.12);
  border: 1px solid var(--border);
  color: var(--accent-strong);
}
.detail-desc { color: var(--text-muted); white-space: pre-wrap; overflow-wrap: break-word; margin-top: 16px; }

@media (max-width: 767.98px) {
  .detail-wrap { padding: 0 14px; margin: 20px auto; }
  .detail-info { padding: 16px; }
  .detail-info h1 { font-size: 19px; }
}

/* ---------------- 特色標籤 chips（每個特色獨立框框） ---------------- */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
  min-width: 0;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.7;
}
.tag-chip.cat-location { background: rgba(193, 93, 139, 0.12); border-color: rgba(193, 93, 139, 0.35); color: #C15D8B; }
.tag-chip.cat-pet      { background: rgba(47, 122, 60, 0.12);  border-color: rgba(47, 122, 60, 0.35);  color: #2F7A3C; }
.tag-chip.cat-type     { background: rgba(29, 111, 165, 0.12); border-color: rgba(29, 111, 165, 0.35); color: #1D6FA5; }
.tag-chip.cat-amenity  { background: rgba(168, 99, 30, 0.12);  border-color: rgba(168, 99, 30, 0.35);  color: #A8631E; }
.tag-chip.cat-condition{ background: rgba(107, 79, 160, 0.12); border-color: rgba(107, 79, 160, 0.35); color: #6B4FA0; }
.tag-chip.cat-promo    { background: rgba(193, 72, 61, 0.12);  border-color: rgba(193, 72, 61, 0.35);  color: #C1483D; }
.tag-chip.cat-extra    { background: var(--surface-secondary); border-color: var(--border); color: var(--text-muted); }

.card .tag-chips { margin: 2px 0 4px; }
.card .tag-chip { font-size: 11.5px; padding: 3px 9px; }

/* ---------------- AI 租屋智能管家 ---------------- */
.ai-concierge-fab {
  position: fixed;
  left: 16px;
  top: 16px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: grab;
  box-shadow: var(--shadow-mid);
  animation: ai-fab-intro 0.5s ease-out;
  touch-action: none;
  user-select: none;
  max-width: calc(100vw - 32px);
}
.ai-concierge-fab:active { cursor: grabbing; }
@keyframes ai-fab-intro {
  from { transform: translateY(-12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.ai-concierge-fab-emoji { font-size: 18px; }
@media (max-width: 560px) {
  .ai-concierge-fab-label { display: none; }
  .ai-concierge-fab { padding: 12px; }
}

.ai-concierge-greeting {
  position: fixed;
  left: 16px;
  top: 76px;
  z-index: 999;
  width: 280px;
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-mid);
}
.ai-concierge-greeting p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.6; }
.ai-concierge-greeting-close {
  position: absolute; top: 4px; right: 4px; background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 16px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.ai-concierge-greeting-actions { display: flex; flex-direction: column; gap: 6px; }
.ai-concierge-greeting-actions button {
  text-align: left;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.ai-concierge-greeting-actions button:hover { border-color: var(--accent); color: var(--accent-strong); }

/* 聊天視窗（由 ai-concierge-widget.js 動態插入時使用這些 class） */
.ai-concierge-window {
  position: fixed;
  z-index: 70;
  right: 20px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 360px;
  max-width: calc(100vw - 24px);
  height: min(70vh, 560px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (max-width: 560px) {
  .ai-concierge-window {
    right: 8px;
    left: 8px;
    width: auto;
    height: min(72vh, 560px);
  }
}
.ai-concierge-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(184, 149, 106, 0.08);
}
.ai-concierge-window-header strong { font-size: 14px; }
.ai-concierge-window-close { background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; }
.ai-concierge-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; overflow-wrap: break-word; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-secondary); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg.user { align-self: flex-end; background: rgba(184, 149, 106, 0.18); border: 1px solid rgba(184, 149, 106, 0.4); border-bottom-right-radius: 4px; }
.ai-msg.typing { color: var(--text-muted); font-style: italic; }
.ai-actions-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ai-actions-row button {
  background: var(--surface-secondary); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.ai-actions-row button:hover { border-color: var(--accent); color: var(--accent-strong); }
.ai-concierge-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.ai-concierge-input-row input {
  flex: 1;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  min-width: 0;
}
.ai-concierge-input-row button {
  background: var(--accent);
  color: var(--text-primary);
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.ai-reco-card {
  display: flex;
  gap: 10px;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.ai-reco-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; display: block; }
.ai-reco-card .pct { color: var(--accent-strong); font-weight: 700; font-size: 12px; }

/* 簡單的資訊型 modal（例如租補試算表說明） */
.ai-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(48, 43, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ai-modal-overlay[hidden] {
  display: none !important; /* 這行很重要：.ai-modal-overlay 有寫死 display:flex，一定要明確蓋掉 hidden 屬性才會真的隱藏 */
}
.ai-modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-strong);
}

/* ---------------- 底部固定業務欄 ---------------- */
.agent-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 253, 252, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.agent-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  min-width: 0;
}
.agent-info .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  color: var(--text-primary);
  flex-shrink: 0;
}
.agent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.agent-actions .btn { padding: 9px 16px; font-size: 13px; }

/* ---------------- 空狀態 / loading ---------------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ---------------- 後台 ---------------- */
.admin-shell { max-width: 1100px; margin: 32px auto; padding: 0 24px; }
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.admin-login-box {
  max-width: 380px;
  margin: 100px auto;
  padding: 32px;
}
.admin-login-box input {
  width: 100%;
  padding: 12px;
  margin: 8px 0 16px;
  background: var(--surface-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.qr-box { text-align: center; margin: 20px 0; }
.qr-box img { background: #fff; padding: 12px; border-radius: 8px; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.admin-table th { color: var(--text-muted); font-weight: 600; }

/* ADMIN EDIT UX MOVE-UP：手機版把 <table> 收成堆疊卡片，不強制橫向
   捲動——每個 <td> 用 data-label 屬性當標籤文字（JS 產生 table 時要帶
   data-label，見 frontend/js/admin.js::loadBuildingTable()/
   loadUnitTable()）。用 flex + order 把「操作」欄位視覺上搬到卡片最
   上面（緊接在主要識別欄位之後），不需要真的改 DOM 順序、不影響桌面版
   表格欄位順序。只有 dashboard.html 用到 .admin-table，改這裡不會
   影響 threads.html／line-advisor.html／viewings.html（那幾頁本來就
   是 card grid，不是 table）。 */
@media (max-width: 767.98px) {
  table.admin-table, table.admin-table thead, table.admin-table tbody { display: block; }
  table.admin-table thead { display: none; }
  table.admin-table tr {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: var(--surface);
  }
  table.admin-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: none;
    text-align: right;
  }
  table.admin-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  table.admin-table td[data-label="地址"],
  table.admin-table td[data-label="房號"] { order: 1; }
  table.admin-table td[data-label="操作"] { order: 2; }
  table.admin-table td[data-label="區域"],
  table.admin-table td[data-label="類型"] { order: 3; }
  table.admin-table td[data-label="狀態"] { order: 4; }
  table.admin-table td[data-label="價格區間"],
  table.admin-table td[data-label="租金"] { order: 5; }
  table.admin-table td[data-label="房號數"],
  table.admin-table td[data-label="坪數"] { order: 6; }
  /* 操作欄位：按鈕改成靠左、可換行堆疊，不用 hover、不需要橫向捲動就能
     全部點得到（需求文件第 4 節）。 */
  table.admin-table td[data-label="操作"] {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }
  table.admin-table td[data-label="操作"]::before { content: none; }
  table.admin-table td[data-label="操作"] button,
  table.admin-table td[data-label="操作"] a {
    flex: 1 1 auto;
    min-width: 72px;
    text-align: center;
  }
}
.status-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
}
.status-pill.available { background: rgba(184, 149, 106, 0.16); color: var(--accent-strong); }
.status-pill.rented { background: var(--surface-secondary); color: var(--text-muted); }

/* Threads 排程頁專用狀態 pill（M5.7 後台可視化，沿用同一套奶油配色，不新增風格） */
.status-pill.pj-pending { background: var(--surface-secondary); color: var(--text-muted); }
.status-pill.pj-claimed { background: rgba(184, 149, 106, 0.16); color: var(--accent-strong); }
.status-pill.pj-publishing { background: rgba(184, 149, 106, 0.28); color: var(--accent-strong); }
.status-pill.pj-published { background: rgba(122, 155, 108, 0.18); color: #4C7A3E; }
.status-pill.pj-failed { background: rgba(193, 72, 61, 0.16); color: #C1483D; }
.status-pill.pj-cancelled { background: var(--surface-secondary); color: var(--text-muted); }

@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .header-nav { display: none; }
  .agent-bar { flex-direction: column; align-items: stretch; padding-left: 16px; padding-right: 16px; }
  .agent-actions { justify-content: stretch; }
  .agent-actions .btn { flex: 1; }
}

/* ---------------- 手機搜尋/篩選 overflow 安全性 ---------------- */
@media (max-width: 767.98px) {
  .hero { padding: 16px 14px 18px; }
  .search-bar { padding: 12px; gap: 8px; }
  .tag-filter-wrap { flex: 1 1 100%; }
  #tagFilterBtn { width: 100%; }
  .tag-filter-panel {
    width: auto;
    max-width: calc(100vw - 48px);
  }
  .filter-chips { padding: 0 12px; }
}
