:root {
	--green: #06c755; --green-d: #05a948; --green-l: #e7f9ee;
	--line: #e6e8eb; --text: #1e1e1e; --muted: #8a8f98; --bg2: #f4f5f7;
	--rail: #2b2f36; --me: #8de055; --them: #ffffff; --chatbg: #8cabd9;
	--panel-w: 360px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif; color: var(--text); background: var(--bg2); font-size: 14px; }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; }
.hidden { display: none !important; }
.small { font-size: 12px; }
svg { width: 22px; height: 22px; fill: currentColor; }

/* ---------- หน้าล็อกอิน ---------- */
.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: #fff; border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.08); text-align: center; }
.card h1 { margin: 8px 0 6px; font-size: 22px; color: var(--green); }
.card p { color: var(--muted); font-size: 14px; margin: 6px 0 16px; line-height: 1.5; }
.field { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; font-size: 16px; background: #fff; }
.btn { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--green); color: #fff; font-weight: 600; font-size: 16px; }
.btn:hover { background: var(--green-d); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 400; font-size: 14px; }
.err { color: #dc2626; font-size: 14px; min-height: 20px; margin: 4px 0 8px; word-break: break-word; }
.qr svg { width: 240px; height: 240px; }
.pin { font-size: 40px; letter-spacing: 8px; font-weight: 700; color: var(--green); margin: 12px 0; }
.spinner { width: 34px; height: 34px; border: 4px solid #d1fae5; border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { font-size: 12px; color: var(--muted); text-align: left; background: var(--bg2); padding: 10px 12px; border-radius: 8px; line-height: 1.6; }

/* ---------- โครงแบบ LINE PC: แถบไอคอน | รายการ | ห้องแชท | แผงขวา ---------- */
#app { display: flex; height: 100dvh; background: #fff; overflow: hidden; }
#rail { width: 64px; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 14px 0 10px; gap: 6px; flex-shrink: 0; }
.rail-me { background: none; border: 0; padding: 0; margin-bottom: 10px; }
.rail-btn { position: relative; width: 46px; height: 46px; border: 0; border-radius: 12px; background: none; color: #9aa1ab; display: flex; align-items: center; justify-content: center; }
.rail-btn svg { width: 26px; height: 26px; }
.rail-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.rail-btn.active { color: #fff; }
.rail-btn.active::before { content: ""; position: absolute; left: -9px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--green); }
.rail-badge { position: absolute; top: 4px; right: 2px; background: #ff3b30; color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 1px 5px; min-width: 18px; }
.rail-spacer { flex: 1; }

#listPane { width: var(--list-w, 320px); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; flex-shrink: 0; }
.pane-head { display: flex; align-items: center; padding: 16px 14px 6px; }
.pane-head h2 { margin: 0; font-size: 20px; flex: 1; }
.search-wrap { padding: 6px 12px; }
#search { width: 100%; padding: 8px 12px; border-radius: 8px; border: 0; background: var(--bg2); font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 8px; max-height: 40vh; overflow-y: auto; }
.filters .row-break { flex-basis: 100%; height: 0; }
.filters button { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 3px 12px; font-size: 13px; white-space: nowrap; color: #555; }
.filters button.active { background: var(--rail); border-color: var(--rail); color: #fff; }
#list { flex: 1; overflow-y: auto; }
.icon-btn { background: none; border: 0; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--bg2); color: var(--text); }

.list-item { display: flex; gap: 12px; padding: 9px 14px; cursor: pointer; align-items: center; }
.list-item:hover { background: #f7f8f9; }
.list-item.active { background: #eef0f3; }
.list-sep { padding: 10px 14px 4px; font-size: 12px; color: var(--muted); }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: #c9ced6; flex-shrink: 0; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; overflow: hidden; }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
.avatar.xs { width: 30px; height: 30px; font-size: 12px; }
.item-meta { flex: 1; min-width: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-name .count { color: var(--muted); font-weight: 400; }
.item-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.item-last { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.badge { background: var(--green); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; flex-shrink: 0; }

/* ห้องแชท */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chatbg); }
#chatHeader { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); min-height: 60px; }
.title-wrap { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtitle { font-size: 12px; color: var(--muted); }
#backBtn { display: none; font-size: 28px; padding: 0 8px; }
.head-actions { display: flex; gap: 2px; }
.head-btn { background: none; border: 0; border-radius: 8px; padding: 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #5b616b; font-size: 11px; }
.head-btn:hover, .head-btn.active { background: var(--bg2); color: var(--green-d); }
#chatBody { flex: 1; position: relative; min-height: 0; }
#messages { position: absolute; inset: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.empty-state { margin: auto; color: #fff; font-size: 15px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: .9; }
#toBottom { position: absolute; right: 16px; bottom: 14px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 18px; }

.msg { display: flex; gap: 8px; max-width: 72%; align-items: flex-start; margin-top: 2px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.cont { margin-top: -1px; }
.msg.cont .avatar { visibility: hidden; }
.msg .body { display: flex; flex-direction: column; min-width: 0; }
.msg.me .body { align-items: flex-end; }
.msg .sender { font-size: 12px; color: #f5f7fa; margin: 0 0 3px 2px; }
.msg .line { display: flex; align-items: flex-end; gap: 5px; }
.msg.me .line { flex-direction: row-reverse; }
.bubble { position: relative; background: var(--them); padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; line-height: 1.45; max-width: 100%; }
.msg.me .bubble { background: var(--me); }
.bubble.media { padding: 0; background: transparent !important; border-radius: 14px; overflow: hidden; }
.bubble img.photo, .bubble video { max-width: min(280px, 62vw); max-height: 340px; border-radius: 14px; display: block; cursor: zoom-in; background: #00000022; }
.bubble video { cursor: default; }
.bubble img.sticker { width: 130px; height: 130px; object-fit: contain; display: block; }
.bubble.locked { color: var(--muted); font-style: italic; }
.bubble a { color: #1d4ed8; }
.bubble audio { display: block; width: min(260px, 62vw); height: 40px; }
.bubble.audio { padding: 6px 8px; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 280px; text-decoration: none; color: inherit !important; }
.file-icon { width: 40px; height: 40px; border-radius: 8px; background: #eef1f5; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--muted); }
.post-card { min-width: 220px; max-width: 280px; cursor: pointer; }
.post-card .tag { font-size: 12px; color: var(--green-d); font-weight: 700; margin-bottom: 4px; }
.quote { font-size: 12px; color: #4b5563; border-left: 3px solid #9ca3af; padding: 2px 8px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; cursor: pointer; }
.meta-col { display: flex; flex-direction: column; font-size: 10.5px; color: #eef2f8; white-space: nowrap; line-height: 1.3; }
.msg.me .meta-col { align-items: flex-end; }
.msg-actions { visibility: hidden; align-self: center; display: flex; gap: 3px; }
.msg:hover .msg-actions { visibility: visible; }
.msg-actions button { border: 0; background: rgba(255,255,255,.9); border-radius: 50%; width: 28px; height: 28px; font-size: 14px; line-height: 1; padding: 0; color: #444; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.msg-actions button:hover { background: #fff; color: var(--green-d); }
/* จอสัมผัส: ซ่อนปุ่มไว้ก่อน แตะข้อความ (หรือกดค้าง) แล้วค่อยโผล่เป็นแถบลอยใต้ข้อความ */
@media (hover: none) {
	.msg .line { position: relative; }
	.msg:hover .msg-actions { visibility: hidden; }
	.msg-actions { display: none; }
	.msg.acts-open .msg-actions { display: flex; visibility: visible; position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; gap: 4px; padding: 4px; background: #fff; border-radius: 22px; box-shadow: 0 4px 14px rgba(0,0,0,.22); }
	.msg.me.acts-open .msg-actions { left: auto; right: 0; }
	.msg-actions button { width: 36px; height: 36px; font-size: 17px; box-shadow: none; background: #f1f3f6; }
	.msg.acts-open { margin-bottom: 50px; }
	.msg.acts-open .bubble { filter: brightness(.93); }
}

/* กริดรูปที่ส่งพร้อมกัน */
.img-group { display: grid; gap: 2px; width: min(300px, 64vw); background: #fff !important; border-radius: 14px; }
.img-group.g2 { grid-template-columns: 1fr 1fr; }
.img-group.g3 { grid-template-columns: 1fr 1fr 1fr; }
.img-group.g4 { grid-template-columns: 1fr 1fr; }
.img-group .thumb { aspect-ratio: 1; }
.group-bar { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: 12px; color: #555; background: #fff; }
.group-dl { color: var(--green-d) !important; font-weight: 700; text-decoration: none; }

/* หน้าต่างแชร์ */
#shareDialog { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.share-box { background: #fff; border-radius: 14px; width: 100%; max-width: 420px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.share-head { padding: 16px 16px 8px; }
.share-head b { font-size: 16px; }
.share-what { font-size: 13px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#shareSearch { margin: 4px 16px 8px; padding: 8px 12px; border-radius: 8px; border: 0; background: var(--bg2); font-size: 14px; }
#shareList { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 200px; }
.share-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.share-item:hover { background: #f7f8f9; }
.share-item input { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; }
.share-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-foot { display: flex; gap: 8px; padding: 12px 16px; }
.share-foot .btn { flex: 1; }
.share-foot .btn:disabled { opacity: .5; }
.day-sep { align-self: center; background: rgba(0,0,0,.18); color: #fff; font-size: 12px; padding: 2px 12px; border-radius: 12px; margin: 10px 0 6px; }
.sys-msg { align-self: center; background: rgba(0,0,0,.14); color: #fff; font-size: 12px; padding: 3px 12px; border-radius: 12px; max-width: 80%; text-align: center; }
#loadOlder { align-self: center; background: rgba(255,255,255,.9); border: 0; border-radius: 12px; padding: 4px 14px; font-size: 13px; margin-bottom: 6px; }
.flash { animation: flash 1.4s; }
@keyframes flash { 0%, 60% { filter: brightness(.8); } }

#replyBar { display: flex; align-items: center; gap: 8px; background: #f7f8fa; border-top: 1px solid var(--line); padding: 6px 12px; }
.reply-info { flex: 1; min-width: 0; font-size: 13px; border-left: 3px solid var(--green); padding-left: 8px; display: flex; flex-direction: column; }
.reply-info span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#composer { display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--line); align-items: flex-end; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#composer textarea { flex: 1; resize: none; border: 0; outline: none; padding: 8px 4px; max-height: 160px; font-size: 15px; line-height: 1.45; background: transparent; }
#sendBtn { background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 600; }
#sendBtn:disabled { opacity: .5; }

/* แผงขวา: โน้ต / อัลบั้ม / สื่อ / สมาชิก */
#sidePanel { width: var(--panel-w); border-left: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.side-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); min-height: 52px; }
.side-tabs { display: flex; flex: 1; }
.side-tabs button { flex: 1; border: 0; background: none; padding: 10px 4px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.side-tabs button.active { color: var(--text); border-bottom-color: var(--green); }
.side-title { flex: 1; font-weight: 700; padding: 0 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sideBody { flex: 1; overflow-y: auto; }
.side-empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.side-count { padding: 10px 14px 4px; font-size: 12px; color: var(--muted); }
.more-btn { display: block; margin: 12px auto 18px; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 16px; font-size: 13px; }

.note-item { padding: 14px; border-bottom: 8px solid var(--bg2); cursor: pointer; }
.note-item:hover { background: #fafbfc; }
.note-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.note-author { font-weight: 600; }
.note-date { font-size: 12px; color: var(--muted); }
.note-text { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.note-item .note-text { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.note-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin-top: 10px; border-radius: 8px; overflow: hidden; }
.note-media.one { grid-template-columns: 1fr; }
.note-media.two { grid-template-columns: 1fr 1fr; }
.thumb { position: relative; aspect-ratio: 1; background: #e5e7eb; overflow: hidden; cursor: zoom-in; }
.note-media.one .thumb { aspect-ratio: auto; max-height: 360px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px; text-shadow: 0 1px 6px #000a; pointer-events: none; }
.thumb .more { position: absolute; inset: 0; background: #0007; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.note-stats { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.comments { border-top: 1px solid var(--line); margin-top: 12px; }
.comment { display: flex; gap: 8px; padding: 10px 0; }
.comment-body { background: var(--bg2); border-radius: 12px; padding: 7px 10px; flex: 1; min-width: 0; }
.comment-body b { font-size: 13px; }
.comment-body div { white-space: pre-wrap; word-break: break-word; }
.comment-body img.sticker { width: 80px; height: 80px; object-fit: contain; }

.album-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
.album { cursor: pointer; }
.album .cover { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e5e7eb; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 32px; }
.album .cover img { width: 100%; height: 100%; object-fit: cover; }
.album-title { font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-count { font-size: 12px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; }
.member { display: flex; gap: 10px; align-items: center; padding: 8px 14px; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.file-row:hover { background: #fafbfc; }

/* ตัวดูรูป/วิดีโอเต็มจอ */
#viewer { position: fixed; inset: 0; background: rgba(10,10,12,.94); z-index: 40; display: flex; align-items: center; justify-content: center; }
#viewerStage { max-width: 92vw; max-height: 86vh; display: flex; align-items: center; justify-content: center; }
#viewerStage img, #viewerStage video { max-width: 92vw; max-height: 86vh; display: block; }
.viewer-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #ddd; font-size: 13px; }
.viewer-top span { flex: 1; }
.viewer-btn { background: rgba(255,255,255,.12); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 18px; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; width: 46px; height: 64px; border-radius: 10px; font-size: 32px; }
.viewer-nav.prev { left: 12px; } .viewer-nav.next { right: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: 90vw; }

/* จอแคบ: ซ่อนแผงขวาเป็นทับเต็มห้องแชท */
@media (max-width: 1100px) {
	#sidePanel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; box-shadow: -6px 0 24px rgba(0,0,0,.15); }
}
@media (max-width: 760px) {
	#rail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: calc(56px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; padding: 4px 8px env(safe-area-inset-bottom); z-index: 20; }
	.rail-me, .rail-spacer { display: none; }
	.rail-btn.active::before { left: 12px; right: 12px; top: auto; bottom: -2px; width: auto; height: 3px; }
	#listPane { width: 100%; border-right: 0; padding-bottom: 60px; }
	#main { display: none; }
	#app.in-chat #listPane, #app.in-chat #rail { display: none; }
	#app.in-chat #main { display: flex; }
	#backBtn { display: inline-block; }
	.head-btn span { display: none; }
	.head-btn { padding: 6px; }
	.msg { max-width: 86%; }
	#sidePanel { width: 100%; }
	.viewer-nav { display: none; }
}

/* ค้นหาข้อความ / ยกเลิกส่ง */
.search-all { color: var(--green-d); font-weight: 600; }
.search-icon { width: 46px; text-align: center; font-size: 20px; }
.search-back { cursor: pointer; color: var(--green-d); }
.search-hit { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg.unsent .bubble { opacity: .55; }
.unsent-tag { font-size: 11px; color: #fee2e2; margin-top: 2px; }
.msg.me .unsent-tag { text-align: right; }

/* ปักหมุด / กลุ่มห้องแชท */
.list-item { position: relative; }
.list-item.pinned { background: #fbfcf8; }
.pin-mark { font-size: 12px; margin-right: 4px; }
.item-more { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: #fff; border-radius: 50%; width: 28px; height: 28px; font-size: 16px; color: #666; box-shadow: 0 1px 4px rgba(0,0,0,.15); display: none; }
.list-item:hover .item-more { display: block; }
@media (hover: none) { .item-more { display: block; background: transparent; box-shadow: none; top: 14px; transform: none; } }
.filters .folder-chip { border-color: #c7ead4; background: var(--green-l); color: #146c3a; }
.filters .folder-chip.active { background: var(--green-d); border-color: var(--green-d); color: #fff; }
.filters .add-chip { border-style: dashed; color: var(--green-d); }
.ctx-menu { position: fixed; z-index: 70; background: #fff; border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.2); padding: 6px; min-width: 220px; max-width: 300px; max-height: 70vh; overflow-y: auto; }
.ctx-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 6px; font-size: 14px; }
.ctx-menu button:hover { background: var(--bg2); }
.ctx-menu button.danger { color: #dc2626; }
.ctx-header { font-size: 12px; color: var(--muted); padding: 8px 12px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.ctx-header:first-child { border-top: 0; margin-top: 0; }

/* การ์ด Flex / RICH จาก LINE OA */
.bubble.flex-msg { padding: 0; background: transparent !important; border-radius: 0; overflow: visible; max-width: min(100%, 400px); }
.fx-carousel { display: flex; gap: 8px; overflow-x: auto; max-width: min(64vw, 640px); padding-bottom: 4px; scroll-snap-type: x mandatory; }
.fx-carousel .fx-bubble { scroll-snap-align: start; flex-shrink: 0; }
.fx-bubble { max-width: min(100%, 72vw); background: #fff; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(0,0,0,.08); white-space: normal; }
.fx-part > .fx-box { padding: 16px 16px; }
.fx-hero > .fx-box, .fx-hero > .fx-image { padding: 0; }
.fx-header > .fx-box { padding-bottom: 12px; }
.fx-footer > .fx-box { padding-top: 10px; }
.fx-box { display: flex; min-width: 0; position: relative; }
.fx-vertical { flex-direction: column; }
.fx-horizontal { flex-direction: row; }
.fx-baseline { flex-direction: row; align-items: baseline; }
.fx-text { min-width: 0; line-height: 1.35; word-break: break-word; }
.fx-nowrap { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx-image { overflow: hidden; display: flex; min-width: 0; }
.fx-image img { width: 100%; height: 100%; display: block; }
.fx-icon { display: inline-block; vertical-align: baseline; }
.fx-button { border: 0; border-radius: 8px; min-height: 52px; padding: 0 12px; font-size: 15px; font-weight: 600; width: 100%; }
.fx-btn-sm { min-height: 40px; }
.fx-btn-primary { background: #17c950; color: #fff; }
.fx-btn-secondary { background: #dcdfe5; color: #111; }
.fx-btn-link { background: transparent; color: #42659a; }
.fx-sep { height: 1px; background: #e5e7eb; flex: none; align-self: stretch; }
.fx-sep-v { width: 1px; height: auto; }
.fx-action { cursor: pointer; }
.fx-action:hover { filter: brightness(.96); }
.bubble.rich-msg { max-width: min(300px, 64vw); width: min(300px, 64vw); }
.fx-rich { position: relative; width: 100%; }
.fx-rich img { width: 100%; height: 100%; display: block; object-fit: cover; }
.fx-area { position: absolute; }
.fx-area.fx-action:hover { background: rgba(255,255,255,.12); outline: 2px solid rgba(255,255,255,.5); }

/* ลากปรับความกว้าง */
.splitter { width: 5px; margin: 0 -2px; cursor: col-resize; position: relative; z-index: 5; flex-shrink: 0; background: transparent; touch-action: none; }
.splitter::after { content: ""; position: absolute; inset: 0 2px; background: var(--line); }
.splitter:hover::after, .splitter.dragging::after { background: var(--green); inset: 0 1px; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe, body.resizing img, body.resizing video { pointer-events: none; }

/* ปุ่มส่งรูป/ไฟล์ + ถาดรอส่ง */
.tool-btn { background: none; border: 0; color: #6b7280; width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tool-btn:hover { background: var(--bg2); color: var(--green-d); }
#attachTray { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 4px; background: #fff; border-top: 1px solid var(--line); max-height: 200px; overflow-y: auto; }
.att-item { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); }
.att-item img, .att-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-item.att-file { width: 210px; display: flex; align-items: center; gap: 8px; padding: 8px; }
.att-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.att-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; line-height: 1; }
.att-badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; text-shadow: 0 1px 6px #000a; pointer-events: none; }
.att-info { width: 100%; font-size: 12px; color: var(--muted); }
#uploadBar { background: #ecfdf3; color: #146c3a; font-size: 13px; padding: 6px 14px; border-top: 1px solid #c7ead4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#main { position: relative; }
.drop-hint { display: none; position: absolute; inset: 0; background: rgba(6,199,85,.12); border: 3px dashed var(--green); color: var(--green-d); font-size: 20px; font-weight: 700; align-items: center; justify-content: center; z-index: 15; pointer-events: none; }
#main.drag-over .drop-hint { display: flex; }

@media (max-width: 1100px) { #sideSplit { display: none; } }
@media (max-width: 760px) { .splitter { display: none; } #listPane { width: 100%; } }

/* หลายผู้ใช้ / ผู้ดูแลดูบัญชีพนักงาน */
.who { font-size: 13px; color: var(--green-d); font-weight: 600; margin-bottom: 4px; }
#viewBanner { background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa; font-size: 13px; padding: 7px 14px; }
body.read-only #composer, body.read-only #attachTray, body.read-only .msg-actions button[title="ตอบกลับ"],
body.read-only .msg-actions button[title^="แชร์"], body.read-only .item-more, body.read-only .add-chip { display: none !important; }

/* ติดตั้งแอป / แจ้งอัปเดต */
#updateBar { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 80; background: var(--green); color: #fff; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 24px); }
#updateBtn { background: #fff; color: var(--green-d); border: 0; border-radius: 8px; padding: 6px 14px; font-weight: 700; }
#updateLater { background: transparent; border: 0; color: #fff; font-size: 14px; padding: 4px 8px; opacity: .85; }
#installHelp { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.install-box { max-width: 380px; }
.install-steps { padding: 0 16px 8px; font-size: 14px; line-height: 1.7; }
.install-steps ol { padding-left: 20px; margin: 6px 0; }
#installBtn { color: #7ee2a8; }
@media (display-mode: standalone) { #installBtn { display: none !important; } }

/* เปิด PDF ในระบบ */
.pdf-frame { width: min(1000px, 94vw); height: 86vh; border: 0; background: #fff; border-radius: 6px; }
#viewerStage:has(.pdf-frame) { max-width: none; }

/* โหมดเลือกหลายข้อความ */
#messages.selecting .msg[data-ids] { cursor: pointer; position: relative; padding-left: 34px; border-radius: 10px; }
#messages.selecting .msg[data-ids]::before { content: ""; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.15); box-sizing: border-box; }
#messages.selecting .msg.me[data-ids] { padding-left: 0; padding-right: 34px; }
#messages.selecting .msg.me[data-ids]::before { left: auto; right: 6px; }
#messages.selecting .msg.selected { background: rgba(255,255,255,.18); }
#messages.selecting .msg.selected::before { background: var(--green); border-color: #fff; box-shadow: inset 0 0 0 3px var(--green); }
#messages.selecting .msg.selected::after { content: "✓"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #fff; font-size: 12px; font-weight: 700; }
#messages.selecting .msg.me.selected::after { left: auto; right: 11px; }
#messages.selecting .msg-actions { display: none; }
#selectBar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--line); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#selCount { flex: 1; font-weight: 600; font-size: 14px; }
#selectBar button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; font-weight: 600; }
#selectBar button.primary { background: var(--green); border-color: var(--green); color: #fff; }
#selectBar button:disabled { opacity: .45; }

/* แท็บ LINE OA / Facebook (แชทลูกค้าจาก accweb) */
.rail-btn { flex-direction: column; }
.rail-label { font-size: 9px; font-weight: 700; line-height: 1; margin-top: 1px; }
#oaFbBtn.active svg, #oaFbBtn:hover svg { color: #4c8dff; }
.oa-account { flex: 1 1 100%; width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; }
.oa-row3 { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.oa-chip { font-size: 10.5px; color: #146c3a; background: var(--green-l); border-radius: 6px; padding: 0 6px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.oa-fb .oa-chip { color: #1d4ed8; background: #e8efff; }
.oa-pending { font-size: 10.5px; color: #b45309; background: #fff7ed; border-radius: 6px; padding: 0 6px; font-weight: 700; }
.oa-over24 { font-size: 10.5px; color: #b91c1c; background: #fee2e2; border-radius: 6px; padding: 0 6px; font-weight: 700; }
.oa-assignee { font-size: 10.5px; color: var(--muted); }
.oa-who { color: #eef2ff; text-align: right; }
#oaBanner { background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa; font-size: 13px; padding: 7px 14px; }
#oaBanner .oa-fb-inbox { display: inline-block; margin-left: 4px; padding: 2px 10px; border-radius: 999px; background: #1877f2; color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
#oaBanner .oa-fb-inbox:hover { background: #166fe5; }
#oaBanner .oa-fb-link { margin-left: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid #fdba74; background: #fff; color: #9a3412; font-size: 12px; cursor: pointer; white-space: nowrap; }
body.oa-mode #headActions { display: none !important; }
body.read-only.oa-mode #composer:not(.hidden), body.read-only.oa-mode #attachTray:not(.hidden):not(:empty) { display: flex !important; }
body.oa-mode #viewBanner { display: none !important; }

/* เครื่องมือแชท OA / Facebook */
.oa-only, .oa-actions { display: none !important; }
body.oa-mode .oa-only { display: inline-flex !important; }
body.oa-mode .oa-actions { display: flex !important; }
body.oa-mode.oa-fb .oa-line-only { display: none !important; }
.tool-btn { font-size: 18px; }
.oa-ico { font-size: 17px; line-height: 1; }
.oa-tag { font-size: 10.5px; color: #6b21a8; background: #f3e8ff; border-radius: 6px; padding: 0 6px; }
#oaPop { position: absolute; left: 12px; right: 12px; bottom: 64px; max-width: 520px; max-height: 55vh; background: #fff; border-radius: 12px; box-shadow: 0 10px 34px rgba(0,0,0,.22); z-index: 25; display: flex; flex-direction: column; overflow: hidden; }
#oaPop.hidden { display: none; }
.oa-pop-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.oa-pop-tabs button { border: 0; background: none; padding: 8px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.oa-pop-tabs button.active { color: var(--text); border-bottom-color: var(--green); }
.oa-pop-x { margin-left: auto; }
.oa-pop-search { margin: 8px; padding: 7px 10px; border: 0; border-radius: 8px; background: var(--bg2); font-size: 14px; }
.oa-pop-list { overflow-y: auto; padding: 0 8px 8px; }
.oa-qr { position: relative; padding: 9px 34px 9px 10px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line); }
.oa-qr:hover { background: #f4fbf7; }
.oa-qr b { font-size: 13px; }
.oa-qr-text { font-size: 13px; color: #444; white-space: pre-wrap; max-height: 4.5em; overflow: hidden; }
.oa-qr-img { max-width: 120px; max-height: 80px; border-radius: 6px; margin-top: 4px; display: block; }
.oa-qr-del { position: absolute; right: 6px; top: 8px; border: 0; background: none; opacity: .5; }
.oa-qr-del:hover { opacity: 1; }
.oa-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; padding: 8px; overflow-y: auto; }
.oa-stickers img { width: 100%; aspect-ratio: 1; object-fit: contain; cursor: pointer; border-radius: 8px; }
.oa-stickers img:hover { background: var(--bg2); }
.oa-form { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.oa-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.oa-field input, .oa-field select, .oa-field textarea { font-size: 14px; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; resize: vertical; }
.oa-order { margin: 10px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.oa-order-head { display: flex; justify-content: space-between; gap: 8px; }
.oa-order-status { font-size: 12px; color: var(--green-d); font-weight: 600; }
.oa-order-item { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.oa-order-sum { display: flex; justify-content: space-between; margin-top: 6px; font-weight: 600; font-size: 13px; }

/* Facebook: ที่มาของแชท (โฆษณา / คอมเมนต์ใต้โพสต์) */
#oaSource { background: #fff; border-bottom: 1px solid var(--line); padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; }
.oa-src { display: flex; gap: 10px; align-items: flex-start; }
.oa-src-img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex-shrink: 0; cursor: zoom-in; background: var(--bg2); }
.oa-src-body { flex: 1; min-width: 0; }
.oa-src-kind { font-weight: 700; font-size: 13px; color: #1d4ed8; }
.oa-src-kind.ad { color: #b45309; }
.oa-src-kind.comment { color: #7c3aed; }
.oa-src-msg { font-size: 13px; color: #374151; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.oa-src-msg.open { -webkit-line-clamp: unset; display: block; }
.oa-src-note { font-size: 12.5px; color: #6b21a8; background: #faf5ff; border-radius: 6px; padding: 3px 8px; margin-top: 3px; }
.oa-src-links { display: flex; gap: 12px; align-items: center; margin-top: 3px; font-size: 12.5px; }
.oa-src-links a { color: #1d4ed8; }
.oa-src-links button { border: 0; background: none; color: var(--muted); font-size: 14px; }
.oa-src-labels { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }

/* การ์ดราคา / เปิดบิล */
#oaModal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; display: flex; align-items: center; justify-content: center; padding: 16px; }
.oa-modal-box { max-width: 560px; max-height: 92vh; }
.oa-modal-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
#oaModalBody { overflow-y: auto; padding: 10px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.oa-brands { display: flex; gap: 6px; flex-wrap: wrap; }
.oa-brands button { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 12px; font-size: 13px; }
.oa-brands button.active { color: #fff; border-color: transparent; background: var(--green); }
.oa-psearch .oa-pop-search { width: 100%; margin: 0; }
.oa-presults { max-height: 240px; overflow-y: auto; }
.oa-presult { display: flex; gap: 8px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.oa-presult:hover { background: #f4fbf7; }
.oa-presult img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.oa-presult b { font-size: 13px; }
.oa-picked { display: flex; flex-direction: column; gap: 8px; }
.oa-pick { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.oa-pick-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.oa-pick-head button, .oa-bill-row button { border: 0; background: none; color: var(--muted); }
.oa-rates { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 13px; margin-top: 6px; }
.oa-pick-line { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 6px; }
.oa-pick-line input { width: 90px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.oa-result { display: flex; flex-direction: column; gap: 8px; }
.oa-result-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.oa-result-msg { width: 100%; font-size: 13px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.oa-bill { display: flex; flex-direction: column; gap: 8px; }
.oa-sub { font-weight: 700; font-size: 13px; margin-top: 4px; }
.oa-bill-row { display: grid; grid-template-columns: 1fr 60px 90px 24px; gap: 6px; margin-bottom: 6px; }
.oa-bill-row input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; min-width: 0; }
.oa-bill-money { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 8px; }
.oa-bill-money input, .oa-bill-money select, .oa-pay select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; width: 100%; }
.oa-bill-total { font-weight: 700; color: var(--green-d); font-size: 14px; }
.oa-pay-modes { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin-bottom: 6px; }
.oa-prev-bill { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.oa-prev-bill span { flex: 1; }
.oa-prev-bill button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
#oaExtra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px 0; background: #fff; border-top: 1px solid var(--line); }
#oaExtra.hidden { display: none; }
.oa-extra-chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 12.5px; background: #f8fafc; }
.oa-extra-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.oa-extra-chip button { border: 0; background: none; color: var(--muted); }
/* #oaExtra ใช้ทั้งแชท OA และ LINE ส่วนตัว (การ์ด/แคตตาล็อกที่แนบรอส่ง) — ซ่อนเองเมื่อว่าง */

/* ผู้ดูแล: มีบัญชีพนักงานที่ LINE หลุด */
#menuBtn.alert-dot { position: relative; }
#menuBtn.alert-dot::after { content: ""; position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 2px var(--rail); }

/* ---------- ก้อนแชท (ผู้ใช้ตั้งเอง หลายก้อน) — ปุ่มบนแถบซ้าย + รายการรวม ---------- */
.rail-groups { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding-top: 8px; margin-top: 2px; border-top: 1px solid rgba(255,255,255,.12); overflow-y: auto; min-height: 0; flex: 0 1 auto; scrollbar-width: none; }
.rail-groups::-webkit-scrollbar { display: none; }
.rail-group { flex-shrink: 0; height: 52px; gap: 2px; }
.rail-group-ico { width: 28px; height: 28px; border-radius: 9px; color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; opacity: .8; }
.rail-group:hover .rail-group-ico, .rail-group.active .rail-group-ico { opacity: 1; }
.rail-group.active .rail-group-ico { box-shadow: 0 0 0 2px #fff; }
.rail-group .rail-label { max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rail-group .rail-badge { top: 0; right: 0; }
.rail-group-add { flex-shrink: 0; width: 34px; height: 34px; font-size: 20px; border: 1px dashed rgba(255,255,255,.25); border-radius: 10px; }
.w-src-chip { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: #e8f8ee; color: #06a046; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.w-src-chip.src-p { background: #eef0f3; color: #4b5563; }
.w-src-chip.src-fb { background: #e8efff; color: #1d4ed8; }
.watch-btn { font-size: 20px; color: #9aa1ab; }
.watch-btn.on { color: #f5b301; }
/* โหมด "นับเฉพาะห้องในก้อน": ตัวเลขรวมของแท็บแชท/OA/FB เป็นสีเทา ไม่แย่งสายตา */
body.watch-focus .rail-btn:not(.rail-group) > .rail-badge { background: #6b7280; }
@media (max-width: 760px) {
	/* มือถือ: แถบล่าง — ก้อนเรียงต่อปุ่มหลัก เลื่อนซ้ายขวาได้ */
	.rail-groups { flex-direction: row; width: auto; flex: 1 1 auto; padding: 0; margin: 0; border-top: 0; border-left: 1px solid rgba(255,255,255,.12); overflow-x: auto; overflow-y: hidden; justify-content: flex-start; gap: 2px; }
	.rail-group { height: 46px; width: 52px; }
	.rail-group-add { width: 30px; height: 30px; margin: auto 6px; }
}

/* ---------- แจ้งเตือนสายเข้า / ไม่ได้รับสาย ---------- */
#callAlert { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 90; width: min(420px, calc(100vw - 24px)); background: #1f2329; color: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.35); display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; animation: ca-in .2s ease-out; }
#callAlert.hidden { display: none; }
@keyframes ca-in { from { opacity: 0; transform: translate(-50%, -10px); } }
#callAlert .avatar { width: 48px; height: 48px; }
.ca-text { flex: 1; min-width: 0; }
.ca-title-row { font-size: 13px; color: #8de055; font-weight: 700; }
.ca-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ca-sub { font-size: 12px; color: #aab0b8; }
.ca-btn { border: 0; background: var(--green); color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.ca-close { border: 0; background: rgba(255,255,255,.1); color: #fff; width: 30px; height: 30px; border-radius: 50%; }
.sys-msg.call-missed { color: #e5484d; font-weight: 600; }

/* ---------- เครื่องมือขายในแชทส่วนตัว + รายละเอียดสินค้า / แคตตาล็อก / แชร์ไฟล์ ---------- */
.tool-any { display: inline-flex; }
body.read-only .tool-any { display: none; }
.oa-dt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.oa-dt-head img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.oa-dt-head > div { flex: 1; min-width: 0; }
.oa-dt-secs { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.oa-dt-sec { border: 1px solid var(--line); border-radius: 10px; padding: 8px; opacity: .6; }
.oa-dt-sec.on { opacity: 1; border-color: var(--green); }
.oa-dt-sec label { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.oa-dt-sec textarea { width: 100%; box-sizing: border-box; margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; resize: vertical; }
.oa-dt-more { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.oa-dt-more button { border: 1px dashed #b8c0cc; background: #fff; border-radius: 14px; padding: 3px 10px; font-size: 12px; color: #4b5563; }
.oa-dt-inc { display: flex; align-items: center; gap: 4px; font-size: 13px; margin: 6px 0 10px; }
.oa-cat-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; max-height: 58vh; overflow-y: auto; }
.oa-cat-ico { font-size: 24px; width: 40px; text-align: center; flex-shrink: 0; }
.oa-share-up { display: block; text-align: center; padding: 10px; border: 1.5px dashed var(--green); border-radius: 10px; color: #067a3a; background: #f2fff7; font-weight: 700; cursor: pointer; margin-bottom: 8px; }
/* ---------- เตือนตามลูกค้า ---------- */
.remind-btn { font-size: 18px; filter: grayscale(1); opacity: .6; }
.remind-btn.on { filter: none; opacity: 1; }
.rem-due .rem-when { color: #e5484d; font-weight: 700; }
.rem-pick { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.rem-pick input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
/* มือถือ: ปุ่มเครื่องมือแถวบน · ช่องพิมพ์ + ส่ง แถวล่างเต็มความกว้าง (เครื่องมือหลายปุ่มไม่บีบช่องพิมพ์) */
@media (max-width: 760px) {
	#composer { flex-wrap: wrap; column-gap: 2px; row-gap: 6px; }
	#composer textarea { flex: 1 1 calc(100% - 80px); min-width: 0; order: 1; margin-right: 6px; background: var(--bg2); border-radius: 18px; padding: 8px 12px; }
	#composer #sendBtn { order: 2; }
}

/* ---------- สร้างกลุ่ม / เปลี่ยนชื่อ ---------- */
.new-group-btn { font-size: 13px; width: auto !important; padding: 0 8px; white-space: nowrap; }
.ng-row { cursor: pointer; }
.ng-row input { width: 18px; height: 18px; flex-shrink: 0; }
.ng-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.ng-chips:empty { display: none; }
.ng-chips button { border: 0; background: #e8f8ee; color: #067a3a; border-radius: 14px; padding: 3px 10px; font-size: 12px; }
body:not(.oa-mode):not(.read-only) #chatTitle { cursor: pointer; }
.af-form { display: flex; gap: 8px; align-items: center; }
.af-form input { flex: 1; margin: 0; }
.af-form .btn { width: auto; margin: 0; padding: 8px 16px; }
.af-out { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.af-card { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.af-card b { font-size: 16px; }

/* ---------- หน้าเพื่อน: หมวด + ทีละ 50 ---------- */
.fr-segs { display: flex; gap: 6px; padding: 8px 12px; position: sticky; top: 0; background: #fff; z-index: 2; overflow-x: auto; scrollbar-width: none; }
.fr-segs::-webkit-scrollbar { display: none; }
.fr-segs button { flex-shrink: 0; white-space: nowrap; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 4px 10px; font-size: 12.5px; color: #374151; }
.fr-segs button.active { background: var(--rail); border-color: var(--rail); color: #fff; }
.fr-more { display: block; width: calc(100% - 24px); margin: 8px 12px 16px; }

/* ---------- เชื่อมบัญชี accweb ---------- */
.link-bg { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.link-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; }
.link-card h1 { font-size: 18px; margin: 0; }
.link-card p { margin: 0; font-size: 13px; color: #4b5563; }
.link-card .more-btn { align-self: center; }
.media-retry { cursor: pointer; text-decoration: underline dotted; }

/* ---------- 🔕 ปิดแจ้งเตือนรายห้อง ---------- */
.mute-btn { font-size: 17px; opacity: .45; filter: grayscale(1); }
.mute-btn.on { opacity: 1; filter: none; }
.mute-mark { font-size: 11px; margin-left: 4px; opacity: .7; }
.badge.muted { background: #b8bec7 !important; }

/* 📦 ประวัติซื้อ (ผูกรหัสลูกค้า) */
.oa-codeform { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.oa-codeform input { flex: 1 1 160px; margin: 0; }
.oa-codeform .btn { flex: 0 0 auto; width: auto; padding: 8px 16px; font-size: 14px; }
.oa-orders-note { font-size: 12px; color: var(--muted); padding: 8px 12px 0; }
.oa-order-item { align-items: center; }
.oa-order-item img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: #f3f4f6; }
.oa-order-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.oa-order-name small { color: var(--muted); font-size: 11px; }
.oa-order-qty { white-space: nowrap; }
.oa-order-link { display: inline-block; margin-top: 6px; font-size: 12px; color: #2563eb; }

/* 👁 พนักงานที่เห็นข้อความลูกค้าแล้ว */
.oa-seen { color: #047857; font-weight: 700; cursor: help; white-space: nowrap; }

/* 🔎 ค้นหาสินค้า / สต็อก */
.oa-prod-form { display: flex; gap: 6px; margin: 10px 0; }
.oa-prod-form input { flex: 1; margin: 0; }
.oa-prod-form .btn { width: auto; padding: 8px 16px; font-size: 14px; }
.oa-prod-list { max-height: 62vh; overflow-y: auto; }
.oa-prod { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.oa-prod-thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 8px; background: #f3f4f6; display: flex; align-items: center; justify-content: center; color: #9ca3af; overflow: hidden; }
.oa-prod-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.oa-prod-body { flex: 1; min-width: 0; }
.oa-prod-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.oa-prod-title b { word-break: break-all; }
.oa-prod-title small { color: var(--muted); }
.oa-stock { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 0 6px; margin-left: auto; }
.oa-stock.ok { color: #047857; background: #d1fae5; }
.oa-stock.low { color: #b45309; background: #fef3c7; }
.oa-stock.out, .oa-stock.unknown { color: #b91c1c; background: #fee2e2; }
.oa-prod-name { font-size: 13px; margin-top: 2px; }
.oa-prod-spec { font-size: 12px; color: var(--muted); }
.oa-prod-price { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin-top: 2px; }
.oa-prod-price b { color: var(--muted); font-weight: 600; }
.oa-prod-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.oa-prod-acts button { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; }
.oa-prod-acts button:hover:not(:disabled) { background: #f4fbf7; border-color: #06c755; }
.oa-prod-acts button:disabled { opacity: .5; cursor: default; }

/* 📣 เรียกเซล */
.oa-call { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.oa-call input.oa-pop-search { margin: 0; }
.oa-call-open { font-size: 12px; color: #b45309; background: #fff7ed; border-radius: 8px; padding: 6px 10px; }
.oa-call-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; }
.oa-call-list h4 { margin: 8px 0 4px; font-size: 12px; color: var(--muted); }
.oa-call-opt { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 8px; cursor: pointer; }
.oa-call-opt.on { background: #ecfdf5; }
.oa-call-opt span { display: flex; flex-direction: column; }
.oa-call-opt small { color: var(--muted); font-size: 11px; }
.oa-call-done { font-weight: 700; margin: 12px 0 6px; }
.oa-call .btn { margin-top: 2px; }

/* 📣 แถบ "แอดมินเรียกให้ตอบ" บนรายการแชท */
#callBar { display: flex; flex-direction: column; gap: 6px; padding: 6px 10px; background: #fff7ed; border-bottom: 1px solid #fed7aa; max-height: 40vh; overflow-y: auto; }
#callBar.hidden { display: none; }
.call-item { display: flex; align-items: center; gap: 6px; }
.call-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12px; }
.call-text b { color: #9a3412; }
.call-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #7c2d12; }
.call-item button { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid #fed7aa; background: #fff; cursor: pointer; white-space: nowrap; }
.call-item .btn { width: auto; font-size: 12px; font-weight: 600; background: var(--green); color: #fff; border-color: var(--green); }

/* รีแอคชันบนข้อความ (แบบแอป LINE) */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.msg.me .reactions { justify-content: flex-end; }
.rx-chip { border: 1px solid #d7dce3; background: #fff; border-radius: 12px; padding: 1px 7px; font-size: 13px; line-height: 20px; color: #374151; cursor: pointer; }
.rx-chip.mine { border-color: var(--green-d); background: #e9f9ef; }
.rx-chip:disabled { cursor: default; }
.msg .line { position: relative; }
.rx-picker { position: absolute; bottom: calc(100% + 4px); left: 0; z-index: 6; display: flex; gap: 2px; padding: 4px 6px; background: #fff; border-radius: 22px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.msg.me .rx-picker { left: auto; right: 0; }
.rx-picker button { border: 0; background: transparent; font-size: 22px; width: 36px; height: 36px; border-radius: 50%; padding: 0; cursor: pointer; transition: transform .12s; }
.rx-picker button:hover { transform: scale(1.25); background: #f1f3f6; }
.rx-picker button.mine { background: #e9f9ef; }

/* 🔵 ห้องที่ทำเป็นยังไม่อ่านเอง (unread.js) */
.badge.marked { background: #2563eb; }

/* @แท็กคนในกลุ่ม (mention.js) */
#composer { position: relative; }
.mention-pop { position: absolute; left: 8px; bottom: calc(100% + 4px); z-index: 30; width: min(320px, calc(100% - 16px)); max-height: 260px; overflow-y: auto; background: #fff; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.22); padding: 4px; }
.mention-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; text-align: left; font-size: 14px; cursor: pointer; color: #111827; }
.mention-item.sel, .mention-item:hover { background: #e9f9ef; }
.mention-all { width: 28px; height: 28px; border-radius: 50%; background: var(--green-d); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.bubble .mention { color: #1d4ed8; font-weight: 600; }
.bubble .mention.me { background: #fef3c7; border-radius: 4px; padding: 0 2px; }

/* 🧸 สติกเกอร์ LINE ส่วนตัว + 😀 อีโมจิ (sticker.js) */
.p-only { display: inline-flex; }
body.oa-mode .p-only, body.read-only .p-only { display: none !important; }
.stk-tab { border: 0; background: none; padding: 4px 6px; border-bottom: 2px solid transparent; font-size: 20px; line-height: 1; min-width: 40px; }
.stk-tab img { width: 32px; height: 32px; object-fit: contain; display: block; }
.stk-tab.active { border-bottom-color: var(--green); background: var(--bg2); border-radius: 6px 6px 0 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 8px; overflow-y: auto; }
.emoji-grid button { border: 0; background: none; font-size: 24px; height: 40px; border-radius: 8px; cursor: pointer; padding: 0; }
.emoji-grid button:hover { background: var(--bg2); }

/* 👁 อ่านแล้ว (ข้อความของเรา) */
.meta-col .read-mark { color: #eef2f8; font-weight: 600; }
/* ขั้นสแกนหน้าตอนเข้าระบบ */
#authView .card + .card { margin-top: 0; }
.face-box { position: relative; width: 100%; max-width: 280px; margin: 0 auto 14px; aspect-ratio: 3 / 4; max-height: 46dvh; border-radius: 14px; overflow: hidden; background: #111; }
.face-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.face-oval { position: absolute; inset: 12% 16%; border: 3px solid rgba(255,255,255,.85); border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.face-qr { display: flex; justify-content: center; margin: 4px 0 8px; }
.face-qr img { width: 220px; height: 220px; image-rendering: pixelated; }
#faceStep .btn + .btn { margin-top: 6px; }
