/* ==========================================================================
   Pacific — ธีมของระบบแชท
   ภาพประกอบ (ไม่บังคับ) วางไว้ใน public/img/ แล้วระบบจะใช้ให้อัตโนมัติ:
   logo.png, login-hero.jpg, empty-chat.png
   ========================================================================== */
:root {
  --deep: #0B2D3F;        /* ทะเลลึก: แถบด้านข้าง, หัวหน้าแอดมิน */
  --deep-2: #12394D;
  --deep-3: #1A4A61;
  --tide: #0E7C7B;        /* สีหลัก: ปุ่ม, ข้อความของเรา */
  --tide-2: #0A6463;
  --tide-soft: #D3EAE6;
  --foam: #EAF2EF;        /* พื้นห้องแชท */
  --paper: #FFFFFF;
  --paper-2: #F5F9F7;
  --sun: #F4B63F;         /* จำนวนข้อความที่ยังไม่อ่าน */
  --ink: #142630;
  --muted: #5D6F78;
  --line: #D5E1DE;
  --danger: #C2412F;
  --ok: #1F8A5B;
  --side-text: #DCE8EA;
  --side-muted: #8FAAB4;

  --bg: var(--foam);
  --panel: var(--paper);
  --panel-2: var(--paper-2);
  --text: var(--ink);
  --accent: var(--tide);
  --accent-2: var(--tide-2);
  --accent-soft: var(--tide-soft);

  --font-ui: "IBM Plex Sans Thai", "Leelawadee UI", "Thonburi", "Noto Sans Thai", system-ui, sans-serif;
  --font-display: "Bai Jamjuree", "IBM Plex Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow-pop: 0 18px 50px -12px rgba(11, 45, 63, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --deep: #06161F;
    --deep-2: #0C2230;
    --deep-3: #143244;
    --tide: #2AA19E;
    --tide-2: #45B8B4;
    --tide-soft: #123B3D;
    --foam: #0B1C25;
    --paper: #102632;
    --paper-2: #0D202B;
    --ink: #E3EEEC;
    --muted: #8FA6AE;
    --line: #1F3C4B;
    --danger: #E0634F;
    --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; background: var(--tide); color: #fff;
  padding: 9px 18px; border-radius: 999px; font-weight: 600; letter-spacing: .01em;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--tide-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #A33626; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.icon-btn {
  background: transparent; border: 0; width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; color: inherit;
}
.icon-btn:hover { background: rgba(127, 160, 170, .18); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--tide); box-shadow: 0 0 0 3px var(--tide-soft);
}
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--tide); }

/* ------------------------------------------------ toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--deep); color: #fff; padding: 11px 16px; border-radius: var(--r);
  box-shadow: var(--shadow-pop); max-width: 360px; font-size: 14px; border-left: 4px solid var(--tide);
  animation: rise .22s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--sun); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------ modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(6, 22, 31, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px;
}
.modal {
  background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: 100%; max-width: 460px;
  max-height: calc(100vh - 32px); overflow: auto; padding: 24px; animation: rise .2s ease-out;
}
.modal h2 { margin: 0 0 18px; font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.member-pick { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 12px; background: var(--panel-2); }
.member-pick .check { display: flex; padding: 6px 0; }

/* ------------------------------------------------ brand mark */
.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.01em; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(160deg, var(--tide) 0%, var(--deep-3) 100%);
  display: grid; place-items: center; color: #fff; font-size: 19px;
  background-size: cover; background-position: center;
}
.has-logo .logo-mark { background-image: var(--art-logo); color: transparent; font-size: 0; }

/* ------------------------------------------------ login */
.login-wrap { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); background: var(--panel); }
.login-art {
  position: relative; overflow: hidden; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 48px 56px;
  background:
    radial-gradient(120% 70% at 85% 0%, rgba(244, 182, 63, .35), transparent 60%),
    repeating-radial-gradient(ellipse at 50% 140%, transparent 0 34px, rgba(255, 255, 255, .05) 35px 37px),
    linear-gradient(175deg, #0E7C7B 0%, #0B2D3F 70%);
}
.has-hero .login-art { background: var(--art-hero) center / cover no-repeat, var(--deep); }
.login-art::after { /* ทำให้ตัวอักษรอ่านง่ายบนภาพ */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(6, 22, 31, .78) 0%, rgba(6, 22, 31, .15) 55%, transparent 100%);
}
.login-art > * { position: relative; z-index: 1; }
.login-art h1 {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(40px, 5.2vw, 72px);
  line-height: 1.02; letter-spacing: -.02em; margin: 0 0 14px; max-width: 12ch;
}
.login-art p { margin: 0; font-size: 17px; max-width: 34ch; color: rgba(255, 255, 255, .86); }
.login-side { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .logo { margin-bottom: 26px; }
.login-card h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin: 0 0 4px; }
.login-card p.sub { margin: 0 0 26px; color: var(--muted); font-size: 15px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-bottom: 6px; }
.switch-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.switch-link a { cursor: pointer; font-weight: 600; }
@media (max-width: 820px) {
  .login-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-art { min-height: 220px; padding: 28px 24px; }
  .login-art h1 { font-size: 38px; }
  .login-art p { font-size: 15px; }
  .login-side { align-items: flex-start; padding: 28px 20px 40px; }
}

/* ------------------------------------------------ chat layout */
.app { display: flex; height: 100%; overflow: hidden; }
.sidebar {
  width: 296px; flex-shrink: 0; background: var(--deep); color: var(--side-text);
  display: flex; flex-direction: column; overflow: hidden;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.side-head .logo { font-size: 19px; margin: 0; color: #fff; }
.side-head .logo-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 14px; scrollbar-color: var(--deep-3) transparent; }
.side-section { margin-top: 16px; }
.side-section h3 {
  display: flex; align-items: center; justify-content: space-between; margin: 0 8px 6px;
  font-size: 13px; color: var(--side-muted); font-weight: 600;
}
.side-section h3 .icon-btn { width: 26px; height: 26px; font-size: 18px; color: var(--side-muted); }
.side-section h3 .icon-btn:hover { color: #fff; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; cursor: pointer;
  color: var(--side-text); position: relative; transition: background .12s;
}
.side-item:hover { background: var(--deep-2); }
.side-item.active { background: #EAF2EF; color: #0B2D3F; }
.side-item.active .ico { color: #0E7C7B; opacity: 1; }
.side-item .ico { width: 22px; text-align: center; opacity: .7; flex-shrink: 0; font-weight: 600; }
.side-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .sub { display: block; font-size: 12px; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item.active .sub { color: #5D6F78; }
.badge { background: var(--sun); color: #3A2600; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #3E5A68; flex-shrink: 0; }
.dot.on { background: #3DDC97; box-shadow: 0 0 0 3px rgba(61, 220, 151, .18); }
.side-search {
  margin: 0 6px 8px; width: calc(100% - 12px); background: var(--deep-2); border: 1px solid transparent;
  color: var(--side-text); padding: 8px 12px; border-radius: 10px; outline: none;
}
.side-search::placeholder { color: var(--side-muted); }
.side-search:focus { border-color: var(--tide); }
.me-box { border-top: 1px solid rgba(255, 255, 255, .07); padding: 12px 14px; display: flex; align-items: center; gap: 10px; background: rgba(0, 0, 0, .12); }
.me-box .who { flex: 1; min-width: 0; }
.me-box .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; }
.me-box .who span { font-size: 12px; color: var(--side-muted); }
.me-box .icon-btn { color: var(--side-muted); }
.me-box .icon-btn:hover { color: #fff; }
.avatar {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 700;
  color: #fff; flex-shrink: 0; font-size: 15px; text-transform: uppercase; font-family: var(--font-display);
}

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg); }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); min-height: 64px;
}
.chat-head .title { flex: 1; min-width: 0; }
.chat-head .title b {
  font-family: var(--font-display); font-size: 19px; font-weight: 600; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.005em;
}
.chat-head .title span { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menuBtn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 2px; }
.load-more { align-self: center; margin: 4px 0 10px; }
.day-sep {
  align-self: stretch; display: flex; align-items: center; gap: 12px; margin: 16px 0 8px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: flex; gap: 10px; max-width: 76%; margin-top: 10px; }
.msg.cont { margin-top: 2px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.cont .meta { display: none; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .body { min-width: 0; display: flex; flex-direction: column; }
.msg.me .body { align-items: flex-end; }
.msg .meta { font-size: 12px; color: var(--muted); margin: 0 4px 3px; }
.msg .meta b { color: var(--text); font-weight: 600; margin-right: 6px; }
.bubble {
  background: var(--panel); border: 1px solid var(--line); padding: 8px 13px;
  border-radius: 16px 16px 16px 5px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; position: relative;
}
.msg.cont:not(.me) .bubble { border-radius: 5px 16px 16px 5px; }
.msg.me .bubble { background: var(--tide); color: #fff; border-color: transparent; border-radius: 16px 16px 5px 16px; }
.msg.me.cont .bubble { border-radius: 16px 5px 5px 16px; }
.msg.me .bubble a { color: #fff; }
.bubble .time { font-size: 11px; opacity: .6; margin-left: 10px; float: right; margin-top: 5px; }
.msg-actions { align-self: center; flex-shrink: 0; }
.del-btn {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  background: var(--panel); border: 1px solid var(--line); color: var(--danger);
  box-shadow: 0 1px 2px rgba(11, 45, 63, .08); transition: background .12s, color .12s, border-color .12s;
}
.del-btn:hover, .del-btn:focus-visible { background: var(--danger); border-color: var(--danger); color: #fff; }

.file-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; min-width: 230px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; margin-bottom: 4px;
  transition: border-color .15s;
}
.file-card:hover { border-color: var(--tide); }
.file-card .fi { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--tide-soft); font-size: 20px; flex-shrink: 0; }
.file-card .fn { flex: 1; min-width: 0; }
.file-card .fn b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.file-card .fn span { font-size: 12px; color: var(--muted); }
.file-card .dl { font-size: 18px; color: var(--tide); }
.file-card.locked { opacity: .7; cursor: not-allowed; }
.file-card.deleted { opacity: .55; font-style: italic; }
.img-wrap { display: block; margin-bottom: 4px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); max-width: 340px; background: var(--panel); }
.img-wrap img { display: block; max-width: 100%; max-height: 320px; object-fit: contain; }
.img-wrap video, .img-wrap audio { display: block; max-width: 100%; }
.img-cap { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; padding: 6px 10px; color: var(--muted); }

.storage-banner { background: #FDF1D4; color: #6B4A06; border-bottom: 1px solid #F1DCA4; padding: 9px 20px; font-size: 13px; }
@media (prefers-color-scheme: dark) { .storage-banner { background: #3A2C0A; color: #F7D98B; border-color: #5A4512; } }
.typing { height: 22px; padding: 0 24px; font-size: 13px; color: var(--muted); font-style: italic; }
.upload-bar { padding: 0 18px; }
.upload-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 12px; margin-bottom: 6px; font-size: 13px; }
.upload-item .bar { height: 5px; border-radius: 9px; background: var(--line); overflow: hidden; margin-top: 5px; }
.upload-item .bar i { display: block; height: 100%; background: var(--tide); width: 0; transition: width .1s; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 18px 16px; background: var(--bg); }
.composer .box {
  flex: 1; display: flex; align-items: flex-end; gap: 4px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 22px; padding: 4px 8px;
}
.composer .box:focus-within { border-color: var(--tide); box-shadow: 0 0 0 3px var(--tide-soft); }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; padding: 8px 4px; max-height: 160px; min-height: 22px; }
.composer .btn { height: 46px; padding: 0 22px; }
.readonly-note { text-align: center; color: var(--muted); padding: 14px; font-size: 14px; border-top: 1px solid var(--line); }

.drop-overlay {
  position: absolute; inset: 0; background: rgba(14, 124, 123, .12); border: 3px dashed var(--tide);
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--tide);
  z-index: 50; pointer-events: none; border-radius: 12px; margin: 8px; font-family: var(--font-display);
}
.empty { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px; }
.empty .big { font-size: 44px; }
.empty b { color: var(--text); font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.empty-art { width: 240px; height: 180px; margin-bottom: 10px; display: grid; place-items: center; font-size: 56px; }
.has-empty .empty-art { background: var(--art-empty) center / contain no-repeat; font-size: 0; }

.side-backdrop { display: none; }
@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 200; transform: translateX(-100%); transition: transform .2s; width: 86%; max-width: 320px; }
  .sidebar.open { transform: none; }
  .side-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(6, 22, 31, .5); z-index: 150; }
  #menuBtn { display: inline-flex; }
  .chat-head { padding: 10px 12px; }
  .msg { max-width: 92%; }
  .messages { padding: 12px 12px 6px; }
  .composer { padding: 8px 10px 12px; }
  .empty-art { width: 180px; height: 135px; }
}

/* ------------------------------------------------ admin */
.admin-top { background: var(--deep); color: var(--side-text); display: flex; align-items: center; gap: 18px; padding: 12px 24px; flex-wrap: wrap; }
.admin-top .logo { font-size: 19px; margin: 0; color: #fff; }
.admin-top .logo-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab { background: transparent; border: 0; color: var(--side-muted); padding: 8px 15px; border-radius: 999px; font-weight: 600; }
.tab:hover { color: #fff; background: var(--deep-2); }
.tab.active { background: #EAF2EF; color: #0B2D3F; }
.admin-top a.btn { text-decoration: none; }
.admin-top .btn.ghost { color: #fff; border-color: var(--deep-3); }
.admin-top .btn.ghost:hover { background: var(--deep-2); }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 26px 24px 64px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 18px; }
.card h2 {
  margin: 0 0 14px; font-family: var(--font-display); font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stat { padding: 16px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.stat span { font-size: 13px; color: var(--muted); }
.stat b { display: block; font-family: var(--font-display); font-size: 30px; font-weight: 600; margin: 2px 0; color: var(--deep); line-height: 1.15; }
@media (prefers-color-scheme: dark) { .stat b { color: var(--tide-2); } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:hover td { background: var(--panel-2); }
.perm-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.perm-grid .check { font-size: 13px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.admin { background: #FDF1D4; color: #6B4A06; border-color: #F1DCA4; }
.pill.off { background: #FBE3DE; color: #8E2A1C; border-color: #F2C3B9; }
.pill.on { background: var(--tide-soft); color: var(--tide-2); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .pill.admin { background: #3A2C0A; color: #F7D98B; border-color: #5A4512; }
  .pill.off { background: #3D1A14; color: #F3A99B; border-color: #5B2A21; }
}
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; align-items: end; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input { max-width: 260px; }
.card h2 .input { font-family: var(--font-ui); font-size: 14px; font-weight: 400; padding: 8px 12px; }
.has-empty .empty-art { background-size: cover; border-radius: 20px; }

/* ------------------------------------------------ หน้าดาวน์โหลดไฟล์ที่แชร์ */
.share-page { background: var(--deep); min-height: 100%; }
.share-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 18px; }
.share-brand { color: #fff; font-size: 19px; }
.share-brand .logo-mark { width: 32px; height: 32px; font-size: 16px; }
.share-card {
  width: 100%; max-width: 420px; background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: 30px 26px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.share-card h1 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 6px 0 0; }
.share-name { overflow-wrap: anywhere; }
.share-card p { margin: 0; }
.share-icon { width: 72px; height: 72px; border-radius: 18px; background: var(--tide-soft); display: grid; place-items: center; font-size: 36px; }
.share-preview { max-width: 100%; max-height: 260px; border-radius: 12px; border: 1px solid var(--line); object-fit: contain; }
.share-dl { width: 100%; padding: 12px; font-size: 16px; margin: 14px 0 6px; text-decoration: none; }
.share-dl[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.share-form { width: 100%; text-align: left; margin-top: 12px; }
.share-form .share-dl { margin-top: 2px; }
.share-foot { color: var(--side-muted); text-align: center; max-width: 420px; }

/* ปุ่มและหน้าต่างแชร์ลิงก์ */
.file-wrap { display: flex; flex-direction: column; align-items: inherit; }
.msg.me .file-wrap { align-items: flex-end; }
.file-share { margin: -2px 4px 4px; }
.share-btn { background: none; border: 0; padding: 2px 4px; color: var(--tide); font-size: 12px; font-weight: 600; cursor: pointer; }
.share-btn:hover { text-decoration: underline; }
.cap-actions { display: inline-flex; gap: 10px; align-items: center; white-space: nowrap; }
.share-result { margin-top: 16px; padding: 12px; border-radius: var(--r); background: var(--tide-soft); }
.share-link-row { display: flex; gap: 8px; margin-top: 8px; }
.share-link-row .input { flex: 1; font-size: 13px; }
.share-existing { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.share-item { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.share-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------ สติกเกอร์ */
.sticker { display: block; margin: 2px 0; }
.sticker-img { width: 140px; height: 140px; object-fit: contain; }
.sticker-emoji { font-size: 76px; line-height: 1.1; }
.sticker-time { font-size: 11px; color: var(--muted); margin: 0 4px; }
.sticker-panel {
  margin: 0 18px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); overflow: hidden; animation: rise .15s ease-out;
}
.sticker-tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; background: var(--panel-2); }
.sticker-tabs button {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; border: 1px solid transparent; background: none;
  border-radius: 10px; padding: 4px 10px; font-size: 13px; color: var(--muted); font-weight: 600;
}
.sticker-tabs button img { width: 24px; height: 24px; object-fit: contain; }
.sticker-tabs button:first-child { font-size: 20px; padding: 2px 8px; }
.sticker-tabs button.active { background: var(--panel); border-color: var(--line); color: var(--text); }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; padding: 10px; max-height: 260px; overflow-y: auto; }
.sticker-grid.emoji { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
.sticker-grid button { border: 0; background: none; border-radius: 12px; padding: 6px; display: grid; place-items: center; }
.sticker-grid button:hover, .sticker-grid button:focus-visible { background: var(--tide-soft); }
.sticker-grid button img { width: 80px; height: 80px; object-fit: contain; }
.sticker-grid.emoji button { font-size: 32px; padding: 4px; }
@media (max-width: 760px) { .sticker-panel { margin: 0 10px 6px; } .sticker-img { width: 120px; height: 120px; } }

.admin-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.admin-sticker { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); }
.admin-sticker img { width: 84%; height: 84%; object-fit: contain; }
.admin-sticker .del-btn { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; font-size: 12px; }

/* ------------------------------------------------ แผงด้านข้าง: ค้นหา / ไฟล์ในห้อง */
.chat-head .icon-btn.on { background: var(--tide-soft); color: var(--tide); }
.chat-head .icon-btn svg { display: block; }
.drawer {
  position: absolute; top: 64px; right: 0; bottom: 0; width: 360px; z-index: 40;
  background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  box-shadow: -12px 0 30px -18px rgba(11, 45, 63, .35); animation: slidein .16s ease-out;
}
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.chat.with-drawer .messages, .chat.with-drawer .composer, .chat.with-drawer .typing, .chat.with-drawer .upload-bar, .chat.with-drawer .sticker-panel { margin-right: 360px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.drawer-head b { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; }
.drawer-search { padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.drawer-hint { padding: 10px 18px; margin: 0; }
.search-hit {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 10px 18px; color: var(--text);
}
.search-hit:hover, .search-hit:focus-visible { background: var(--panel-2); }
.search-meta { font-size: 12px; color: var(--muted); }
.search-meta b { color: var(--text); }
.search-text { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.search-file { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
mark { background: #FCE7A8; color: inherit; border-radius: 3px; padding: 0 1px; }
@media (prefers-color-scheme: dark) { mark { background: #6B5310; } }
.msg.flash .bubble, .msg.flash .file-card, .msg.flash .img-wrap, .msg.flash .sticker { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--sun); } 100% { box-shadow: 0 0 0 0 transparent; } }
.file-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.file-tabs button { flex: 1; border: 1px solid transparent; background: none; border-radius: 999px; padding: 6px 4px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.file-tabs button span { font-weight: 400; opacity: .8; }
.file-tabs button.active { background: var(--tide-soft); color: var(--tide-2); }
.file-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px; }
.file-thumb { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; border: 1px solid var(--line); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb:hover { border-color: var(--tide); }
.file-thumb.locked { color: var(--muted); }
.file-list { padding: 4px 0; }
.file-row { display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.file-row .fi { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--tide-soft); font-size: 19px; flex-shrink: 0; }
.file-row .fn { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.file-row .fn b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fn > span { font-size: 12px; color: var(--muted); }
.file-row-actions { display: flex; gap: 10px; align-items: center; margin-top: 2px; font-size: 12px; }
.file-row-actions a { font-weight: 600; }
@media (max-width: 1100px) { .chat.with-drawer .messages, .chat.with-drawer .composer, .chat.with-drawer .typing, .chat.with-drawer .upload-bar, .chat.with-drawer .sticker-panel { margin-right: 0; } }
@media (max-width: 760px) { .drawer { width: 100%; top: 56px; } }
