#dm-dock {
  position: fixed;
  right: 16px; bottom: 0;
  z-index: 100;
  pointer-events: none;
}
#dm-dock > * { pointer-events: auto; }

.dm-panel {
  position: relative;
  width: 380px; height: 520px;
  max-width: calc(100vw - 32px); max-height: calc(100vh - 24px);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.dm-rz { position: absolute; z-index: 6; touch-action: none; }
/* Bottom-right grip sits in the composer's right gutter so it never overlaps Send. */
.dm-rz-se { right: 0; bottom: 0; width: 16px; height: 16px; cursor: nwse-resize; }
.dm-rz-se::after {
  content: ''; position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px;
  border-right: 2px solid var(--ink-4, var(--ink-3)); border-bottom: 2px solid var(--ink-4, var(--ink-3));
  opacity: 0.55;
}

/* Top-left drag affordance; decorative — the header behind it captures the drag. */
.dm-panel::before {
  content: "\283F";
  position: absolute; top: 7px; left: 8px; z-index: 7;
  font-size: 0.8rem; line-height: 1;
  color: var(--ink-3); opacity: 0.55;
  pointer-events: none;
}

.dm-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px 9px 22px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--divider);
  cursor: move;
  user-select: none;
  touch-action: none;   /* drag the header on touch instead of scrolling the page */
}
.dm-av { width: 30px; height: 30px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; }
.dm-head-id { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.dm-title {
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto;
}
.dm-pres { font-size: 0.72rem; font-weight: 600; white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 4px; }
.dm-pres::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dm-pres-online  { color: var(--laurel-2); }
.dm-pres-battle  { color: var(--bronze-2); }
.dm-pres-offline { color: var(--ink-3); }
.dm-head-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.dm-ico {
  all: unset; cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px;
  display: inline-grid; place-items: center;
  color: var(--ink-3); font-size: 0.95rem; line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.dm-ico:hover { color: var(--ink); background: var(--bg-hover); }
.dm-x:hover { color: var(--porphyry-2); }

.dm-tabs { display: flex; padding: 6px 8px; background: var(--bg-2); }
.dm-tabs-scroll { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.dm-tab { flex: none; display: flex; align-items: center; max-width: 150px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.dm-tab.active { border-color: var(--bronze); box-shadow: inset 0 0 0 1px var(--bronze); }
.dm-tab-btn { all: unset; cursor: pointer; display: flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 4px 4px 6px; }
.dm-tab-av { width: 18px; height: 18px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 0.6rem; font-weight: 600; }
.dm-tab-name { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-tab.active .dm-tab-name { color: var(--ink); }
.dm-tab-x { all: unset; cursor: pointer; flex: none; width: 20px; align-self: stretch; display: grid; place-items: center; color: var(--ink-3); font-size: 0.68rem; }
.dm-tab-x:hover { color: var(--porphyry-2); }

.dm-actions-row { display: flex; justify-content: flex-end; padding: 0 10px 8px; background: var(--bg-2); border-bottom: 1px solid var(--divider); }
.dm-invite-wrap { position: relative; }
.dm-invite-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-m); color: var(--ink-2); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.dm-invite-btn:hover, .dm-invite-btn.is-on { border-color: var(--bronze); color: var(--bronze-2); background: color-mix(in srgb, var(--bronze-2) 10%, transparent); }
.dm-invite-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 240px; background: var(--bg-1); border: 1px solid var(--border-strong); border-radius: var(--radius-m); box-shadow: var(--shadow-2); padding: 8px; z-index: 4; }
.dm-inv-search { width: 100%; box-sizing: border-box; background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-m); padding: 6px 9px 6px 30px; color: var(--ink); font: inherit; font-size: 0.82rem; margin-bottom: 6px; background-image: var(--search-icon); background-repeat: no-repeat; background-position: left 10px center; background-size: 13px 13px; }
.dm-inv-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; }
.dm-inv-note { padding: 12px 4px; text-align: center; color: var(--ink-3); font-size: 0.8rem; }
.dm-inv-row { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: var(--radius-s); }
.dm-inv-row:hover { background: var(--bg-hover); }
.dm-inv-av { width: 24px; height: 24px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; }
.dm-inv-name { flex: 1 1 auto; min-width: 0; font-size: 0.85rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-inv-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dm-dot-online { background: var(--laurel-2); }
.dm-dot-battle { background: var(--bronze-2); }

.dm-msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-1); }
.dm-row { display: flex; align-items: flex-start; gap: 8px; }
.dm-row.me { justify-content: flex-end; }
.dm-msg-av { width: 28px; height: 28px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 0.72rem; font-weight: 600; margin-top: 2px; }
.dm-msg-col { display: flex; flex-direction: column; min-width: 0; max-width: 78%; }
.dm-sender { font-size: 0.66rem; font-weight: 600; color: var(--bronze-2); margin: 0 0 2px 4px; }
.dm-group-av { background: var(--bg-hover); border: 1px solid var(--border); font-size: 0.82em; }
.dm-row.me .dm-msg-col { align-items: flex-end; }
.dm-row.them .dm-msg-col { align-items: flex-start; }
.dm-msg { padding: 7px 11px; border-radius: 12px; font-size: 0.86rem; line-height: 1.4; overflow-wrap: anywhere; }
/* Own messages are lapis (not board bronze/gold) so they read distinct from the other person's. */
.dm-me   { background: linear-gradient(180deg, var(--lapis-2), var(--lapis)); color: #fff; }
.dm-them { background: var(--bg-2); color: var(--ink); border: 1px solid var(--border); }
.dm-time { font-size: 0.66rem; color: var(--ink-3); margin-top: 3px; padding: 0 4px; }
.dm-sys  { align-self: center; color: var(--ink-3); font-size: 0.78rem; font-style: italic; text-align: center; }
.dm-empty { margin: auto; color: var(--ink-3); font-size: 0.82rem; text-align: center; }

/* Typing line, fixed height so the composer never shifts. */
.dm-typing { height: 16px; padding: 0 12px; font-size: 0.72rem; color: var(--ink-3); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dm-input-row { display: flex; gap: 6px; padding: 8px 18px 8px 8px; border-top: 1px solid var(--divider); background: var(--bg-1); }
.dm-input { flex: 1 1 auto; min-width: 0; background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius-m); padding: 8px 11px; color: var(--ink); font: inherit; font-size: 0.86rem; }
.dm-send { all: unset; cursor: pointer; flex: none; padding: 0 16px; display: grid; place-items: center; border-radius: var(--radius-m); background: var(--bronze-gradient); color: var(--on-bronze); font-size: 0.84rem; font-weight: 600; }
.dm-send:hover { background: var(--bronze-gradient-hover); }

.dm-unread { flex: none; background: var(--porphyry); color: #fff; border-radius: 999px; font-size: 0.62rem; font-weight: 700; padding: 1px 5px; min-width: 8px; text-align: center; }
.dm-tab-badge { margin-right: 2px; }

.dm-bar {
  display: flex; align-items: center; gap: 8px;
  width: 300px; max-width: calc(100vw - 32px);
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--bg-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius-m); box-shadow: var(--shadow-2);
}
.dm-bar-av { width: 28px; height: 28px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-family: var(--font-display); font-size: 0.75rem; font-weight: 600; }
.dm-bar-name { font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.dm-bar-unread { margin-left: 2px; }
.dm-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }

/* Mobile: full-screen overlay above the nav. */
@media (max-width: 640px) {
  #dm-dock { left: 0; right: 0; top: 0; bottom: 0; z-index: 1300; }
  .dm-panel {
    position: fixed !important; inset: 0 !important;
    width: auto !important; height: auto !important;
    max-width: none !important; max-height: none !important;
    border-radius: 0 !important; border: 0 !important;
  }
  .dm-rz { display: none !important; }
  .dm-head { cursor: default; padding-left: 10px; }
  .dm-panel::before { display: none; }
  .dm-bar { position: fixed; left: 8px; right: 8px; bottom: 72px; width: auto; margin: 0; }
}
