/* ==========================================================================
   Korat Next-Gen Social Feed — Perfect Responsive Glassmorphism Design
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Color Palette */
  --bg-app: #070814;
  --bg-card: rgba(15, 16, 32, 0.75);
  --bg-card-hover: rgba(22, 24, 48, 0.88);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-input-focus: rgba(255, 255, 255, 0.09);
  --bg-rail: rgba(10, 11, 24, 0.8);
  --bg-header: rgba(7, 8, 20, 0.85);

  /* Borders & Dividers */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(139, 61, 255, 0.5);

  /* Typography Colors */
  --text-main: #F8F9FC;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;

  /* Accent & Gradients */
  --accent-pink: #FF3B88;
  --accent-purple: #8B3DFF;
  --accent-blue: #3B82F6;
  --accent-green: #10B981;
  --brand-gradient: linear-gradient(135deg, #FF3B88 0%, #8B3DFF 52%, #3B82F6 100%);
  --brand-hover: linear-gradient(135deg, #FF5499 0%, #9C54FF 52%, #5492F6 100%);
  --brand-glow: 0 4px 20px rgba(139, 61, 255, 0.4);

  /* Shadows & Radius */
  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.1);
  --modal-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Fonts */
  --font-main: "Noto Sans Thai", "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", "Noto Sans Thai", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-app: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input: #F8FAFC;
  --bg-input-focus: #F1F5F9;
  --bg-rail: #FFFFFF;
  --bg-header: rgba(255, 255, 255, 0.96);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --text-main: #0F172A;
  --text-muted: #475569;
  --text-dim: #64748B;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.1);
  --modal-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.25);
}

/* Reset & Global Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg-app); color: var(--text-main); font-family: var(--font-main); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }
input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* Layout Shell — Compact 210px Left Rail */
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 0 12px;
}

/* Left Navigation Rail */
.left-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  gap: 14px;
  z-index: 30;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: transform 0.2s ease;
}
.brand-logo:hover { transform: scale(1.03); }
.brand-logo-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--brand-glow);
}
.logo-text { font-family: var(--font-display); font-size: 20px; font-weight: 800; background: var(--brand-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* Structured Glass Menu Box with Row Dividers */
.nav-menu {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: var(--card-shadow);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--border);
}
.nav-item:last-child { border-bottom: none; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; transition: transform 0.2s ease, color 0.2s ease; }
.nav-item:hover { background: var(--bg-input-focus); color: var(--text-main); transform: translateX(2px); }
.nav-item.active {
  background: var(--brand-gradient);
  color: #FFFFFF !important;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(139, 61, 255, 0.38);
  border-color: transparent;
}
.nav-item.active svg { color: #FFFFFF !important; transform: scale(1.08); }

.icon-wrap { position: relative; display: inline-flex; }
.badge-dot {
  position: absolute;
  top: -2px; right: -2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #FF3B88;
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.badge-num {
  position: absolute;
  top: -5px; right: -9px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: #FF3B88;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.btn-create-post {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--brand-glow);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.btn-create-post svg { width: 18px !important; height: 18px !important; flex-shrink: 0; }
.btn-create-post:hover { background: var(--brand-hover); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(139, 61, 255, 0.5); }

/* Left Rail Frosted Mini Widget Card */
.rail-mini-card {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
}
.rail-mini-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}
.mini-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mini-card-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  box-shadow: var(--brand-glow);
}
.mini-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}
.mini-card-progress-wrap {
  height: 5px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 2px;
}
.mini-progress-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: 5px;
}
.mini-card-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.user-profile-pill {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all 0.2s ease;
}
.user-profile-pill:hover { background: var(--bg-card-hover); border-color: var(--border-strong); }
.avatar-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified-icon { width: 15px; height: 15px; color: var(--accent-blue); flex-shrink: 0; }
.user-handle { font-size: 12px; color: var(--text-dim); }
.more-options { color: var(--text-dim); padding: 4px; border-radius: 50%; flex-shrink: 0; }

/* Feed Sub-Tabs (สำหรับคุณ / กำลังติดตาม) */
.feed-sub-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 56px;
  z-index: 25;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.sub-tab-item {
  flex: 1;
  text-align: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}
.sub-tab-item:hover {
  color: var(--text-main);
  background: var(--bg-input-focus);
}
.sub-tab-item.active {
  color: var(--text-main);
  font-weight: 700;
}
.sub-tab-item.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand-gradient);
  box-shadow: var(--brand-glow);
}

/* Main Content Column */
.main-content {
  min-width: 0;
  border-inline: 1px solid var(--border);
  min-height: 100vh;
  background: var(--bg-app);
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.header-title-wrap h2 { font-size: 18px; font-weight: 800; font-family: var(--font-display); }
.header-tabs { display: flex; gap: 24px; height: 100%; }
.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s ease;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--text-main); font-weight: 700; }
.tab-indicator {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand-gradient);
  display: none;
}
.tab-btn.active .tab-indicator { display: block; }

.icon-btn-ghost {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.icon-btn-ghost svg { width: 20px; height: 20px; }
.icon-btn-ghost:hover { background: var(--bg-input-focus); color: var(--text-main); transform: scale(1.05); }

/* View Panels */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* Stories Section */
.stories-section { padding: 16px; border-bottom: 1px solid var(--border); }
.stories-container { display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none; }
.stories-container::-webkit-scrollbar { display: none; }
.story-card {
  position: relative;
  flex: 0 0 100px;
  height: 145px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.story-card:hover { transform: translateY(-4px) scale(1.02); }
.story-bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: transform 0.3s ease; }
.story-card:hover .story-bg { transform: scale(1.08); }
.story-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.85) 100%); }
.story-avatar { position: absolute; top: 8px; left: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; padding: 2px; }
.story-avatar.ring-active { background: var(--brand-gradient); box-shadow: 0 0 10px rgba(139, 61, 255, 0.4); }
.story-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.story-name { position: absolute; bottom: 8px; left: 8px; right: 8px; z-index: 2; font-size: 12px; font-weight: 700; color: #FFF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.create-story .add-story-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -60%);
  z-index: 2;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #FFF;
  display: grid; place-items: center;
  box-shadow: var(--brand-glow);
}
.create-story .add-story-btn svg { width: 20px; height: 20px; }

/* Post Composer */
.composer-card {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
}
.composer-top { display: flex; gap: 12px; }
.composer-input-area { flex: 1; }
.composer-input-area textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  color: var(--text-main);
  min-height: 64px;
  max-height: 280px;
  overflow-y: auto;
  transition: height 0.15s ease;
}
.composer-input-area textarea::placeholder { color: var(--text-dim); }

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.composer-tools { display: flex; gap: 4px; }
.tool-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent-pink);
  transition: all 0.18s ease;
}
.tool-btn:hover { background: rgba(255, 59, 136, 0.15); transform: scale(1.08); }
.tool-btn svg { width: 20px; height: 20px; }
/* รูป/วิดีโอล็อกกันเอง (feed.js: `syncMediaLock`) — สื่อโพสต์ทั้งใบเก็บได้แบบเดียว
   ในคราวเดียว เพดานปุ่มที่ปิดต้องไม่ดูเหมือนกดได้ */
.tool-btn:disabled { opacity: .35; cursor: not-allowed; }
.tool-btn:disabled:hover { background: none; transform: none; }

.composer-submit { display: flex; align-items: center; gap: 14px; }
.char-counter { font-size: 13px; color: var(--text-dim); }
.btn-publish {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--brand-glow);
  transition: all 0.2s ease;
}
.btn-publish:hover:not(:disabled) { background: var(--brand-hover); transform: translateY(-1px); }
.btn-publish:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-publish svg { width: 16px; height: 16px; transform: rotate(45deg); }

/* Posts Stream */
.posts-stream { display: flex; flex-direction: column; }
.post-card {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  transition: background-color 0.2s ease;
}
.post-card:hover { background: var(--bg-card-hover); }

.post-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.post-user-meta { flex: 1; min-width: 0; }
.post-author-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.author-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.author-handle { font-size: 13px; color: var(--text-dim); }
.bullet { color: var(--text-dim); }
.post-time { font-size: 13px; color: var(--text-dim); }
/* บรรทัดล่างของหัวโพสต์: @handle · เวลา · ไอคอนการมองเห็น — แยกจากชื่อผู้โพสต์
   ตามที่เจ้าของสั่ง (เดิมทุกอย่างอยู่บรรทัดเดียวกับชื่อ) */
.post-meta-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; margin-top: 1px; }
.post-vis-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-dim); }
.post-vis-icon svg { width: 14px; height: 14px; }
.post-audience { font-size: 12px; color: var(--text-dim); display: block; margin-top: 2px; }
.post-more-btn { color: var(--text-dim); padding: 4px; border-radius: 50%; }
.post-more-btn svg { width: 18px; height: 18px; }

.post-body { margin-bottom: 14px; }
.post-text { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.hashtag { color: var(--accent-pink); font-weight: 600; }
.hashtag:hover { text-decoration: underline; }

/* Poll Widget */
.poll-widget { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.poll-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.poll-option:hover { border-color: var(--accent-purple); }
.poll-progress { position: absolute; top: 0; bottom: 0; left: 0; background: linear-gradient(90deg, rgba(139, 61, 255, 0.25), rgba(255, 59, 136, 0.25)); border-radius: var(--radius-md); transition: width 0.4s ease; }
.poll-label { position: relative; z-index: 2; font-size: 14px; font-weight: 600; }
.poll-percent { position: relative; z-index: 2; font-size: 13px; font-weight: 700; color: var(--accent-pink); }
.poll-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* Media Grids & Galleries */
.media-grid, .media-gallery {
  margin-top: 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: grid;
  gap: 3px;
  border: 1px solid var(--border);
}
.grid-1, .gallery-1 {
  grid-template-columns: 1fr;
  max-height: 480px;
}
.grid-2, .gallery-2 {
  grid-template-columns: 1fr 1fr;
  height: 260px;
}
.grid-3, .gallery-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  height: 320px;
}
.grid-3 .media-item:first-child,
.gallery-3 .media-item:first-child {
  grid-row: 1 / span 2;
  height: 100%;
}
.media-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #15172A;
  height: 100%;
}
.media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, filter 0.3s ease;
}
.media-item:hover img {
  transform: scale(1.03);
  filter: brightness(1.05);
}

/* Post Footer Actions */
.post-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
.post-actions-group { display: flex; gap: 8px; }
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
}
.action-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.action-btn:hover { background: var(--bg-input-focus); color: var(--text-main); transform: scale(1.05); }
.like-btn:hover { color: var(--accent-pink); background: rgba(255, 59, 136, 0.12); }
.like-btn.liked { color: var(--accent-pink); background: rgba(255, 59, 136, 0.15); }
.like-btn.liked svg { fill: var(--accent-pink); stroke: var(--accent-pink); }
.repost-btn:hover { color: var(--accent-green); background: rgba(16, 185, 129, 0.12); }
.bookmark-btn:hover { color: var(--accent-purple); background: rgba(139, 61, 255, 0.12); }

/* Comments Section */
.comments-section {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.comments-section.open { display: block; }

.comment-input-row { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-field-wrap { flex: 1; display: flex; gap: 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 4px 6px 4px 14px; }
.comment-input { flex: 1; background: transparent; border: none; outline: none; font-size: 13px; color: var(--text-main); }
.send-comment-btn { padding: 4px 14px; border-radius: var(--radius-pill); background: var(--brand-gradient); color: #FFF; font-size: 12px; font-weight: 700; }

.comments-list { display: flex; flex-direction: column; gap: 10px; }
.comment-item { display: flex; gap: 10px; }
.comment-bubble { flex: 1; background: var(--bg-input); border-radius: var(--radius-md); padding: 10px 14px; border: 1px solid var(--border); }
.comment-author { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.comment-text { font-size: 13px; color: var(--text-main); line-height: 1.4; }
.comment-meta { display: flex; gap: 12px; margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.reply-link { color: var(--accent-pink); font-weight: 600; }

/* Secondary Views Design System */
.view-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Explore View */
.explore-search-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.category-chips-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.category-chips-bar::-webkit-scrollbar { display: none; }
.chip-item {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.chip-item:hover, .chip-item.active {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
  box-shadow: var(--brand-glow);
}

.explore-hero-card {
  margin: 16px;
  background: linear-gradient(135deg, rgba(139, 61, 255, 0.3), rgba(255, 59, 136, 0.3)), url('https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?auto=format&fit=crop&w=1200&q=80') center/cover;
  border-radius: var(--radius-lg);
  padding: 24px;
  color: #FFF;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}
.hero-badge {
  background: var(--brand-gradient);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 10px;
}
.explore-hero-card h2 { font-size: 22px; font-weight: 800; margin: 0 0 6px 0; font-family: var(--font-display); }
.explore-hero-card p { font-size: 13px; opacity: 0.9; margin: 0; max-width: 480px; line-height: 1.5; }

.explore-trending-section { border-bottom: 1px solid var(--border); }
.trend-rank {
  font-size: 18px;
  font-weight: 900;
  color: var(--accent-pink);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

/* Notifications View (Wall-to-Wall Rows) */
.notifs-header-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.notif-tab {
  flex: 1;
  padding: 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}
.notif-tab.active {
  color: var(--text-main);
  font-weight: 700;
  border-bottom-color: var(--accent-pink);
}

.notifs-list-container {
  display: flex;
  flex-direction: column;
}
.notif-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  transition: all 0.2s ease;
}
.notif-item.unread { background: rgba(139, 61, 255, 0.06); }
.notif-item:hover { background: var(--bg-card-hover); }
.notif-avatar-wrap { position: relative; flex-shrink: 0; }
.notif-badge-icon {
  position: absolute; bottom: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-gradient); display: flex;
  align-items: center; justify-content: center;
  font-size: 10px; color: #FFF; border: 2px solid var(--bg-card);
}
.notif-content { flex: 1; min-width: 0; }
.notif-text { font-size: 13px; color: var(--text-main); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-dim); margin-top: 2px; display: block; }

/* Business & Studio Views */
.business-container, .studio-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.business-metrics-grid, .studio-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
}
.stat-card:hover { border-color: var(--border-focus); transform: translateY(-2px); }
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--text-main); font-family: var(--font-display); }
.stat-val.highlight { color: var(--accent-pink); }
.stat-change.positive { font-size: 11px; font-weight: 700; color: #10B981; }
.stat-sub { font-size: 11px; color: var(--text-dim); }

.campaign-card {
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.campaign-title { font-weight: 700; font-size: 14px; color: var(--text-main); }
.campaign-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.btn-report-sm {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  border: none;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  box-shadow: var(--brand-glow);
}

.studio-hero-card {
  padding: 24px;
  background: var(--brand-gradient);
  border-radius: var(--radius-lg);
  color: #FFF;
  box-shadow: var(--brand-glow);
}
.studio-hero-card h2 { margin: 0 0 8px 0; font-size: 20px; font-weight: 800; font-family: var(--font-display); }
.studio-hero-card p { margin: 0; font-size: 13px; opacity: 0.9; line-height: 1.5; }

.bookmarks-notice-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}

/* User Profile View */
.profile-header-wrap { border-bottom: 1px solid var(--border); }
.profile-cover {
  height: 180px;
  width: 100%;
  background: var(--brand-gradient);
  margin: 0;
  border-radius: 0;
}
.profile-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
  margin-top: -44px;
  position: relative;
  z-index: 2;
}
.profile-avatar-large {
  width: 88px; height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-card);
  background: var(--bg-card);
  box-shadow: var(--card-shadow);
}
.btn-edit-profile {
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: all 0.2s ease;
}
.btn-edit-profile:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.profile-info-section { padding: 16px 16px 0 16px; margin-bottom: 16px; }
.profile-name { margin: 0; font-size: 22px; font-weight: 800; color: var(--text-main); display: flex; align-items: center; gap: 6px; font-family: var(--font-display); }
.profile-handle { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.profile-bio { font-size: 14px; color: var(--text-main); margin: 12px 0; line-height: 1.5; }
.profile-stats-row { display: flex; gap: 20px; font-size: 13px; color: var(--text-dim); }

.profile-subtabs { display: flex; border-bottom: 1px solid var(--border); margin-top: 16px; }
.profile-tab {
  flex: 1; padding: 12px 0; font-size: 14px; font-weight: 600;
  color: var(--text-muted); background: transparent; border: none;
  border-bottom: 2px solid transparent; cursor: pointer; text-align: center;
  transition: all 0.2s ease;
}
.profile-tab.active { color: var(--text-main); font-weight: 700; border-bottom-color: var(--accent-pink); }

/* Messages Chat View Layout */
.chat-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: calc(100vh - 56px);
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
  transition: grid-template-columns 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Side Swapped State (Chat Threads on Right, Room in Center) */
.chat-layout.side-swapped {
  grid-template-columns: minmax(0, 1fr) 240px;
}
.chat-layout.side-swapped .chat-threads {
  order: 2;
  border-right: none;
  border-left: 1px solid var(--border);
}
.chat-layout.side-swapped .chat-room {
  order: 1;
}

/* Collapsed State (Collapsed Threads to 80px Icon-Only) */
.chat-layout.collapsed {
  grid-template-columns: 80px minmax(0, 1fr);
}
.chat-layout.side-swapped.collapsed {
  grid-template-columns: minmax(0, 1fr) 80px;
}

.chat-layout.collapsed .threads-title,
.chat-layout.collapsed .chat-search-wrap,
.chat-layout.collapsed .thread-meta {
  display: none !important;
}

.chat-layout.collapsed .chat-threads-header {
  justify-content: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.chat-layout.collapsed .chat-threads-controls {
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chat-layout.collapsed .thread-item {
  justify-content: center;
  padding: 12px 0;
  margin: 4px 6px;
  border-radius: var(--radius-md);
  border-bottom: none;
}

.chat-layout.collapsed .thread-item.active {
  background: linear-gradient(135deg, rgba(255, 59, 136, 0.2), rgba(139, 61, 255, 0.25));
  border: 1px solid rgba(139, 61, 255, 0.4);
  box-shadow: 0 0 16px rgba(139, 61, 255, 0.25);
  border-left: none;
}

.chat-threads {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  min-width: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-threads-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.chat-threads-header h3 { font-size: 16px; font-weight: 800; font-family: var(--font-display); }
.chat-threads-controls { display: flex; align-items: center; gap: 4px; }

.chat-search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-search-wrap .search-box { background: var(--bg-input); }

.chat-threads-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}
.thread-item:hover { background: var(--bg-card-hover); }
.thread-item.active {
  background: linear-gradient(135deg, rgba(255, 59, 136, 0.12), rgba(139, 61, 255, 0.16));
  border-left: 3px solid var(--accent-pink);
}

.avatar-wrap { position: relative; flex-shrink: 0; }
.online-status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-green); border: 2px solid var(--bg-card);
  box-shadow: 0 0 8px var(--accent-green);
}
.online-status-dot.offline { background: var(--text-dim); box-shadow: none; }

.thread-meta { flex: 1; min-width: 0; }
.thread-name-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.thread-name { font-size: 14px; font-weight: 700; color: var(--text-main); }
.thread-time { font-size: 11px; color: var(--text-dim); }

.thread-preview-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.thread-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-count-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--brand-gradient);
  color: #FFF; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; box-shadow: var(--brand-glow);
}

/* Chat Room Panel */
.chat-room {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}

.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-header); backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.chat-user-meta { flex: 1; min-width: 0; }
.chat-user-name { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.chat-user-status { font-size: 12px; color: var(--accent-green); font-weight: 500; margin-top: 1px; }
.chat-header-actions { display: flex; gap: 6px; }

.chat-messages-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.msg-group { display: flex; gap: 10px; max-width: 75%; }
.msg-group.incoming { align-self: flex-start; }
.msg-group.outgoing { align-self: flex-end; flex-direction: row-reverse; }

.msg-stack { display: flex; flex-direction: column; gap: 4px; }
.msg-group.outgoing .msg-stack { align-items: flex-end; }

.msg-bubble {
  padding: 12px 18px; border-radius: 20px;
  font-size: 14px; line-height: 1.5; word-break: break-word;
}
.msg-bubble.incoming {
  background: var(--bg-card); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; color: var(--text-main);
  box-shadow: var(--card-shadow);
}
.msg-bubble.outgoing {
  background: var(--brand-gradient); color: #FFF;
  border-bottom-right-radius: 4px; box-shadow: var(--brand-glow);
}
.msg-time { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.chat-input-bar {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-header); backdrop-filter: blur(20px);
  flex-shrink: 0;
}
.chat-input-bar input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 10px 18px;
  font-size: 14px; outline: none; transition: border-color 0.2s ease;
}
.chat-input-bar input:focus { border-color: var(--border-focus); background: var(--bg-input-focus); }
.chat-send-btn {
  display: inline-flex; align-items: center; gap: 0;
  justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: var(--brand-gradient); color: #FFF;
  font-size: 13px; font-weight: 700; box-shadow: var(--brand-glow);
  transition: all 0.2s ease;
}
.chat-send-btn svg { display: block; width: 18px; height: 18px; transform: translateX(-2px) rotate(45deg); transition: transform 0.2s ease; }
.chat-send-btn:hover { background: var(--brand-hover); transform: translateY(-1px); }
.chat-send-btn:hover svg { transform: translateX(-2px) rotate(45deg) translateX(2px); }

/* Audio Voice Note Bubble */
.audio-bubble { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.audio-play-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-gradient); color: #FFF; display: grid; place-items: center; flex-shrink: 0; }
.audio-waveform { flex: 1; display: flex; align-items: center; gap: 3px; }
.audio-waveform span { flex: 1; width: 3px; background: rgba(255, 255, 255, 0.4); border-radius: 3px; }
.audio-duration { font-size: 11px; color: var(--text-dim); }

/* Chat Info Drawer (Overlay Slide In) */
.chat-info-drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 300px; border-left: 1px solid var(--border);
  background: var(--bg-header); backdrop-filter: blur(24px) saturate(180%);
  padding: 16px; display: none; flex-direction: column; gap: 16px;
  overflow-y: auto; z-index: 30; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.chat-info-drawer.open { display: flex; }
.info-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.info-user-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 0; }
.info-user-card img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-strong); }
.info-section h5 { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; font-weight: 700; text-transform: uppercase; }
.info-media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.info-media-grid img { width: 100%; height: 70px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.info-toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }

/* Bookmarks View */
.bookmarks-header { margin-bottom: 20px; }
.bookmarks-header h3 { font-size: 20px; font-weight: 800; font-family: var(--font-display); }
.bookmarks-header p { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* Profile View */
.profile-header-wrap {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.profile-cover {
  height: 180px;
  background: var(--brand-gradient);
  background-size: cover;
  background-position: center;
  position: relative;
}
.profile-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 20px;
  margin-top: -45px;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}
.profile-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid var(--bg-app);
  object-fit: cover;
  box-shadow: var(--card-shadow);
  background: var(--bg-card);
}
.btn-edit-profile {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 700;
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-edit-profile:hover { background: var(--bg-card-hover); border-color: var(--accent-pink); }
.profile-info-block {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.profile-handle {
  font-size: 13.5px;
  color: var(--text-dim);
}
.profile-bio {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
.profile-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.profile-stats-row {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-dim);
}
.profile-stats-row strong {
  color: var(--text-main);
  font-weight: 700;
}

.profile-nav-tabs, .profile-subtabs {
  display: flex;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.profile-tab {
  flex: 1;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.profile-tab:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.03); }
.profile-tab.active { color: var(--accent-pink); font-weight: 700; border-bottom-color: var(--accent-pink); }

.profile-meta-chips { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.profile-meta-chips span { display: inline-flex; align-items: center; gap: 4px; }


/* Right Sidebar Widgets */
.right-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  overflow-y: auto;
}

.widget {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--card-shadow);
}
.widget-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.widget-header h3 { font-size: 15px; font-weight: 700; }

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  transition: all 0.2s ease;
}
.search-box:focus-within { border-color: var(--border-focus); background: var(--bg-input-focus); box-shadow: 0 0 14px rgba(139, 61, 255, 0.25); }
.search-icon { width: 16px; height: 16px; color: var(--text-dim); margin-right: 6px; flex-shrink: 0; }
.search-box input { flex: 1; background: transparent; border: none; outline: none; font-size: 13px; color: var(--text-main); }
.clear-btn { font-size: 16px; color: var(--text-dim); }

/* Trending List */
.trending-list { display: flex; flex-direction: column; gap: 4px; }
.trending-item { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: var(--radius-sm); transition: background 0.18s ease; }
.trending-item:hover { background: var(--bg-input-focus); }
.trend-category { font-size: 10px; color: var(--text-dim); }
.trend-title { font-size: 13px; font-weight: 700; color: var(--text-main); }
.trend-count { font-size: 11px; color: var(--text-dim); }

/* Follow List */
.follow-list { display: flex; flex-direction: column; gap: 8px; }
.follow-item { display: flex; align-items: center; gap: 10px; }
.follow-info { flex: 1; min-width: 0; }
.follow-name { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.follow-handle { font-size: 12px; color: var(--text-dim); }
.btn-follow {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.18s ease;
}
.btn-follow:hover { transform: scale(1.05); }

/* Floating Mini Quick Chat Popup Box */
.quick-chat-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 320px;
  height: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45), var(--brand-glow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  overflow: hidden;
}
.quick-chat-popup.open {
  transform: translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
.popup-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}
.popup-user-info { display: flex; align-items: center; gap: 10px; }
.popup-user-info h4 { font-size: 13px; font-weight: 700; color: var(--text-main); margin: 0; }
.popup-status-text { font-size: 10px; color: var(--accent-green); display: block; }
.popup-online-dot { position: absolute; bottom: 0; right: 0; width: 9px; height: 9px; border-radius: 50%; background: #10B981; border: 2px solid #FFF; }

.popup-actions {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
}

.popup-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s ease;
  cursor: pointer;
  text-decoration: none;
}
.popup-btn-icon:hover { color: var(--text-main); background: var(--bg-input-focus); }

.popup-chat-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-app);
}

.popup-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-header);
}
.popup-chat-input-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  color: var(--text-main);
}
.popup-send-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #FFF;
  display: grid; place-items: center;
  box-shadow: var(--brand-glow);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.popup-send-btn svg { display: block; transform: translateX(-1.8px) rotate(45deg); transition: transform 0.2s ease; }
.popup-send-btn:hover { transform: scale(1.05); }
.popup-send-btn:hover svg { transform: translateX(-1.8px) rotate(45deg) translateX(2px); }

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 8px 8px 4px 8px;
}

/* Mobile Controls Default Hidden on Desktop */
.mobile-nav, .mobile-hamburger-btn, .mobile-drawer-overlay, .mobile-drawer { display: none !important; }

/* Modals */
.compose-modal, .lightbox-modal, .story-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(12px);
  display: none; place-items: center; padding: 16px;
}
.compose-modal.open, .lightbox-modal.open, .story-modal.open { display: grid; }

.compose-modal-content {
  width: 100%; max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--modal-shadow);
  position: relative;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-weight: 700; font-size: 16px; }
.modal-close { font-size: 24px; color: var(--text-dim); }
.modal-close:hover { color: var(--text-main); }

.lightbox-close { position: absolute; top: 20px; right: 24px; font-size: 36px; line-height: 1; color: #FFF; background: none; border: none; cursor: pointer; z-index: 5; }

.story-modal-content { position: relative; width: 100%; max-width: 400px; height: 80vh; max-height: 700px; background: #000; border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--modal-shadow); }
.story-progress-bar { position: absolute; top: 12px; left: 12px; right: 12px; height: 3px; background: rgba(255,255,255,0.3); border-radius: 3px; z-index: 10; }
.story-progress-fill { height: 100%; width: 0; background: #FFF; border-radius: 3px; }
.story-modal-header { position: absolute; top: 24px; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; z-index: 10; color: #FFF; font-weight: 700; font-size: 14px; }
.story-modal-close { margin-left: auto; font-size: 28px; color: #FFF; }
.story-modal-image { width: 100%; height: 100%; object-fit: cover; }

/* Story Bottom Bar & Viewers Sheet */
.story-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.story-viewers-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #FFF;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s ease;
}
.story-viewers-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.story-quick-replies {
  display: flex;
  align-items: center;
  gap: 8px;
}
.story-reply-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  color: #FFF;
  font-size: 12.5px;
  outline: none;
}
.story-reply-input::placeholder { color: rgba(255, 255, 255, 0.6); }
.story-emoji-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.story-emoji-btn:hover { transform: scale(1.25); }

.story-viewers-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70%;
  background: rgba(18, 20, 36, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
  animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.story-viewers-sheet.open { display: flex; }
@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.story-viewers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
}
.story-viewers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 240px;
  padding-right: 4px;
}
.story-viewer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.story-viewer-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.story-viewer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-pink);
}

/* ==========================================================================
   DIRECTORY & SHOPS PAGE STYLES (https://koratland.com/directory/)
   ========================================================================== */
.directory-hero {
  padding: 24px 20px;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.12) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.directory-hero-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.directory-hero-sub {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 600px;
  line-height: 1.5;
}
.directory-search-bar {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}
.directory-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.directory-search-input-wrap input {
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  color: var(--text-main);
  font-size: 13.5px;
}
.directory-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 20px;
  background: rgba(0,0,0,0.1);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.directory-cat-chip {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.directory-cat-chip:hover, .directory-cat-chip.active {
  background: var(--accent-pink);
  color: #FFF;
  border-color: var(--accent-pink);
  box-shadow: var(--brand-glow);
}
.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 20px;
}
.shop-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}
.shop-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--modal-shadow);
}
.shop-cover-wrap {
  position: relative;
  height: 140px;
  background: #1e1b4b;
  overflow: hidden;
}
.shop-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.shop-card:hover .shop-cover-img {
  transform: scale(1.05);
}
.shop-status-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
}
.shop-status-open { background: rgba(16, 185, 129, 0.85); color: #FFF; }
.shop-status-closed { background: rgba(239, 68, 68, 0.85); color: #FFF; }
.shop-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}
.shop-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.shop-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}
.shop-rating-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
}
.shop-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.shop-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shop-highlights {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 6px;
}
.shop-highlight-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.shop-footer-actions {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}


/* ==========================================================================
   EXPLICIT RESPONSIVE BREAKPOINTS (Desktop, Tablet, Mobile)
   ========================================================================== */

/* 1. Desktop & Large Displays (>= 1025px) */
@media (min-width: 1025px) {
  .app-shell { grid-template-columns: 260px minmax(0, 1fr) 340px; }
  .mobile-nav { display: none !important; }
}

/* 2. Tablet Layout (641px - 1024px) */
@media (max-width: 1024px) and (min-width: 641px) {
  .app-shell { grid-template-columns: 80px minmax(0, 1fr); padding: 0 12px; gap: 16px; }
  .logo-text, .nav-item .lbl, .btn-create-post .lbl, .user-info, .more-options { display: none; }
  .left-rail { align-items: center; padding: 16px 0; }
  .nav-item { padding: 12px; justify-content: center; border-radius: 50%; }
  .btn-create-post { width: 48px; height: 48px; padding: 0; border-radius: 50%; justify-content: center; }
  .user-profile-pill { padding: 4px; border-radius: 50%; justify-content: center; }
  .right-sidebar { display: none; }
  .chat-layout { grid-template-columns: 80px 1fr; }
  .thread-meta, .thread-time { display: none; }
  .thread-item { justify-content: center; padding: 12px 0; }
  .mobile-nav { display: none !important; }
}

/* 3. Mobile Layout (<= 640px) */
@media (max-width: 640px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; }
  .left-rail { display: none; }
  .right-sidebar { display: none; }
  .main-content { border-inline: none; margin-bottom: 64px; }

  /* Mobile Hamburger Button & Slide-out Drawer */
  .mobile-hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    margin-right: 4px;
  }
  .mobile-hamburger-btn:hover {
    background: var(--bg-input-focus);
  }

  .mobile-drawer-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .mobile-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-drawer {
    display: flex !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 270px;
    max-width: 82vw;
    z-index: 9995;
    background: var(--bg-app);
    backdrop-filter: blur(28px) saturate(180%);
    border-right: 1px solid var(--border);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    padding: 16px 14px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
  }
  .mobile-drawer.open {
    transform: translateX(0);
  }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  .drawer-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
  }
  .drawer-close-btn:hover {
    color: var(--text-main);
    background: var(--bg-input-focus);
  }

  .drawer-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 12px 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: var(--card-shadow);
  }

  .drawer-nav-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
  }
  .drawer-nav {
    display: flex;
    flex-direction: column;
  }
  .drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: all 0.18s ease;
  }
  .drawer-nav-item:last-child {
    border-bottom: none;
  }
  .drawer-nav-item svg { width: 18px; height: 18px; color: var(--text-dim); }
  .drawer-nav-item:hover {
    background: var(--bg-input-focus);
    color: var(--text-main);
  }
  .drawer-nav-item.active {
    background: var(--brand-gradient) !important;
    color: #FFFFFF !important;
    font-weight: 700;
    box-shadow: var(--brand-glow);
  }
  .drawer-nav-item.active svg {
    color: #FFFFFF !important;
  }
  .header-title-wrap {
    flex: 1;
    display: flex;
    justify-content: space-around;
  }
  .header-tabs {
    gap: 12px;
    justify-content: space-around;
    width: 100%;
  }
  .tab-btn {
    font-size: 13px;
    font-weight: 700;
    padding: 0 6px;
  }

  /* Mobile Floating Quick Chat Popup */
  .quick-chat-popup {
    bottom: 68px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    height: 380px !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6) !important;
  }

  /* Mobile Bottom Navigation Bar */
  .mobile-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
    z-index: 40; background: var(--bg-header);
    backdrop-filter: blur(20px) saturate(180%); border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  }
  .mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-dim); padding: 8px; transition: color 0.18s ease;
  }
  .mobile-nav-item.active { color: var(--accent-pink); }
  .mobile-nav-item svg { width: 24px; height: 24px; }

  /* Mobile adjustments */
  .chat-layout { grid-template-columns: 1fr; }
  .chat-threads { display: none; }
  .explore-gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .media-grid.grid-3 { height: 240px; }
}

/* ==========================================================================
   v3 ADDITIONS ONLY — everything above this line is byte-for-byte v.1
   All new classes are prefixed k3- and only APPEND. Nothing above is edited.
   Values are taken from v.1: --bg-card / --border / --radius-md / --radius-lg
   / --radius-pill / --brand-gradient / --card-shadow / --text-*, etc.
   Owner's rule: cards are square (radius 0), buttons may be round.
   ========================================================================== */

/* --- Shared square-card shell for every new v3 block --- */
.k3-card {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);  /* การ์ดชั้นใน = โค้ง 20px (owner, รอบ 3).
                                       แกนกลาง .main-content และ .post-card ยังเหลี่ยมตามเดิม */
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.k3-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.k3-card-head svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent-pink); }
.k3-title { font-size: 14px; font-weight: 700; color: var(--text-main); }
.k3-sub { font-size: 11px; color: var(--text-dim); }
.k3-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.k3-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-md);  /* แถวย่อยในการ์ด = 14px โค้งน้อยกว่าตัวการ์ด */
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.k3-row-main { flex: 1; min-width: 0; }
.k3-row-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.k3-row-sub { font-size: 11px; color: var(--text-dim); }
.k3-price { font-size: 13px; font-weight: 700; color: var(--text-main); flex-shrink: 0; }
.k3-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; border: 1px solid var(--border); }

/* --- Status badges: fixed literals, never accent-derived --- */
.k3-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  color: #FFF;
  flex-shrink: 0;
  white-space: nowrap;
}
.k3-badge-wait { background: #F59E0B; }   /* รอ */
.k3-badge-done { background: #22C55E; }   /* พร้อม / ยืนยันแล้ว */
.k3-badge-out  { background: #EF4444; }   /* ของหมด / ปิด */
.k3-badge-info { background: #3B82F6; }   /* รับแล้ว */
.k3-badge-cook { background: #0EA5E9; }   /* กำลังทำ / กำลังส่ง */
.k3-badge-vip  { background: #8B5CF6; }   /* ระดับสมาชิก / แอดมิน */
/* ไอคอนในชิป — SVG ไม่สนใจ `font-size` ⇒ ถ้าไม่กำหนดขนาด จะได้ไอคอนไร้ขนาด
   ซึ่งเป็นบั๊กที่ไม่มีตัวตรวจไหนจับได้ (คลาสมี แต่ไม่มีกฎ) · `currentColor` ทำให้
   ไอคอนรับสีจากชิปเองทั้งโหมดสว่างและมืด */
.k3-badge > svg {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
  margin-inline-end: 3px;
}
.k3-badge { display: inline-flex; align-items: center; gap: 0; }

.k3-badge-soft {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.k3-row.k3-out { opacity: 0.55; }

/* --- Buttons: round is allowed (owner), pill borrowed from v.1 --- */
.k3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--brand-glow);
  transition: all 0.2s ease;
  cursor: pointer;
}
.k3-btn:hover { background: var(--brand-hover); transform: translateY(-1px); }
.k3-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.k3-btn-ghost {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border);
  box-shadow: none;
}
.k3-btn-ghost:hover { background: var(--bg-input-focus); }
.k3-btn-row { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.k3-btn-row .k3-btn { flex: 1; }

/* --- Queue ticket --- */
.k3-queue { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.k3-queue-num {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  flex-shrink: 0;
}
.k3-queue-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* --- Room / stay card --- */
.k3-room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 14px; }
.k3-room {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);  /* แถวย่อยในการ์ด = 14px */
  background: var(--bg-input);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* --- Premium neon ring / frame (avatar + card) --- */
.k3-neon-ring {
  padding: 2px;
  border-radius: 50%;
  background: var(--brand-gradient);
  box-shadow: 0 0 12px rgba(139, 61, 255, 0.45);
  display: inline-block;
  flex-shrink: 0;
}
.k3-neon-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.k3-neon-frame {
  border: 1px solid rgba(139, 61, 255, 0.55);
  box-shadow: 0 0 18px rgba(139, 61, 255, 0.28), var(--card-shadow);
}

/* --- Neon daily quota meter (reuses v.1 progress metrics) --- */
.k3-quota-wrap { padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.k3-quota-head { display: flex; align-items: center; justify-content: space-between; }
.k3-quota-track { height: 5px; background: var(--bg-input); border-radius: 5px; overflow: hidden; }
.k3-quota-fill { height: 100%; background: var(--brand-gradient); border-radius: 5px; }

/* --- Loading / failed / empty states --- */
.k3-state { padding: 16px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.k3-state svg { width: 22px; height: 22px; color: var(--text-dim); }
.k3-state-text { font-size: 13px; color: var(--text-muted); }
.k3-state-reason { font-size: 11px; color: var(--text-dim); word-break: break-word; }
.k3-skel {
  height: 12px;
  border-radius: var(--radius-sm);  /* ชิ้นเล็กสุด = 8px */
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-input-focus) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: k3-shimmer 1.2s linear infinite;
}
.k3-skel + .k3-skel { margin-top: 8px; }
.k3-skel-60 { width: 60%; }
@keyframes k3-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.k3-hidden { display: none !important; }

/* ==========================================================================
   v3 ADDITIONS — round 2. Append only. Nothing above this line is edited.
   ========================================================================== */

/* --- Order status stepper (real dine-in states: pending → ordered → cooking → served) --- */
.k3-track { display: flex; padding: 12px 14px 10px 14px; gap: 0; }
.k3-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative; min-width: 0; }
.k3-step::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}
.k3-step:first-child::before { display: none; }
.k3-step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.k3-step-label { font-size: 10px; font-weight: 700; color: var(--text-dim); text-align: center; line-height: 1.25; }
.k3-step-time { font-size: 9px; color: var(--text-dim); }
.k3-step.k3-s-wait .k3-step-dot { background: #F59E0B; border-color: #F59E0B; }
.k3-step.k3-s-wait .k3-step-label { color: #F59E0B; }
.k3-step.k3-s-acc  .k3-step-dot { background: #3B82F6; border-color: #3B82F6; }
.k3-step.k3-s-acc  .k3-step-label { color: #3B82F6; }
.k3-step.k3-s-cook .k3-step-dot { background: #0EA5E9; border-color: #0EA5E9; }
.k3-step.k3-s-cook .k3-step-label { color: #0EA5E9; }
.k3-step.k3-s-done .k3-step-dot { background: #22C55E; border-color: #22C55E; }
.k3-step.k3-s-done .k3-step-label { color: #22C55E; }
.k3-step.k3-s-now .k3-step-dot { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.10); }

/* --- Bill lines --- */
.k3-bill { padding: 4px 14px 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.k3-bill-line { display: flex; align-items: baseline; gap: 8px; }
.k3-bill-name { flex: 1; min-width: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k3-bill-qty { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.k3-bill-amt { font-size: 12px; font-weight: 600; color: var(--text-main); flex-shrink: 0; }
.k3-bill-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.k3-bill-total .k3-bill-amt { font-size: 15px; font-weight: 800; }

/* --- Disabled button + the reason it is disabled (never a silent dead button) --- */
.k3-btn:disabled,
.k3-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.k3-btn:disabled:hover { transform: none; }
.k3-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 0 14px 10px 14px;
  font-size: 11px;
  color: var(--text-dim);
}
.k3-note svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; color: var(--text-dim); }

/* --- Chips (quick replies, coupons, search filters) --- */
.k3-chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; }
.k3-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px 10px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
.k3-chip:hover { background: var(--bg-input-focus); color: var(--text-main); }

/* --- Loyalty points + coupons --- */
.k3-points { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.k3-points-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  flex-shrink: 0;
}
.k3-coupon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);  /* แถวย่อยในการ์ด = 14px */
  background: var(--bg-input);
}
.k3-coupon-cut {
  width: 34px;
  flex-shrink: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-pink);
  border-right: 1px dashed var(--border-strong);
  padding-right: 8px;
}
.k3-coupon.k3-out { opacity: 0.5; }

/* --- Floating cart (fixed, bottom-left so it never sits under the chat popup) --- */
.k3-cart {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  box-shadow: var(--brand-glow), 0 12px 32px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transform: translateY(140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.k3-cart.k3-cart-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.k3-cart svg { width: 18px; height: 18px; flex-shrink: 0; }
.k3-cart-count {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.k3-cart-total { font-size: 14px; font-weight: 800; }

/* --- Chat popup: call bar + quick-reply templates (injected, popup itself untouched) --- */
.k3-callbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
}
.k3-callbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.k3-callbtn:hover { color: var(--text-main); border-color: var(--border-strong); }
.k3-callbtn svg { width: 13px; height: 13px; }
.k3-callbtn.k3-on { background: var(--brand-gradient); color: #FFF; border-color: transparent; }
.k3-tplbar {
  display: flex;
  gap: 6px;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.k3-tplbar::-webkit-scrollbar { display: none; }
.k3-tplbar .k3-chip { font-size: 11px; padding: 4px 9px; }
.k3-callnote { font-size: 10px; color: var(--text-dim); margin-left: auto; text-align: right; }

/* --- Link preview card for koratland.com/b/<slug> --- */
.k3-linkcard {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);  /* การ์ดในฟองแชท = 14px */
  background: var(--bg-input);
  overflow: hidden;
  max-width: 240px;
}
.k3-linkcard-media { width: 100%; height: 84px; object-fit: cover; display: block; }
.k3-linkcard-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.k3-linkcard-title { font-size: 12px; font-weight: 700; color: var(--text-main); }
.k3-linkcard-sub { font-size: 10px; color: var(--text-dim); }
.k3-linkcard-host { font-size: 9px; color: var(--text-dim); text-transform: lowercase; }
.k3-linkcard .k3-state { padding: 12px 10px; }
.k3-linkcard .k3-state-text { font-size: 11px; }
.k3-linkcard .k3-btn { padding: 5px 12px; font-size: 11px; }

/* --- Profile: neon ring that actually spins --- */
.k3-neon-spin {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  padding: 3px;
  flex-shrink: 0;
  background: conic-gradient(from 0deg, #FF3B88, #8B3DFF, #3B82F6, #FF3B88);
  animation: k3-spin 3.2s linear infinite;
  box-shadow: 0 0 18px rgba(139, 61, 255, 0.5);
}
.k3-neon-spin img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--bg-card);
}
@keyframes k3-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .k3-neon-spin { animation: none; }
  .k3-skel { animation: none; }
}
.k3-profile-row { display: flex; align-items: center; gap: 14px; padding: 14px; }
.k3-idrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.k3-id {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 10px;
}
.k3-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  cursor: pointer;
}
.k3-copy-btn:hover { color: var(--text-main); }
.k3-copy-btn svg { width: 12px; height: 12px; }
.k3-verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  color: #FFF;
  background: #22C55E;
  border-radius: 10px;
  padding: 2px 8px;
}
.k3-verified svg { width: 11px; height: 11px; color: #FFF; }

/* --- Story: seen vs unseen ring + viewer count (added at runtime, HTML untouched) --- */
.story-avatar.k3-seen {
  background: var(--border-strong) !important;
  box-shadow: none !important;
}
.k3-story-count {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #FFF;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}
.k3-story-count svg { width: 10px; height: 10px; }

/* --- Mixed search results panel (overlay: costs zero layout height) --- */
.k3-search-panel {
  position: fixed;
  z-index: 9995;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);  /* แผงลอย = การ์ดชั้นบนสุด 20px */
  box-shadow: var(--modal-shadow);
  display: none;
}
.k3-search-panel.k3-open { display: block; }
.k3-group-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  padding: 8px 12px 4px 12px;
  letter-spacing: 0.02em;
}
.k3-res {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
}
.k3-res:hover { background: var(--bg-input); }
.k3-res img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.k3-res-glyph {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);  /* ชิ้นเล็กสุด = 8px */
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-weight: 800;
  font-size: 13px;
}
.k3-res-glyph svg { width: 14px; height: 14px; }
.k3-res-main { flex: 1; min-width: 0; }

/* --- Collapsible section for anything that would stretch a column --- */
.k3-fold-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}
.k3-fold-btn:hover { color: var(--text-main); }
.k3-fold-btn svg { width: 14px; height: 14px; transition: transform 0.2s ease; }
.k3-fold-btn.k3-open svg { transform: rotate(180deg); }

/* --- Mobile: keep the floating cart clear of v.1's bottom nav bar --- */
@media (max-width: 1024px) {
  .k3-cart { bottom: 84px; left: 16px; padding: 8px 14px; }
}
@media (max-width: 560px) {
  .k3-track { padding: 12px 8px 10px 8px; }
  .k3-step-label { font-size: 9px; }
  .k3-room-grid { grid-template-columns: 1fr; }
  .k3-neon-spin { width: 68px; height: 68px; }
}

/* ==========================================================================
   Ported v2 Components Styles (Toast, Sheet Modal, Dev Tools Fab)
   ========================================================================== */

/* Toast Notification */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 20px);
  z-index: 999;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: rgba(15, 16, 32, 0.95);
  border: 1px solid var(--border-strong);
  color: #FFF;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--modal-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Sheetwrap Modal (Dine-in QR Code) */
.sheetwrap {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sheetwrap.open {
  opacity: 1;
  pointer-events: auto;
}
.sheet-modal {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
  overflow: hidden;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.sheet-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
.sheet-close:hover {
  color: var(--text-main);
}
.sheet-body {
  padding: 20px 18px;
}

/* Dev Tools Fab */
.devfab {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.devtoggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(15, 16, 32, 0.92);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all 0.2s ease;
}
.devtoggle-btn:hover {
  color: var(--text-main);
  border-color: var(--accent-pink);
  transform: translateY(-2px);
}
.devpanel {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 220px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(15, 16, 32, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--modal-shadow);
  backdrop-filter: blur(16px);
}
.devpanel.on {
  display: flex;
}
.devpanel button {
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.devpanel button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}
.devpanel button[aria-pressed="true"] {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@media (max-width: 860px) {
  .devfab { bottom: 76px; right: 12px; }
}

/* --- Chat label bar (header) + thread labels --- */
.header-title-wrap { display: flex; align-items: center; gap: 14px; min-width: 0; }
.header-labels {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.header-labels::-webkit-scrollbar { display: none; }
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.label-chip:hover { color: var(--text-main); }
.label-chip.active {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
  box-shadow: var(--brand-glow);
}
.label-chip.active .label-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.55); }
.label-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.label-count {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: rgba(127, 127, 127, 0.18);
}
.label-chip.active .label-count { background: rgba(255,255,255,0.28); color: #FFF; }

.thread-label {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}
.threads-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.thread-name-row .thread-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-name-row { gap: 6px; }

@media (max-width: 900px) {
  .header-title-wrap { gap: 8px; }
  .header-title-wrap h2 { display: none; }
  .header-labels { flex: 1; }
  .label-chip { padding: 4px 10px; font-size: 12px; }
}

/* Online / official / add-label chips */
.label-verified { color: #3B82F6; flex-shrink: 0; }
.label-chip.active .label-verified { color: #FFF; }
.thread-verified { color: #3B82F6; width: 13px; height: 13px; flex-shrink: 0; }
.label-chip-add {
  padding: 5px 8px;
  color: var(--text-main);
  border-style: dashed;
}
.label-chip-add:hover {
  background: var(--brand-gradient);
  color: #FFF;
  border-color: transparent;
  border-style: solid;
  box-shadow: var(--brand-glow);
}

/* Label bar scroller — the "+" sits outside it so it never scrolls away */
.header-labels-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.thread-label-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Long thread lists must scroll inside the layout, never push the composer off-screen */
.chat-layout { grid-template-rows: minmax(0, 1fr); }
.chat-threads, .chat-room { min-height: 0; }
.chat-threads-list { min-height: 0; }

/* Per-thread archive / trash / restore, revealed on hover */
.thread-item { position: relative; }
.thread-actions {
  position: absolute;
  right: 8px;
  bottom: 6px;
  display: none;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.thread-item:hover .thread-actions { display: flex; }
.thread-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
}
.thread-action-btn:hover { background: rgba(127, 127, 127, 0.16); color: var(--text-main); }
.thread-action-btn[title="ย้ายไปถังขยะ"]:hover { color: #EF4444; }
.thread-item:not([data-state]) .restore-only { display: none; }
.thread-item[data-state] .inbox-only { display: none; }

/* --- ซีรีส์ (EP) ในกล่องเขียนโพสต์ --- */
.series-picker { position: relative; display: inline-flex; }
.tool-btn.active {
  background: var(--brand-gradient);
  color: #FFF;
  box-shadow: var(--brand-glow);
}

.series-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 5px 6px 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(139, 61, 255, 0.14);
  color: var(--accent-purple, #8B5CF6);
  font-size: 12px;
  font-weight: 700;
}
.series-chip[hidden] { display: none; }
.series-chip-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}
.series-chip-clear:hover { background: rgba(139, 61, 255, 0.22); }

.series-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 260px;
  max-width: 74vw;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  max-height: 260px;
  overflow-y: auto;
}
.series-menu[hidden] { display: none; }
.series-list { display: flex; flex-direction: column; gap: 2px; }
.series-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}
.series-option:hover { background: rgba(127, 127, 127, 0.12); }
.series-option.selected { background: rgba(139, 61, 255, 0.14); }
.series-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-option-ep { font-size: 11px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.series-option.is-none { color: var(--text-muted); border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.series-option.series-create { color: var(--accent-blue, #3B82F6); border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; }

/* ป้ายซีรีส์บนโพสต์ — เดิมการ์ดใส่ class="post-card ep" ซึ่งไปชนกับ .ep
   (ป้ายเล็กในลิสต์ตอนของ series.js บรรทัด 3787 ด้านล่าง) ตรง ๆ เพราะ .ep ไม่ได้
   ถูก scope ไว้ใต้ .post-card เลย ผลคือพื้นหลังม่วง/รัศมีมนของ .ep ไปเคลือบทั้ง
   การ์ดโพสต์ (กลายเป็นก้อนมนยักษ์) และ font-size 11.5px ของมันก็ไหลลงไปทุก
   ลูกในการ์ด บีบให้ป้ายตอนแคบจนตัวอักษรตกบรรทัดทีละตัว — เปลี่ยนชื่อ modifier
   เป็น .post-card--series (ไม่ชนกับอะไร) พร้อมกับกันไม่ให้ป้ายตัวจริงหักบรรทัด */
.post-card.post-card--series { position: relative; }
.post-series-tag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 100%;
  gap: 6px;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(139, 61, 255, 0.14);
  color: var(--accent-purple, #8B5CF6);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.post-series-tag > span:not(.post-series-ep) {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.post-series-ep {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF;
  font-size: 10.5px;
  white-space: nowrap;
}
/* ไอคอนหนังสือใน `.post-series-tag` เป็น SVG ดิบ (`V3.series`) ไม่มี
   width/height ของตัวเอง — ทุกปุ่มไอคอนอื่นในไฟล์นี้ (.tool-btn, .k3-btn, …)
   กำหนดขนาด svg ของตัวเองเสมอ จุดนี้เพิ่งถูกลืม: ตอนคลาสการ์ดยังชื่อ `.ep`
   font-size: 11.5px ของ `.ep` (ท้ายไฟล์ บรรทัด ~3805) รั่วลงไปคุมขนาดไอคอน
   โดยบังเอิญผ่านหน่วย em/สืบทอด พอเปลี่ยนเป็น `.post-card--series` (คอมเมนต์ด้านบน)
   เส้นทางนั้นขาด ⇒ ไอคอนคืนสู่ขนาดปริยายของเบราว์เซอร์ (ใหญ่เกือบเต็มกล่องแม่)
   ดันความสูงเม็ดยาทั้งใบและบีบพื้นที่ชื่อซีรีส์จนต้องตัด — กำหนดขนาดตายตัวตรงนี้
   แทนการพึ่ง font-size ที่สืบทอดมา */
.post-series-tag svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

/* --- ตัวเลือกซีรีส์ / เช็กอิน ในแถบเครื่องมือของกล่องเขียนโพสต์ --- */
.picker-wrap { position: relative; display: inline-flex; }
.picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 264px;
  max-width: 74vw;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  max-height: 280px;
  overflow-y: auto;
}
.picker-menu[hidden] { display: none; }
/* flipped by JS when there is not enough room below the button */
.picker-menu.drop-up { top: auto; bottom: calc(100% + 8px); }
.picker-menu.align-right { left: auto; right: 0; }
.picker-list { display: flex; flex-direction: column; gap: 2px; }
.picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}
.picker-option svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-dim); }
.picker-option:hover { background: rgba(127, 127, 127, 0.12); }
.picker-option.selected { background: rgba(139, 61, 255, 0.14); }
.picker-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-option-sub { font-size: 11px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.picker-option.is-none { color: var(--text-muted); border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
.picker-option.picker-create { color: var(--accent-blue, #3B82F6); border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; }

.composer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.composer-chips[hidden] { display: none; }
.composer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
}
.composer-chip[hidden] { display: none; }
.composer-chip svg { width: 13px; height: 13px; }
.chip-series { background: rgba(139, 61, 255, 0.14); color: var(--accent-purple, #8B5CF6); }
.chip-place { background: rgba(14, 165, 233, 0.14); color: #0EA5E9; }

/* ชื่อตอน — โผล่เฉพาะโพสต์ที่ผูกซีรีส์ (ดู feed.js composer() "data-eptitlewrap") */
.composer-eptitle-wrap { display: flex; flex-direction: column; gap: 2px; margin: 0 0 10px; }
.composer-eptitle-wrap[hidden] { display: none; }
.composer-eptitle {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 10px;
}
.composer-eptitle:focus { outline: none; border-color: var(--accent-purple); }
.composer-eptitle-count { font-size: 11px; font-weight: 500; color: var(--text-dim); align-self: flex-end; }
.composer-eptitle-count[hidden] { display: none; }
.composer-eptitle-count.over { color: #EF4444; }
.chip-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}
.chip-clear:hover { background: rgba(127, 127, 127, 0.22); }
.post-location { color: var(--accent-blue, #0EA5E9); font-weight: 600; }

/* The composer must sit above the feed, or its pop-up menus paint behind the
   first post card (both are static, so z-index alone does not save them). */
.composer-card { position: relative; z-index: 20; }
.picker-wrap { z-index: 21; }
.picker-menu { z-index: 60; }

/* Attached-image previews in the compose modal (they had no styling at all,
   so picked images collapsed to a bare × button). */
.composer-attachments-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.composer-attachments-preview:not(:empty) { margin-top: 8px; }
.preview-item { position: relative; width: 70px; height: 70px; }
.preview-item img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-app);
}
.preview-item .remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #EF4444;
  color: #FFF;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
/* คลิปที่แนบในกล่องเขียนโพสต์ (feed.js composer(): `drawVideoPreview`) — ตรา
   ความยาว มุมล่างขวาของปก, ทับปก ไม่ใช่สไลด์ที่สอง */
.video-preview-item .video-dur-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: rgba(0, 0, 0, .72);
  color: #FFF;
  font-size: 9.5px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
  pointer-events: none;
}

/* Chat panel header controls sit as a tight cluster, not spread out */
.chat-threads-controls { gap: 0; }
.chat-threads-controls .icon-btn-ghost { width: 30px; height: 30px; }
.chat-threads-controls .icon-btn-ghost svg { width: 17px; height: 17px; }

/* Collapsed rail: only the expand chevron stays — swap, new-chat and the
   per-thread archive/trash buttons have no room and cover the avatars. */
.chat-layout.collapsed .chat-threads-controls .icon-btn-ghost:not(#toggle-chat-collapse),
.chat-layout.collapsed .thread-actions,
.chat-layout.collapsed .threads-empty {
  display: none !important;
}
.chat-layout.collapsed .chat-threads-controls { gap: 0; }

/* Chat room header actions as a tight cluster, matching the threads header */
.chat-header-actions { gap: 0; }
.chat-header-actions .icon-btn-ghost { width: 32px; height: 32px; }
.chat-header-actions .icon-btn-ghost svg { width: 18px; height: 18px; }

/* --- ตัวเลือกภาษาในหน้าตั้งค่า --- */
.lang-picker { position: relative; }
.lang-trigger { display: inline-flex; align-items: center; gap: 6px; }
.lang-flag { font-size: 15px; line-height: 1; }
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 220px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.lang-menu[hidden] { display: none; }
.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}
.lang-option:hover { background: rgba(127, 127, 127, 0.12); }
.lang-option.selected { background: rgba(139, 61, 255, 0.14); }
.lang-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-code { font-size: 10.5px; font-weight: 700; color: var(--text-dim); }

/* --- ตัวดูรูปภาพ: เวทีขนาดคงที่ + คอมเมนต์ด้านซ้าย ------------------------
   The stage never changes size; portrait and landscape images are contained
   inside it, so the viewer does not jump around between photos. */
.lightbox-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(1120px, 94vw);
  height: min(680px, 86vh);
  border-radius: var(--radius-lg, 18px);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--modal-shadow);
}
.lightbox-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-card);
}
.lightbox-post {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.lightbox-post-meta { min-width: 0; }
.lightbox-author { font-size: 14px; font-weight: 700; color: var(--text-main); }
.lightbox-time { font-size: 11.5px; color: var(--text-dim); }
.lightbox-caption {
  margin: 0;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  max-height: 30%;
  overflow-y: auto;
}
.lightbox-caption[hidden] { display: none; }
.lightbox-comments {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lightbox-empty { font-size: 12.5px; color: var(--text-dim); text-align: center; padding: 16px 0; }
.lightbox-comment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.lightbox-comment-bar input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
}
.lightbox-comment-bar .chat-send-btn { width: 34px; height: 34px; }

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  background: #0B0B10;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.lightbox-modal .lightbox-stage img {
  /* absolutely filled + contain: the picture is letterboxed inside a stage
     whose size never depends on the picture (percent max-height inside a grid
     area resolves against auto rows, which let portraits stretch the box). */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #FFF;
  cursor: pointer;
}
.lightbox-nav[hidden] { display: none; }
.lightbox-nav svg { width: 20px; height: 20px; }
.lightbox-nav:hover { background: rgba(0, 0, 0, 0.7); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.55);
  color: #FFF;
  font-size: 11.5px;
  font-weight: 700;
}
.lightbox-counter[hidden] { display: none; }

@media (max-width: 860px) {
  .lightbox-shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: min(680px, 88vh); }
  .lightbox-side { order: 2; border-right: none; border-top: 1px solid var(--border); max-height: 46%; }
  .lightbox-stage { order: 1; }
}

/* The rail's divider runs the full height of the screen: it belongs to the
   sticky 100vh rail, not to the main column (whose height follows content). */
.left-rail { border-right: 1px solid var(--border); }
.main-content { border-inline-start: 0; }

/* Straight dividers in the rail: full-width lines, no curved ends.
   The nav card clips its first/last row instead of insetting every row. */
.nav-menu { padding: 0; overflow: hidden; }
.nav-item { border-radius: 0; }
.nav-item:hover { transform: none; }

/* Squared-off left rail: the nav card, the compose button and the profile row
   all run edge to edge with straight corners, no rounded chips. */
.app-shell { padding-left: 0; }
.left-rail { padding: 0; gap: 0; }
.left-rail .brand-logo { padding: 16px 14px; border-radius: 0; }
.left-rail .nav-menu {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}
.left-rail .btn-create-post {
  border-radius: 0;
  box-shadow: none;
  height: 48px;
}
.left-rail .btn-create-post:hover { transform: none; box-shadow: none; }
.left-rail .user-profile-pill {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  padding: 12px 14px;
}

/* No dead gap beside the rail: its right divider sits directly against the
   menu and reads as the boundary between the rail and the feed. */
.app-shell { gap: 0; column-gap: 0; }
.main-content { padding-inline: 0; }
.app-shell > .right-sidebar { padding-left: 16px; }

/* The rail divider needs to read against the white feed — 8% black at 1px
   disappears on most screens, so this one line uses the stronger token. */
.left-rail { border-right: 1px solid var(--border-strong); }
.main-content { border-inline-end: 1px solid var(--border-strong); }

/* Stories: not watched yet = blurred cover, watched = sharp. */
.story-card.k3-story-unseen .story-bg { filter: blur(14px) saturate(1.1); transform: scale(1.25); }
.story-card.k3-story-unseen:hover .story-bg { filter: blur(9px) saturate(1.1); transform: scale(1.26); }
.story-card.k3-story-seen .story-bg { filter: none; }
.story-card .story-bg { transition: filter 0.3s ease, transform 0.3s ease; }

/* Right-column search: taller, easier target than the 6px-padded default */
.right-sidebar .search-box { padding: 11px 14px; }
.right-sidebar .search-box input { font-size: 13.5px; }
.right-sidebar .search-icon { width: 18px; height: 18px; margin-right: 8px; }

/* --- ไดเรกทอรี: สลับมุมมองตาราง / รายการ --- */
.directory-viewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px 0;
}
.directory-count { font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.view-toggle {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.view-toggle-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.view-toggle-btn svg { width: 17px; height: 17px; }
.view-toggle-btn:hover { color: var(--text-main); }
.view-toggle-btn.active {
  background: var(--brand-gradient);
  color: #FFF;
  box-shadow: var(--brand-glow);
}

/* List mode: one card per row, cover still on top and full width */
.directory-grid.as-list { grid-template-columns: 1fr; gap: 14px; }
.directory-grid.as-list .shop-cover-wrap { height: 220px; }

/* Grid mode is a real 2-column grid (auto-fill at 320px collapsed to one
   column inside the ~640px feed column). */
.directory-grid:not(.as-list) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) {
  .directory-grid:not(.as-list) { grid-template-columns: 1fr; }
}

/* --- หน้างาน & รับสมัคร (Korat Jobs) --- */
.job-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 20px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.job-tabs::-webkit-scrollbar { display: none; }
.job-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.job-tab:hover { color: var(--text-main); background: var(--bg-input-focus); }
.job-tab.active { background: var(--brand-gradient); color: #FFF; box-shadow: var(--brand-glow); }
.job-tab-count {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(127, 127, 127, 0.2);
}
.job-tab.active .job-tab-count { background: rgba(255, 255, 255, 0.28); }

.job-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px 20px 20px;
}
.job-grid.as-list { grid-template-columns: 1fr; gap: 12px; }
@media (max-width: 640px) { .job-grid { grid-template-columns: 1fr; } }

.job-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.job-card:hover { border-color: var(--border-strong); box-shadow: var(--modal-shadow); }
.job-card-head { display: flex; align-items: flex-start; gap: 10px; }
.job-logo { width: 44px; height: 44px; border-radius: var(--radius-md); object-fit: cover; flex-shrink: 0; }
.job-head-main { flex: 1; min-width: 0; }
.job-title { font-size: 15px; font-weight: 800; color: var(--text-main); line-height: 1.35; }
.job-company { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.job-save-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}
.job-save-btn svg { width: 17px; height: 17px; }
.job-save-btn:hover { background: var(--bg-input-focus); color: var(--text-main); }
.job-save-btn.saved { color: var(--accent-purple, #8B5CF6); }

.job-types { display: flex; flex-wrap: wrap; gap: 5px; }
.job-type { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-pill); }
.job-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.job-salary { color: var(--accent-purple, #8B5CF6); font-weight: 800; }
.job-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.job-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.job-actions .k3-btn[disabled] { opacity: 0.75; cursor: default; }

.job-empty {
  padding: 28px 20px 36px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}
.job-empty[hidden] { display: none; }

/* Hero search bars (directory + jobs) are a primary action — give them height */
.directory-search-bar .search-box { padding: 13px 16px; }
.directory-search-bar .search-box input { font-size: 14px; }
.directory-search-bar .search-icon { width: 19px; height: 19px; margin-right: 9px; }
.directory-search-bar .btn-publish { min-height: 50px; font-size: 14px; }
.directory-search-input-wrap { padding: 14px 16px; }

/* --- หน้าสินค้า (Korat Marketplace) --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px 20px 20px;
}
.product-grid.as-list { grid-template-columns: 1fr; gap: 12px; }
@media (max-width: 640px) { .product-grid { grid-template-columns: 1fr; } }

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.product-card:hover { border-color: var(--border-strong); box-shadow: var(--modal-shadow); }
.product-card.is-out .product-cover img { filter: grayscale(0.8) brightness(0.85); }

.product-cover { position: relative; height: 170px; background: var(--bg-app); }
.product-grid.as-list .product-cover { height: 200px; }
.product-cover img { width: 100%; height: 100%; object-fit: cover; }
.product-off {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: #EF4444;
  color: #FFF;
  font-size: 11px;
  font-weight: 800;
}
.product-out-tag {
  position: absolute; bottom: 10px; left: 10px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.7);
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
}
.product-like {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #64748B;
  cursor: pointer;
}
.product-like svg { width: 16px; height: 16px; }
.product-like:hover { background: #FFF; color: #EF4444; }
.product-like.liked { color: #EF4444; }

.product-body { display: flex; flex-direction: column; gap: 5px; padding: 12px 14px 0; flex: 1; }
.product-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-shop { display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.product-price-row { display: flex; align-items: baseline; gap: 8px; }
.product-price { font-size: 17px; font-weight: 800; color: var(--accent-purple, #8B5CF6); }
.product-was { font-size: 12px; color: var(--text-dim); text-decoration: line-through; }
.product-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.product-cat { color: var(--text-muted); }
.product-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

.product-actions { display: flex; align-items: center; gap: 8px; padding: 12px 14px 14px; margin-top: auto; }
.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
}
.qty-stepper button {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
}
.qty-stepper button:hover { background: var(--bg-input-focus); }
.qty-value { min-width: 22px; text-align: center; font-size: 13px; font-weight: 800; color: var(--text-main); }

.cart-summary {
  margin: 0 20px 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}
.cart-summary[hidden] { display: none; }
.cart-summary-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); font-weight: 600; }
.cart-summary-total { font-size: 15px; font-weight: 800; color: var(--text-main); border-top: 1px solid var(--border); padding-top: 8px; }

/* Header actions were never given a layout — with only the theme button nobody
   noticed; a second button (cart) stacked underneath it. */
.header-actions { display: flex; align-items: center; gap: 2px; }
.header-actions .icon-wrap { display: inline-flex; }
.header-actions .badge-num { top: -4px; right: -6px; }

/* ค้นหาล่าสุด (ported from site/app/search-history.js) */
.k3-recent-head { display: flex; align-items: center; justify-content: space-between; }
.k3-recent-clear, .k3-recent-x { color: var(--text-dim); font-size: 11.5px; font-weight: 700; cursor: pointer; background: none; border: none; }
.k3-recent-clear:hover, .k3-recent-x:hover { color: var(--text-main); }
.k3-recent-x { font-size: 15px; line-height: 1; padding: 0 4px; }
.k3-res.k3-recent { align-items: center; }

/* --- บัตรคิว (ported from site/app/queue.js) --- */
.q-chip { font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: var(--radius-pill); white-space: nowrap; }

.q-take { padding: 14px 20px 0; }
.q-take-title { font-size: 13px; font-weight: 800; color: var(--text-dim); margin-bottom: 8px; }
.q-take-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; }
.q-take-btn { display: flex; align-items: center; gap: 10px; justify-content: flex-start; text-align: left; padding: 10px 12px; }
.q-take-code {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--brand-gradient);
  color: #FFF;
  font-weight: 800;
  flex-shrink: 0;
}
.q-take-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.q-take-main b { font-size: 13px; color: var(--text-main); }
.q-take-main span { font-size: 11px; color: var(--text-dim); }
.q-take-wait { font-size: 11px; font-weight: 700; color: var(--text-dim); white-space: nowrap; }

.q-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 14px 20px 20px; }
.q-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.q-card.q-done { opacity: 0.65; }
.q-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.q-place { font-size: 13.5px; font-weight: 800; color: var(--text-main); }
.q-group { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
/* A queue number is the one thing this screen must never render small. */
.q-big {
  font-size: 46px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 1px;
  color: var(--accent-purple, #8B5CF6);
  text-align: center;
  padding: 6px 0;
}
.q-facts { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.q-callout { color: #3B82F6; }
.q-acts { display: flex; gap: 8px; margin-top: 4px; }
.q-acts .k3-btn { flex: 1; }

.q-board { padding: 14px 20px 4px; display: flex; flex-direction: column; gap: 10px; }
.q-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}
.q-board-group { font-size: 14px; font-weight: 800; color: var(--text-main); }
.q-board-place { font-size: 11.5px; color: var(--text-dim); }
.q-board-num { font-size: 44px; font-weight: 800; color: var(--accent-purple, #8B5CF6); letter-spacing: 1px; }
.q-board-counter { text-align: right; font-size: 13px; font-weight: 700; color: var(--text-main); display: flex; flex-direction: column; gap: 2px; }
.q-board-counter span { font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.q-board-note { padding: 4px 20px 20px; font-size: 11.5px; color: var(--text-dim); }

.q-staffbar { display: flex; gap: 8px; padding: 14px 20px 0; overflow-x: auto; scrollbar-width: none; }
.q-staffbar::-webkit-scrollbar { display: none; }
.q-staff-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px 0; }
.q-table { display: flex; flex-direction: column; gap: 6px; padding: 12px 20px 20px; }
.q-row {
  display: grid;
  grid-template-columns: 74px auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.q-row-code { font-size: 15px; font-weight: 800; color: var(--text-main); }
.q-row-counter, .q-row-time { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.q-row-acts { display: flex; gap: 6px; }
.q-mini { padding: 4px 10px; font-size: 11.5px; }
.q-danger { color: #EF4444; }
@media (max-width: 720px) {
  .q-row { grid-template-columns: 64px auto 1fr; }
  .q-row-counter, .q-row-time { display: none; }
  .q-row-acts { grid-column: 1 / -1; }
}

/* ===========================================================================
   Ported pages (friends · groups · events · loyalty · parking · series ·
   resume · work console) — one shared vocabulary of rows, sections and cards.
   =========================================================================== */
.rel-page { padding: 4px 20px 24px; }
.rel-section { margin-top: 14px; }
.rel-head { display: flex; align-items: center; gap: 8px; padding: 10px 0 8px; }
.rel-head h3 { font-size: 14px; font-weight: 800; color: var(--text-main); }
.rel-count {
  font-size: 11px; font-weight: 800;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(127, 127, 127, 0.18);
  color: var(--text-dim);
}
.rel-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
}
.rel-main { flex: 1; min-width: 0; }
.rel-name { font-size: 14px; font-weight: 800; color: var(--text-main); }
.rel-sub { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.rel-acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* groups */
.grp-searchbar { display: flex; gap: 10px; padding: 12px 0 4px; }
.grp-searchbar .search-box { flex: 1; padding: 11px 14px; }
.grp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grp-grid { grid-template-columns: 1fr; } }
.grp-card {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--card-shadow);
}
.grp-cover { position: relative; height: 108px; }
.grp-cover img { width: 100%; height: 100%; object-fit: cover; }
.grp-priv {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  background: rgba(0,0,0,0.62); color: #FFF; font-size: 10.5px; font-weight: 700;
}
.grp-body { padding: 12px 14px 0; flex: 1; }
.grp-name { font-size: 15px; font-weight: 800; color: var(--text-main); }
.grp-meta { font-size: 11.5px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.grp-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-top: 6px; }
.grp-reqline {
  display: block; margin-top: 8px; font-size: 12px; font-weight: 700;
  color: var(--accent-purple, #8B5CF6); cursor: pointer; background: none; border: none; padding: 0;
}
.grp-acts { display: flex; gap: 8px; padding: 12px 14px 14px; }

/* events */
.ev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 700px) { .ev-grid { grid-template-columns: 1fr; } }
.ev-card, .ev-ticket {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--card-shadow);
}
.ev-cover { position: relative; height: 140px; }
.ev-cover img { width: 100%; height: 100%; object-fit: cover; }
.ev-tag, .ev-full {
  position: absolute; top: 8px; padding: 2px 9px;
  border-radius: var(--radius-pill); font-size: 10.5px; font-weight: 800;
}
.ev-tag { left: 8px; background: rgba(0,0,0,0.6); color: #FFF; }
.ev-full { right: 8px; background: #F59E0B; color: #FFF; }
.ev-body { padding: 12px 14px 0; flex: 1; }
.ev-name { font-size: 15px; font-weight: 800; color: var(--text-main); line-height: 1.35; }
.ev-host { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
.ev-facts { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ev-acts { display: flex; align-items: center; gap: 8px; padding: 12px 14px 14px; }
.ev-ticket-head { display: flex; justify-content: space-between; gap: 10px; padding: 14px 14px 0; }
.ev-ticket-body { display: flex; align-items: center; gap: 12px; padding: 12px 14px 0; }
.ev-qr {
  font-size: 17px; font-weight: 800; letter-spacing: 1px;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--bg-input); border: 1px dashed var(--border-strong); color: var(--text-main);
}
.ev-ticket-facts { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.ev-in { color: #22C55E; font-weight: 800; }
.ev-door-head { padding: 6px 0 12px; }

/* loyalty */
.loy-rule {
  margin: 10px 0 14px; padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.14); color: #B45309;
  font-size: 12.5px; font-weight: 700;
}
.loy-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); padding: 14px; }
.loy-head { display: flex; align-items: center; gap: 10px; }
.loy-logo { width: 44px; height: 44px; border-radius: var(--radius-md); object-fit: cover; }
.loy-head-main { flex: 1; min-width: 0; }
.loy-points { text-align: right; }
.loy-points b { display: block; font-size: 22px; font-weight: 800; color: var(--accent-purple, #8B5CF6); }
.loy-points span { font-size: 11px; color: var(--text-dim); font-weight: 700; }
.loy-rewards { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.loy-reward-line { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--text-main); }
.loy-reward-cost { color: var(--text-dim); }
.loy-bar { height: 6px; border-radius: var(--radius-pill); background: rgba(127,127,127,0.18); margin: 5px 0 3px; overflow: hidden; }
.loy-bar-fill { height: 100%; background: var(--brand-gradient); }
.loy-reward-note { font-size: 11.5px; color: var(--text-dim); font-weight: 700; }
.loy-reward-note.ready { color: #22C55E; }
.loy-hist-main { display: flex; flex-direction: column; min-width: 0; }
.loy-hist-main span { font-size: 11.5px; color: var(--text-dim); }

/* parking */
.pk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0 12px; }
.pk-cap { text-align: right; }
.pk-cap b { font-size: 22px; font-weight: 800; color: var(--accent-purple, #8B5CF6); }
.pk-cap span { font-size: 11.5px; color: var(--text-dim); font-weight: 700; }
.pk-checkin { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pk-checkin input[type="text"] {
  flex: 1; min-width: 180px; padding: 11px 14px;
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-main); font-size: 13px;
}
.pk-pass { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.pk-row .q-row-code { font-size: 14px; }

/* series */
.ser-page { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; }
@media (max-width: 820px) { .ser-page { grid-template-columns: 1fr; } }
.ser-card {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-card); margin-bottom: 6px; cursor: pointer;
}
.ser-card.active { border-color: var(--accent-purple, #8B5CF6); box-shadow: var(--brand-glow); }
.ser-card img { width: 46px; height: 46px; border-radius: var(--radius-sm, 10px); object-fit: cover; }
.ser-card-main { min-width: 0; }
.ser-hero { display: flex; gap: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.ser-hero img { width: 180px; height: 130px; object-fit: cover; flex-shrink: 0; }
.ser-hero-body { padding: 12px 14px; }
.ser-hero-body h2 { font-size: 18px; font-weight: 800; color: var(--text-main); }
.ser-hero-body p { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

/* สารบัญซีรีส์ — #/series/<id> (series.js renderSeries). `.epno` ไม่เคยมีกฎ
   เลยสักบรรทัด: มันคือ <span> ปริยายจึง white-space อยู่ที่ normal — พื้นที่แถว
   ตึงเมื่อชื่อตอนยาว ทำให้เลข "EP 2" ตกบรรทัดกลางคำ (EP บนบรรทัดเดียว 2 อีกบรรทัด)
   ล็อกให้เป็นเม็ดยาไม่หด ไม่ตกบรรทัด แบบเดียวกับ `.ep` ท้ายไฟล์นี้ */
.eprow .epno {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: rgba(139, 61, 255, 0.14);
  color: var(--accent-purple, #8B5CF6);
}
.epnote { padding: 10px 4px; font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* หัวซีรีส์บนหน้าสารบัญ — `.serieshead` ไม่มีกฎเลยมาก่อน (`* { margin:0 }`
   ของ v3.css บรรทัด 68 ทำให้ h2 ไม่มีระยะขอบใด ๆ เหลือ ⇒ ชื่อซีรีส์ชิดมุมบนซ้าย) */
.serieshead { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 6px; }
.serieshead .cover { width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--radius-lg); margin-bottom: 4px; }
.serieshead h2 { font-size: 20px; font-weight: 800; color: var(--text-main); line-height: 1.3; }
.serieshead .desc { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.serieshead .acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.epnav-box { margin-top: 12px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.epnav-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.epnav-line .grow { flex: 1; }
/* ป้าย "EP 3" ทับชื่อซีรีส์ได้เมื่อชื่อยาว — ป้ายห้ามหด ปุ่มชื่อต้องหดแล้วตัด
   ด้วย ... แทนการล้นทับ (เดิมไม่มี min-width:0/overflow ⇒ flexbox ล้นซ้อนกัน) */
.epnav-line .ep { flex-shrink: 0; }
.epnav-line [data-toc] {
  min-width: 0; flex: 1 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: start;
}
.ep { font-size: 11.5px; font-weight: 800; padding: 2px 9px; border-radius: var(--radius-pill); background: rgba(139,61,255,0.14); color: var(--accent-purple, #8B5CF6); }
.linkbtn { background: none; border: none; cursor: pointer; font-size: 12.5px; color: var(--text-muted); font-weight: 700; }
.linkbtn.strong { color: var(--text-main); }
.linkbtn:hover { text-decoration: underline; }
.epnav-acts { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ser-episode { margin-top: 12px; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.ser-episode h3 { font-size: 15px; font-weight: 800; color: var(--text-main); }
.ser-episode p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin-top: 8px; }
.ser-toc-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; margin-bottom: 4px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card);
}
.ser-toc-row.active { border-color: var(--accent-purple, #8B5CF6); }
.ser-toc-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* resume */
.rz-editor { display: flex; flex-direction: column; gap: 10px; }
.rz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .rz-grid { grid-template-columns: 1fr; } }
.rz-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.rz-field input, .rz-field textarea {
  padding: 10px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-main); font-size: 13px; font-family: inherit; font-weight: 500;
}
.rz-skills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rz-skills .shop-highlight-pill button { background: none; border: none; cursor: pointer; margin-left: 4px; color: inherit; }
.rz-item { padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; }
.rz-item-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; color: var(--text-main); }
.rz-item-head span { font-size: 11.5px; color: var(--text-dim); font-weight: 700; }
.rz-item p { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 8px; line-height: 1.5; }
.rz-share { margin-top: 12px; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.rz-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.rz-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.rz-link code { font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--bg-input); color: var(--accent-purple, #8B5CF6); }
.rz-paper { background: #FFF; color: #111; padding: 28px 30px; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.rz-paper h1 { font-size: 24px; font-weight: 800; }
.rz-paper h2 { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; margin: 16px 0 6px; color: #444; }
.rz-paper p { font-size: 13px; line-height: 1.6; }
.rz-paper-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #111; padding-bottom: 10px; }
.rz-headline { font-size: 13.5px; color: #444; margin-top: 2px; }
.rz-contact { text-align: right; font-size: 12px; color: #444; }
.rz-p-item { margin-bottom: 8px; font-size: 13px; }
.rz-p-item span { color: #666; font-size: 12px; }
.rz-printbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
@media print {
  body * { visibility: hidden !important; }
  #rz-paper, #rz-paper * { visibility: visible !important; }
  #rz-paper { position: absolute; inset: 0; margin: 0; border: none; border-radius: 0; }
}

/* work console */
.wk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px 0; }
.wk-bar .view-toggle-btn { width: auto; padding: 0 12px; font-size: 12px; font-weight: 700; }
.wk-order-main { display: flex; flex-direction: column; min-width: 0; }
.wk-order-main span { font-size: 11.5px; color: var(--text-dim); }
.job-tab.wk-locked { opacity: 0.6; }
.wk-denied {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px; border-radius: var(--radius-lg);
  background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
}
.wk-denied b { font-size: 14px; color: #EF4444; }
.wk-denied span { font-size: 12.5px; color: var(--text-muted); }
.wk-denied code { background: rgba(127,127,127,0.16); padding: 1px 6px; border-radius: 6px; }
.wk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.wk-stat { padding: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.wk-stat span { display: block; font-size: 11.5px; color: var(--text-dim); font-weight: 700; }
.wk-stat b { font-size: 20px; font-weight: 800; color: var(--text-main); }

/* บัตรของฉัน — membership + parking bits on top of the loyalty card styles */
.mem-benefit { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-top: 10px; }
.mem-exp { margin-top: 10px; }
.pk-fee { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; }
.pk-fee b { font-size: 26px; font-weight: 800; color: var(--accent-purple, #8B5CF6); }
.pk-fee span { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }

/* ===========================================================================
   Auth screens (login · register · forgot · reset · logout) — standalone, no
   app shell: the real client replaces the shell with this screen too.
   =========================================================================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(236, 72, 153, 0.16), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(99, 102, 241, 0.16), transparent 60%),
    var(--bg-app);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 26px 26px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
}
.auth-brand { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; text-decoration: none; }
.auth-brand img { width: 34px; height: 34px; border-radius: 10px; }
.auth-brand span { font-size: 20px; font-weight: 800; font-family: var(--font-display); background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-title { font-size: 22px; font-weight: 800; color: var(--text-main); }
.auth-sub { font-size: 12.5px; color: var(--text-dim); margin: 4px 0 18px; line-height: 1.5; }

.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.auth-google:hover { background: var(--bg-input-focus); }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--text-dim); font-size: 11.5px; font-weight: 700; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.auth-field > span { font-size: 12px; font-weight: 700; color: var(--text-dim); }
.auth-field input {
  height: 46px; padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 14px; font-family: inherit;
}
.auth-field input:focus { outline: none; border-color: var(--border-focus); background: var(--bg-input-focus); }
.auth-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); margin: 4px 0 14px; }
.auth-check a { color: var(--accent-purple, #8B5CF6); }
.auth-submit {
  width: 100%; height: 46px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  color: #FFF; font-size: 14px; font-weight: 800; cursor: pointer;
  box-shadow: var(--brand-glow);
}
.auth-submit:disabled { opacity: 0.7; cursor: default; }
.auth-links { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-top: 12px; }
.auth-links .linkbtn { font-size: 12.5px; }
.auth-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-dim); text-align: center; }
.auth-foot a { color: var(--accent-purple, #8B5CF6); font-weight: 700; }

.auth-msg-slot { min-height: 4px; }
.auth-say { margin-top: 12px; padding: 11px 13px; border-radius: var(--radius-md); font-size: 12.5px; line-height: 1.6; }
.auth-say[hidden] { display: none; }
.auth-say a { color: inherit; font-weight: 800; text-decoration: underline; }
.auth-ok { background: rgba(34, 197, 94, 0.14); color: #15803D; }
.auth-err { background: rgba(239, 68, 68, 0.12); color: #B91C1C; }
.auth-info { background: rgba(59, 130, 246, 0.12); color: #1D4ED8; }

.pw-meter { font-size: 11.5px; font-weight: 700; margin: -6px 0 12px; }
.pw-meter.s0, .pw-meter.s1 { color: #EF4444; }
.pw-meter.s2 { color: #F59E0B; }
.pw-meter.s3, .pw-meter.s4 { color: #22C55E; }

.auth-qr { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; width: 100%; }
.auth-qr[hidden] { display: none; }
.auth-qr .qr-lede { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; color: var(--text-main); text-align: center; }
.auth-qr-box {
  width: 195px; height: 195px; padding: 10px; background: #FFF; border-radius: var(--radius-md);
  border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: grid; place-items: center;
}
.auth-qr-box svg { display: block; width: 100%; height: 100%; }

/* The verify matching number card - Compact, clean & light-friendly */
.auth-qr .qr-match-box,
.qr-match-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; max-width: 180px; padding: 6px 10px; border-radius: var(--radius-md, 12px);
  background: color-mix(in srgb, var(--accent-purple, #8B3DFF) 7%, var(--bg-card, #FFFFFF));
  border: 1px solid color-mix(in srgb, var(--accent-purple, #8B3DFF) 22%, var(--border, #E2E8F0));
  box-shadow: 0 2px 8px rgba(139, 61, 255, 0.06);
  margin-block: 4px 2px;
  box-sizing: border-box;
}
.auth-qr .qr-matchlede,
.qr-matchlede {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #64748B);
  text-align: center;
  line-height: 1.2;
}
.auth-qr .qr-match,
.qr-match {
  margin: 1px 0;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .06em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--accent-purple, #8B3DFF);
}
.auth-qr .qr-match-warn,
.qr-match-warn {
  margin: 2px 0 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  color: var(--amber, #D97706);
}

[data-theme="dark"] .auth-qr .qr-match-box,
[data-theme="dark"] .qr-match-box {
  background: color-mix(in srgb, var(--accent-purple, #8B3DFF) 14%, var(--bg-input, #151628));
  border: 1px solid color-mix(in srgb, var(--accent-purple, #8B3DFF) 35%, var(--border, #262840));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .auth-qr .qr-matchlede,
[data-theme="dark"] .qr-matchlede {
  color: #C4B5FD;
}
[data-theme="dark"] .auth-qr .qr-match,
[data-theme="dark"] .qr-match {
  color: #D8B4FE;
  text-shadow: 0 0 16px rgba(192, 132, 252, 0.4);
}
[data-theme="dark"] .auth-qr .qr-match-warn,
[data-theme="dark"] .qr-match-warn {
  color: #FBBF24;
}
.auth-qr .qr-countdown { margin: 2px 0 0; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.auth-qr .qr-countdown bdi { font-variant-numeric: tabular-nums; color: var(--text-main); font-weight: 700; }
.auth-qr .qr-device { margin: 0; font-size: 11px; line-height: 1.4; color: var(--text-dim); text-align: center; }
.auth-qr .qr-note { margin: 2px 0 0; font-size: 11px; line-height: 1.4; color: var(--text-dim); text-align: center; }
.auth-qr .qr-btn-refresh {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--bg-input);
  color: var(--text-muted); font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; margin-top: 4px; font-family: inherit;
}
.auth-qr .qr-btn-refresh:hover {
  background: var(--bg-input-focus); color: var(--text-main); border-color: var(--border-focus);
}

.auth-user { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 14px; }
.auth-user img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.auth-user b { display: block; font-size: 14px; color: var(--text-main); }
.auth-user span { font-size: 12px; color: var(--text-dim); }
.auth-cancel { display: block; text-align: center; margin-top: 10px; font-size: 12.5px; color: var(--text-dim); }
.auth-swept { margin-top: 12px; padding: 11px 13px; border-radius: var(--radius-md); background: var(--bg-input); font-size: 11.5px; color: var(--text-muted); line-height: 1.7; word-break: break-all; }
.auth-swept[hidden] { display: none; }

/* Profile row: name/avatar opens the profile, the icon signs out */
.user-profile-pill { display: flex; align-items: center; gap: 6px; }
.pill-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-decoration: none; }
.pill-signout {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--text-dim);
  flex-shrink: 0;
  text-decoration: none;
}
.pill-signout svg { width: 18px; height: 18px; }
.pill-signout:hover { background: rgba(239, 68, 68, 0.12); color: #EF4444; }
.auth-card { position: relative; }
.auth-theme {
  position: absolute; top: 18px; right: 18px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  background: none; border: none; cursor: pointer;
}
.auth-theme svg { width: 17px; height: 17px; }
.auth-theme:hover { background: var(--bg-input-focus); color: var(--text-main); }

/* ==========================================================================
   Modal สร้างสตอรี่ระดับ Facebook (Story Creator Studio)
   ========================================================================== */
.compose-modal.story-studio-modal { z-index: 9999; }
.compose-modal.story-studio-modal .compose-modal-content {
  max-width: 920px;
  width: 95vw;
  height: 88vh;
  max-height: 740px;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid var(--border);
}

.story-studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.story-studio-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.story-type-tabs {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-pill);
  gap: 2px;
}
.story-type-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-type-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.story-studio-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 0;
  color: var(--text-muted);
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-studio-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
}

.story-studio-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Studio Left Sidebar Controls */
.story-studio-sidebar {
  padding: 18px 20px;
  overflow-y: auto;
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-card);
}
.story-author-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.story-author-card img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.story-author-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.story-author-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.story-aud-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  cursor: pointer;
}

.story-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* Upload zone & photo samples */
.story-upload-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-upload-box:hover {
  border-color: var(--accent-purple);
  background: rgba(139, 61, 255, 0.04);
}
.story-upload-box svg {
  width: 32px;
  height: 32px;
  color: var(--accent-purple);
}
.story-upload-box span {
  font-size: 12px;
  color: var(--text-muted);
}

.story-photo-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.story-photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-photo-thumb:hover, .story-photo-thumb.active {
  border-color: var(--accent-purple);
  transform: scale(1.04);
}

/* Text Story Controls */
.story-textarea-wrap textarea {
  width: 100%;
  height: 90px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13.5px;
  resize: none;
  font-family: inherit;
}
.story-textarea-wrap textarea:focus {
  border-color: var(--accent-purple);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 61, 255, 0.12);
}

/* Background Presets */
.story-bg-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.story-bg-swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.story-bg-swatch:hover, .story-bg-swatch.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent-purple);
}

/* Font & Styles Picker */
.story-font-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.story-font-chip {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-input);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.story-font-chip.active {
  background: var(--text-main);
  color: var(--bg-card);
  border-color: var(--text-main);
}

/* Interactive Add-ons (Music, Location) */
.story-addon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.story-addon-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}
.story-addon-select {
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 11.5px;
  cursor: pointer;
}

/* Right Studio Stage & Phone Canvas */
.story-studio-stage {
  background: #0B0F19;
  background-image: radial-gradient(circle at 50% 50%, rgba(139, 61, 255, 0.18) 0%, rgba(0,0,0,0.85) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.story-stage-badge {
  position: absolute;
  top: 14px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.story-phone-mockup {
  width: 270px;
  height: 480px;
  aspect-ratio: 9 / 16;
  border-radius: 28px;
  background: #000;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 6px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

/* Inside Phone Preview */
.story-canvas-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: all 0.3s ease;
}
.story-canvas-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.45) 0%, transparent 25%, transparent 70%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
}

.story-top-bars {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 10px 10px 4px;
}
.story-bar-segment {
  flex: 1;
  height: 2.5px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 2px;
}
.story-bar-segment.active {
  background: #FFFFFF;
}

.story-canvas-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
}
.story-canvas-author {
  display: flex;
  align-items: center;
  gap: 8px;
}
.story-canvas-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-purple);
  object-fit: cover;
}
.story-canvas-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #FFFFFF;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.story-canvas-time {
  font-size: 10px;
  font-weight: 400;
  opacity: 0.8;
}

/* Floating interactive chips on canvas */
.story-floating-chips {
  position: relative;
  z-index: 2;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.story-music-chip, .story-location-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 600;
  animation: pulseMusic 2s infinite ease-in-out;
}
@keyframes pulseMusic {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; transform: scale(1.02); }
}

/* Story Text Canvas Content */
.story-main-text-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 14px;
  text-align: center;
}
.story-rendered-text {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.4;
  color: #FFFFFF;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  word-break: break-word;
  max-width: 100%;
  transition: all 0.2s ease;
}
.story-rendered-text.highlight {
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
}

/* Bottom studio action bar */
.story-studio-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.story-footer-note {
  font-size: 11.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.story-footer-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 768px) {
  .compose-modal.story-studio-modal .compose-modal-content {
    height: 96vh;
    max-height: none;
    border-radius: 0;
  }
  .story-studio-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .story-studio-stage {
    padding: 10px;
  }
  .story-phone-mockup {
    width: 220px;
    height: 390px;
  }
}

/* ==========================================================================
   Voice & Video Call Modals (Glassmorphic HD Calling Experience)
   ========================================================================== */
.call-modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 8, 18, 0.82);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.call-modal-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

/* Call Window Container */
.call-window {
  width: 92vw;
  max-width: 880px;
  height: 84vh;
  max-height: 640px;
  background: #090D18;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.92) translateY(24px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.call-modal-scrim.open .call-window {
  transform: scale(1) translateY(0);
}

/* Voice Call specific compact mode */
.call-window.voice-mode {
  max-width: 440px;
  height: 580px;
  background: radial-gradient(circle at 50% 30%, rgba(139, 61, 255, 0.22) 0%, #080B14 80%);
}

/* Top Bar */
.call-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: linear-gradient(180deg, rgba(0,0,0,0.65) 0%, transparent 100%);
  color: #FFFFFF;
}
.call-peer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.call-peer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent-purple);
  object-fit: cover;
}
.call-peer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.call-peer-name {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 6px;
}
.call-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #34D399;
  background: rgba(52, 211, 153, 0.14);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.call-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.call-btn-ghost-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.call-btn-ghost-sm:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.05);
}

/* Call Main Stage */
.call-stage-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.voice-stage-content[hidden] { display: none !important; }
.video-stage-content[hidden] { display: none !important; }

/* Voice Call Visualizer Stage */
.voice-stage-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  z-index: 5;
  width: 100%;
}
.voice-avatar-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
}
.voice-avatar-main {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 30px rgba(139, 61, 255, 0.5);
  position: relative;
  z-index: 3;
}
.voice-pulse-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(139, 61, 255, 0.4);
  animation: voicePulse 2.4s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  z-index: 1;
}
.voice-pulse-ring:nth-child(2) {
  animation-delay: 0.8s;
}
.voice-pulse-ring:nth-child(3) {
  animation-delay: 1.6s;
}
@keyframes voicePulse {
  0% { transform: scale(0.85); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 0.25; }
  100% { transform: scale(1.85); opacity: 0; }
}

.voice-status-text {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.3px;
}
.voice-duration-timer {
  font-size: 28px;
  font-weight: 800;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

/* Audio Wave Equalizer */
.voice-wave-visualizer {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  margin-top: 6px;
}
.wave-bar {
  width: 4px;
  height: 12px;
  background: var(--brand-gradient);
  border-radius: 2px;
  animation: waveMotion 1.2s infinite ease-in-out;
}
.wave-bar:nth-child(1) { animation-delay: 0.1s; }
.wave-bar:nth-child(2) { animation-delay: 0.3s; }
.wave-bar:nth-child(3) { animation-delay: 0.5s; }
.wave-bar:nth-child(4) { animation-delay: 0.2s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.15s; }
.wave-bar:nth-child(7) { animation-delay: 0.35s; }
.wave-bar:nth-child(8) { animation-delay: 0.25s; }
@keyframes waveMotion {
  0%, 100% { height: 8px; opacity: 0.4; }
  50% { height: 32px; opacity: 1; }
}

/* Video Call Stage (Peer Video + Self PiP) */
.video-stage-content {
  position: absolute;
  inset: 0;
  background: #000;
}
.video-peer-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-self-pip {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 160px;
  height: 220px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  background: #111;
  z-index: 10;
  cursor: grab;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.video-self-pip:hover {
  transform: scale(1.03);
  border-color: var(--accent-purple);
}
.video-self-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.video-self-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.6);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
}

/* In-call Quality Tag */
.call-quality-badge {
  position: absolute;
  bottom: 96px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  z-index: 10;
}
.call-quality-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px #22C55E;
}

/* Bottom Floating Control Dock */
.call-bottom-dock {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: rgba(18, 24, 38, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.call-dock-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.call-dock-btn svg {
  width: 20px;
  height: 20px;
}
.call-dock-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(1.08);
}
.call-dock-btn.active-off {
  background: rgba(239, 68, 68, 0.25);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.call-dock-btn.btn-hangup {
  background: #EF4444;
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: #FFFFFF;
  width: 52px;
  height: 52px;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
}
.call-dock-btn.btn-hangup:hover {
  background: #DC2626;
  transform: scale(1.1);
  box-shadow: 0 6px 26px rgba(239, 68, 68, 0.7);
}

/* Floating Picture-in-Picture Minimized Call Widget */
.call-pip-floating-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 220px;
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(15, 20, 32, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  animation: slideInPip 0.3s ease;
}
@keyframes slideInPip {
  from { transform: translateY(50px) scale(0.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.call-pip-floating-widget:hover {
  border-color: var(--accent-purple);
  box-shadow: 0 16px 40px rgba(139, 61, 255, 0.3);
}
.call-pip-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--accent-purple);
}
.call-pip-info {
  flex: 1;
  min-width: 0;
}
.call-pip-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-pip-timer {
  font-size: 11px;
  color: #34D399;
  font-weight: 600;
}
.call-pip-end {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #EF4444;
  border: 0;
  color: #FFF;
  display: grid;
  place-items: center;
  cursor: pointer;
}

@media (max-width: 640px) {
  .call-window {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
  .video-self-pip {
    top: 60px;
    right: 12px;
    width: 110px;
    height: 155px;
  }
  .call-bottom-dock {
    gap: 8px;
    padding: 8px 12px;
    bottom: 16px;
  }
  .call-dock-btn {
    width: 42px;
    height: 42px;
  }
}

/* ── บันทึกการโทรในห้องแชท (Modern Call Record Card) ── */
.msg-bubble:has(> .chat-call-card),
.msg-bubble:has(> .att-card.call),
.bubble:has(> .chat-call-card),
.bubble:has(> .att-card.call) {
  background: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  border: 0 !important;
}

.chat-call-card {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 320px;
  min-width: 170px;
  user-select: none;
}

.chat-call-card:hover {
  border-color: var(--border-strong, var(--border));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.chat-call-card .call-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.chat-call-card:hover .call-icon-badge {
  transform: scale(1.06);
}

.chat-call-card .call-icon-badge svg {
  width: 20px;
  height: 20px;
}

.chat-call-card.call-completed .call-icon-badge {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
}
[data-theme="dark"] .chat-call-card.call-completed .call-icon-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #34D399;
}

.chat-call-card.call-missed .call-icon-badge {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
}
[data-theme="dark"] .chat-call-card.call-missed .call-icon-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
}

.chat-call-card .call-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: start;
}

.chat-call-card .call-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-call-card.call-missed .call-title {
  color: #EF4444;
}
[data-theme="dark"] .chat-call-card.call-missed .call-title {
  color: #F87171;
}

.chat-call-card .call-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.2;
}

.msg-group.outgoing .chat-call-card,
.msg.mine .chat-call-card {
  border-bottom-right-radius: 4px;
}
.msg-group.incoming .chat-call-card,
.msg:not(.mine) .chat-call-card {
  border-bottom-left-radius: 4px;
}

