.chat-app, .container.mobile-friendly {
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}
:root {
  --panel-bg:   #f7f8fc;

  --accent:     #1a6b5e;
  --accent-lt:  #e8f5f2;
  --accent-msg: #1a6b5e;

  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;

  --bubble-in:  #ffffff;
  --bubble-out: #1a6b5e;
  --bubble-out-text: #ffffff;
  --bubble-in-text:  #1a1d2e;

  --active-bg:  #f0f9f7;
  --active-border: #1a6b5e;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.12);

  --chat-sidebar-w: 280px;
  --detail-w:  260px;
  --header-h:  64px;
  --input-h:   72px;

  --pub-online:      #16a34a;
  --pub-online-bg:   rgba(22,163,74,.10);
  --pub-online-br:   rgba(22,163,74,.22);
  --pub-msg-hover:   rgba(0,0,0,.04);
  --pub-accent-glow: rgba(26,107,94,.18);
  --pub-mono:        'JetBrains Mono', monospace;
  --pub-code-bg:     #f0f4f8;
  --pub-code-col:    #b45309;
}
.saas-container {
  & .main-view {
    padding: 0px !important;
    transition: 0.3s;
  }
}

.chat-app {
  display: grid;
  grid-template-columns: var(--chat-sidebar-w) 1fr var(--detail-w);
  overflow: hidden;
  gap: 0;
  max-height: 800px;
}

.chat_sidebar {
  background: var(--card-header-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 800px;

  & .chat_sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;

    & h2 {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-color);
      margin-bottom: 14px;
    }
  }

  & .search-bar {
    position: relative;

    & input {
      width: 100%;
      background: var(--card-body-bg);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 9px 14px 9px 36px;
      font-family: inherit;
      font-size: 0.85rem;
      color: var(--text-color);
      outline: none;
      transition: border-color .2s;

      &:focus { border-color: var(--accent); }
    }

    & .search-icon {
      position: absolute;
      left: 11px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
      font-size: 0.8rem;
    }
  }

  & .friends-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;

    &::-webkit-scrollbar { width: 4px; }
    &::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  }

  & .friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s;
    position: relative;

    &:hover { background: var(--card-body-bg); }

    &.active {
      background: var(--active-bg);
      border-left-color: var(--active-border);

      & .btn-delete { display: flex; }
    }

    & .friend-avatar {
      position: relative;
      flex-shrink: 0;

      & img {
        width: 44px; height: 44px;
        border-radius: 50%;
        object-fit: cover;
        display: block;
      }
    }

    & .friend-info { flex: 1; min-width: 0; }

    & .friend-name-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 2px;
    }

    & .friend-name {
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    & .friend-time {
      font-size: 0.72rem;
      color: var(--text-muted);
      flex-shrink: 0;
      margin-left: 6px;
    }

    & .friend-preview {
      font-size: 0.78rem;
      color: var(--text-secondary);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    & .btn-delete {
      display: none;
      position: absolute;
      right: 12px;
      top: 50%;
      transform: translateY(-50%);
      background: #fee2e2;
      border: none;
      color: #ef4444;
      border-radius: var(--radius-sm);
      padding: 4px 8px;
      font-size: 0.72rem;
      cursor: pointer;
      gap: 4px;
      align-items: center;
      transition: background .2s;

      &:hover { background: #fecaca; }
    }
  }
}

.online-dot {
  width: 10px; height: 10px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
  bottom: 1px; right: 1px;
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--card-body-bg);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background .2s, color .2s;

  &:hover { background: var(--accent-lt); color: var(--accent); }
}

.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  background: var(--card-body-bg);
  position: relative;
  max-height: 800px;

  & .chat-header {
    height: var(--header-h);
    background: var(--card-header-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    flex-shrink: 0;

    & .chat-header-avatar {
      position: relative;

      & img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
    }

    & .chat-header-info { flex: 1; min-width: 0; }

    & .chat-header-name {
      font-size: 0.95rem;
      font-weight: 600;
      color: var(--text-color);
    }

    & .chat-header-status {
      font-size: 0.75rem;
      color: #22c55e;
      display: flex;
      align-items: center;
      gap: 4px;

      &::before {
        content: '';
        width: 6px; height: 6px;
        border-radius: 50%;
        background: #22c55e;
        display: inline-block;
      }
    }

    & .chat-header-actions { display: flex; gap: 6px; }
  }

  & .chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 2px;
    max-height: 800px;

    &::-webkit-scrollbar { width: 4px; }
    &::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  }

  & .scroll-to-bottom-btn {
    position: absolute;
    bottom: 90px; right: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--card-header-bg);
    color: var(--accent);
    box-shadow: var(--shadow-md);
    display: none;
    align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background .2s, transform .2s;
    z-index: 10;

    &:hover { background: var(--accent-lt); transform: translateY(-2px); }
  }

  & .chat-input-bar {
    background: var(--card-header-bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;

    & .message-input-wrap {
      flex: 1;
      background: var(--card-body-bg);
      border: 1px solid var(--border);
      border-radius: 24px;
      display: flex;
      align-items: center;
      padding: 0 14px;
      transition: border-color .2s;
      position: relative;

      &:focus-within { border-color: var(--accent); }

      & textarea {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        resize: none;
        font-family: inherit;
        font-size: 0.875rem;
        color: var(--text-color);
        padding: 10px 0;
        max-height: 120px;
        line-height: 1.5;
        word-break: break-word;
        overflow-y: auto;

        &::placeholder { color: var(--text-muted); }
      }

      & .char-counter {
        font-size: 0.68rem;
        color: var(--text-muted);
        white-space: nowrap;
        padding-left: 8px;
        transition: color .2s;
        font-variant-numeric: tabular-nums;

        &.warn  { color: #f59e0b; }
        &.error { color: #ef4444; font-weight: 600; }
      }
    }

    & .send-btn {
      width: 44px; height: 44px;
      border-radius: 50%;
      border: none;
      background: var(--accent);
      color: #fff;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer;
      font-size: 1rem;
      flex-shrink: 0;
      transition: background .2s, transform .1s;
      box-shadow: 0 2px 10px rgba(26,107,94,.3);

      &:hover { background: #155f54; }
      &:active { transform: scale(.95); }
      &:disabled { background: var(--border); box-shadow: none; cursor: not-allowed; }
    }
  }

  & .chat-error-bar {
    display: none;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.78rem;
    padding: 6px 16px;
    border-top: 1px solid #fecaca;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
  }
}

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;

  &::before, &::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  & span {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--card-body-bg);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
  }
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 2px;
  animation: fadeUp .2s ease;

  &.outgoing { flex-direction: row-reverse; }
  &.hide-avatar .msg-avatar { visibility: hidden; }

  & .msg-avatar {
    & img {
      width: 30px; height: 30px;
      border-radius: 50%;
      object-fit: cover;
      display: block;
      cursor: pointer;
      transition: opacity .15s;

      &:hover { opacity: .8; }
    }
  }

  & .msg-bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 100%;
  }

  & .msg-bubble {
    padding: 11px 15px;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
  }

  &.incoming .msg-bubble {
    background: var(--bubble-in);
    color: var(--bubble-in-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
  }

  &.outgoing .msg-bubble {
    background: var(--bubble-out);
    color: var(--bubble-out-text);
    border-bottom-right-radius: 4px;
  }

  & .msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);

    & .read-tick { color: var(--accent); }
  }

  &.outgoing .msg-meta { justify-content: flex-end; }

  & .msg-bubble img.msg-image {
    width: 100%;
    max-width: 260px;
    border-radius: var(--radius-md);
    margin-top: 6px;
    display: block;
  }
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;

  & span {
    font-size: 0.78rem;
    color: var(--accent);
    font-style: italic;
  }

  & .typing-dots {
    display: flex;
    gap: 3px;

    & i {
      width: 6px; height: 6px;
      border-radius: 50%;
      background: var(--accent);
      animation: bounce 1.2s infinite;
      display: block;

      &:nth-child(2) { animation-delay: .2s; }
      &:nth-child(3) { animation-delay: .4s; }
    }
  }
}

.loading-spinner {
  display: none;
  justify-content: center;
  padding: 20px;

  & .spinner-ring {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  padding: 40px 20px;

  & i { font-size: 3rem; color: var(--border); }
  & h4 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
  & a  { color: var(--accent); font-size: 0.85rem; }
}

.detail-panel {
  background: var(--card-header-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 800px;

  &::-webkit-scrollbar { width: 4px; }
  &::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  & .detail-top-bar {
    display: flex;
    justify-content: flex-end;
    padding: 14px 14px 0;
    gap: 6px;
  }

  & .detail-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);

    & .detail-avatar {
      width: 72px; height: 72px;
      border-radius: 50%;
      object-fit: cover;
      border: 3px solid var(--accent-lt);
      margin-bottom: 10px;
      transition: transform .2s;

      &:hover { transform: scale(1.05); }
    }

    & .detail-name {
      font-size: 0.95rem;
      font-weight: 700;
      color: var(--text-color);
      margin-bottom: 2px;
    }

    & .detail-badge {
      font-size: 0.72rem;
      color: var(--text-secondary);
    }
  }

  & .detail-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);

    & .detail-section-title {
      font-size: 0.68rem;
      font-weight: 700;
      letter-spacing: .08em;
      text-transform: uppercase;
      color: var(--text-muted);
      margin-bottom: 12px;
    }
  }

  & .vehicle-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow .2s;

    &:hover { box-shadow: var(--shadow-md); }

    & img { width: 100%; height: 110px; object-fit: cover; display: block; }

    & .vehicle-card-body {
      padding: 10px 12px;

      & .vehicle-title {
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      & .vehicle-price {
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--accent);
      }
    }
  }

  & .specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;

    & .spec-item {
      background: var(--card-body-bg);
      border-radius: var(--radius-sm);
      padding: 8px 10px;

      & .spec-label {
        font-size: 0.65rem;
        color: var(--text-muted);
        font-weight: 500;
        margin-bottom: 2px;
      }

      & .spec-value {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-color);
      }
    }
  }

  & .doc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity .15s;

    &:last-child { border-bottom: none; }
    &:hover { opacity: .7; }

    & .doc-icon {
      width: 32px; height: 32px;
      border-radius: var(--radius-sm);
      display: flex; align-items: center; justify-content: center;
      font-size: 0.8rem;
      flex-shrink: 0;

      &.pdf { background: #fee2e2; color: #ef4444; }
      &.img { background: #fef3c7; color: #f59e0b; }
    }

    & .doc-name {
      font-size: 0.78rem;
      color: var(--text-color);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  & .detail-actions {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;

    & .action-link {
      font-size: 0.82rem;
      font-weight: 500;
      cursor: pointer;
      background: none;
      border: none;
      text-align: left;
      padding: 4px 0;
      transition: opacity .15s;

      &:hover { opacity: .7; }
      &.mute  { color: var(--text-secondary); }
      &.block { color: #ef4444; }
    }
  }
}

#id_page_number { display: none; }

.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--card-body-bg);
  color: var(--text-secondary);
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  margin-right: 4px;
  flex-shrink: 0;
}

/* ── private chat responsive ── */
@media (max-width: 1100px) {
  .chat-app { grid-template-columns: var(--chat-sidebar-w) 1fr; }
  .detail-panel { display: none; }
}

@media (max-width: 700px) {
  .chat-app {
    grid-template-columns: 1fr;
    position: relative;
    margin-bottom: 10px;
  }

  .chat_sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 85vw;
    max-width: 320px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);

    &.open { transform: translateX(0); }
  }

  .chat-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 199;

    &.open { display: block; }
  }

  .chat-main {
    grid-column: 1;
    padding-bottom: env(safe-area-inset-bottom, 0px);

    & .chat-input-bar { margin-bottom: 60px; }
  }

  .msg-bubble-wrap { max-width: 85% !important; }
  .mobile-menu-btn { display: flex !important; }
}


/* ============================================================
   PUBLIC / FORUM CHAT  (.container.mobile-friendly)
   All colours from :root — adapts automatically to dark mode
   ============================================================ */

.container.mobile-friendly {
  max-width: 860px;
  padding: 0 12px 80px;
}

/* card shell */
.container.mobile-friendly .card {
  background: var(--card-header-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* card header */
.container.mobile-friendly .card-header {
  background: var(--card-header-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.container.mobile-friendly .card-header .d-flex { width: 100%; }

/* forum title with # prefix */
.container.mobile-friendly .card-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.container.mobile-friendly .card-header h3::before {
  content: '#';
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-muted);
  line-height: 1;
}

/* online users pill */
.container.mobile-friendly .connected-users-icon {
  font-size: 1rem !important;
  color: var(--pub-online);
}

.container.mobile-friendly .connected-users {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--pub-online);
  font-variant-numeric: tabular-nums;
  background: var(--pub-online-bg);
  border: 1px solid var(--pub-online-br);
  border-radius: 20px;
  padding: 2px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.container.mobile-friendly .connected-users::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--pub-online);
  display: inline-block;
  animation: pub-pulse 2s ease-in-out infinite;
}

@keyframes pub-pulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

/* card body */
.container.mobile-friendly .card-body {
  background: var(--card-body-bg);
  padding: 0 !important;
}

/* chat log container */
.container.mobile-friendly #id_chat_log_container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px - 130px);
  min-height: 400px;
  max-height: 720px;
}

/* spinner */
.container.mobile-friendly #id_chatroom_loading_spinner_container {
  padding: 12px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
}

.container.mobile-friendly .spinner-border {
  width: 22px !important; height: 22px !important;
  border-width: 2px !important;
  border-color: var(--border) !important;
  border-top-color: var(--accent) !important;
}

/* message log — newest at bottom via column-reverse */
.container.mobile-friendly .chat-log {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex !important;
  flex-direction: column-reverse;
  padding: 12px 0 6px;
  gap: 1px;
  scroll-behavior: smooth;
}

.container.mobile-friendly .chat-log::-webkit-scrollbar { width: 4px; }
.container.mobile-friendly .chat-log::-webkit-scrollbar-track { background: transparent; }
.container.mobile-friendly .chat-log::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.container.mobile-friendly .chat-log::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* message row — left-aligned only, no outgoing variant */
.container.mobile-friendly .message-container {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 11px;
  padding: 4px 16px;
  border-radius: var(--radius-sm);
  transition: background .12s;
  animation: pub-fadeUp .18s ease;
  position: relative;
}

.container.mobile-friendly .message-container:hover {
  background: var(--pub-msg-hover);
}

@keyframes pub-fadeUp {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* avatar */
.container.mobile-friendly .profile-image {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
  transition: opacity .15s, border-color .15s;
  border: 2px solid transparent;
}

.container.mobile-friendly .profile-image:hover {
  opacity: .85;
  border-color: var(--accent);
}

/* message content column */
.container.mobile-friendly .message-container > div.d-flex.flex-column {
  flex: 1;
  min-width: 0;
}

/* username + timestamp row */
.container.mobile-friendly .message-container .d-flex.flex-row {
  display: flex !important;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

/* username */
.container.mobile-friendly .username-span {
  font-size: 0.855rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  transition: color .15s;
  letter-spacing: .01em;
}

.container.mobile-friendly .username-span:hover {
  color: var(--accent-msg);
  text-decoration: underline;
}

/* timestamp */
.container.mobile-friendly .timestamp-span {
  font-size: 0.68rem !important;
  color: var(--text-muted) !important;
  font-variant-numeric: tabular-nums;
  cursor: default;
  flex-shrink: 0;
}

/* message text */
.container.mobile-friendly .msg-p {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-color);
  word-break: break-word;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 0 !important;
}

.container.mobile-friendly .msg-p p { margin: 0 0 4px; }
.container.mobile-friendly .msg-p p:last-child { margin-bottom: 0; }

.container.mobile-friendly .msg-p a {
  color: var(--accent);
  text-decoration: none;
}
.container.mobile-friendly .msg-p a:hover { text-decoration: underline; }

.container.mobile-friendly .msg-p code {
  font-family: var(--pub-mono);
  font-size: 0.8em;
  background: var(--pub-code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--pub-code-col);
}

.container.mobile-friendly .msg-p pre.hljs {
  background: var(--card-header-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 6px 0 2px;
}

.container.mobile-friendly .msg-p pre.hljs code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-color);
}

/* input bar */
.container.mobile-friendly .chat-message-input-container {
  flex-shrink: 0;
  display: flex !important;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px 14px;
  background: var(--card-header-bg);
  border-top: 1px solid var(--border);
  position: relative;
}

/* styled ring behind the textarea */
.container.mobile-friendly .chat-message-input-container::before {
  content: '';
  position: absolute;
  inset: 12px 74px 14px 16px;
  background: var(--card-body-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  pointer-events: none;
  transition: border-color .2s, box-shadow .2s;
}

.container.mobile-friendly .chat-message-input-container:focus-within::before {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--pub-accent-glow);
}

.container.mobile-friendly .chat-message-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  resize: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text-color);
  padding: 11px 14px;
  max-height: 140px;
  line-height: 1.5;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

.container.mobile-friendly .chat-message-input::placeholder { color: var(--text-muted); }

.container.mobile-friendly .chat-message-input::-webkit-scrollbar { width: 3px; }
.container.mobile-friendly .chat-message-input::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* send button */
.container.mobile-friendly .chat-message-submit-button {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  border: none !important;
  background: var(--accent) !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 12px var(--pub-accent-glow);
  transition: background .2s, transform .1s, box-shadow .2s;
  padding: 0 !important;
  position: relative;
  z-index: 1;
}

.container.mobile-friendly .chat-message-submit-button:hover:not(:disabled) {
  background: #155f54 !important;
  box-shadow: 0 4px 18px var(--pub-accent-glow);
  transform: scale(1.06);
}

.container.mobile-friendly .chat-message-submit-button:active:not(:disabled) {
  transform: scale(.94);
}

.container.mobile-friendly .chat-message-submit-button:disabled {
  background: var(--border) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
}

.container.mobile-friendly #id_chat_message_submit {
  font-size: 1.1rem !important;
  pointer-events: none;
}

/* error bar */
.container.mobile-friendly .errormessagechat {
  flex-shrink: 0;
  padding: 0 16px;
}

.container.mobile-friendly .errormessagechat .alert-danger {
  background: rgba(239,68,68,.10);
  border: 1px solid rgba(239,68,68,.25);
  color: #dc2626;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  padding: 8px 12px;
  gap: 8px;
}

.container.mobile-friendly .hidden { display: none !important; }

/* ── shared keyframes ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── public chat responsive ── */
@media (max-width: 600px) {
  .container.mobile-friendly {
    padding: 0 0 70px;
  }

  .container.mobile-friendly .card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .container.mobile-friendly #id_chat_log_container {
    height: calc(100svh - 52px - 110px);
    max-height: none;
  }

  .container.mobile-friendly .card-header { padding: 0 12px; }
  .container.mobile-friendly .card-header h3 { font-size: 0.82rem; }

  .container.mobile-friendly .message-container {
    padding: 3px 10px;
    gap: 8px;
  }

  .container.mobile-friendly .profile-image {
    width: 30px !important;
    height: 30px !important;
  }

  .container.mobile-friendly .username-span { font-size: 0.80rem; }
  .container.mobile-friendly .msg-p        { font-size: 0.83rem; }

  .container.mobile-friendly .chat-message-input-container {
    padding: 10px 10px 12px;
    gap: 8px;
  }

  .container.mobile-friendly .chat-message-input-container::before {
    inset: 10px 62px 12px 10px;
  }

  .container.mobile-friendly .chat-message-submit-button {
    width: 40px !important;
    height: 40px !important;
  }
}

@media (max-width: 360px) {
  .container.mobile-friendly .profile-image       { width: 26px !important; height: 26px !important; }
  .container.mobile-friendly .chat-message-submit-button { width: 36px !important; height: 36px !important; }
}