/* Melloq — Apple-style, white + light green from the logo (core tokens & components in /ui-core.css) */
html, body { height: 100%; }
body {
  margin: 0;
  background: #e9ece6;
  color: var(--label);
  font: 17px/1.4 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }

/* custom slim floating scrollbars */
.scroll::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.panel-body::-webkit-scrollbar,
.roster-scroll::-webkit-scrollbar,
.picker-list::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
.scroll::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.panel-body::-webkit-scrollbar-track,
.roster-scroll::-webkit-scrollbar-track,
.picker-list::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-button,
.messages::-webkit-scrollbar-button,
.panel-body::-webkit-scrollbar-button,
.roster-scroll::-webkit-scrollbar-button,
.picker-list::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.scroll::-webkit-scrollbar-corner,
.messages::-webkit-scrollbar-corner,
.panel-body::-webkit-scrollbar-corner,
.roster-scroll::-webkit-scrollbar-corner,
.picker-list::-webkit-scrollbar-corner { background: transparent; }
.scroll::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb,
.roster-scroll::-webkit-scrollbar-thumb,
.picker-list::-webkit-scrollbar-thumb {
  background: rgba(23, 52, 4, 0.2);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover,
.panel-body::-webkit-scrollbar-thumb:hover,
.roster-scroll::-webkit-scrollbar-thumb:hover,
.picker-list::-webkit-scrollbar-thumb:hover {
  background: rgba(23, 52, 4, 0.38);
  border: 2px solid transparent;
  background-clip: content-box;
}
@supports not selector(::-webkit-scrollbar) {
  .scroll, .messages, .panel-body, .roster-scroll, .picker-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(23, 52, 4, 0.22) transparent;
  }
}

/* phone-width app column, centered on desktop */
.app {
  position: relative;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 20px 60px rgba(23, 52, 4, 0.08);
}
.view { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.view.grouped { background: var(--grouped); }
.view.push { animation: push 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes push { from { transform: translateX(30%); opacity: 0; } }

.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }

/* ---------- navigation bars ---------- */
.navbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 72px 1fr 72px; align-items: center;
  min-height: 52px;
  padding: max(6px, env(safe-area-inset-top)) 8px 6px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.navbar .title { text-align: center; font-weight: 600; font-size: 17px; min-width: 0; }
.navbar .left { justify-self: start; }
.navbar .right { justify-self: end; }
.nav-btn { display: inline-flex; align-items: center; gap: 2px; padding: 8px; color: var(--green-text); font-size: 17px; border-radius: 10px; }
.nav-btn:active { opacity: 0.5; }

.large-header {
  padding: max(14px, env(safe-area-inset-top)) 20px 8px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.large-title { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.brand { height: 30px; width: auto; display: block; }

.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- tab bar ---------- */
.tabbar {
  display: flex; justify-content: space-around;
  padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; padding: 4px 0; color: var(--secondary); font-size: 11px; font-weight: 500; }
.tab.active { color: var(--green-ink); }
.tab.active .icon { stroke-width: 2.2; }
.tab .badge { position: absolute; top: 0; left: 50%; margin-left: 6px; }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 12px; font-weight: 600;
}

/* ---------- lists ---------- */
.list { margin: 0; padding: 0; list-style: none; }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 20px;
  text-align: left;
  background: var(--bg);
}
.row:active { background: var(--fill); }
.row .body { flex: 1; min-width: 0; padding: 4px 0; }
.list > li + li .row .body { border-top: 0.5px solid var(--separator); margin-top: -10px; padding-top: 14px; }
.row .name { display: flex; align-items: baseline; gap: 6px; font-weight: 600; }
.row .name .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .time { font-weight: 400; font-size: 14px; color: var(--secondary); white-space: nowrap; }
.row .sub { display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 15px; }
.row .sub .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .sub .grow { color: var(--label); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: inset 0 0 0 1px rgba(23, 52, 4, 0.15); flex: none; }
.chev { color: var(--tertiary); }

.pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--fill); color: var(--secondary); font-size: 12px; font-weight: 500; }
.pill.green { background: var(--green-soft); color: var(--green-text); }

.requests-row { width: auto; margin: 4px 16px 8px; border-radius: 14px; background: var(--green-soft); padding: 12px 14px; }
.requests-row:active { background: #e2f6d3; }
.requests-row .req-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); flex: none; }

/* ---------- avatar ---------- */
.avatar {
  flex: none;
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-grid; place-items: center; vertical-align: middle;
  background: var(--green-soft); color: var(--green-ink);
  font-weight: 600; font-size: 19px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }

/* ---------- empty states ---------- */
.empty { padding: 56px 32px; text-align: center; color: var(--secondary); }
.empty > .icon { width: 44px; height: 44px; stroke-width: 1.4; color: var(--tertiary); margin-bottom: 8px; }
.empty h3 { margin: 0 0 4px; color: var(--label); font-size: 20px; font-weight: 600; }
.empty p { margin: 0 0 16px; font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 0 20px;
  border-radius: 14px;
  background: var(--green); color: var(--green-ink);
  font-weight: 600;
  transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.98); filter: brightness(0.96); }
.btn.block { width: 100%; }
.btn.plain { background: var(--fill); color: var(--label); }
.btn.danger { background: var(--fill); color: var(--red); }
.btn.sm { min-height: 34px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
.btn:disabled { opacity: 0.5; }

/* ---------- search field ---------- */
.searchbar { padding: 4px 16px 10px; }
.search-field {
  display: flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 10px;
  border-radius: 12px;
  background: var(--fill);
  color: var(--secondary);
}
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--label); font-size: 17px; }

/* ---------- grouped inset forms (iOS Settings style) ---------- */
.section { margin: 0 16px 24px; }
.section-title { margin: 0 4px 6px 16px; font-size: 13px; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.02em; }
.section-foot { margin: 6px 16px 0; font-size: 13px; color: var(--secondary); }
.group { background: var(--bg); border-radius: 12px; overflow: hidden; }
.field { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 16px; }
.field + .field { border-top: 0.5px solid var(--separator); }
.field label, .field .label { width: 104px; flex: none; font-size: 16px; }
.field input, .field select, .field textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; color: var(--label); padding: 12px 0; }
.field select { appearance: none; text-align: right; color: var(--secondary); cursor: pointer; }
.field .prefix { color: var(--secondary); margin-right: -10px; }
.field textarea { resize: none; }

.segmented { display: flex; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, 0.12); }
.segmented button { flex: 1; padding: 6px 4px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmented button.on { background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04); }

.error { margin: 0 20px 12px; color: var(--red); font-size: 14px; text-align: center; }

/* ---------- auth ---------- */
.auth { justify-content: center; }
.auth-hero { text-align: center; padding: 32px 24px 24px; }
.auth-hero img { width: 120px; height: auto; }
.auth-hero h1 { margin: 12px 0 4px; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.auth-hero p { margin: 0; color: var(--secondary); font-size: 15px; }
.auth .segmented { margin: 0 16px 20px; }
.auth-forgot { display: flex; justify-content: flex-end; margin-top: 8px; padding: 0 4px; }
.link-btn { color: var(--green-text); font-size: 14px; font-weight: 600; padding: 4px 6px; border-radius: 8px; }
.link-btn:hover { background: var(--green-soft); }

/* ---------- profile ---------- */
.profile-head { text-align: center; padding: 8px 20px 24px; }
.avatar-edit { position: relative; display: inline-block; }
.avatar-edit .cam {
  position: absolute; right: 2px; bottom: 2px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green); color: var(--green-ink);
  border: 3px solid var(--grouped);
}
.profile-head h2 { margin: 16px 0 0; font-size: 24px; font-weight: 700; line-height: 1.4; }
.profile-head .handle { color: var(--secondary); }
.profile-head .bio { margin: 8px 0 0; font-size: 15px; }
.profile-head .meta { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }

/* ---------- chat ---------- */
.chat-title { display: flex; flex-direction: column; align-items: center; gap: 3px; line-height: 1.35; padding: 2px 0; }
.chat-title .t { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.45; padding-top: 2px; }
.chat-title .s { font-size: 12px; color: var(--secondary); font-weight: 400; }
.messages { flex: 1; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 3px; }
.notice { align-self: center; margin: 8px 16px 12px; padding: 8px 14px; border-radius: 14px; background: var(--fill); color: var(--secondary); font-size: 13px; text-align: center; }

/* กล่องแชท + แท็บรูปโปรไฟล์ติดมุมบน (ซ้ายสำหรับเพื่อน, ขวาสำหรับเรา) */
.msg { --tab: 40px; --tab-r: 14px; --bubble-bg: var(--fill); display: flex; flex-direction: column; max-width: 82%; }
.msg.mine { --bubble-bg: var(--green); align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg + .msg.gap { margin-top: 10px; }
.line { display: flex; align-items: flex-start; }
.mine .line { flex-direction: row-reverse; }
.line:not(.has-tab) { padding-left: var(--tab); }
.mine .line:not(.has-tab) { padding-left: 0; padding-right: var(--tab); }

.tab-avatar {
  position: relative;
  flex: none;
  width: var(--tab); height: var(--tab);
  display: grid; place-items: center;
  background: var(--bubble-bg);
  border-radius: var(--tab-r) 0 0 var(--tab-r);
}
.mine .tab-avatar { border-radius: 0 var(--tab-r) var(--tab-r) 0; }
.tab-avatar .avatar { width: 30px; height: 30px; font-size: 12px; box-shadow: 0 0 0 2px var(--bg); }

.bubble { min-width: 0; padding: 8px 14px; border-radius: 20px; background: var(--bubble-bg); white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; font-size: 17px; line-height: 22px; }
/* บรรทัดเดียว: กล่องสูงเท่าแท็บพอดี (มุมล่างฝั่งแท็บเป็นมุมฉาก ต่อกันเป็นชิ้นเดียว)
   หลายบรรทัด: มุมล่างค่อย ๆ โค้งกลับเป็น 20px ตามความสูงที่เกินแท็บ */
.has-tab .bubble {
  min-height: var(--tab);
  padding-top: 9px; padding-bottom: 9px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 20px clamp(0px, calc(100% - var(--tab)), 20px);
}
.mine .has-tab .bubble {
  border-top-left-radius: 20px; border-bottom-left-radius: 20px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 20px clamp(0px, calc(100% - var(--tab)), 20px);
}
.mine .bubble { color: var(--green-ink); }
.theirs .meta, .theirs .details { margin-left: calc(var(--tab) + 8px); }
.mine .meta, .mine .details { margin-right: calc(var(--tab) + 8px); }
.bubble.pending { color: var(--secondary); }
.bubble.pending .shimmer { display: block; margin-top: 2px; font-size: 13px; }
.meta { display: flex; align-items: center; gap: 4px; margin: 2px 8px 0; font-size: 11px; color: var(--secondary); }
.meta .ai { color: var(--green-text); font-weight: 500; }
.details { margin: 4px 0 2px; padding: 8px 12px; border-radius: 14px; border: 0.5px solid var(--separator); font-size: 14px; background: var(--bg); }
.details dt { font-size: 11px; color: var(--secondary); margin-top: 6px; }
.details dt:first-child { margin-top: 0; }
.details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.shimmer {
  background: linear-gradient(90deg, var(--secondary) 0%, var(--green-text) 50%, var(--secondary) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  padding: 7px 14px; min-height: 36px;
  border-radius: 18px; border: 0.5px solid var(--tertiary);
  background: var(--bg); outline: 0;
  font-size: 17px; line-height: 1.3;
  scrollbar-width: none;
}
.composer textarea::-webkit-scrollbar { display: none; }
.send { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); flex: none; }
.send:disabled { background: var(--fill); color: var(--tertiary); }

.request-bar {
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--separator);
  background: var(--bg);
  text-align: center;
}
.request-bar p { margin: 0 0 12px; font-size: 14px; color: var(--secondary); }
.request-bar .actions { display: flex; gap: 10px; }
.request-bar .actions .btn { flex: 1; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  max-width: 90vw;
  padding: 10px 18px; border-radius: 14px;
  background: rgba(28, 28, 30, 0.88); color: #fff;
  font-size: 15px;
  backdrop-filter: blur(20px);
  z-index: 20;
}

@media (prefers-reduced-motion: reduce) { .view.push, .shimmer { animation: none; } }

/* ---------- flags ---------- */
.fi { border-radius: 3px; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12); }
/* ธงต่อท้ายชื่อ — จัดกึ่งกลางแนวตั้งกับตัวอักษร */
.name-flag { flex: none; display: block; width: 1.25em; height: 0.94em; border-radius: 3px; }
.row .name .grow, .chat-title .t, .profile-head h2 { display: flex; align-items: center; gap: 6px; }
.chat-title .t { gap: 5px; justify-content: center; }
.profile-head h2 { justify-content: center; gap: 8px; }
.row .name .nm, .chat-title .t .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title .t .nm { line-height: 1.45; padding-top: 1px; }
.row .name .name-flag { font-size: 15px; }
.chat-title .t .name-flag { font-size: 14px; }
.profile-head h2 .name-flag { font-size: 20px; }
.pill .fi { margin-right: 2px; }

/* ---------- custom picker ---------- */
.field.picker { cursor: pointer; }
.field.picker:active { background: var(--fill); }
.field.picker .value .fi { margin-inline-end: 4px; }
.picker-sheet { display: flex; flex-direction: column; max-height: 78vh; padding-top: 8px; }
.picker-sheet.tall { height: 78vh; }
.picker-head { display: grid; grid-template-columns: 1fr auto 1fr; grid-auto-flow: dense; align-items: center; min-height: 44px; margin-bottom: 6px; }
.picker-head b { grid-column: 2; font-size: 17px; }
.picker-head .nav-btn { grid-column: 3; justify-self: end; font-weight: 600; }
.picker-sheet .search-field { margin-bottom: 8px; flex: none; }
.picker-list { list-style: none; margin: 0 -16px; padding: 0; overflow-y: auto; overscroll-behavior: contain; }
.picker-list li { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 20px; cursor: pointer; }
.picker-list li + li { box-shadow: inset 0 0.5px 0 var(--separator); }
.picker-list li:hover, .picker-list li:active { background: var(--fill); }
.picker-list li.on { color: var(--green-text); font-weight: 600; }
.picker-list .opt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.picker-list .opt small { color: var(--secondary); font-weight: 400; font-size: 13px; }
.picker-list .opt-flag { width: 28px; height: 21px; flex: none; }
.picker-list .check { color: var(--green-text); stroke-width: 2.4; }
.picker-list li.none { justify-content: center; color: var(--secondary); cursor: default; }

/* ---------- small additions ---------- */
.auth-top { display: flex; justify-content: flex-end; padding: max(10px, env(safe-area-inset-top)) 16px 0; }
.ui-lang { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg); color: var(--label); font-size: 14px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.ui-lang .icon { color: var(--green-text); }
.notice.block { display: block; margin: 12px 16px; }
.field .value { flex: 1; text-align: end; color: var(--secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-row { width: 100%; color: var(--red); }
.nav-btn.strong { font-weight: 600; }
.profile-head .meta { flex-wrap: wrap; }

/* ---------- attachments ---------- */
.attach { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--green-text); flex: none; }
.attach:active { opacity: 0.6; }
.bubble.has-media { padding: 4px; }
.media { display: flex; flex-direction: column; gap: 4px; }
.media-img, .media-video { display: block; max-width: min(260px, 64vw); max-height: 320px; width: 100%; border-radius: 16px; object-fit: cover; background: rgba(0, 0, 0, 0.06); }
.media-img { cursor: zoom-in; }
.media-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 200px; border-radius: 14px; background: rgba(255, 255, 255, 0.6); color: inherit; }
.media-file .fname { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.media-file b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-file small { color: var(--secondary); font-size: 12px; }
.expiry { display: inline-flex; align-items: center; gap: 3px; padding: 0 8px 2px; font-size: 12px; color: var(--secondary); }
.mine .expiry { color: rgba(23, 52, 4, 0.7); }
.media.gone { flex-direction: row; align-items: center; gap: 6px; padding: 6px 10px; font-size: 14px; color: var(--secondary); font-style: italic; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.35); animation: fade 0.2s; }
.sheet {
  width: 100%; max-width: 480px;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  animation: rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-preview { display: grid; place-items: center; margin-bottom: 14px; }
.sheet-preview img, .sheet-preview video { max-width: 100%; max-height: 42vh; border-radius: 16px; }
.sheet-preview .media-file { background: var(--fill); width: 100%; }
.sheet-label { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-weight: 600; font-size: 15px; }
.sheet-note { margin: 10px 2px 0; font-size: 13px; color: var(--secondary); }
.sheet-progress { margin: 10px 2px 0; font-size: 14px; color: var(--green-text); font-weight: 500; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.lightbox { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, 0.92); cursor: zoom-out; animation: fade 0.15s; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40%); } }

/* ---------- QR page ---------- */
.searchbar { display: flex; align-items: center; gap: 8px; }
.searchbar .search-field { flex: 1; }
.qr-btn { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--green-soft); color: var(--green-ink); }
.qr-btn:active { opacity: 0.6; }
.qr-tabs { margin: 12px 16px 4px; }
.qr-card { margin: 12px 16px 20px; padding: 20px 20px 16px; border-radius: 22px; background: var(--bg); text-align: center; box-shadow: 0 8px 30px rgba(23, 52, 4, 0.06); }
.qr-card.dead .qr-code { opacity: 0.2; filter: grayscale(1); }
.qr-who { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; font-weight: 600; }
.qr-who .t { display: flex; align-items: center; gap: 6px; }
.qr-code { position: relative; width: min(240px, 64vw); margin: 0 auto; aspect-ratio: 1; }
.qr-code svg { width: 100%; height: 100%; display: block; }
.qr-code svg path, .qr-code svg rect[fill="black"], .qr-code svg rect:not([fill="white"]) { fill: var(--green-ink); }
.qr-logo { position: absolute; left: 50%; top: 50%; width: 22%; transform: translate(-50%, -50%); border-radius: 22%; box-shadow: 0 0 0 5px #fff; }
.qr-status { margin: 14px 0 2px; font-weight: 600; font-size: 15px; color: var(--green-text); }
.qr-card.dead .qr-status { color: var(--red); }
.qr-hint { margin: 0; font-size: 13px; color: var(--secondary); }
.qr-hint.center { text-align: center; margin: 10px 24px 16px; }
.link-row .link-text { text-align: start; color: var(--label); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.actions-row { padding: 0; }
.actions-row .act { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; color: var(--green-text); font-weight: 500; }
.actions-row .act + .act { border-inline-start: 0.5px solid var(--separator); }
.toggle-row { cursor: pointer; }
.toggle-row .label { width: auto; flex: 1; display: flex; flex-direction: column; padding: 8px 0; }
.toggle-row small { font-size: 12px; color: var(--secondary); }
.green-row { width: 100%; justify-content: center; color: var(--green-text); font-weight: 600; }

/* iOS switch */
.field input.switch, .switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 51px; height: 31px; margin: 0; padding: 0; border-radius: 999px; background: rgba(120, 120, 128, 0.16); cursor: pointer; transition: background 0.2s; }
.field input.switch::after, .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s; }
.field input.switch:checked, .switch:checked { background: #5cc93a; }
.field input.switch:checked::after, .switch:checked::after { transform: translateX(20px); }
.field input.switch:focus-visible, .switch:focus-visible { outline: 2px solid var(--green-text); outline-offset: 2px; }

/* scanner */
.scanner { position: relative; margin: 12px 16px 0; aspect-ratio: 1; border-radius: 22px; overflow: hidden; background: #111; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border-radius: 22px; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); border: 3px solid var(--green); }
.scanner.off { display: grid; place-items: center; padding: 24px; text-align: center; color: #ddd; font-size: 15px; }

/* join */
.join { padding-top: max(24px, env(safe-area-inset-top)); }
.join-logo { display: block; height: 34px; margin: 0 auto 12px; }
.join-title { margin: 14px 0 0; font-size: 18px; font-weight: 600; }
.section-foot.center { text-align: center; margin-top: 10px; }
.btn.mt { margin-top: 18px; }
.link-btn { display: block; margin: 18px auto 0; color: var(--green-text); font-weight: 500; }
.chat-title:not([href]) { cursor: default; }
.grouped .btn.plain { background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.name-flag { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14); }

/* ---------- stickers & GIF ---------- */
.attach.emoji.on { background: var(--green); color: var(--green-ink); }
.sticker { position: relative; display: inline-block; width: 100%; aspect-ratio: 1; line-height: 0; }
.sticker img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* คำบนสติ๊กเกอร์ — ระบบใส่เองเป็นภาษาของคนดู */
.sticker .cap {
  position: absolute; left: 4%; right: 4%; top: 3%;
  text-align: center; line-height: 1.1;
  font-weight: 800; font-size: 1.05em; letter-spacing: -0.01em;
  color: var(--green-ink);
  -webkit-text-stroke: 0.22em #fff; paint-order: stroke fill;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
  overflow-wrap: anywhere; pointer-events: none;
}
.sticker .cap.bottom { top: auto; bottom: 3%; }
.sticker.big { width: min(170px, 46vw); font-size: 22px; }
.sticker.mini { width: 64px; font-size: 10px; }
.sticker.missing { width: 120px; display: grid; place-items: center; font-size: 48px; line-height: 1; }
.msg .line .sticker.big { margin: 2px 0; }

.gifmsg { position: relative; width: min(240px, 62vw); border-radius: 18px; overflow: hidden; background: var(--fill); line-height: 0; }
.gifmsg video { width: 100%; display: block; object-fit: cover; }
.klipy-mark { position: absolute; right: 8px; bottom: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 10px; font-weight: 700; line-height: 1.5; letter-spacing: 0.04em; }

.panel { height: min(320px, 42vh); display: flex; flex-direction: column; background: var(--grouped); border-top: 0.5px solid var(--separator); padding-bottom: env(safe-area-inset-bottom); }
.panel-body { flex: 1; overflow-y: auto; padding: 10px 12px 12px; }
.panel-body .search-field { margin-bottom: 8px; background: var(--bg); position: sticky; top: 0; z-index: 1; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sticker-grid button { border-radius: 14px; padding: 4px; font-size: 13px; }
.sticker-grid button:hover, .sticker-grid button:active { background: var(--bg); }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.gif-grid button { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--fill); }
.gif-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-empty { grid-column: 1 / -1; text-align: center; color: var(--secondary); font-size: 14px; }
.klipy-powered { margin: 10px 0 0; text-align: center; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--secondary); }
.empty.small { padding: 28px 16px; }
.empty.small .icon { width: 36px; height: 36px; color: var(--tertiary); }

/* แถบแนะนำสติ๊กเกอร์/GIF ระหว่างพิมพ์ */
.suggest { display: flex; gap: 14px; overflow-x: auto; padding: 8px 12px; background: rgba(255, 255, 255, 0.94); border-top: 0.5px solid var(--separator); scrollbar-width: none; }
.suggest::-webkit-scrollbar { display: none; }
.sg-group { display: flex; align-items: center; gap: 6px; flex: none; }
.sg-group.klipy { padding-inline-start: 12px; border-inline-start: 0.5px solid var(--separator); }
.sg-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10px; font-weight: 700; color: var(--secondary); letter-spacing: 0.06em; }
.sg-item { flex: none; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--fill); }
.sg-item.st { background: transparent; }
.sg-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sg-item.st img { object-fit: contain; }
.sg-item:active { transform: scale(0.94); }

/* ---------- per-chat artistic themes (scoped only to .chat-view) ---------- */
.chat-view {
  --chat-accent: var(--green);
  --chat-accent-soft: var(--green-soft);
  --chat-ink: var(--green-ink);
  --chat-text: var(--green-text);
  --chat-canvas: #fafcf7;
  --chat-chrome: rgba(255, 255, 255, 0.88);
  --chat-theirs-bg: #eef2ea;
  --chat-theirs-fg: var(--label);
  --chat-border: var(--separator);
  --chat-fg: var(--label);
  --chat-muted: var(--secondary);
  --chat-input-bg: #ffffff;
  --chat-pattern-size: 190px 190px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='190' height='190' viewBox='0 0 190 190' fill='none'%3E%3Cpath d='M-10 45 C30 15 65 75 105 45 C145 15 170 75 205 45' stroke='%232e7a12' stroke-opacity='0.09' stroke-width='1.5'/%3E%3Cpath d='M-10 135 C30 105 65 165 105 135 C145 105 170 165 205 135' stroke='%232e7a12' stroke-opacity='0.07' stroke-width='1.5'/%3E%3Cpath d='M50 85 C58 65 82 65 88 85 C82 105 58 105 50 85Z' stroke='%232e7a12' stroke-opacity='0.08' stroke-width='1.4'/%3E%3Ccircle cx='146' cy='88' r='14' stroke='%232e7a12' stroke-opacity='0.08' stroke-width='1.4'/%3E%3C/svg%3E");
  background: var(--chat-canvas);
  color: var(--chat-fg);
}
.chat-view[data-chat-theme="sakura"] {
  --chat-accent: #ffbad4;
  --chat-accent-soft: #ffeaf2;
  --chat-ink: #4a0723;
  --chat-text: #ab1e59;
  --chat-canvas: #fff9fb;
  --chat-chrome: rgba(255, 249, 251, 0.88);
  --chat-theirs-bg: #f8e8ef;
  --chat-pattern-size: 180px 180px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180' fill='none'%3E%3Cpath d='M42 36 C48 22 62 24 62 36 C54 44 44 42 42 36Z' fill='%23e8649a' fill-opacity='0.11'/%3E%3Cpath d='M132 108 C144 98 156 106 150 118 C140 122 130 116 132 108Z' fill='%23e8649a' fill-opacity='0.11'/%3E%3Cpath d='M86 146 C92 132 106 134 106 146 C98 154 88 152 86 146Z' fill='%23e8649a' fill-opacity='0.09'/%3E%3Cpath d='M0 95 Q55 60 95 95 T180 95' stroke='%23ab1e59' stroke-opacity='0.08' stroke-width='1.3'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="cobalt"] {
  --chat-accent: #a6cbff;
  --chat-accent-soft: #e8f1ff;
  --chat-ink: #082056;
  --chat-text: #164ab5;
  --chat-canvas: #f7faff;
  --chat-chrome: rgba(247, 250, 255, 0.88);
  --chat-theirs-bg: #e9effa;
  --chat-pattern-size: 160px 160px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none'%3E%3Ccircle cx='40' cy='40' r='24' stroke='%23164ab5' stroke-opacity='0.09' stroke-width='1.5'/%3E%3Cpath d='M120 20 A24 24 0 0 1 144 44 L120 44 Z' fill='%23164ab5' fill-opacity='0.08'/%3E%3Cpath d='M24 128 A22 22 0 0 1 68 128' stroke='%23164ab5' stroke-opacity='0.1' stroke-width='1.6'/%3E%3Crect x='106' y='104' width='28' height='28' rx='6' stroke='%23164ab5' stroke-opacity='0.08' stroke-width='1.5' transform='rotate(15 120 118)'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="terracotta"] {
  --chat-accent: #ffc196;
  --chat-accent-soft: #fff0e5;
  --chat-ink: #4a1903;
  --chat-text: #b34612;
  --chat-canvas: #fffaf5;
  --chat-chrome: rgba(255, 250, 245, 0.88);
  --chat-theirs-bg: #f6ebe2;
  --chat-pattern-size: 180px 180px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180' fill='none'%3E%3Cpath d='M24 38 L44 26 L50 48 Z' fill='%23c4511a' fill-opacity='0.1'/%3E%3Cpath d='M118 28 Q138 18 148 38 Q132 50 118 28Z' fill='%23e58c4e' fill-opacity='0.13'/%3E%3Cpath d='M72 96 L96 86 L88 112 Z' fill='%238c340a' fill-opacity='0.08'/%3E%3Cpath d='M132 132 Q154 124 156 146 Q134 154 132 132Z' fill='%23c4511a' fill-opacity='0.11'/%3E%3Cpath d='M12 88 C28 76 42 98 58 86' stroke='%23b34612' stroke-opacity='0.11' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="lavender"] {
  --chat-accent: #d3c2ff;
  --chat-accent-soft: #f2edff;
  --chat-ink: #240f54;
  --chat-text: #5932b0;
  --chat-canvas: #faf8ff;
  --chat-chrome: rgba(250, 248, 255, 0.88);
  --chat-theirs-bg: #eee9fa;
  --chat-pattern-size: 200px 200px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200' fill='none'%3E%3Cpath d='M40 44 L86 68 L138 36 L160 92' stroke='%235932b0' stroke-opacity='0.09' stroke-width='1.1' stroke-dasharray='3 4'/%3E%3Cpath d='M40 44 L43 52 L51 55 L43 58 L40 66 L37 58 L29 55 L37 52 Z' fill='%235932b0' fill-opacity='0.12'/%3E%3Cpath d='M84 146 A24 24 0 1 0 112 168 A19 19 0 1 1 84 146Z' fill='%235932b0' fill-opacity='0.09'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="matcha"] {
  --chat-accent: #9ae0cb;
  --chat-accent-soft: #e6f8f2;
  --chat-ink: #062e23;
  --chat-text: #0f6e56;
  --chat-canvas: #f6fcfa;
  --chat-chrome: rgba(246, 252, 250, 0.88);
  --chat-theirs-bg: #e7f3ef;
  --chat-pattern-size: 120px 60px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60' fill='none'%3E%3Ccircle cx='60' cy='60' r='54' stroke='%230f6e56' stroke-opacity='0.08' stroke-width='1.3'/%3E%3Ccircle cx='60' cy='60' r='38' stroke='%230f6e56' stroke-opacity='0.08' stroke-width='1.3'/%3E%3Ccircle cx='60' cy='60' r='22' stroke='%230f6e56' stroke-opacity='0.08' stroke-width='1.3'/%3E%3Ccircle cx='0' cy='30' r='54' stroke='%230f6e56' stroke-opacity='0.07' stroke-width='1.3'/%3E%3Ccircle cx='0' cy='30' r='38' stroke='%230f6e56' stroke-opacity='0.07' stroke-width='1.3'/%3E%3Ccircle cx='120' cy='30' r='54' stroke='%230f6e56' stroke-opacity='0.07' stroke-width='1.3'/%3E%3Ccircle cx='120' cy='30' r='38' stroke='%230f6e56' stroke-opacity='0.07' stroke-width='1.3'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="amber"] {
  --chat-accent: #ffe078;
  --chat-accent-soft: #fff7db;
  --chat-ink: #3d2500;
  --chat-text: #946000;
  --chat-canvas: #fffdf5;
  --chat-chrome: rgba(255, 253, 245, 0.88);
  --chat-theirs-bg: #f6f0dc;
  --chat-pattern-size: 160px 160px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none'%3E%3Cpolygon points='80,14 146,52 146,128 80,152 14,128 14,52' stroke='%23946000' stroke-opacity='0.09' stroke-width='1.3'/%3E%3Cpath d='M80 14 V80 L146 128 M80 80 L14 128' stroke='%23946000' stroke-opacity='0.07' stroke-width='1.2'/%3E%3C/svg%3E");
}
.chat-view[data-chat-theme="obsidian"] {
  color-scheme: dark;
  --chat-accent: #eab949;
  --chat-accent-soft: rgba(234, 185, 73, 0.16);
  --chat-ink: #1a1404;
  --chat-text: #f3c862;
  --chat-canvas: #14161a;
  --chat-chrome: rgba(22, 24, 29, 0.9);
  --chat-theirs-bg: #242830;
  --chat-theirs-fg: #f3f4f6;
  --chat-border: rgba(255, 255, 255, 0.12);
  --chat-fg: #f3f4f6;
  --chat-muted: #989ca6;
  --chat-input-bg: #1e2128;
  --chat-pattern-size: 220px 220px;
  --chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220' fill='none'%3E%3Cpath d='M0 40 L48 64 L76 124 L138 142 L176 196 L220 205' stroke='%23eab949' stroke-opacity='0.22' stroke-width='1.4'/%3E%3Cpath d='M48 64 L98 22 L152 54 L220 28' stroke='%23eab949' stroke-opacity='0.15' stroke-width='1.1'/%3E%3Cpath d='M76 124 L32 178 L0 190' stroke='%23eab949' stroke-opacity='0.15' stroke-width='1.1'/%3E%3C/svg%3E");
}

.chat-view .navbar { background: var(--chat-chrome); border-bottom-color: var(--chat-border); color: var(--chat-fg); }
.chat-view .chat-title .s, .chat-view .meta, .chat-view .notice { color: var(--chat-muted); }
.chat-view .notice { background: var(--chat-theirs-bg); }
.chat-view .nav-btn { color: var(--chat-text); }
.chat-view .messages { background-color: var(--chat-canvas); background-image: var(--chat-pattern); background-size: var(--chat-pattern-size); }
.chat-view .msg.mine { --bubble-bg: var(--chat-accent); }
.chat-view .msg.theirs { --bubble-bg: var(--chat-theirs-bg); }
.chat-view .msg.mine .bubble { color: var(--chat-ink); }
.chat-view .msg.theirs .bubble { color: var(--chat-theirs-fg); }
.chat-view .tab-avatar .avatar { box-shadow: 0 0 0 2px var(--chat-canvas); }
.chat-view .meta .ai { color: var(--chat-text); }
.chat-view .details { background: var(--chat-input-bg); border-color: var(--chat-border); color: var(--chat-fg); }
.chat-view .details dt { color: var(--chat-muted); }
.chat-view .composer { background: var(--chat-chrome); border-top-color: var(--chat-border); }
.chat-view .composer textarea { background: var(--chat-input-bg); border-color: var(--chat-border); color: var(--chat-fg); }
.chat-view .composer textarea::placeholder { color: var(--chat-muted); }
.chat-view .attach { background: var(--chat-accent-soft); color: var(--chat-text); }
.chat-view .attach.emoji.on { background: var(--chat-accent); color: var(--chat-ink); }
.chat-view .send { background: var(--chat-accent); color: var(--chat-ink); }
.chat-view .send:disabled { background: var(--chat-theirs-bg); color: var(--chat-muted); }
.chat-view .panel { background: var(--chat-chrome); border-top-color: var(--chat-border); }
.chat-view .suggest { background: var(--chat-chrome); border-top-color: var(--chat-border); }
.chat-view .sg-label { color: var(--chat-muted); }
.chat-view .request-bar { background: var(--chat-chrome); border-top-color: var(--chat-border); color: var(--chat-fg); }
.chat-view .request-bar p { color: var(--chat-muted); }
.chat-view .request-bar .btn:not(.danger) { background: var(--chat-accent); color: var(--chat-ink); }
.chat-view .sticker-grid button:hover, .chat-view .sticker-grid button:active { background: var(--chat-accent-soft); }
.chat-view .bubble.pending { color: var(--chat-muted); }
.chat-view .messages::-webkit-scrollbar-thumb,
.chat-view .panel-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--chat-text) 28%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
}
.chat-view .messages::-webkit-scrollbar-thumb:hover,
.chat-view .panel-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--chat-text) 52%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* theme picker sheet */
.theme-sub { margin: 0 0 12px; text-align: center; font-size: 13px; color: var(--secondary); }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding-bottom: 6px; }
.theme-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 16px; background: var(--fill); border: 2px solid transparent;
  text-align: left; transition: transform 0.12s, border-color 0.15s;
}
.theme-card:active { transform: scale(0.97); }
.theme-card.on { border-color: var(--green-text); background: var(--green-soft); }
.theme-swatch {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  background-size: 90px 90px;
}
.theme-card .tmeta { min-width: 0; flex: 1; }
.theme-card .tname { display: block; font-size: 14px; font-weight: 600; color: var(--label); }
.theme-card .tdesc { display: block; font-size: 12px; color: var(--secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- desktop & tablet studio responsive shell ---------- */
.shell { position: relative; height: 100%; }
.rail, .roster, .stage-welcome, .auth-art { display: none; }
.stage { position: relative; height: 100%; overflow: hidden; }
.chats-mobile-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }

@keyframes floatArtA {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-10px) rotate(-2deg); }
}
@keyframes floatArtB {
  0%, 100% { transform: translateY(0) rotate(7deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

@media (min-width: 768px) {
  body { background: radial-gradient(circle at 12% 14%, #eef7e6 0%, #dde6d5 52%, #d2ddd0 100%); }
  .app { max-width: none; width: 100%; background: transparent; box-shadow: none; display: flex; align-items: center; justify-content: center; }
  .shell {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 264px;
    width: 100%;
    height: 100%;
    background: var(--bg);
  }
  .shell.solo { display: block; width: 100%; max-width: 480px; height: 100%; margin: 0 auto; box-shadow: 0 20px 60px rgba(23, 52, 4, 0.12); }

  /* Artistic split-screen Auth showcase on Tablet & Desktop */
  .shell.solo:has(.auth) {
    max-width: 1080px;
    width: calc(100% - 36px);
    height: min(740px, calc(100vh - 36px));
    border-radius: 30px;
    overflow: hidden;
    background: var(--grouped);
    box-shadow: 0 32px 90px rgba(15, 28, 8, 0.22), 0 0 0 1px rgba(23, 52, 4, 0.1);
  }
  .view.auth {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
  }
  .auth-art {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 32px;
    overflow: hidden;
    color: #f3f7ef;
    background-color: #10180d;
    background-image:
      radial-gradient(circle at 16% 18%, rgba(159, 232, 112, 0.25) 0%, transparent 46%),
      radial-gradient(circle at 86% 74%, rgba(234, 185, 73, 0.18) 0%, transparent 48%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260' fill='none'%3E%3Cpath d='M-20 60 C40 10 95 110 155 60 C215 10 240 90 280 55' stroke='%239fe870' stroke-opacity='0.14' stroke-width='1.5'/%3E%3Cpath d='M-20 185 C50 135 110 235 175 180 C225 140 250 210 280 185' stroke='%23eab949' stroke-opacity='0.14' stroke-width='1.3'/%3E%3Ccircle cx='195' cy='72' r='34' stroke='%239fe870' stroke-opacity='0.12' stroke-width='1.2'/%3E%3Ccircle cx='64' cy='196' r='22' stroke='%23eab949' stroke-opacity='0.12' stroke-width='1.2'/%3E%3C/svg%3E");
  }
  .art-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 2; }
  .art-badge { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: #ffffff; }
  .art-badge img { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 14px rgba(159, 232, 112, 0.35); }
  .art-pill {
    padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
    background: rgba(255, 255, 255, 0.08); color: #cfe2c4; border: 1px solid rgba(255, 255, 255, 0.12);
  }
  .art-canvas {
    position: relative;
    display: flex; flex-direction: column; justify-content: center; gap: 14px;
    margin: auto 0; padding: 16px 0; z-index: 2;
  }
  .art-card {
    position: relative;
    max-width: 340px;
    padding: 13px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.26);
  }
  .art-card.card-a { align-self: flex-start; transform: rotate(-1.5deg); margin-right: 56px; }
  .art-card.card-b { align-self: flex-end; transform: rotate(1.5deg); margin-right: 54px; background: rgba(159, 232, 112, 0.12); border-color: rgba(159, 232, 112, 0.28); }
  .ac-head { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 4px; color: #ffffff; }
  .ac-lang { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); color: var(--green); }
  .ac-orig { font-size: 13px; color: rgba(243, 247, 239, 0.68); margin-bottom: 5px; }
  .ac-tr { display: flex; align-items: flex-start; gap: 5px; font-size: 15px; font-weight: 600; color: var(--green); line-height: 1.3; }
  .ac-tr .icon { flex: none; margin-top: 2px; }
  .art-st { position: absolute; pointer-events: none; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.35)); z-index: 3; }
  .art-st.st-a { width: 98px; right: -8px; top: -22px; animation: floatArtB 4.8s ease-in-out infinite; }
  .art-st.st-b { width: 92px; left: -6px; bottom: -18px; animation: floatArtA 5.4s ease-in-out infinite; }
  .art-st.st-c { width: 84px; left: 42%; bottom: -38px; animation: floatArtB 6s ease-in-out infinite; }
  .art-foot { z-index: 2; }
  .art-foot h2 { margin: 0 0 6px; font-size: 36px; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; color: #ffffff; }
  .art-foot h2 span { color: var(--green); font-style: italic; }
  .art-foot p { margin: 0 0 14px; font-size: 14px; color: rgba(243, 247, 239, 0.74); }
  .art-langs { display: flex; flex-wrap: wrap; gap: 6px; }
  .art-langs span {
    padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
    background: rgba(255, 255, 255, 0.07); color: rgba(243, 247, 239, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  .auth-form-pane { display: flex; flex-direction: column; justify-content: flex-start; padding: 12px 14px 24px; background: var(--grouped); }
  .auth-form-pane .auth-hero { padding: 14px 20px 18px; }
  .auth-form-pane .auth-hero img { width: 84px; }
  .auth-form-pane .auth-hero h1 { font-size: 28px; margin-top: 8px; }

  /* IG-inspired dark botanical left navigation rail */
  .rail {
    display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    padding: 16px 0;
    background: #131a10; color: #dbe7d2;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
  }
  .rail-logo {
    width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
    background: var(--green); box-shadow: 0 6px 18px rgba(159, 232, 112, 0.28);
    transition: transform 0.15s;
  }
  .rail-logo img { width: 28px; height: 28px; border-radius: 8px; display: block; }
  .rail-logo:hover { transform: scale(1.06); }
  .rail-nav, .rail-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
  .rail-btn {
    position: relative; width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center; color: #9fb094;
    transition: background 0.15s, color 0.15s, transform 0.12s;
  }
  .rail-btn:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; transform: translateY(-1px); }
  .rail-btn.active { background: rgba(159, 232, 112, 0.18); color: var(--green); }
  .rail-btn.active .icon { stroke-width: 2.2; }
  .rail-btn .badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; font-size: 11px; box-shadow: 0 0 0 2px #131a10; }
  .rail-btn .avatar.sm { width: 28px; height: 28px; font-size: 12px; box-shadow: 0 0 0 2px transparent; }
  .rail-btn.active .avatar.sm { box-shadow: 0 0 0 2px var(--green); }

  /* Center stage */
  .stage { background: var(--bg); }
  .tabbar { display: none; }
  .chats-mobile-wrap { display: none; }
  .stage-welcome {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; padding: 32px; text-align: center; overflow-y: auto;
    background:
      radial-gradient(circle at 20% 20%, rgba(159, 232, 112, 0.18), transparent 42%),
      radial-gradient(circle at 80% 80%, rgba(159, 232, 112, 0.12), transparent 44%),
      var(--bg);
  }
  .stage-welcome.has-hub {
    justify-content: flex-start;
    align-items: stretch;
    padding: 28px 32px 36px;
    text-align: start;
  }
  .welcome-wrap {
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  .stage-welcome:not(.has-hub) .welcome-hero {
    display: flex; flex-direction: column; align-items: center; text-align: center;
  }
  .stage-welcome.has-hub .welcome-hero {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 18px 20px; border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(23, 52, 4, 0.08);
    box-shadow: 0 10px 28px rgba(23, 52, 4, 0.05);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .stage-welcome img:not(.avatar img) { width: 84px; height: 84px; border-radius: 24px; box-shadow: 0 12px 30px rgba(23, 52, 4, 0.12); margin-bottom: 16px; }
  .stage-welcome.has-hub .welcome-hero > img { width: 54px; height: 54px; border-radius: 16px; margin-bottom: 0; flex: none; }
  .welcome-hero-text { flex: 1; min-width: 200px; }
  .stage-welcome h2 { margin: 0 0 6px; font-size: 26px; font-weight: 700; color: var(--green-ink); }
  .stage-welcome.has-hub .welcome-hero h2 { font-size: 21px; margin: 0 0 2px; }
  .stage-welcome p { margin: 0 0 20px; max-width: 340px; color: var(--secondary); font-size: 15px; }
  .stage-welcome.has-hub .welcome-hero p { margin: 0; max-width: none; font-size: 13.5px; }
  .stage-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

  /* Right live conversations roster (per hand-drawn layout) */
  .roster {
    display: flex; flex-direction: column; height: 100%; min-width: 0;
    background: #fcfdfb;
    border-inline-start: 1px solid var(--separator);
  }
  .roster-head { padding: 16px 14px 10px; border-bottom: 0.5px solid var(--separator); }
  .roster-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .roster-top h2 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
  .roster-add { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--green-soft); color: var(--green-text); }
  .roster-add:hover { background: var(--green); color: var(--green-ink); }
  .roster-filter { height: 34px; font-size: 14px; }
  .roster-filter input { font-size: 14px; }
  .roster-scroll { flex: 1; overflow-y: auto; padding: 6px 8px 14px; }
  .roster .requests-row { margin: 2px 2px 8px; padding: 10px 12px; }
  .roster .row { padding: 9px 10px; border-radius: 14px; background: transparent; margin-bottom: 2px; }
  .roster .row:hover { background: var(--fill); }
  .roster .row.active-chat { background: var(--green-soft); }
  .roster .list > li + li .row .body { border-top: 0; margin-top: 0; padding-top: 4px; }
  .roster .avatar { width: 44px; height: 44px; font-size: 16px; }
  .roster .empty { padding: 36px 16px; }

  .shell:not(.solo) .chat-view .navbar .left { visibility: hidden; pointer-events: none; }
  .chat-view .msg { max-width: 68%; }
  .chat-view .composer { margin: 0 12px 12px; border-radius: 26px; border: 0.5px solid var(--chat-border); padding: 8px 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06); }
  .chat-view .suggest { margin: 0 12px 6px; border-radius: 18px; border: 0.5px solid var(--chat-border); }
  .chat-view .panel { margin: 0 12px 12px; border-radius: 20px; border: 0.5px solid var(--chat-border); overflow: hidden; }
  .chat-view .sticker-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 1080px) {
  .shell {
    grid-template-columns: 74px minmax(0, 1fr) 336px;
    gap: 14px;
    padding: 14px;
    width: 100%;
    background: transparent;
  }
  .rail { border-radius: 24px; border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 18px 44px rgba(19, 26, 16, 0.22); }
  .stage { border-radius: 24px; border: 1px solid rgba(23, 52, 4, 0.08); box-shadow: 0 18px 48px rgba(23, 52, 4, 0.08); }
  .roster { border-radius: 24px; border: 1px solid rgba(23, 52, 4, 0.08); box-shadow: 0 18px 48px rgba(23, 52, 4, 0.06); overflow: hidden; }
  .chat-view .sticker-grid { grid-template-columns: repeat(8, 1fr); }
}

/* รหัสกู้คืนในหน้าตั้งค่า */
.rec-current { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; user-select: text; }

/* ---------- กำลังพิมพ์ ---------- */
.typing-row { animation: fade .18s ease-out; }
.bubble.typing { display: inline-flex; align-items: center; gap: 4px; padding: 12px 14px; min-height: 0; }
.bubble.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .35;
  animation: typingDot 1.2s ease-in-out infinite;
}
.bubble.typing i:nth-child(2) { animation-delay: .15s; }
.bubble.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-4px); opacity: .9; }
}

/* ---------- กำลังส่ง (ขึ้นทันทีก่อน server ตอบ) ---------- */
.msg.sending .bubble { opacity: .7; }
.msg.sending .meta { font-style: italic; }

/* ---------- แถบชวนเปิดแจ้งเตือน ---------- */
.push-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 12px; padding: 10px 12px;
  border-radius: 14px; background: var(--green-soft); color: var(--fg, inherit);
}
.push-banner .pb-icon { font-size: 20px; }
.push-banner .pb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.push-banner .pb-body small { color: var(--secondary); font-size: 12px; }
.push-banner .pb-close { padding: 6px; color: var(--secondary); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  .bubble.typing i { animation: none; opacity: .6; }
}

/* จอกว้าง: เต็มจอเสมอ (เดิมตันที่ 1480px แล้วเว้นขอบว่าง) · ขยายช่องรายการแชท แต่คุมความกว้างข้อความให้อ่านง่าย */
@media (min-width: 1080px) {
  .msg { max-width: min(82%, 680px); }
}
@media (min-width: 1600px) {
  .shell { grid-template-columns: 80px minmax(0, 1fr) 380px; gap: 16px; padding: 16px; }
}
@media (min-width: 2200px) {
  .shell { grid-template-columns: 84px minmax(0, 1fr) 420px; gap: 18px; padding: 18px; }
}

/* ปุ่ม + เพิ่มเพื่อน: กระพริบช่องค้นหาให้รู้ว่าพร้อมพิมพ์ */
.flash { animation: flashRing .7s ease-out; }
@keyframes flashRing { 0% { box-shadow: 0 0 0 0 rgba(159, 232, 112, .9); } 100% { box-shadow: 0 0 0 10px rgba(159, 232, 112, 0); } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

/* =================== สะพานความสนิท =================== */
.bond { --bond-a: #6fcf3f; --bond-b: #b9f28f; --bond-track: rgba(23, 52, 4, 0.13); display: inline-flex; line-height: 0; }
.bond svg { display: block; overflow: visible; }
.bond-track path { fill: var(--bond-track); }
.bond-liquid {
  transform: translateX(calc(var(--fill) * var(--w)));
  transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
  animation: bondPour 1.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@keyframes bondPour { from { transform: translateX(0); } }
.bond-wave { animation: bondWave 0.9s linear infinite; }
@keyframes bondWave { to { transform: translateY(12px); } }
.bond.full .bond-wave { display: none; }
.bond.full svg { filter: drop-shadow(0 0 6px rgba(159, 232, 112, 0.8)); animation: bondGlow 2.4s ease-in-out infinite; }
@keyframes bondGlow { 50% { filter: drop-shadow(0 0 2px rgba(159, 232, 112, 0.4)); } }
.bond.sm svg { width: 84px; height: 13px; }
.bond.lg svg { width: 176px; height: 26px; }
.bond.xl svg { width: 236px; height: 35px; }
.bond-btn { display: grid; place-items: center; padding: 8px 6px; border-radius: 10px; margin-left: auto; }
.bond-btn:hover { background: var(--fill); }
.chat-view .bond { --bond-track: color-mix(in srgb, var(--chat-text, #173404) 16%, transparent); }
.bond-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border-radius: 16px; background: var(--fill); text-align: start; }
.bond-card span { display: flex; flex-direction: column; }
.bond-card small { color: var(--secondary); font-size: 12px; }
.bond-sheet .bond-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 6px; text-align: center; }
.bond-sheet h3 { margin: 8px 0 0; font-size: 20px; }
.bond-sheet .bond-hero p { margin: 0; color: var(--secondary); font-size: 14px; }
.bond-levels { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }
.bond-levels li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--fill); font-size: 14px; color: var(--secondary); }
.bond-levels li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg); }
.bond-levels li.done { color: inherit; font-weight: 600; }
.bond-levels li.done span { background: var(--green); color: var(--green-ink); }
.bond-levelup { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px auto; padding: 10px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--green) 22%, transparent); font-size: 13px; font-weight: 600; text-align: center; animation: rise .5s cubic-bezier(.22,1,.36,1); }

/* =================== โปสการ์ด =================== */
.pc-strip { display: flex; gap: 12px; overflow-x: auto; padding: 6px 16px 12px; scrollbar-width: none; }
.pc-strip::-webkit-scrollbar { display: none; }
.roster .pc-strip { padding: 4px 6px 10px; }
.pc-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; flex: none; }
.pc-ring { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; padding: 3px; background: var(--bg); box-shadow: 0 0 0 2px var(--separator); }
.pc-ring .avatar { width: 100%; height: 100%; }
.pc-item.unseen .pc-ring, .pc-ring.has { background: conic-gradient(from 200deg, #9fe870, #2fb5a6, #4f8cff, #9fe870); box-shadow: none; }
.pc-item.unseen .pc-ring, .pc-ring.has { padding: 3px; }
.pc-item.unseen .pc-ring .avatar, .pc-ring.has .avatar { box-shadow: none; outline: 2.5px solid var(--bg); outline-offset: -2.5px; }
.pc-item.seen .pc-ring { box-shadow: 0 0 0 2px var(--separator); }
.pc-plus { position: absolute; top: 40px; right: 2px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); box-shadow: 0 0 0 2.5px var(--bg); }
.pc-name { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--secondary); }

.pc-card { --pc-w: min(86vw, 420px); position: relative; width: var(--pc-w); aspect-ratio: 4 / 5; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); transform: rotate(-1.2deg); }
.pc-card.flipped { transform: rotate(1deg) rotateY(180deg); }
.pc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 6px; background: #fffdf7; padding: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden; }
.pc-back { transform: rotateY(180deg); display: flex; flex-direction: column; color: #2b2b2b;
  background: repeating-linear-gradient(-45deg, #e63946 0 10px, #fffdf7 10px 20px, #1d4ed8 20px 30px, #fffdf7 30px 40px) top/100% 8px no-repeat, #fffdf7; }
.pc-photo { position: absolute; inset: 12px 12px 12px 12px; border-radius: 3px; overflow: hidden; background: #ddd; }
.pc-photo img, .pc-photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* แสตมป์: ขอบหยักเฉพาะรอบนอก (ชั้น content-box ทึบปิดรูตรงกลาง) */
.pc-stamp { position: absolute; top: 22px; right: 22px; width: 62px; padding: 5px; transform: rotate(3deg);
  background: #fffdf7; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
  -webkit-mask: radial-gradient(circle 2.6px, #0000 96%, #000) -4px -4px / 8px 8px round, linear-gradient(#000 0 0) content-box;
  mask: radial-gradient(circle 2.6px, #0000 96%, #000) -4px -4px / 8px 8px round, linear-gradient(#000 0 0) content-box; }
.pc-stamp-in { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0 4px; border: 1px solid rgba(23, 52, 4, .25); }
.pc-stamp .fi { width: 40px; height: 30px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.pc-stamp-globe { font-size: 24px; line-height: 30px; }
.pc-stamp small { font-size: 7.5px; font-weight: 800; letter-spacing: .14em; color: #173404; }
/* ตราประทับ: วงกลมซ้อนมุมล่างซ้ายของแสตมป์ + เส้นคลื่นลากไปทางซ้าย · พื้นกระดาษจาง ๆ ให้อ่านออกบนรูป */
.pc-postmark { position: absolute; top: 74px; right: 60px; width: 58px; height: 58px; border-radius: 50%;
  border: 1.6px solid rgba(23, 52, 4, .7); box-shadow: inset 0 0 0 3px rgba(255,253,247,.5), inset 0 0 0 4.2px rgba(23, 52, 4, .45);
  background: rgba(255, 253, 247, .62); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; transform: rotate(-12deg);
  color: rgba(23, 52, 4, .85); font-weight: 700; text-align: center; line-height: 1.15; white-space: nowrap; }
.pc-postmark span { font-size: 8.5px; letter-spacing: .02em; }
.pc-postmark b { font-size: 14px; letter-spacing: .06em; }
.pc-postmark::before { content: ""; position: absolute; right: calc(100% - 4px); top: 50%; width: 56px; height: 16px; transform: translateY(-50%); opacity: .7;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='16' fill='none' stroke='%23173404' stroke-width='1.4'%3E%3Cpath d='M0 3q7-3 14 0t14 0 14 0 14 0M0 8q7-3 14 0t14 0 14 0 14 0M0 13q7-3 14 0t14 0 14 0 14 0'/%3E%3C/svg%3E") no-repeat; }
.pc-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 40px 16px 14px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); border-radius: 0 0 3px 3px; }
.pc-caption p { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.35; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.pc-caption p.shimmer { color: transparent; }
.pc-tr { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; padding: 3px 8px; border-radius: 99px; background: rgba(159, 232, 112, .92); color: #173404; font-size: 11px; font-weight: 700; }
.pc-lines { flex: 1; margin-top: 18px; padding: 10px 8px; background: repeating-linear-gradient(transparent 0 33px, rgba(29, 78, 216, .18) 33px 34px); }
.pc-hand { margin: 0; font-family: "Mali", "Caveat", cursive, var(--font, sans-serif); font-size: 22px; line-height: 34px; color: #1e3a8a; white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-back-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #555; }
.pc-slam { position: absolute; left: 50%; top: 42%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 16px; border: 3px solid #d62828; border-radius: 12px;
  color: #d62828; background: rgba(255,255,255,.18); font-weight: 900; text-transform: uppercase; letter-spacing: .04em; mix-blend-mode: multiply;
  transform: translate(-50%, -50%) rotate(-12deg); animation: slam .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.pc-slam span { font-size: 34px; }
@keyframes slam { from { transform: translate(-50%, -50%) rotate(-30deg) scale(2.4); opacity: 0; } }

.pc-viewer { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(circle at 30% 20%, #2a3a22, #0d130b 70%); color: #fff; animation: fade .2s ease-out; }
.pc-top { width: min(100%, 520px); padding: max(10px, env(safe-area-inset-top)) 14px 6px; }
.pc-bars { display: flex; gap: 4px; }
.pc-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.28); overflow: hidden; }
.pc-bar i { display: block; height: 100%; width: 0; background: #fff; }
.pc-bar.done i { width: 100%; }
@keyframes pcbar { to { width: 100%; } }
.pc-head { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.pc-head small { color: rgba(255,255,255,.6); }
.pc-x { margin-left: auto; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; color: #fff; }
.pc-x:hover { background: rgba(255,255,255,.12); }
.pc-stage { position: relative; flex: 1; width: 100%; display: grid; place-items: center; perspective: 1400px; min-height: 0; }
.pc-stage .pc-card { --pc-w: min(86vw, 420px, calc((100dvh - 250px) * .8)); }
.pc-tap { position: absolute; top: 0; bottom: 0; width: 30%; z-index: 2; }
.pc-tap.prev { left: 0; }
.pc-tap.next { right: 0; }
.pc-tools { height: 40px; display: grid; place-items: center; }
.pc-flip { padding: 7px 14px; border-radius: 99px; background: rgba(255,255,255,.14); color: #fff; font-size: 13px; font-weight: 600; }
.pc-flip:hover { background: rgba(255,255,255,.24); }
.pc-foot { width: min(100%, 520px); padding: 6px 14px max(14px, env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pc-stamps { display: flex; gap: 6px; width: 100%; justify-content: space-between; }
.pc-stampbtn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: #fff; min-width: 0; }
.pc-stampbtn span { font-size: 24px; transition: transform .15s; }
.pc-stampbtn small { font-size: 10.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.pc-stampbtn:hover span { transform: scale(1.2) rotate(-6deg); }
.pc-reply { display: flex; gap: 8px; width: 100%; }
.pc-reply input { flex: 1; min-width: 0; height: 42px; padding: 0 16px; border-radius: 99px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: #fff; font: inherit; }
.pc-reply input::placeholder { color: rgba(255,255,255,.6); }
.pc-reply .send { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); }
.pc-foot .btn.plain { color: #fff; background: rgba(255,255,255,.12); }
.pc-over { z-index: 70; }
.pc-got { font-size: 13px; font-weight: 600; white-space: nowrap; }
.pc-compose .pc-preview { display: grid; place-items: center; padding: 6px 0 16px; perspective: 1000px; }
.pc-compose .pc-card { --pc-w: min(64vw, 260px); }

.story-ref { display: flex; align-items: center; gap: 8px; margin: 0 8px 4px; font-size: 12px; color: var(--secondary); }
.mine .story-ref { flex-direction: row-reverse; }
.story-ref-thumb { width: 44px; height: 55px; border-radius: 4px; overflow: hidden; background: #fffdf7; padding: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.15); transform: rotate(-3deg); flex: none; }
.story-ref-thumb img, .story-ref-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 2px; }
.story-ref-thumb.gone { background: repeating-linear-gradient(45deg, #eee 0 6px, #f8f8f8 6px 12px); }
.story-ref-thumb.gone > * { display: none; }

/* =================== guest → สมาชิก =================== */
.guest-nudge { display: flex; align-items: center; gap: 10px; margin: 0 10px 8px; padding: 8px 8px 8px 14px; border-radius: 14px; background: var(--green-soft); font-size: 13px; font-weight: 600; animation: rise .4s cubic-bezier(.22,1,.36,1); }
.guest-nudge span { flex: 1; }
.link-btn.inline { display: inline; margin: 0; padding: 0 2px; }
.join-lang { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 8px 0 0; font-size: 14px; color: var(--green-text); font-weight: 600; text-align: center; }

/* =================== พาสปอร์ตภาษา =================== */
.passport { padding: 14px 16px; border-radius: 16px; background: linear-gradient(135deg, #173404, #2f5a12); color: #e9ffd9; }
.pp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.pp-head b { font-size: 15px; letter-spacing: .02em; }
.pp-head span { font-size: 12px; opacity: .8; }
.pp-flags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pp-flag .fi { width: 30px; height: 22px; border-radius: 3px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.4); transform: rotate(-4deg); display: block; }
.pp-flag:nth-child(even) .fi { transform: rotate(3deg); }
.pp-empty { font-size: 13px; opacity: .8; }

@media (prefers-reduced-motion: reduce) {
  .bond-liquid, .bond-wave, .bond.full svg, .pc-slam, .pc-card { animation: none !important; transition: none !important; }
}

/* หัวแชท: ชื่อ + สะพานความสนิทอยู่กลาง */
.chat-center { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.chat-center .bond-btn { margin: 1px 0 0; padding: 3px 6px; }

/* =================== แชทกลุ่ม =================== */
.group-av { position: relative; background: transparent !important; overflow: visible; }
.group-av .ga { position: absolute; width: 72%; height: 72%; display: block; }
.group-av .ga .avatar { width: 100%; height: 100%; font-size: 0.8em; }
.group-av .ga1 { top: 0; left: 0; }
.group-av .ga2 { right: 0; bottom: 0; }
.group-av .ga2 .avatar { box-shadow: 0 0 0 2px var(--bg); }
.chat-view .group-av .ga2 .avatar { box-shadow: 0 0 0 2px var(--chat-chrome, var(--bg)); }
.g-count { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--secondary); }
.g-count .icon { width: 13px; height: 13px; }
.roster-actions { display: flex; gap: 6px; }
.hdr-btn { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 10px; padding: 7px 12px; border-radius: 99px; background: var(--green-soft); color: var(--green-text); font-size: 13px; font-weight: 600; }
.chat-title .s .name-flag { margin-right: 1px; }
.msg.system { align-self: center; max-width: 90%; }
.sys-note { margin: 8px auto; padding: 5px 12px; border-radius: 99px; background: var(--fill); color: var(--secondary); font-size: 12.5px; text-align: center; }
.chat-view .sys-note { background: color-mix(in srgb, var(--chat-text, #173404) 8%, transparent); color: var(--chat-muted); }
.sender-name { display: flex; align-items: center; gap: 4px; margin: 6px 0 2px calc(var(--tab) + 10px); font-size: 12px; font-weight: 600; color: var(--green-text); }
.chat-view .sender-name { color: var(--chat-accent-text, var(--green-text)); }
.typing-who { display: block; margin: 0 0 2px calc(var(--tab) + 10px); font-size: 11.5px; color: var(--secondary); }
.typing-who:empty { display: none; }
.group-sheet { max-height: 88dvh; display: flex; flex-direction: column; }
.g-pick { overflow-y: auto; flex: 1; min-height: 120px; max-height: 46dvh; margin: 0 -4px; }
.g-row { cursor: pointer; }
.g-check { width: 22px; height: 22px; accent-color: var(--green-text); flex: none; }
.g-mix { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 0; margin: 0 2px 8px; font-size: 12.5px; color: var(--green-text); font-weight: 600; }
.g-mix:empty { margin: 0; }
.g-world { padding: 14px 16px; border-radius: 16px; background: linear-gradient(135deg, #173404, #2f5a12); color: #e9ffd9; text-align: center; }
.g-world .pp-flags { justify-content: center; margin: 0 0 8px; }
.g-world p { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
.g-world small { opacity: .8; font-size: 12px; }
.section-head { margin: 0 4px 6px; font-size: 13px; font-weight: 600; color: var(--secondary); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--secondary); font-weight: 400; }
.g-flag { display: inline-block; width: 1.2em; height: 0.9em; margin-right: 2px; vertical-align: -1px; border-radius: 2px; }
.chat-title .group-av { width: 34px; height: 34px; margin-bottom: 2px; }
.g-create-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.g-av-pick {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%;
  background: var(--green-soft); color: var(--green-text);
  display: grid; place-items: center;
}
.g-av-preview {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
}
.g-av-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-av-pick .cam {
  position: absolute; right: -2px; bottom: -2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--green); color: var(--green-ink);
  border: 2px solid var(--bg);
  display: grid; place-items: center;
}
.g-av-pick .cam .icon { width: 11px; height: 11px; }

/* ---------- กลุ่มสาธารณะในหน้าแรก ---------- */
.welcome-hub { display: flex; flex-direction: column; gap: 16px; }
.welcome-panel {
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(23, 52, 4, 0.08);
  box-shadow: 0 12px 32px rgba(23, 52, 4, 0.05);
}
.welcome-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.wph-title { display: flex; align-items: flex-start; gap: 12px; }
.wph-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: var(--green-soft); color: var(--green-text);
  display: grid; place-items: center;
}
.wph-row { display: flex; align-items: center; gap: 8px; }
.wph-row h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--green-ink); }
.welcome-panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--secondary); max-width: none; }
.pub-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.pub-group-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 14px; border-radius: 18px;
  background: var(--bg);
  border: 1px solid rgba(23, 52, 4, 0.09);
  transition: transform 0.14s, box-shadow 0.14s, border-color 0.14s;
}
.pub-group-card:hover {
  transform: translateY(-1px);
  border-color: rgba(92, 201, 58, 0.45);
  box-shadow: 0 10px 24px rgba(23, 52, 4, 0.07);
}
.pg-top { display: flex; align-items: center; gap: 11px; min-width: 0; }
.pg-info { flex: 1; min-width: 0; }
.pg-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pg-title b { font-size: 15px; font-weight: 700; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-title .pill { flex: none; white-space: nowrap; }
.pg-meta { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 12px; color: var(--secondary); }
.pg-meta .icon { width: 13px; height: 13px; }
.pg-langs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 10px; border-radius: 11px;
  background: var(--grouped); font-size: 12px; color: var(--secondary);
}
.pg-flags { display: inline-flex; align-items: center; gap: 2px; }
.pg-lang-list { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--green-text); }
.pg-foot { display: flex; align-items: center; gap: 8px; }
.pg-foot .pg-action { flex: 1; justify-content: center; }
.pg-foot .pg-gear { padding: 0 10px; flex: none; }
.pub-groups-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 24px 16px; border-radius: 16px;
  background: var(--grouped); color: var(--secondary);
}
.pub-groups-empty .icon { width: 32px; height: 32px; color: var(--green-text); margin-bottom: 6px; opacity: 0.85; }
.pub-groups-empty b { font-size: 14.5px; color: var(--fg); margin-bottom: 4px; }
.pub-groups-empty p { margin: 0; font-size: 13px; max-width: 380px; }

.my-owned-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.my-owned-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 15px;
  background: var(--bg); border: 1px solid rgba(23, 52, 4, 0.08);
}
.mor-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.mor-body { display: flex; flex-direction: column; min-width: 0; }
.mor-body b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mor-body small { font-size: 12px; color: var(--secondary); }
.mor-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; }
.mor-state { font-size: 12px; font-weight: 600; color: var(--secondary); }
.mor-state.on { color: var(--green-text); }

.mobile-pub-groups { padding: 12px 14px 20px; }
.mobile-pub-groups .section-head { display: flex; align-items: center; gap: 5px; margin-bottom: 10px; }

/* =================== เครดิตแปล AI =================== */
.tr-btn { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; background: var(--green-soft); color: var(--green-text); font-size: 11.5px; font-weight: 700; }
.tr-btn:hover { background: var(--green); color: var(--green-ink); }
.tr-btn .icon { width: 12px; height: 12px; }
.chat-view .tr-btn { background: color-mix(in srgb, var(--chat-accent) 30%, transparent); color: inherit; }
.credit-note { margin: 0 10px 6px; padding: 7px 12px; border-radius: 12px; background: var(--green-soft); color: var(--green-text); font-size: 12.5px; font-weight: 600; text-align: center; }
.credit-note.empty { background: #fff3e0; color: #8a4b00; }
.credit-count { font-variant-numeric: tabular-nums; }

/* =================== ชวนเพื่อน / เครดิตหมด / Pro / ข้อกำหนด =================== */
.ooc-sheet { text-align: center; }
.ooc-hero { padding: 8px 4px 4px; }
.ooc-gift { display: inline-block; font-size: 52px; animation: giftBob 1.6s ease-in-out infinite; }
@keyframes giftBob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.ooc-hero h3 { margin: 6px 0 4px; font-size: 20px; }
.ooc-hero p { margin: 0; color: var(--secondary); font-size: 14px; }
.ooc-deal { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; text-align: start; margin: 14px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--green-soft); }
.ooc-deal b { font-size: 20px; color: var(--green-text); }
.ooc-deal span { font-size: 13px; font-weight: 600; }
.ooc-pro { display: block; margin-top: 12px; padding: 10px; border-radius: 12px; background: linear-gradient(135deg, #173404, #2f5a12); color: #e9ffd9; font-size: 13px; font-weight: 600; text-decoration: none; }
.credit-note a { color: inherit; font-weight: 800; text-decoration: underline; margin-left: 4px; }
.ref-banner { margin: 10px 2px 0; padding: 10px 12px; border-radius: 12px; background: var(--green-soft); color: var(--green-text); font-size: 13px; font-weight: 600; }

.earn-hero { padding: 18px 16px; border-radius: 18px; background: radial-gradient(circle at 85% 0%, #c9f7a6 0%, #9fe870 45%, #7fd34f 100%); color: #173404; text-align: center; }
.earn-balance { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.55); font-size: 12px; font-weight: 600; }
.earn-balance b { font-size: 18px; }
.earn-hero h2 { margin: 12px 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.earn-hero p { margin: 0 0 12px; font-size: 14px; opacity: .85; }
.earn-link { padding: 9px 12px; border-radius: 12px; background: rgba(255,255,255,.7); font-size: 13px; overflow-wrap: anywhere; }
.earn-link code { font-family: ui-monospace, Menlo, monospace; }
.earn-actions { display: flex; gap: 8px; margin-top: 10px; }
.earn-actions .btn { flex: 1; }
.earn-hero .btn.plain { background: rgba(255,255,255,.6); color: #173404; }
.earn-hero .btn:not(.plain) { background: #173404; color: #e9ffd9; }
.earn-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.earn-steps li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--fill); font-size: 14px; }
.earn-steps span { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); font-weight: 800; font-size: 12px; }
.earn-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.earn-stats div { padding: 12px 8px; border-radius: 14px; background: var(--fill); text-align: center; display: flex; flex-direction: column; gap: 2px; }
.earn-stats b { font-size: 22px; color: var(--green-text); }
.earn-stats small { font-size: 12px; color: var(--secondary); }
.earn-progress { width: 56px; height: 6px; border-radius: 6px; background: var(--fill); overflow: hidden; margin-right: 6px; }
.earn-progress i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.earn-bonus-sub { margin: -4px 0 10px; font-size: 13px; color: var(--secondary); }
.earn-milestones { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.earn-milestones li { padding: 12px 6px; border-radius: 14px; background: var(--fill); text-align: center; display: flex; flex-direction: column; gap: 2px; }
.earn-milestones b { font-size: 17px; color: var(--secondary); }
.earn-milestones small { font-size: 12px; color: var(--secondary); }
.earn-milestones li.done { background: var(--green); }
.earn-milestones li.done b, .earn-milestones li.done small { color: var(--green-ink); }
.earn-milestones li.next { box-shadow: inset 0 0 0 2px var(--green); }
.earn-milestones li.next b { color: var(--green-text); }

.pro-card { padding: 18px 16px; border-radius: 18px; background: linear-gradient(160deg, #0f1d08, #22400d 60%, #2f5a12); color: #e9ffd9; }
.pro-head { display: flex; align-items: center; gap: 8px; }
.pro-badge { padding: 3px 9px; border-radius: 8px; background: linear-gradient(135deg, #ffd66b, #ff9f43); color: #3b2300; font-weight: 900; font-size: 12px; letter-spacing: .08em; }
.pro-soon { font-size: 12px; opacity: .75; }
.pro-card h3 { margin: 10px 0 2px; font-size: 22px; }
.pro-tag { margin: 0 0 10px; opacity: .8; font-size: 14px; }
.pro-features { margin: 0 0 12px; padding-left: 0; list-style: none; display: grid; gap: 6px; font-size: 14px; }
.pro-features li::before { content: "✓"; color: #9fe870; font-weight: 900; margin-right: 8px; }
.pro-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pro-price b { font-size: 26px; }
.pro-price span { font-size: 13px; opacity: .75; }
.pro-early { margin: 8px 0 12px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 214, 107, .14); color: #ffd66b; font-size: 13px; font-weight: 700; }
.pro-cta { background: linear-gradient(135deg, #ffd66b, #ff9f43) !important; color: #3b2300 !important; font-weight: 800; }
.pro-done { padding: 12px; border-radius: 12px; background: rgba(159, 232, 112, .18); color: #c9f7a6; text-align: center; font-weight: 700; }
.pro-alt { display: flex; justify-content: center; gap: 16px; margin-top: 10px; }
.pro-alt .link-btn { color: rgba(233, 255, 217, .75); font-size: 13px; }
.pro-alt .link-btn.on { color: #9fe870; text-decoration: underline; }
.pro-note { margin: 10px 0 0; font-size: 11.5px; opacity: .6; text-align: center; }

.terms-check { display: flex; align-items: flex-start; gap: 10px; margin: 12px 2px 0; font-size: 13px; color: var(--secondary); line-height: 1.45; cursor: pointer; }
.terms-check input { flex: none; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--green-text); }
.terms-check a, .legal-links a, .section-foot a { color: var(--green-text); font-weight: 600; }
.legal-links { text-align: center; font-size: 12px; color: var(--secondary); margin: 4px 0 24px; }
.legal { padding: 4px 18px 40px; max-width: 760px; margin: 0 auto; line-height: 1.65; font-size: 15px; }
.legal h1 { font-size: 24px; margin: 8px 0 2px; }
.legal h2 { font-size: 17px; margin: 22px 0 6px; }
.legal .legal-meta { margin: 0 0 14px; color: var(--secondary); font-size: 13px; }
.legal ul { padding-left: 20px; }
.legal li { margin: 4px 0; }
.legal a { color: var(--green-text); }

/* =================== หลังบ้านแอดมิน =================== */
.adm { --adm-bg: #f3f5f1; --adm-card: #ffffff; --adm-line: rgba(23, 52, 4, .08); --adm-ink: #13210b; --adm-mute: #6b7a63;
  position: fixed; inset: 0; display: grid; grid-template-columns: 232px 1fr; background: var(--adm-bg); color: var(--adm-ink); z-index: 1; }
.adm-side { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px; background: #131a10; color: #d8e8cf; overflow-y: auto; }
.adm-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; text-decoration: none; font-weight: 800; font-size: 18px; }
.adm-brand img { width: 32px; height: 32px; border-radius: 9px; }
.adm-brand small { display: block; font-size: 11px; font-weight: 600; color: #9fe870; letter-spacing: .08em; text-transform: uppercase; }
.adm-side nav { display: flex; flex-direction: column; gap: 2px; }
.adm-side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: #c4d6ba; text-decoration: none; font-size: 14px; font-weight: 600; }
.adm-side nav a span { width: 22px; text-align: center; }
.adm-side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.adm-side nav a.on { background: rgba(159, 232, 112, .16); color: #9fe870; }
.adm-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.adm-foot a { color: #9fe870; text-decoration: none; font-weight: 600; }
.adm-foot small { color: #7d8f73; }
.adm-main { overflow-y: auto; padding: 22px 26px 40px; }
.adm-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.adm-top h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.adm-tools { display: flex; gap: 8px; align-items: center; }
.adm-seg { display: inline-flex; padding: 3px; border-radius: 12px; background: #e6ebe1; }
.adm-seg button { padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--adm-mute); }
.adm-seg button.on { background: #fff; color: var(--adm-ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.adm-btn { padding: 7px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--adm-line); font-size: 13px; font-weight: 600; }
.adm-btn:disabled { opacity: .4; }
.adm-loading { padding: 40px; text-align: center; color: var(--adm-mute); }

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; grid-auto-flow: dense; }
.adm-card { position: relative; background: var(--adm-card); border: 1px solid var(--adm-line); border-radius: 20px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(19, 33, 11, .04); min-width: 0; overflow: hidden; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.r2 { grid-row: span 2; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-h b { font-size: 15px; }
.card-h small, .card-h a { font-size: 12px; color: var(--adm-mute); text-decoration: none; font-weight: 600; }
.card-h a:hover { color: var(--green-text); }

.kpi { display: flex; flex-direction: column; gap: 4px; min-height: 118px; }
.kpi-l { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--adm-mute); }
.kpi-v { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 16px; font-weight: 600; color: var(--adm-mute); }
.kpi-s { font-size: 12px; color: var(--adm-mute); }
.kpi .spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40px; }
.kpi-delta { padding: 2px 7px; border-radius: 99px; font-size: 11px; background: #eef1ea; color: var(--adm-mute); }
.kpi-delta.up { background: #e3f8d5; color: #2f7a0d; }
.kpi-delta.down { background: #fde8eb; color: #be123c; }
.kpi.gold { background: linear-gradient(160deg, #fff8e6, #fff); border-color: #f6dfa6; }
.kpi.bad .kpi-v { color: #be123c; }
.c2.kpi { min-height: 104px; }
.c2 .kpi-v { font-size: 24px; }

.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-grid div { padding: 10px 12px; border-radius: 14px; background: #f5f7f2; display: flex; flex-direction: column; gap: 2px; }
.mini-grid small { font-size: 11.5px; color: var(--adm-mute); font-weight: 600; }
.mini-grid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.warn { color: #c2410c !important; }

.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -2px 0 6px; font-size: 12px; color: var(--adm-mute); }
.ch-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ch-legend i, .ch-tip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.ch-legend b { color: var(--adm-ink); }
.ch-wrap { position: relative; }
.ch { width: 100%; height: auto; display: block; touch-action: pan-y; }
.ch-grid { stroke: #e9eee5; stroke-width: 1; }
.ch-yl { font-size: 10.5px; fill: #93a089; text-anchor: end; }
.ch-xl { font-size: 10.5px; fill: #93a089; text-anchor: middle; }
.ch-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: chDraw 1.2s cubic-bezier(.22, 1, .36, 1) forwards; }
@keyframes chDraw { to { stroke-dashoffset: 0; } }
.ch-area { opacity: 0; animation: chFade .8s .35s ease-out forwards; }
@keyframes chFade { to { opacity: 1; } }
.ch-cursor { stroke: #c5d0bd; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.ch-dot { opacity: 0; stroke: #fff; stroke-width: 2; }
.ch.hover .ch-cursor, .ch.hover .ch-dot { opacity: 1; }
.ch-tip { position: absolute; top: 6px; transform: translateX(-50%); padding: 8px 10px; border-radius: 10px; background: #13210b; color: #e9ffd9; font-size: 12px;
  display: flex; flex-direction: column; gap: 3px; pointer-events: none; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.ch-tip span { display: flex; align-items: center; gap: 6px; }

.adm-bars { display: grid; gap: 8px; }
.adm-bar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto auto; align-items: center; gap: 10px; font-size: 13px; }
.adm-bar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.adm-bar .bt { height: 10px; border-radius: 6px; background: #eef2ea; overflow: hidden; }
.adm-bar .bt i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #9fe870, #5cc72a); }
.adm-bar small { color: var(--adm-mute); width: 34px; text-align: end; }
.adm-hint, .adm-note { font-size: 12px; color: var(--adm-mute); margin: 10px 2px 0; }
.adm-note { margin-top: 16px; }
.adm-empty { color: var(--adm-mute); text-align: center; padding: 24px 0; }

.adm-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.adm-filters .search-field { flex: 1; min-width: 220px; }
.adm-table { display: grid; }
.adm-table .tr { display: grid; grid-template-columns: minmax(220px, 2.4fr) 1fr .8fr 1fr .8fr .6fr 1fr; gap: 10px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--adm-line); text-align: start; font-size: 13px; width: 100%; }
.adm-table .tr:not(.th):hover { background: #f6f9f3; }
.adm-table .th { font-size: 11.5px; font-weight: 700; color: var(--adm-mute); text-transform: uppercase; letter-spacing: .03em; }
.adm-table .who, .adm-li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nm { display: flex; flex-direction: column; min-width: 0; font-weight: 600; }
.nm small { font-weight: 500; color: var(--adm-mute); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 6px; background: #eef1ea; color: var(--adm-mute); font-size: 11px; font-weight: 700; }
.tag.admin { background: #e8e3ff; color: #5b3fd6; }
.tag.early { background: #fff1cc; color: #8a5a00; }
.tag.maybe { background: #e0f2fe; color: #0369a1; }
.tag.too_much { background: #fde8eb; color: #be123c; }
.adm-pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 12px; font-size: 13px; color: var(--adm-mute); }
.adm-list { display: grid; gap: 2px; }
.adm-li { padding: 8px; border-radius: 12px; width: 100%; text-align: start; }
button.adm-li:hover { background: #f6f9f3; }
.adm-li .nm { flex: 1; }
.adm-li .rank { width: 20px; color: var(--adm-mute); font-weight: 700; text-align: center; }

.adm-drawer-bg { position: fixed; inset: 0; z-index: 80; background: rgba(10, 16, 7, .35); display: flex; justify-content: flex-end; animation: fade .15s; }
.adm-drawer { width: min(440px, 100%); height: 100%; overflow-y: auto; background: #fff; padding: 22px 20px 40px; position: relative; animation: drw .25s cubic-bezier(.22,1,.36,1); color: #13210b; }
@keyframes drw { from { transform: translateX(40px); opacity: 0; } }
.adm-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; background: #f1f4ee; }
.drw-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.drw-head h2 { margin: 8px 0 0; display: flex; align-items: center; gap: 6px; }
.drw-head .handle { color: #6b7a63; font-size: 13px; }
.drw-tags { display: flex; gap: 6px; margin-top: 4px; }
.drw-stats { margin-top: 16px; }
.drw-meta { font-size: 12.5px; color: #6b7a63; text-align: center; margin: 12px 0 0; }
.drw-sec { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(23, 52, 4, .08); }
.drw-sec h3 { margin: 0 0 10px; font-size: 14px; }
.drw-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.drw-quick button { padding: 6px 12px; border-radius: 99px; background: #e3f8d5; color: #2f7a0d; font-weight: 700; font-size: 13px; }
.drw-quick button.neg { background: #fde8eb; color: #be123c; }
.drw-form { display: flex; flex-wrap: wrap; gap: 8px; }
.drw-form input { flex: 1 1 140px; min-width: 0; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(23, 52, 4, .15); font: inherit; background: #fff; }
.adm-log { display: grid; }
.log-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(23, 52, 4, .06); font-size: 13px; align-items: baseline; }
.log-a { font-weight: 700; color: #5b3fd6; }
.log-row small { color: #6b7a63; white-space: nowrap; }

@media (max-width: 1180px) {
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .c2 { grid-column: span 2; } .c3, .c4, .c5 { grid-column: span 3; } .c6, .c7, .c8, .c12 { grid-column: span 6; }
  .r2 { grid-row: auto; }
}
@media (max-width: 760px) {
  .adm { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .adm-side { flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; gap: 4px; }
  .adm-brand { padding: 0 8px 0 0; font-size: 15px; }
  .adm-brand small { display: none; }
  .adm-side nav { flex-direction: row; }
  .adm-side nav a { white-space: nowrap; padding: 8px 10px; font-size: 13px; }
  .adm-foot { display: none; }
  .adm-main { padding: 14px 12px 30px; }
  .adm-top h1 { font-size: 21px; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .c2, .c3 { grid-column: span 1; } .c4, .c5, .c6, .c7, .c8, .c12 { grid-column: span 2; }
  .kpi-v { font-size: 24px; }
  .adm-table .tr { grid-template-columns: 1fr auto; }
  .adm-table .tr > span:nth-child(n + 4), .adm-table .tr > span:nth-child(2) { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ch-line, .ch-area { animation: none; stroke-dashoffset: 0; opacity: 1; } }
/* ชื่อ + ธง อยู่บรรทัดเดียวกัน ส่วน @username อยู่บรรทัดล่าง */
.adm-table .nm, .adm-li .nm { display: grid; grid-template-columns: auto auto 1fr; align-items: center; column-gap: 5px; }
.adm-table .nm > small, .adm-li .nm > small { grid-column: 1 / -1; }
.adm-table .nm > .nm, .adm-li .nm > .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- desktop integration & drag-drop ---------- */
.chat-view.drag-over::after {
  content: attr(data-drop-label);
  position: absolute; inset: 12px; z-index: 25;
  display: grid; place-items: center;
  border-radius: 20px;
  border: 2.5px dashed var(--green-text);
  background: rgba(238, 251, 228, 0.9);
  color: var(--green-ink);
  font-weight: 700; font-size: 18px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.desktop-join-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin: 14px auto 0; padding: 7px 14px;
  border-radius: 999px; background: rgba(23, 52, 4, 0.06);
  color: var(--green-ink); font-size: 13px; font-weight: 600;
}
.desktop-join-btn:hover { background: var(--green-soft); color: var(--green-text); }


/* ---------- โทร / วิดีโอคอลแปลภาษา ---------- */
.navbar:has(.nav-actions) { grid-template-columns: minmax(72px, auto) 1fr minmax(72px, auto); }
.nav-actions { display: flex; align-items: center; gap: 0; }
.nav-actions .nav-btn { padding: 7px; }
.call {
  --call-bg: #0f1a0a; --call-fg: #f4fbef; --call-dim: rgba(244, 251, 239, 0.66);
  position: fixed; inset: 0; z-index: 60;
  display: grid; grid-template-rows: 1fr auto auto; justify-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 50% 0%, #24421a 0%, var(--call-bg) 62%);
  color: var(--call-fg); overflow: hidden;
  animation: call-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes call-in { from { opacity: 0; transform: scale(1.03); } }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.call.peer-cam .call-remote { opacity: 1; }
.call-peer { position: relative; align-self: center; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; transition: transform 0.3s, opacity 0.3s; }
.call-peer .avatar { box-shadow: 0 0 0 6px rgba(159, 232, 112, 0.14), 0 0 0 14px rgba(159, 232, 112, 0.06); }
.call[data-phase="ringing"] .call-peer .avatar, .call[data-phase="calling"] .call-peer .avatar { animation: call-pulse 1.6s ease-in-out infinite; }
@keyframes call-pulse { 50% { box-shadow: 0 0 0 10px rgba(159, 232, 112, 0.22), 0 0 0 24px rgba(159, 232, 112, 0.07); } }
.call-name { font-size: 24px; font-weight: 600; margin-top: 10px; }
.call-status { color: var(--call-dim); font-size: 15px; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.call-badge { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; padding: 2px 8px; border-radius: 999px; background: rgba(159, 232, 112, 0.16); color: var(--green); }
.call.peer-cam .call-peer { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; flex-direction: row; gap: 10px; align-items: center; text-align: left; }
.call.peer-cam .call-peer .avatar, .call.peer-cam .call-badge { display: none; }
.call.peer-cam .call-name { font-size: 17px; margin: 0; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.call.peer-cam .call-status { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.call-local {
  position: absolute; right: 16px; top: max(16px, env(safe-area-inset-top)); width: 104px; aspect-ratio: 3 / 4;
  object-fit: cover; border-radius: 14px; background: #000; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); display: none;
}
.call.my-cam .call-local { display: block; }
.call-local.mirror { transform: scaleX(-1); }
.call-min { position: absolute; left: 12px; bottom: 132px; z-index: 2; padding: 10px; border-radius: 50%; color: var(--call-fg); background: rgba(0, 0, 0, 0.28); }
.call.peer-cam .call-min { top: auto; }
.call-captions { position: relative; z-index: 1; width: min(640px, 100%); display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-height: 64px; justify-content: flex-end; }
.cap { margin: 0; padding: 8px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 2px; animation: cap-in 0.2s ease-out; }
@keyframes cap-in { from { opacity: 0; transform: translateY(6px); } }
.cap-main { font-size: 19px; line-height: 1.35; font-weight: 500; }
.cap-orig { font-size: 13px; color: var(--call-dim); }
.cap.mine { align-self: flex-end; font-size: 14px; color: var(--call-dim); background: rgba(0, 0, 0, 0.26); }
.cap.mine b { color: var(--green); font-weight: 600; margin-right: 4px; }
.cap-hint { margin: 0; text-align: center; font-size: 14px; color: var(--call-dim); }
.call-controls { position: relative; z-index: 1; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.call-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--call-fg); font-size: 12px; min-width: 64px; }
.call-btn .icon { width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background 0.15s, transform 0.1s; }
.call-btn:active .icon { transform: scale(0.94); }
.call-btn.on .icon { background: var(--call-fg); color: var(--call-bg); }
.call-btn.end .icon { background: var(--red); color: #fff; }
.call-btn.end .icon { transform: rotate(135deg); }
.call-btn.accept .icon { background: #34c759; color: #fff; animation: call-wiggle 1.2s ease-in-out infinite; }
@keyframes call-wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg); } 80% { transform: rotate(12deg); } 90% { transform: rotate(-6deg); } }
.call[data-phase="ringing"] .call-controls { gap: 72px; }
.call[data-phase="ringing"] .call-min, .call[data-phase="ringing"] .call-captions { visibility: hidden; }
/* ย่อสายไว้มุมจอ — กลับไปแชทต่อได้ */
.call.mini {
  inset: auto 16px calc(16px + env(safe-area-inset-bottom)) auto; width: 168px; height: 224px; padding: 10px;
  border-radius: 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); cursor: pointer; grid-template-rows: 1fr;
}
.call.mini .call-controls, .call.mini .call-captions, .call.mini .call-min, .call.mini .call-local, .call.mini .call-badge { display: none; }
.call.mini .call-peer .avatar { width: 64px; height: 64px; font-size: 24px; }
.call.mini .call-name { font-size: 15px; margin-top: 4px; }
.call.mini.peer-cam .call-peer { left: 10px; top: 10px; }
@media (min-width: 900px) {
  .call-local { width: 180px; }
  .call-min { bottom: auto; top: max(16px, env(safe-area-inset-top)); left: auto; right: 210px; }
  .call:not(.my-cam) .call-min { right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .call, .cap, .call-btn.accept .icon, .call-peer .avatar { animation: none !important; }
}

/* ---------- เมนูแชท (⋯ / กดค้าง / คลิกขวา) ---------- */
.menu-sheet { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.menu-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 14px; border-bottom: 0.5px solid var(--separator); margin-bottom: 6px; }
.menu-head b { display: block; font-size: 17px; }
.menu-head small { color: var(--secondary); font-size: 13px; }
.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 13px 6px; border-radius: 12px; font-size: 16px; text-align: left; color: var(--label); }
.menu-item:hover { background: var(--fill); }
.menu-item .icon { color: var(--green-text); }
.menu-item span { display: flex; flex-direction: column; }
.menu-item small { color: var(--secondary); font-size: 12px; }
.menu-item.danger, .menu-item.danger .icon { color: var(--red); }
.menu-cancel { margin-top: 8px; }
.menu-confirm { text-align: center; padding: 8px 8px 16px; }
.menu-confirm-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 59, 48, 0.1); color: var(--red); margin-bottom: 8px; }
.menu-confirm h3 { margin: 4px 0 6px; font-size: 18px; }
.menu-confirm p { margin: 0; color: var(--secondary); font-size: 14px; line-height: 1.45; }
.btn.danger { background: var(--red); color: #fff; }
.nick-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 12px; color: var(--secondary); }
a.row[href^="#/c/"] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ---------- ค้นในแชท ---------- */
.chat-search { position: relative; z-index: 4; background: var(--chat-chrome, var(--bg)); border-bottom: 0.5px solid var(--chat-border, var(--separator)); }
.chat-search-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.chat-search-bar .search-field { flex: 1; margin: 0; }
.chat-search-results { position: absolute; left: 0; right: 0; top: 100%; max-height: min(60vh, 420px); overflow: auto; background: var(--bg); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12); }
.cs-hit { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 10px 14px; text-align: left; border-bottom: 0.5px solid var(--separator); }
.cs-hit:hover { background: var(--fill); }
.cs-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cs-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.cs-top small { color: var(--secondary); }
.cs-text { font-size: 14px; color: var(--secondary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cs-text mark, .row .sub mark { background: var(--green-soft); color: var(--green-ink); border-radius: 3px; padding: 0 1px; }
.cs-empty { padding: 18px; text-align: center; color: var(--secondary); margin: 0; }
.msg.jump-hit .bubble { animation: jump-hit 2.4s ease-out; }
@keyframes jump-hit { 0%, 40% { box-shadow: 0 0 0 3px var(--green); } 100% { box-shadow: 0 0 0 0 transparent; } }
.back-latest { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 5; padding: 8px 16px; border-radius: 999px; background: var(--label); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); }
.chats-filter { margin: 0 16px 10px; }
.list-head { margin: 16px 16px 6px; font-size: 13px; font-weight: 600; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.02em; }

/* ---------- Mell (@mell) ---------- */
.avatar.mell-av { background: var(--green); }
.avatar.mell-av img { object-fit: cover; }
.msg.mell .mell-stack { display: flex; flex-direction: column; gap: 6px; max-width: min(640px, 100%); min-width: 0; }
.msg.mell .bubble.md { white-space: normal; line-height: 1.55; }
.bubble.md > :first-child { margin-top: 0; }
.bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p { margin: 0 0 0.6em; }
.bubble.md h1, .bubble.md h2, .bubble.md h3, .bubble.md h4 { margin: 0.9em 0 0.4em; font-size: 1.05em; line-height: 1.3; }
.bubble.md h1 { font-size: 1.2em; }
.bubble.md ul, .bubble.md ol { margin: 0.3em 0 0.6em; padding-left: 1.3em; }
.bubble.md li { margin: 0.2em 0; }
.bubble.md a { color: var(--green-text); text-decoration: underline; }
.bubble.md blockquote { margin: 0.5em 0; padding: 2px 10px; border-left: 3px solid var(--green); color: var(--secondary); }
.bubble.md code { font: 0.88em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(0, 0, 0, 0.06); padding: 1px 5px; border-radius: 5px; }
.bubble.md pre { position: relative; margin: 0.5em 0; padding: 30px 12px 12px; background: #17210f; color: #e8f5dc; border-radius: 12px; overflow-x: auto; }
.bubble.md pre::before { content: attr(data-lang); position: absolute; left: 12px; top: 8px; font-size: 11px; color: #9fe870; text-transform: lowercase; }
.bubble.md pre code { background: none; padding: 0; color: inherit; white-space: pre; }
.md-copy { position: absolute; right: 8px; top: 6px; font-size: 11px; color: #cfe9bb; padding: 2px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); }
.bubble.md table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.92em; display: block; overflow-x: auto; }
.bubble.md th, .bubble.md td { border: 1px solid var(--separator); padding: 5px 9px; text-align: left; }
.bubble.md th { background: rgba(0, 0, 0, 0.04); }
.bubble.md hr { border: 0; border-top: 1px solid var(--separator); margin: 0.8em 0; }
.mell-caret { display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--green-text); border-radius: 2px; animation: mell-caret 0.9s steps(2) infinite; }
@keyframes mell-caret { 50% { opacity: 0; } }
.mell-thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--secondary); }
.mell-blink { display: inline-flex; color: var(--green-text); animation: mell-blink 1.4s ease-in-out infinite; }
@keyframes mell-blink { 0%, 70%, 100% { transform: scaleY(1); } 80% { transform: scaleY(0.15); } }
/* การ์ดเว็บแอพ */
.mell-app { display: flex; align-items: center; gap: 12px; width: min(340px, 100%); padding: 12px 14px; border-radius: 18px; text-align: left;
  background: linear-gradient(135deg, #f3fce9 0%, #e3f7d1 100%); border: 1px solid rgba(46, 122, 18, 0.18); box-shadow: 0 4px 14px rgba(23, 52, 4, 0.08); transition: transform 0.12s; }
.mell-app:active { transform: scale(0.98); }
.mell-app-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--green); color: var(--green-ink); }
.mell-app-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mell-app-txt b { font-size: 15px; color: var(--green-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mell-app-txt small { color: var(--green-text); font-size: 12px; }
.mell-app-go { flex: none; font-size: 13px; font-weight: 700; color: #fff; background: var(--green-text); padding: 6px 11px; border-radius: 999px; }
.mell-app.building { cursor: default; }
.mell-dots { display: inline-flex; gap: 3px; }
.mell-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--green-text); animation: mell-dot 1.1s infinite; }
.mell-dots i:nth-child(2) { animation-delay: 0.15s; }
.mell-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mell-dot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
/* การ์ดล็อก / เกินโควตา */
.mell-card { width: min(320px, 100%); padding: 16px; border-radius: 20px; background: var(--bg); border: 1px solid var(--separator); text-align: center; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05); }
.mell-card b { display: block; font-size: 16px; margin: 4px 0; }
.mell-card p { margin: 0 0 12px; color: var(--secondary); font-size: 14px; line-height: 1.45; }
.mell-card.limit p { margin: 0; }
.mell-card-img { width: 72px; height: 72px; border-radius: 24%; }
/* แชท Mell ยังว่าง */
.mell-starters { margin: auto 0; padding: 24px 16px; text-align: center; }
.mell-hero { width: 104px; height: 104px; border-radius: 24%; box-shadow: 0 10px 30px rgba(46, 122, 18, 0.22); animation: mell-float 3.2s ease-in-out infinite; }
@keyframes mell-float { 50% { transform: translateY(-6px); } }
.mell-starters h3 { margin: 14px 0 4px; font-size: 19px; }
.mell-starters p { margin: 0 auto 16px; max-width: 340px; color: var(--secondary); font-size: 14px; line-height: 1.5; }
.mell-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.mell-chips .chip { padding: 9px 14px; border-radius: 999px; background: var(--bg); border: 1px solid var(--separator); font-size: 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04); }
.mell-chips .chip:hover { border-color: var(--green); background: var(--green-soft); }
/* หน้าต่างรันแอพ */
.mell-viewer { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); animation: kv-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes kv-in { from { transform: translateY(24px); opacity: 0; } }
.kv-bar { display: flex; align-items: center; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 8px 6px; border-bottom: 0.5px solid var(--separator); }
.kv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kv-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-title small { font-size: 12px; color: var(--secondary); }
.kv-tabs { display: flex; padding: 3px; border-radius: 10px; background: var(--fill); }
.kv-tabs button { padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--secondary); }
.kv-tabs button.on { background: var(--bg); color: var(--label); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.kv-body { flex: 1; min-height: 0; display: flex; }
.kv-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.kv-loading { margin: auto; color: var(--secondary); padding: 24px; text-align: center; }
.kv-code { flex: 1; overflow: auto; padding: 12px; background: #17210f; }
.kv-code pre { margin: 10px 0 0; color: #e8f5dc; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
/* หน้าความจำ */
.mell-mem { padding: 0 16px 32px; }
.mell-mem-hero { text-align: center; padding: 18px 8px 4px; }
.mell-mem-hero img { width: 88px; height: 88px; border-radius: 24%; box-shadow: 0 8px 24px rgba(46, 122, 18, 0.2); }
.mell-mem-hero p { color: var(--secondary); font-size: 14px; line-height: 1.5; max-width: 420px; margin: 10px auto 0; }
.mell-mem .mell-card { margin: 14px auto; }
.mell-mem .list-head { margin-left: 2px; }
.mell-mem-list { list-style: none; margin: 0; padding: 0; border-radius: 14px; background: var(--fill); overflow: hidden; }
.mell-mem-list li { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 0.5px solid var(--separator); font-size: 15px; transition: opacity 0.2s; }
.mell-mem-list li:last-child { border-bottom: 0; }
.mell-mem-list li.going { opacity: 0.3; }
.mell-mem-list li > span { flex: 1; line-height: 1.45; }
.mell-mem-list.episodes small { display: block; font-size: 12px; color: var(--green-text); font-weight: 600; margin-bottom: 2px; }
.mell-forget { flex: none; width: 28px; height: 28px; border-radius: 50%; color: var(--secondary); font-size: 20px; line-height: 1; }
.mell-forget:hover { background: rgba(255, 59, 48, 0.1); color: var(--red); }
.mell-mem-empty { color: var(--secondary); font-size: 14px; margin: 4px 2px 8px; }
.mell-mem-note { color: var(--secondary); font-size: 13px; line-height: 1.5; margin: 18px 2px; }
@media (prefers-reduced-motion: reduce) { .mell-hero, .mell-blink, .mell-caret, .mell-dots i, .mell-viewer { animation: none !important; } }

/* ---------- @mention + Mell ในกลุ่ม ---------- */
.mention-pop { margin: 0 10px 6px; border-radius: 16px; background: var(--bg); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14); overflow: hidden; }
.mention-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; text-align: left; }
.mention-pop button:hover, .mention-pop button:first-child { background: var(--fill); }
.mention-pop span { display: flex; flex-direction: column; }
.mention-pop small { color: var(--secondary); font-size: 12px; }
.mell-add-row { display: flex; align-items: center; gap: 10px; }
.mell-add-row .label { display: flex; flex-direction: column; color: var(--green-text); }
.mell-add-row small { font-weight: 400; color: var(--secondary); font-size: 12px; }

/* ---------- ความปลอดภัย: รายงาน/บล็อก ---------- */
.safety-link { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 10px; padding: 6px; background: none; border: 0; color: var(--red, #e5484d); font-size: 13px; font-weight: 600; }
.safety-link svg { width: 15px; height: 15px; }
.rep-list { display: grid; gap: 12px; margin-top: 12px; }
.rep { border: 1px solid var(--adm-line); border-radius: 14px; padding: 12px 14px; }
.rep header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rep header small { flex-basis: 100%; color: var(--adm-mute); }
.rep-note { margin: 8px 0; font-style: italic; }
.rep details { margin: 8px 0; }
.rep summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.rep-ev { display: grid; gap: 4px; max-height: 280px; overflow: auto; margin-top: 6px; padding: 8px; background: #f6f8f3; border-radius: 10px; font-size: 13px; }
.rep-ev .ev small { display: block; color: var(--adm-mute); font-size: 11px; }
.rep-ev .ev.target { color: #be123c; }
.rep footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---------- ล็อกอินด้วย Google ---------- */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1px solid #dadce0; text-decoration: none; }
.google-btn:hover { background: #f8f9fa; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 14px 4px 0; color: var(--secondary); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--separator, rgba(0, 0, 0, .12)); }
.field svg[viewBox="0 0 48 48"] { vertical-align: -3px; margin-inline-end: 4px; }

/* ---------- ตอบกลับ / แก้ไข / มาร์คคำ / อ่านแล้ว ---------- */
.msg + .msg:not(.gap) { margin-top: 2px; }
.line { position: relative; }
.msg-act {
  flex: none; align-self: center; width: 28px; height: 28px; margin: 0 4px; border-radius: 50%;
  display: grid; place-items: center; color: var(--chat-muted, var(--secondary)); opacity: 0; transition: opacity .15s;
}
.msg-act:hover { background: var(--fill); }
@media (hover: hover) and (pointer: fine) { .msg:hover .msg-act, .msg-act:focus-visible { opacity: 1; } }
@media not ((hover: hover) and (pointer: fine)) { .msg-act { display: none; } }
.reply-quote {
  display: flex; flex-direction: column; gap: 1px; max-width: min(100%, 360px); margin: 2px 0 3px;
  padding: 6px 12px; border-radius: 14px; border-left: 3px solid var(--chat-accent, var(--green));
  background: color-mix(in srgb, var(--chat-chrome, var(--bg)) 70%, transparent); text-align: left; font-size: 13px; color: var(--label);
}
.theirs .reply-quote { margin-left: var(--tab); }
.mine .reply-quote { margin-right: var(--tab); }
.reply-quote b { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--chat-muted, var(--secondary)); }
.reply-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble mark { background: #fff36b; color: #1c1c1e; border-radius: 4px; padding: 0 1px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.meta .edited { font-style: italic; }
.receipt { margin: 1px calc(var(--tab) + 8px) 0 0; font-size: 11px; font-weight: 600; color: var(--chat-text, var(--green-text)); }
.receipt[data-names] { cursor: pointer; }
.compose-ctx {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--chat-chrome, var(--bg)); border-top: 0.5px solid var(--chat-border, var(--separator));
}
.compose-ctx[hidden] { display: none; }
.compose-ctx > .icon { color: var(--chat-text, var(--green-text)); flex: none; }
.compose-ctx .ctx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; border-left: 3px solid var(--chat-accent, var(--green)); padding-left: 8px; }
.compose-ctx .ctx-body b { font-size: 12px; }
.compose-ctx .ctx-body span { color: var(--secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-menu-preview {
  margin: 4px 4px 8px; padding: 10px 14px; border-radius: 16px; background: var(--fill); font-size: 15px;
  max-height: 6.5em; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mark-text { margin: 14px 2px 10px; font-size: 19px; line-height: 2; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; }
.mark-word { font: inherit; color: inherit; padding: 2px 3px; border-radius: 6px; background: var(--fill); margin: 0 1px; }
.mark-word.on { background: #fff36b; color: #1c1c1e; }
@media (min-width: 900px) { .chat-view .compose-ctx { margin: 0 12px 6px; border-radius: 18px; border: 0.5px solid var(--chat-border); } }
.fix-input { width: 100%; margin-top: 10px; padding: 10px 12px; border-radius: 14px; border: 0.5px solid var(--separator); background: var(--fill); font: inherit; font-size: 16px; resize: vertical; color: var(--label); }

/* ===================== โปรไฟล์มืออาชีพ ===================== */
.profile-head .headline { margin: 6px 16px 0; font-size: 15px; font-weight: 600; color: var(--label); text-align: center; }
.prof-sec-h { margin: 8px 16px 2px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--secondary); }
.prof-sec-sub { margin: 0 16px 8px; font-size: 13px; color: var(--secondary); }
.group select { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--label); text-align: end; appearance: none; padding: 0; }
.prof-tags { padding: 4px 0; }
.tag-field { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.tag-field + .tag-field { border-top: 0.5px solid var(--separator); }
.tag-field > label { font-size: 15px; font-weight: 600; }
.tag-box { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-radius: 12px; background: var(--bg); border: 0.5px solid var(--separator); cursor: text; }
.tag-input { flex: 1; min-width: 120px; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--label); padding: 4px; outline: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 99px; background: var(--green); color: var(--green-ink); font-size: 14px; font-weight: 600; }
.tag-chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; line-height: 1; color: inherit; opacity: .7; }
.tag-chip button:hover { opacity: 1; background: rgba(0,0,0,.08); }
.tag-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-sugg button { padding: 4px 10px; border-radius: 99px; border: 0.5px dashed var(--separator); font-size: 12.5px; color: var(--secondary); }
.tag-sugg button:hover { color: var(--label); border-style: solid; }
.seg-pick, .lang-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-pick label, .lang-pick label { position: relative; }
.seg-pick input, .lang-pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.seg-pick span, .lang-pick span { display: inline-block; padding: 7px 12px; border-radius: 99px; border: 0.5px solid var(--separator); font-size: 14px; cursor: pointer; }
.seg-pick input:checked + span, .lang-pick input:checked + span { background: var(--label); color: var(--bg); border-color: var(--label); font-weight: 600; }
.seg-pick input:focus-visible + span, .lang-pick input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }
/* การ์ดโปรไฟล์มืออาชีพ (ชื่อ class แยกจาก .pro-card ของหน้า Melloq Pro ที่เป็นพื้นเขียวเข้ม) */
.prof-card { padding: 14px 16px; border-radius: 16px; background: var(--bg); color: var(--label); }
.pro-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.pro-meta span { padding: 4px 10px; border-radius: 99px; background: var(--fill); color: var(--label); font-size: 13px; font-weight: 600; }
.pro-meta .role { background: var(--green); color: var(--green-ink); }
.prof-card h4 { margin: 12px 0 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--secondary); }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip { padding: 4px 10px; border-radius: 99px; background: var(--fill); color: var(--label); border: 0.5px solid var(--separator); font-size: 13px; }
.pchip.teach { background: #e9f8df; border-color: #c6ebb0; color: #1f4a0b; }
.pchip.learn { background: #eef2ff; border-color: #cdd7ff; color: #23306b; }

/* ===================== Connect: waitlist + เดโม ===================== */
/* ทิศทาง: ใช้ภาษาเดียวกับแอพ (หน้าเรียบ สีเขียวใบไม้ เส้นบาง) · ข้อความชิดซ้ายอ่านง่าย · เดโมคือ "ภาพหน้าจอที่ขยับได้" ไม่ใช่โปสเตอร์ */
.cx-page { padding: 16px 16px 40px; }
.cx { display: grid; gap: 28px; max-width: 1040px; margin: 0 auto; }
.cx-copy h1 { margin: 4px 0 10px; font-size: clamp(28px, 6vw, 38px); line-height: 1.12; letter-spacing: -.02em; }
.cx-lead { margin: 0; font-size: 16.5px; line-height: 1.55; color: var(--secondary); max-width: 46ch; }
.cx-access { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 18px; }
.cx-access small { color: var(--secondary); font-size: 13px; }
.cx-steps { list-style: none; margin: 22px 0 0; padding: 0; border-top: 0.5px solid var(--separator); }
.cx-steps li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 0.5px solid var(--separator); }
.cx-steps li > span { flex: none; width: 18px; font-size: 14px; font-weight: 700; color: var(--green-text); font-variant-numeric: tabular-nums; }
.cx-steps p { margin: 0; font-size: 14.5px; line-height: 1.45; color: var(--secondary); }
.cx-steps b { display: block; color: var(--label); font-size: 15px; }
.cx-safe { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--secondary); max-width: 52ch; }
.cx-safe b { color: var(--label); }
.cx-cta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 20px; }
.cx-in { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--green-text); }
.cx-count { margin: 10px 0 0; font-size: 13px; color: var(--secondary); }
.cx-demo { display: flex; flex-direction: column; align-items: center; }
.phone { position: relative; display: flex; flex-direction: column; width: min(300px, 84vw); padding: 10px 12px 14px; border-radius: 30px;
  background: var(--bg); border: 0.5px solid var(--separator); box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 18px 40px -18px rgba(23, 52, 4, .35); }
.phone-bar { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 6px 10px; font-size: 15px; }
.phone-bar small { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--secondary); text-transform: uppercase; }
.deck { position: relative; aspect-ratio: 3 / 4.3; }
.phone .deck { aspect-ratio: auto; flex: 1; min-height: 360px; }
.mcard { position: absolute; inset: 0; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--bg);
  border: 0.5px solid var(--separator); transition: transform .45s cubic-bezier(.3,.8,.4,1), opacity .45s; touch-action: pan-y; user-select: none; }
.mcard.dragging { transition: none; }
.mcard.out-r { transform: translateX(120%) rotate(12deg); opacity: 0; }
.mcard.out-l { transform: translateX(-120%) rotate(-12deg); opacity: 0; }
.mc-photo { position: relative; flex: 1.2; min-height: 0; background: var(--fill); }
.mc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.mc-photo.none { display: grid; place-items: center; }
.mc-photo.none .avatar { width: 96px; height: 96px; font-size: 38px; }
.mc-stamp { position: absolute; top: 14px; padding: 3px 9px; border: 2px solid; border-radius: 6px; font-size: 15px; font-weight: 800; opacity: 0; transition: opacity .15s; background: var(--bg); }
.mc-stamp.like { left: 14px; color: var(--green-text); transform: rotate(-8deg); }
.mc-stamp.nope { right: 14px; color: var(--secondary); transform: rotate(8deg); }
.mcard[data-dir="r"] .mc-stamp.like, .mcard.out-r .mc-stamp.like, .mcard[data-dir="l"] .mc-stamp.nope, .mcard.out-l .mc-stamp.nope { opacity: 1; }
.mc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.mc-body h3 { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 6px; }
.mc-title { margin: 0; font-size: 14px; font-weight: 600; }
.mc-meta { margin: 0; font-size: 12.5px; color: var(--secondary); }
.mc-row { margin: 4px 0 0; font-size: 13px; line-height: 1.4; }
.mc-row small { display: block; font-size: 11.5px; font-weight: 600; color: var(--secondary); }
.deck-btns { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 12px; }
.dbtn { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); border: 0.5px solid var(--separator); color: var(--secondary); transition: transform .15s, background .15s; }
.dbtn .icon { width: 24px; height: 24px; stroke-width: 2.2; }
.dbtn.like { background: var(--green); border-color: transparent; color: var(--green-ink); }
.dbtn.report { width: 38px; height: 38px; }
.dbtn.report .icon { width: 16px; height: 16px; stroke-width: 1.8; }
.dbtn.hit, .dbtn:active { transform: scale(1.12); }
.demo-match { position: absolute; left: 22px; right: 22px; bottom: 82px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px;
  background: var(--label); color: var(--bg); font-size: 13px; animation: cx-in .25s ease-out; }
.demo-match .icon { color: var(--green); }
@keyframes cx-in { from { transform: translateY(6px); opacity: 0; } }
.cx-credit { margin: 12px 0 0; max-width: 320px; font-size: 11px; line-height: 1.45; text-align: center; color: var(--secondary); }
.cx-credit a { color: inherit; }
/* คอม: ข้อความซ้าย เดโมขวา อ่านจบในจอเดียว ไม่ต้องเลื่อน */
@media (min-width: 900px) {
  .cx-page { display: flex; align-items: center; padding: 20px 40px; overflow: auto; }
  .cx { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 56px; width: 100%; }
  .phone { width: auto; height: min(600px, calc(100vh - 160px)); aspect-ratio: 300 / 600; }
  .phone .deck { min-height: 0; }
}
@media (min-width: 900px) and (max-height: 720px) {
  .cx-copy h1 { font-size: 30px; }
  .cx-steps li { padding: 8px 0; }
  .cx-lead { font-size: 15px; }
}

/* ===================== Connect: ของจริง ===================== */
.match-app { padding: 12px 16px 40px; }
.match-app .deck { width: min(360px, 100%); margin: 8px auto 0; }
.match-setup, .match-empty { max-width: 440px; margin: 16px auto; display: grid; gap: 12px; }
.match-setup h2, .match-empty h2 { margin: 0; font-size: 22px; }
.match-setup p, .match-empty p { margin: 0; color: var(--secondary); }
.checklist { list-style: none; margin: 0; padding: 0; border-top: 0.5px solid var(--separator); }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 0.5px solid var(--separator); color: var(--secondary); }
.checklist li.ok { color: var(--label); }
.checklist li .icon { color: var(--green-text); }
.checklist li i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--separator); }
.match-on { border-radius: 14px; background: var(--fill); }
.mp-avatars { display: flex; justify-content: center; margin-bottom: 8px; }
.mp-avatars .avatar + .avatar { margin-left: -18px; box-shadow: 0 0 0 4px var(--bg); }
.match-pop-in { text-align: center; }
.match-pop-in h2 { margin: 6px 0; font-size: 24px; }
.match-pop-in p { margin: 0 0 14px; color: var(--secondary); }

/* ===================== แพ็กเกจและราคา ===================== */
.pricing { padding: 16px 16px 40px; }
.pr-wrap { max-width: 1080px; margin: 0 auto; }
.pr-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.pr-head h1 { margin: 0 0 6px; font-size: clamp(24px, 5vw, 32px); letter-spacing: -.02em; }
.pr-head p { margin: 0; color: var(--secondary); max-width: 52ch; }
.pr-toggle { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--fill); }
.pr-toggle button { padding: 6px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--secondary); }
.pr-toggle button[aria-pressed="true"] { background: var(--bg); color: var(--label); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 20px; }
.pr-card { display: flex; flex-direction: column; padding: 16px; border-radius: 16px; background: var(--bg); border: 0.5px solid var(--separator); }
.pr-card.best { border: 1.5px solid var(--green); }
.pr-card h2 { margin: 0; font-size: 17px; }
.pr-card h2 small { margin-left: 4px; font-size: 12px; font-weight: 700; color: var(--green-text); }
.pr-for { margin: 4px 0 0; font-size: 13px; color: var(--secondary); min-height: 2.7em; }
.pr-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px; margin: 10px 0 12px; }
.pr-price b { font-size: 28px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pr-price small { font-size: 13px; color: var(--secondary); }
.pr-price em { flex-basis: 100%; font-style: normal; font-size: 12px; font-weight: 600; color: var(--green-text); }
.pr-card ul { margin: 0 0 14px; padding: 12px 0 0; list-style: none; display: grid; align-content: start; gap: 8px; flex: 1; font-size: 14px; border-top: 0.5px solid var(--separator); }
.pr-card li { display: flex; gap: 8px; line-height: 1.35; }
.pr-card li .icon { flex: none; margin-top: 2px; color: var(--green-text); }
.pr-current { margin: 0; padding: 10px 0; text-align: center; font-size: 14px; color: var(--secondary); }
.pr-done .icon { vertical-align: -3px; }
.pr-foot { margin: 16px 0 0; font-size: 12.5px; color: var(--secondary); }
.adm-li-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: start; }

/* แถวหน้าโปรไฟล์: อิโมจิหน้าข้อความ · ป้าย New */
.row-em { display: inline-block; width: 1.6em; margin-right: 2px; text-align: center; }
.new-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: var(--green); color: var(--green-ink); font-size: 10.5px; font-weight: 800; letter-spacing: .02em; vertical-align: 2px; }
.rail-btn .rail-new { position: absolute; top: 2px; right: -4px; padding: 0 4px; border-radius: 5px; background: var(--green); color: #173404; font-size: 8.5px; font-weight: 800; line-height: 13px; letter-spacing: .02em; box-shadow: 0 0 0 2px #131a10; }
.tag-sugg button { border: 0; background: var(--fill); }
.field .label:has(> .row-em) { display: flex; align-items: center; width: auto; flex: 1; min-width: 0; }
.field .label:has(> .row-em) .row-em { flex: none; }
.toggle-row .label:has(> .row-em) { flex-direction: row; }

/* ---------- ห้องลับ /bomb ---------- */
.bomb-view { display: flex; flex-direction: column; height: 100%; }
.bomb-bar .title { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.bomb-bar .title small { font-size: 12px; font-weight: 600; color: #d4380d; font-variant-numeric: tabular-nums; }
.bomb-actions { display: flex; align-items: center; gap: 6px; justify-self: end; }
.bomb-actions .btn { white-space: nowrap; }
.bomb-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bomb-info { padding: 10px 16px 0; }
.bomb-note { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--fill); font-size: 13px; color: var(--secondary); text-align: center; }
.bomb-code-card { padding: 18px 16px; border-radius: 18px; background: var(--fill); text-align: center; }
.bomb-code-card p { margin: 0 0 10px; font-size: 14px; }
.bomb-code-card .muted { margin: 10px 0 0; font-size: 13px; }
.bomb-code { font: 800 34px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.18em; padding: 14px 18px; border-radius: 14px; border: 2px dashed var(--green); background: var(--bg, #fff); color: var(--fg); cursor: pointer; }
.bomb-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.bomb-empty { margin: auto; max-width: 320px; text-align: center; font-size: 13px; color: var(--secondary); }
.bomb-msg { max-width: min(560px, 85%); padding: 8px 12px 10px; border-radius: 16px; background: var(--fill); align-self: flex-start; }
.bomb-msg.mine { align-self: flex-end; background: var(--green); color: var(--green-ink); }
.bomb-who { display: block; font-size: 11px; opacity: 0.7; margin-bottom: 4px; }
.bomb-text { margin: 0; white-space: pre-wrap; word-break: break-word; font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.bomb-copy { font-size: 12px; margin-top: 4px; color: inherit; opacity: 0.75; }
.bomb-file { display: flex; align-items: center; gap: 10px; padding: 6px 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.bomb-file span { display: flex; flex-direction: column; min-width: 0; }
.bomb-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.bomb-file small { font-size: 12px; opacity: 0.75; }
.bomb-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--separator, rgba(0, 0, 0, 0.08)); }
.bomb-compose textarea { flex: 1; min-height: 40px; max-height: 160px; resize: vertical; padding: 10px 12px; border-radius: 18px; border: 0; background: var(--fill); color: inherit; font: 14px/1.4 inherit; }
.bomb-compose .act, .bomb-compose .send { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 0; background: var(--fill); color: inherit; cursor: pointer; }
.bomb-compose .send { background: var(--green); color: var(--green-ink); }
.bomb-compose .send:disabled { opacity: 0.4; }
.bomb-icon { font-size: 20px; }
.bomb-safety-code { display: block; margin: 6px 0; font: 800 24px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.08em; color: var(--fg); }
