/* ตลาดทุเรียน — mobile-first, ภาษาไทย (Tahoma เรนเดอร์ไทยได้ดีบน Windows) */
:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --gold: #e0982e;
  --line: #06c755;
  --bg: #f6f6f3;
  --card: #ffffff;
  --ink: #222;
  --muted: #777;
  --border: #e4e4de;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --maxw: 680px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16px;
}

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

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 14px; }

/* ---- inline SVG icons (Heroicons-outline style, templates/_icons/) ---- */
.icon { width: 1.1em; height: 1.1em; flex: none; display: inline-block; vertical-align: -0.18em; }
.empty__icon .icon { width: 40px; height: 40px; opacity: .55; }
.card__thumb-icon .icon { width: 40px; height: 40px; }
.detail__thumb-icon .icon { width: 58px; height: 58px; }
.brand__mark .icon { width: 22px; height: 22px; vertical-align: -0.3em; }

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--green); color: #fff;
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand__mark { font-size: 22px; }
.brand__name small { font-weight: 400; opacity: .85; font-size: 12px; display: block; line-height: 1; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: #eee; color: var(--ink);
}
.btn--primary { background: var(--gold); color: #fff; }
.btn--post:disabled { opacity: .55; cursor: not-allowed; }
.btn--line { background: var(--line); color: #fff; }
.btn--phone { background: #fff; color: var(--green-dark); border-color: var(--green); }

.main { padding: 14px 14px 40px; }

/* ---- filters / chips ---- */
.filters { margin-bottom: 14px; }
.filters__row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.filters__label { font-size: 12px; color: var(--muted); min-width: 42px; flex: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none; display: inline-flex; align-items: center;
  min-height: 40px; padding: 8px 15px; border-radius: 9px;
  background: #fff; border: 1px solid var(--border); color: #555;
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { border-color: var(--green); }
.chip--active {
  background: var(--green-dark); border-color: var(--green-dark);
  color: #fff; font-weight: 700;
}

/* ---- results ---- */
.results { transition: opacity .15s; }
#board.htmx-request .results { opacity: .45; }
.results__count { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

/* ---- card ---- */
.card {
  display: flex; flex-direction: column; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .1s, box-shadow .1s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, .1); }
.card__thumb {
  aspect-ratio: 16 / 9; background: linear-gradient(135deg, #eef4ee, #e3ece1);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
}
.card__thumb-icon { font-size: 42px; opacity: .55; }
.card__body { padding: 11px 13px 13px; }
.card__badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.card__title { font-size: 16px; margin: 0 0 6px; line-height: 1.35; }
.card__meta { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.card__price { margin: 0; }

/* ---- badges / price ---- */
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.badge--cat { background: #eef4ee; color: var(--green-dark); }
.badge--verified { background: #e8f5e9; color: var(--green); }
.badge--muted { background: #eee; color: var(--muted); }
.price { font-size: 17px; font-weight: 800; color: var(--green-dark); }
.price--lg { font-size: 24px; }
.price--board { font-size: 14px; font-weight: 700; color: var(--gold); }
.price--ask { font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---- empty ---- */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty__icon { font-size: 46px; }
.empty__title { font-weight: 700; margin: 8px 0 2px; color: #555; }
.empty__hint { font-size: 13px; margin: 0; }

/* ---- detail ---- */
.backlink { display: inline-block; margin: 4px 0 12px; color: var(--green-dark); font-weight: 600; font-size: 14px; }
.detail { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 0 18px; overflow: hidden; }
.detail__thumb { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #eef4ee, #e3ece1); display: flex; align-items: center; justify-content: center; }
.detail__thumb-icon { font-size: 72px; opacity: .55; }
.detail__badges { display: flex; gap: 6px; flex-wrap: wrap; padding: 14px 16px 0; }
.detail__title { font-size: 22px; font-weight: 800; margin: 8px 16px 4px; }
.detail__area { margin: 0 16px 8px; color: var(--muted); font-size: 14px; }
.detail__price { margin: 0 16px 10px; }
.detail__desc { margin: 0 16px 14px; white-space: pre-line; }
.detail__posted { margin: 10px 16px 0; }

.block { margin: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.block__title { font-size: 15px; font-weight: 700; margin: 0 0 10px; color: #333; }

/* attributes */
.attrs { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.attrs dt { color: var(--muted); font-size: 14px; }
.attrs dd { margin: 0; font-weight: 600; font-size: 14px; }

/* price table */
.table-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th, .ptable td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ptable thead th { background: #f3f6f2; color: var(--green-dark); font-size: 13px; }
.ptable .num { text-align: right; font-weight: 700; color: var(--green-dark); }

/* offers */
.offers__top { margin: 0 0 8px; font-size: 15px; }
.offers__top strong { color: var(--gold); font-size: 18px; }
.offers { list-style: none; margin: 0; padding: 0; }
.offers__item { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.offers__price { font-weight: 800; color: var(--green-dark); min-width: 84px; }
.offers__by { font-size: 14px; }

/* contact */
.contact__btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.contact__seller { font-size: 14px; color: #444; margin: 0; }

/* utils */
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- header nav / auth ---- */
.site-nav { display: flex; align-items: center; gap: 10px; }
.btn--post { padding: 8px 12px; font-size: 14px; }
.logout-form { margin: 0; }
.linkbtn { background: none; border: none; color: #fff; font: inherit; font-size: 13px; cursor: pointer; opacity: .9; text-decoration: underline; padding: 0; }
.linkbtn:hover { opacity: 1; }

/* ---- page title / selector ---- */
.page-title { font-size: 22px; font-weight: 800; margin: 6px 0 14px; }
.selector { margin-bottom: 16px; }
.selector__label { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.selector__hint { margin: 8px 0 0; }

/* ---- forms ---- */
.postform { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.postform__cat { margin: 0 0 14px; font-size: 14px; color: #555; }
.postform-empty { background: #fff; border: 1px dashed var(--border); border-radius: var(--radius); padding: 30px 16px; text-align: center; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; color: #444; }
.field .req { color: #c0392b; }
.postform input[type="text"],
.postform input[type="number"],
.postform input[type="password"],
.postform input[type="date"],
.postform input:not([type]),
.postform select,
.postform textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--ink);
}
.postform textarea { resize: vertical; }
.postform input:focus, .postform select:focus, .postform textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12);
}
.field--error input, .field--error select, .field--error textarea { border-color: #c0392b; }
.field__hint { display: block; margin-top: 4px; }
.field__err { display: block; margin-top: 4px; color: #c0392b; font-size: 12px; }
.form-errors { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; border-radius: 9px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.btn--block { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }

/* ---- buy-board form (price rows) ---- */
.board-rows__title { margin-top: 6px; }
.board-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: #fbfbf8; }
.board-row__grid {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 1fr 1fr 36px;
  grid-template-areas:
    "type  type  del"
    "grade price unit"
    "note  note  note";
}
.brc--type  { grid-area: type; }
.brc--grade { grid-area: grade; }
.brc--price { grid-area: price; }
.brc--unit  { grid-area: unit; }
.brc--note  { grid-area: note; }
.board-row__del {
  grid-area: del; align-self: stretch; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; color: #c0392b; cursor: pointer; font-size: 14px; line-height: 1;
}
.board-row__del:hover { background: #fdecea; border-color: #f5c6cb; }
.board-row__err { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.boardform input.inp-err, .boardform select.inp-err { border-color: #c0392b; }

@media (min-width: 600px) {
  .board-row__grid {
    grid-template-columns: 1.5fr .9fr 1fr .8fr 1.6fr 36px;
    grid-template-areas: "type grade price unit note del";
  }
}

.btn--ghost { background: #fff; border: 1px solid var(--green); color: var(--green-dark); }
.btn--ghost:hover { background: #f0f6f0; }
.btn--addrow { margin: 2px 0 16px; }

/* กล่องเคลมแผง curated */
.claim-box {
  border: 2px dashed var(--gold); border-radius: 10px;
  padding: 12px 14px; margin: 12px 0; background: #fffbef;
}
.claim-box p { margin: 4px 0; }

/* ---- กระดานราคากลาง ---- */
/* แถบสรุปหัวกระดาน: วันที่ · จำนวนแผง · ช่วงราคา */
.boardbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
.boardbar__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.boardbar__item .icon { color: var(--green); }

/* กล่องแจ้งข้อมูล (ไม่ใช่ error) เช่น "วันนี้ยังไม่มีแผงลงราคา" */
.notice {
  background: #fff7e6; border: 1px solid #eeda9f; color: #8a5a00;
  border-radius: 9px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}

/* ตารางกระดาน (desktop): หัวเข้ม แถวสลับสี ราคาเด่นสุด */
.btable__stall { font-weight: 700; color: var(--green-dark); text-decoration: none; }
.btable__stall:hover { text-decoration: underline; }
.btable thead th { background: var(--green-dark); color: #fff; font-weight: 700; }
.btable tbody tr:nth-child(even) { background: #f4f7f3; }
.btable td.num { font-size: 16px; font-weight: 800; }

/* จอแคบยุบตารางเป็นการ์ดต่อแถว (มือถือสำคัญสุด) */
@media (max-width: 599px) {
  .btable thead { display: none; }
  .btable, .btable tbody, .btable tr, .btable td { display: block; width: 100%; }
  .btable tbody tr:nth-child(even) { background: #fff; }
  .btable tr {
    border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 10px; padding: 6px 0; background: #fff;
    box-shadow: var(--shadow);
  }
  .btable td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    border-bottom: none; padding: 3px 12px; white-space: normal; text-align: right;
  }
  .btable td::before {
    content: attr(data-label);
    color: #7a7a72; font-size: 12px; flex-shrink: 0; text-align: left;
  }
  .btable td.num { font-size: 18px; }
}

/* แถวราคารายวันของแผง (stalls) — 4 ช่อง ไม่มี unit (fix บาท/กก.) */
.price-row__grid {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 1fr 1fr 36px;
  grid-template-areas:
    "variety grade del"
    "price   note  note";
}
.prc--variety { grid-area: variety; }
.prc--grade   { grid-area: grade; }
.prc--price   { grid-area: price; }
.prc--note    { grid-area: note; }
@media (min-width: 600px) {
  .price-row__grid {
    grid-template-columns: 1.2fr 1.1fr .9fr 1.8fr 36px;
    grid-template-areas: "variety grade price note del";
  }
}

/* ---- photos ---- */
.card__thumb { position: relative; }
.card__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__count {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .6);
  color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 4px;
}

/* แกลเลอรีหน้า detail ประกาศ — รูปแรกใหญ่ + แถว thumbnail (แบบเฟส) */
.dgal__main { display: block; background: #eef4ee; }
.dgal__main img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; display: block; }
.dgal__thumbs {
  display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
}
.dgal__thumb {
  flex: none; width: 64px; height: 64px; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border);
}
.dgal__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* รูปหน้าแผง — ลิงก์ครอบรูปให้เต็มกรอบเดิม */
.detail__thumb-link { display: block; width: 100%; height: 100%; cursor: zoom-in; }

.photo-field input[type="file"] { width: 100%; font-size: 14px; padding: 8px 0; }

/* ---- owner controls (เจ้าของประกาศ) ---- */
.owner-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 16px 0; }
.owner-bar__form { margin: 0; }
.btn--warn { background: #e08a2e; color: #fff; }
.btn--warn:hover { background: #c8761f; }

/* ---- auth ---- */
.auth { max-width: 380px; margin: 0 auto; }
.auth__hint { margin-top: 14px; text-align: center; }

/* ---- footer ---- */
.site-footer { border-top: 1px solid var(--border); padding: 18px 0 28px; color: var(--muted); font-size: 12px; text-align: center; }

/* ============ Facebook-style composer ============ */

/* กล่องโพสต์บนสุดของฟีด */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--green); color: #fff; font-weight: 800; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.fbcomposer {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; margin-bottom: 14px;
}
.fbcomposer__row { display: flex; align-items: center; gap: 10px; }
.fbcomposer__input {
  flex: 1; background: #f0f2ec; border-radius: 20px; padding: 10px 16px;
  color: var(--muted); font-size: 15px;
}
.fbcomposer__row:hover .fbcomposer__input { background: #e9ece4; }
.fbcomposer__actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.fbcomposer__actions a {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; border-radius: 9px; font-size: 13px; font-weight: 600; color: #555;
}
.fbcomposer__actions a:hover { background: #f0f2ec; }
.fbcomposer__actions .icon { color: var(--green); }

/* card สร้างโพสต์ (/post/) */
.composer-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; max-width: 560px; margin: 0 auto;
}
.composer-card__title {
  font-size: 17px; font-weight: 800; text-align: center;
  margin: 0 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.composer-card .postform { border: none; box-shadow: none; padding: 0; }

/* segmented selector 4 หมวด */
.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border); border-radius: 9px; overflow: hidden; margin-bottom: 12px;
}
.segmented__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 54px; padding: 8px 4px; font-size: 12.5px; font-weight: 600; color: #555;
  border-right: 1px solid var(--border); text-align: center;
}
.segmented__item:last-child { border-right: none; }
.segmented__item .icon { width: 20px; height: 20px; }
.segmented__item:hover { background: #f0f2ec; }
.segmented__item--active { background: var(--green-dark); color: #fff; }
.segmented__item--active:hover { background: var(--green-dark); }

/* ช่องหัวเรื่องใหญ่ไร้กรอบ */
.postform textarea.composer-title, .composer-title {
  width: 100%; border: none; outline: none; resize: none; background: transparent;
  font: inherit; font-size: 20px; font-weight: 600; line-height: 1.45;
  padding: 8px 2px; min-height: 64px; color: var(--ink); border-radius: 0;
}
.composer-title::placeholder { color: #b9beb3; font-weight: 500; }
.postform textarea.composer-title:focus { box-shadow: none; border: none; }
.composer-title.inp-err { border-bottom: 2px solid #c0392b; }

/* ฟิลด์รอง — แถวกะทัดรัด */
.composer-more { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.crow__label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 5px; }
.crow--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.crow--grid .crow { margin: 0; }

/* chip เลือกค่า (radio) + chip เติมค่า (ปุ่ม) */
.chipset { display: flex; flex-wrap: wrap; gap: 8px; }
.chipset--fill { margin-bottom: 8px; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 7px 13px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: #555;
  font-size: 14px; cursor: pointer;
}
.chip-radio input:checked + span {
  background: var(--green-dark); border-color: var(--green-dark); color: #fff; font-weight: 700;
}
.chip-radio input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 1px; }
.fillchip {
  display: inline-flex; align-items: center; min-height: 40px; padding: 7px 13px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: #555;
  font: inherit; font-size: 14px; cursor: pointer;
}
.fillchip:hover { border-color: var(--green); color: var(--green-dark); }

/* กล่องอัปรูป drag-drop + preview */
.photobox {
  border: 2px dashed var(--border); border-radius: 10px; padding: 14px;
  text-align: center; background: #fbfbf8;
}
.photobox.is-drag { border-color: var(--green); background: #f0f6f0; }
.photobox__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photobox__btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--green); border-radius: 9px; background: #fff;
  color: var(--green-dark); font-weight: 700; font-size: 15px; cursor: pointer;
}
.photobox__btn .icon { width: 20px; height: 20px; }
.photobox__hint { margin: 8px 0 0; }

/* collage preview ใหญ่แบบเฟส — layout ขับด้วย data-n (จำนวนรูป) */
.photobox--has { padding: 8px; border-style: solid; text-align: left; }
.photobox--has .photobox__btn, .photobox--has .photobox__hint { display: none; }
.photobox__stage { position: relative; }
.photobox__addmore {
  position: absolute; top: 8px; left: 8px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 36px; padding: 6px 12px; border-radius: 9px;
  background: rgba(255, 255, 255, .92); border: 1px solid var(--border);
  color: var(--ink); font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow);
}
.photobox__addmore .icon { width: 16px; height: 16px; }
.photobox__previews { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.photobox__previews[data-n="1"] { grid-template-columns: 1fr; }
.photobox__thumb {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
}
.photobox__previews[data-n="1"] .photobox__thumb { aspect-ratio: 4 / 3; }
.photobox__previews[data-n="3"] .photobox__thumb:first-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.photobox__previews .photobox__thumb:nth-child(n+5) { display: none; }  /* เกิน 4 → ซ่อนหลังม่าน +N */
.photobox__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photobox__rm {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.photobox__rm:hover { background: rgba(0, 0, 0, .8); }
.photobox__more {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 26px; font-weight: 800;
}
.composer-submit { margin-top: 14px; }

/* ปุ่มเพิ่มแถว (ฟอร์มราคาแผง + บอร์ด) ให้เด่นและกดง่ายบนมือถือ */
.btn--addrow { width: 100%; min-height: 44px; border-style: dashed; font-size: 15px; }

/* ---- ฟอร์มโพสต์ minimal: รูปคือพระเอก ---- */
.composer-form > .crow { margin-top: 12px; }
.composer-form .photobox { padding: 26px 14px; }
.composer-form .photobox__btn { min-height: 52px; padding: 12px 26px; font-size: 16px; }
.composer-form .photobox__btn .icon { width: 24px; height: 24px; }
.composer-content {
  min-height: 0; overflow: hidden;  /* auto-resize ด้วย JS — ไม่มี scrollbar ใน textarea */
  font-size: 17px; font-weight: 500; margin-top: 4px;
}
.composer-area { margin-top: 4px; }

/* แถบ "เพิ่มลงในโพสต์" (composer action bar) */
.addbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 4px 6px 4px 12px; margin-top: 10px;
}
.addbar__label { font-size: 13.5px; font-weight: 600; color: #555; }
.addbar__icons { display: flex; gap: 4px; }
.addbar__btn {
  position: relative; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 9px; background: transparent; color: #7a7a72; cursor: pointer;
}
.addbar__btn:hover { background: #f0f2ec; }
.addbar__btn .icon { width: 22px; height: 22px; }
.addbar__btn--set { color: var(--green-dark); }
.addbar__btn--set::after {
  content: ""; position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
}
.addbar-field { margin-top: 8px; }
.addbar-field:not([hidden]) { animation: addbar-in .15s ease-out; }
@keyframes addbar-in { from { opacity: 0; transform: translateY(-4px); } }
.addbar-field input {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--ink);
}
.addbar-field input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12);
}

/* พิกัด/ตำบล ใต้พื้นที่ (หน้า detail) */
.detail__loc { margin-top: -4px; }
.detail__loc-link { color: var(--green-dark); font-weight: 600; text-decoration: underline; }

/* ---- lightbox (static/js/lightbox.js) ---- */
.lb {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; background: rgba(0, 0, 0, .93);
}
.lb--open { display: flex; }
.lb__img { max-width: 96vw; max-height: 92vh; object-fit: contain; display: block; }
.lb__count {
  position: absolute; top: 12px; left: 14px; color: #fff;
  font-size: 14px; font-weight: 700; letter-spacing: .5px;
}
.lb__close {
  position: absolute; top: 8px; right: 10px; width: 40px; height: 40px;
  border: none; border-radius: 9px; background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.lb__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px; border: none; border-radius: 9px;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 32px; line-height: 1; cursor: pointer;
}
.lb__nav--prev { left: 8px; }
.lb__nav--next { right: 8px; }
.lb__close:hover, .lb__nav:hover { background: rgba(255, 255, 255, .25); }

/* ---- ติดตามแผง (followbox) ---- */
.followbox { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 4px 16px 10px; }
.followbox form { margin: 0; }
.followbox__btn { min-height: 40px; }
.followbox__count { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }

/* ---- กระดิ่งแจ้งเตือน (nav) ---- */
.notifwrap { position: relative; display: flex; }
.notifbell {
  position: relative; width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 9px; background: transparent; color: #fff; cursor: pointer;
}
.notifbell:hover { background: rgba(255, 255, 255, .14); }
.notifbell .icon { width: 22px; height: 22px; }
.notifbadge { position: absolute; top: 1px; right: -1px; pointer-events: none; }
/* จอแคบ: บีบช่องไฟ nav ให้กระดิ่งเข้าแถวได้โดยไม่ล้นขอบ (เช็คที่ 375px) */
@media (max-width: 420px) {
  .site-nav { gap: 6px; }
  .notifbell { width: 34px; }
}
.notifbadge__num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: #e53935; color: #fff; font-size: 11px; font-weight: 800; line-height: 1;
}

/* dropdown แจ้งเตือน — desktop ห้อยใต้กระดิ่ง, มือถือเต็มความกว้าง */
.notifpanel {
  position: absolute; right: 0; top: 46px; width: 340px; max-height: 70vh; overflow-y: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); z-index: 30;
}
@media (max-width: 599px) {
  .notifpanel { position: fixed; left: 8px; right: 8px; top: 62px; width: auto; }
}
.notifpanel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 15px;
}
.notifpanel__readall {
  background: none; border: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--green-dark); text-decoration: underline; cursor: pointer;
}
.notifpanel__all { display: block; text-align: center; padding: 11px; font-size: 14px; font-weight: 700; color: var(--green-dark); border-top: 1px solid var(--border); }
.notifpanel__all:hover { background: #f4f7f3; }

/* รายการแจ้งเตือน (ใช้ทั้ง dropdown และหน้ารวม) */
.notiflist { list-style: none; margin: 0; padding: 0; }
.notif a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif:last-child a { border-bottom: none; }
.notif a:hover { background: #f4f7f3; }
.notif--unread a { background: #eef6ee; }
.notif--unread .notif__msg { font-weight: 700; }
.notif__msg { display: block; font-size: 14px; line-height: 1.45; }
.notif__time { display: block; margin-top: 2px; }
.notiflist__empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* หน้ารวมแจ้งเตือน /notifications/ */
.notifpage__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notifpage__head form { margin: 0 0 10px; }
.notiflist--page {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pager__info { flex: none; }

/* ---- ใจ + คอมเมนต์ ---- */
/* การ์ดเปลี่ยนโครงจาก <a> เดี่ยวเป็น div + ลิงก์ภายใน (ปุ่มใจต้องกดได้ ไม่ซ้อนใน <a>) */
.card__link { display: flex; flex-direction: column; flex: 1; }
.card__foot {
  display: flex; align-items: center; gap: 4px;
  border-top: 1px solid var(--border); padding: 2px 8px;
}
.likebox form { margin: 0; display: inline-flex; }
.likebtn {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 38px; padding: 6px 10px; border: none; border-radius: 9px;
  background: transparent; color: var(--muted); font: inherit; font-size: 13.5px;
  font-weight: 600; cursor: pointer;
}
.likebtn:hover { background: #f0f2ec; }
.likebtn .icon { width: 19px; height: 19px; }
.likebtn--on { color: #e53935; }
.likebtn--on .icon { fill: currentColor; }
.card__cmt {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 38px; padding: 6px 10px; border-radius: 9px;
  color: var(--muted); font-size: 13.5px; font-weight: 600;
}
.card__cmt:hover { background: #f0f2ec; }
.card__cmt .icon { width: 19px; height: 19px; }

/* แถวใจ+คอมเมนต์บนหน้า detail (เหนือ section คอมเมนต์) */
.detail__engage {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 16px 0; padding-top: 10px; border-top: 1px solid var(--border);
}
.detail__engage .likebtn { font-size: 14.5px; }
.detail__cmtcount {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 38px; padding: 6px 10px; border-radius: 9px;
  color: var(--muted); font-size: 14.5px; font-weight: 600;
}
.detail__cmtcount:hover { background: #f0f2ec; }

/* รายการคอมเมนต์ */
.comment-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comment-list__empty { padding: 4px 0; font-size: 14px; }
/* มีคอมเมนต์จริงเข้ามา (htmx append) → ซ่อนแถว "ยังไม่มีคอมเมนต์" */
.comment-list__empty:not(:only-child) { display: none; }
.comment { display: flex; align-items: flex-start; gap: 8px; }
.avatar--sm { width: 32px; height: 32px; font-size: 15px; margin-top: 2px; }
.comment__bubble {
  flex: 1; min-width: 0; background: #f0f2ec; border-radius: 12px; padding: 7px 12px;
}
.comment__name { display: block; font-size: 13px; color: var(--green-dark); }
.comment__text { display: block; font-size: 14.5px; line-height: 1.5; overflow-wrap: break-word; }
.comment__time { display: block; margin-top: 1px; }
.comment__hideform { margin: 2px 0 0; }
.comment__hide {
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer;
}
.comment__hide:hover { background: #fdecea; color: #c0392b; }

/* ปุ่มจิ้มสำเร็จรูป + ช่องพิมพ์ */
.quickreplies { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.comment-form { display: flex; gap: 8px; }
.comment-form input {
  flex: 1; min-width: 0; padding: 10px 14px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 20px; background: #fff; color: var(--ink);
}
.comment-form input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12);
}
.comment-login { font-size: 14px; }

/* ---- แก้ไขประกาศ (เฟส 13) ---- */
/* แถบยืนยันหลัง redirect (django messages) */
.flash {
  border-radius: 9px; padding: 10px 14px; margin-bottom: 12px;
  font-size: 14.5px; font-weight: 600;
  background: #e8f3e8; color: var(--green-dark); border: 1px solid #bcd9bc;
}
.flash--error, .flash--warning { background: #fdecea; color: #c0392b; border-color: #f5c6cb; }

/* รูปเดิมในฟอร์มแก้ไข — ติ๊ก ✕ เพื่อลบ (checkbox ทำงานได้แม้ไม่มี JS) */
.photobox__olds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 6px; }
.photobox__old {
  position: relative; aspect-ratio: 1;
  border-radius: 9px; overflow: hidden; border: 1px solid var(--border);
}
.photobox__old img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photobox__del {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
}
.photobox__del:hover { background: rgba(0, 0, 0, .8); }
.photobox__del input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
/* ติ๊กลบแล้ว → รูปจาง + ปุ่มแดง (กดซ้ำ = ยกเลิก) */
.photobox__old:has(input:checked) img { opacity: .35; filter: grayscale(1); }
.photobox__old:has(input:checked) .photobox__del { background: #c0392b; }
.photobox__oldhint { margin: 0 0 10px; }

/* หน้าประกาศของฉัน + ลิงก์บนฟีด */
.feed-minelink { text-align: right; margin: -6px 0 10px; }
.mine-item__bar { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.mine-item__bar .btn { flex: 1; }

/* ---- ผูกแผงกับโพสต์บอร์ด (เฟส 14) ---- */
.composer-stall { margin-bottom: 12px; }
.composer-stall .crow__label { display: block; margin-bottom: 5px; }
.composer-stall__hint { margin: 5px 0 0; }
/* ชื่อแผงท้ายการ์ดฟีด — ชิดขวา กดไปหน้าแผง */
.card__stall {
  display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  min-height: 38px; padding: 6px 10px; border-radius: 9px;
  color: var(--green-dark); font-size: 13.5px; font-weight: 700;
  max-width: 55%; overflow: hidden;
}
.card__stall span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card__stall .icon { flex: 0 0 auto; width: 16px; height: 16px; }
.card__stall:hover { background: #eef3ea; }
.detail__stall a { font-weight: 700; }

/* badge "ทีมงานรวบรวมจากประกาศสาธารณะของแผง" (เฟส 14.1) — ข้อความยาว ให้ตัวเล็กและห่อบรรทัดได้ */
.badge--collected { white-space: normal; line-height: 1.35; text-align: left; font-weight: 600; }

/* ---- ฟอร์มย่อ "เพิ่มแผงใหม่" ในฟอร์มโพสต์บอร์ด (เฟส 15, staff) ---- */
.newstall {
  margin-top: 10px; padding: 12px; border: 1px dashed var(--border);
  border-radius: 10px; background: #fbfbf8;
  display: flex; flex-direction: column; gap: 10px;
}
.newstall__field input[type="text"], .newstall__field input[type="tel"] { width: 100%; }
.newstall__hint { margin: 0; }
.newstall__warn {
  border: 1px solid #e8c97a; background: #fdf6e3; border-radius: 9px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.newstall__warn-title { margin: 0; font-weight: 700; font-size: 14px; }
.newstall__sim {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 14px;
}
.newstall__sim .btn { flex: 0 0 auto; min-height: 36px; padding: 6px 12px; }

/* hotfix เฟส 15: display:flex ของ .newstall ทับ attribute hidden (UA style แพ้ author style)
   + input เบอร์โทร (type=tel) ในฟอร์มย่อไม่โดน selector กลางของ .postform ที่ไม่มี tel */
.newstall[hidden] { display: none; }
.newstall__field input[type="tel"], .newstall__field input[type="text"] {
  padding: 10px 12px; font: inherit; font-size: 15px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--ink);
}
.newstall__field input:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, .12);
}

/* ---- วางข้อมูลราคา bulk ในฟอร์มโพสต์บอร์ด (เฟส 16, staff) ---- */
.bulkpaste { margin: -6px 0 16px; }  /* ชิดใต้ปุ่ม "+ เพิ่มแถว" */
.bulkpaste__toggle { min-height: 40px; }
.bulkpaste__panel { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.bulkpaste__panel[hidden] { display: none; }  /* display:flex ทับ hidden — บทเรียน hotfix เฟส 15 */
.bulkpaste__text { font-size: 14px; line-height: 1.5; }
.bulkpaste__hint { margin: 0; }
/* ช่องที่ bulk paste ให้ตรวจ (ชนิด/เกรดไม่ตรง DB, ราคาว่าง) — สีส้มเตือน ไม่ใช่แดง error */
.boardform input.inp-warn { border-color: #d97706; background: #fff7e6; }
