/* Buyer–seller chat, shared by Sellerhub and the shop's My Account. Uses the page's tokens when present. */

.chat, .threads, .dsc-contact, .dsc-inbox {
	--c-ink: var(--ink, #121212);
	--c-paper: var(--paper, #F3F2EE);
	--c-white: var(--white, #FFFFFF);
	--c-line: var(--line, #E2DFD8);
	--c-muted: var(--muted, #5C5A55);
	--c-lime: var(--lime, #D4FF3A);
	--c-mine: #E9FF9A;
	--c-read: #1D9BF0;
}

.chat {
	display: flex; flex-direction: column;
	height: min(72vh, 680px); min-height: 420px;
	background: var(--c-white); border: 1px solid var(--c-line); border-radius: 16px;
	overflow: hidden; color: var(--c-ink);
}
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--c-ink); color: var(--c-white); flex: none; }
.chat-back { display: inline-grid; place-items: center; width: 36px; height: 36px; margin-left: -6px; border-radius: 10px; color: inherit; text-decoration: none; }
.chat-back:hover { background: rgba(255, 255, 255, .1); }
.chat-avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--c-lime); color: #121212; font-weight: 700; font-size: 17px; }
.chat-who { display: grid; min-width: 0; line-height: 1.25; }
.chat-who strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who small { font-size: 12.5px; opacity: .72; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-log {
	flex: 1; overflow-y: auto; overscroll-behavior: contain;
	display: flex; flex-direction: column; gap: 4px;
	padding: 14px 14px 18px;
	background-color: var(--c-paper);
	background-image: radial-gradient(rgba(18, 18, 18, .05) 1px, transparent 1.4px);
	background-size: 18px 18px;
}
.chat-log:focus-visible { outline: 2px solid var(--c-ink); outline-offset: -2px; }
.chat-note { align-self: center; max-width: 440px; margin: 0 0 8px; padding: 8px 12px; border-radius: 10px; background: #FFF6CC; color: #5A4A00; font-size: 12.5px; text-align: center; line-height: 1.45; }
.chat-empty { align-self: center; max-width: 380px; margin: auto 0; color: var(--c-muted); text-align: center; line-height: 1.55; }
.chat-day { align-self: center; margin: 10px 0 6px; }
.chat-day span { display: inline-block; padding: 4px 10px; border-radius: 8px; background: var(--c-white); color: var(--c-muted); font-size: 12px; font-weight: 600; box-shadow: 0 1px 1px rgba(18, 18, 18, .06); }

.msg { position: relative; max-width: min(78%, 520px); padding: 7px 10px 6px; border-radius: 12px; box-shadow: 0 1px 1px rgba(18, 18, 18, .08); animation: msg-in .22s ease-out; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.msg-mine { align-self: flex-end; background: var(--c-mine); border-top-right-radius: 4px; }
.msg-theirs { align-self: flex-start; background: var(--c-white); border-top-left-radius: 4px; }
.msg + .msg-mine.msg, .msg-mine + .msg-mine { margin-top: 0; }
.msg-theirs + .msg-mine, .msg-mine + .msg-theirs { margin-top: 6px; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; color: rgba(18, 18, 18, .55); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.msg-tick { position: relative; display: inline-block; width: 16px; height: 10px; }
.msg-tick::before, .msg-tick::after { content: ""; position: absolute; top: 0; width: 4px; height: 8px; border: solid currentColor; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.msg-tick::before { left: 3px; }
.msg-tick::after { left: 8px; }
.msg-tick.is-read { color: var(--c-read); }
.msg.is-pending { opacity: .7; }
.msg.is-failed { background: #FDE8E7; cursor: pointer; }
.msg.is-failed .msg-meta { color: #8A1B12; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .msg { animation: none; } }

.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--c-white); border-top: 1px solid var(--c-line); flex: none; }
.chat-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chat-form textarea {
	flex: 1; min-height: 44px; max-height: 160px; resize: none;
	padding: 11px 16px !important; border-radius: 22px !important;
	border: 1.5px solid var(--c-line) !important; background: var(--c-paper) !important; color: var(--c-ink) !important;
	font: inherit !important; font-size: 15px !important; line-height: 1.4 !important; box-shadow: none !important;
}
.chat-form textarea:focus { outline: none; border-color: var(--c-ink) !important; background: var(--c-white) !important; }
.chat-send { display: inline-grid; place-items: center; flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--c-ink); color: var(--c-lime); cursor: pointer; transition: transform .15s ease-out; }
.chat-send:hover { transform: scale(1.05); }
.chat-send:focus-visible { outline: 3px solid var(--c-lime); outline-offset: 2px; }
.chat-readonly { margin: 0; padding: 12px 16px; border-top: 1px solid var(--c-line); color: var(--c-muted); font-size: 14px; text-align: center; }

/* Conversation list */
.threads { list-style: none; margin: 0; padding: 0; }
.threads a { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--c-ink); border-bottom: 1px solid var(--c-line); }
.threads li:last-child a { border-bottom: 0; }
.threads a:hover { background: var(--c-paper); }
.threads a[aria-current="page"] { background: var(--c-paper); box-shadow: inset 3px 0 0 var(--c-ink); }
.thread-text { display: grid; gap: 1px; min-width: 0; }
.thread-top { display: flex; justify-content: space-between; gap: 8px; }
.thread-top strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-top time { flex: none; font-size: 12px; color: var(--c-muted); }
.thread-sub { font-size: 12px; color: var(--c-muted); }
.thread-last { font-size: 14px; color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threads a.is-unread .thread-top strong, .threads a.is-unread .thread-last { font-weight: 700; color: var(--c-ink); }
.threads a.is-unread .thread-top time { color: #13532A; font-weight: 600; }
.thread-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--c-lime); color: #121212; font-size: 12px; font-weight: 700; }

/* Sellerhub inbox */
.inbox { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.inbox-list { max-height: min(72vh, 680px); overflow-y: auto; padding: 0; }
.inbox-none { padding: 16px; margin: 0; }
.inbox-pick { display: grid; place-items: center; gap: 10px; min-height: 420px; color: var(--c-muted); text-align: center; }
.inbox-pick .i { width: 32px; height: 32px; }
.inbox .chat-back { display: none; }
.inbox .chat { height: max(440px, calc(100vh - 290px)); }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--c-lime, #D4FF3A); color: #121212; font: 700 12px/22px var(--ui, sans-serif); text-align: center; }
@container (max-width: 760px) {
	.inbox { grid-template-columns: minmax(0, 1fr); }
	.inbox.is-open .inbox-list { display: none; }
	.inbox:not(.is-open) .inbox-chat { display: none; }
	.inbox .chat-back { display: inline-grid; }
	.inbox .chat { height: calc(100dvh - 280px); min-height: 360px; }
	.inbox-list { max-height: none; }
}
@media (max-width: 760px) {
	.main:has(.inbox.is-open) > .ph { display: none; }
}
@media (min-width: 761px) and (max-width: 1100px) {
	.nav-count { position: absolute; top: 4px; right: 6px; min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; }
	.nav a { position: relative; }
}

/* Shop: My Account */
.dsc-inbox { display: grid; gap: 14px; }
.dsc-inbox .threads { background: var(--c-white); border: 1px solid var(--c-line); border-radius: 16px; overflow: hidden; }
.dsc-inbox-empty { margin: 0; color: var(--c-muted); }
.dsc-inbox-foot { margin: 0; }
.dsc-inbox-foot a, .dsc-inbox-empty a { color: var(--c-ink) !important; font-weight: 700; text-underline-offset: 4px; }
.dsc-contact { margin: 24px 0 0; padding: clamp(18px, 2.6vw, 26px); border-radius: 20px; background: var(--c-paper); color: var(--c-ink); }
.dsc-contact h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.dsc-contact p { margin: 0 0 14px; color: var(--c-muted); }
.dsc-contact ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dsc-contact li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--c-white); }
.dsc-contact-store { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dsc-contact-store > span:last-child { display: grid; }
.dsc-contact-store small { color: var(--c-muted); font-size: 12.5px; }
html body .dsc-contact-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 999px; background: #121212; color: #D4FF3A !important; font-weight: 700; text-decoration: none !important; }
html body .dsc-contact-btn:hover { transform: translateY(-1px); }
@media (max-width: 600px) {
	.dsc-contact li { align-items: stretch; }
	.dsc-contact-btn { width: 100%; }
	.dsc-inbox .chat { height: calc(100dvh - 180px); border-radius: 12px; }
	.msg { max-width: 86%; }
}
