/* messages.html — direct messages: two panes (list | chat), mobile = two views; locked state = lock panel over a blurred list */

.dm {
  --dm-vh: 100vh;
  --dm-headh: 68px;                                    /* page title row + gap */
  /* vertical space taken by everything that is not the panes: header, shell padding, tab bar (mobile), breathing room */
  --dm-above: calc(var(--header-h) + var(--sp-4) + var(--tabbar-h) + var(--safe-bottom) + var(--sp-3) + var(--qdock-room, 0px));   /* + the floating quick dock */
  --dm-h: max(440px, calc(var(--dm-vh) - var(--dm-above) - var(--dm-headh)));
  min-width: 0;
}
@supports (height: 100dvh) { .dm { --dm-vh: 100dvh; } }
@media (min-width: 900px) {
  .dm { --dm-above: calc(var(--header-h) + var(--sp-6) + var(--sp-6) + var(--qdock-room, 0px) + var(--sp-4)); }
}

/* ---- title row */
.dm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); min-height: calc(var(--dm-headh) - var(--sp-4)); margin-bottom: var(--sp-4); }
.dm-head__main { display: grid; gap: var(--sp-1); min-width: 0; }
.dm-head__title { font-size: var(--fs-2xl); line-height: 1.05; }
.dm-head .meta .icon { color: var(--text-muted); }
.dm-head [data-dm-unread] { color: var(--text-strong); font-weight: var(--fw-semibold); }

/* ---- panes */
.dm-panes { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); min-width: 0; }
.dm-list { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; min-height: 0; }
.dm-list__tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2); flex: none; }
.dm-list__tools .btn span { display: none; }
.dm-list .convo-list { flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.dm-list__empty { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-5) var(--sp-4); font-size: var(--fs-md); color: var(--text-muted); background: var(--surface-1); border: var(--bw) solid var(--border-subtle); border-radius: var(--r-md); }
.dm-list__empty .icon { flex: none; }
.dm-list__empty b { color: var(--text-strong); font-weight: var(--fw-semibold); overflow-wrap: anywhere; }
.dm-list__empty[hidden] { display: none; }

.dm-chatpane { min-width: 0; min-height: 0; }
.dm-chatpane .chat { height: 100%; }

/* mobile (< 700): list and chat are two views of the same page */
@media (max-width: 699.98px) {
  .dm[data-view="list"] .dm-chatpane { display: none; }
  .dm[data-view="chat"] .dm-list { display: none; }
  .dm[data-view="list"] .dm-list { min-height: calc(var(--dm-vh) - var(--dm-above) - var(--dm-headh)); }
  .dm[data-view="chat"] .dm-chatpane { height: max(380px, calc(var(--dm-vh) - var(--dm-above))); }
  /* the title stays in the DOM for assistive tech but gives its space to the chat */
  .dm[data-view="chat"] .dm-head { position: absolute; width: 1px; height: 1px; min-height: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dm-list__tools .btn { padding-inline: 0; width: var(--tap); }
}
.dm-list__tools .btn { flex: none; }
@media (min-width: 420px) and (max-width: 699.98px) {
  .dm-list__tools .btn span { display: inline; }
  .dm-list__tools .btn { width: auto; padding-inline: var(--sp-4); }
}

/* tablet + desktop: two panes at a fixed, viewport-fitting height */
@media (min-width: 700px) {
  .dm-panes { grid-template-columns: 300px minmax(0, 1fr); height: var(--dm-h); }
  .dm-list__tools { grid-template-columns: minmax(0, 1fr); }
  .dm-list__tools .btn span { display: inline; }
  .dm-list__tools .btn { width: 100%; }
  .dm-back { display: none; }
}
@media (min-width: 900px) { .dm-panes { grid-template-columns: 360px minmax(0, 1fr); } .dm-head__title { font-size: var(--fs-3xl); } .dm-head { align-items: center; } }
@media (min-width: 1200px) { .dm-panes { grid-template-columns: 400px minmax(0, 1fr); } }
/* below the two-pane breakpoint the list is a plain card of rows */
@media (max-width: 699.98px) { .dm-list .convo-list { overflow: visible; } }

/* ---- chat header */
.dm-chat__head { gap: var(--sp-2); min-height: 60px; padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2); }
@media (min-width: 700px) { .dm-chat__head { padding-left: var(--sp-4); } }
.dm-who { display: flex; align-items: center; gap: var(--sp-3); flex: 1 1 auto; min-width: 0; }
.dm-who .avatar-wrap { --ring-color: var(--surface-1); flex: none; }
.dm-who__text { display: grid; gap: 2px; min-width: 0; }
.dm-who__name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dm-who__name .username { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-md); }
.dm-who .meta { flex-wrap: nowrap; gap: var(--sp-2); overflow: hidden; }
.dm-who .meta > * { flex: none; white-space: nowrap; }
.dm-who .meta > span:first-child { display: none; }
.dm-who .meta > .flair { display: none; }
@media (min-width: 480px) { .dm-who .meta > .flair { display: inline-flex; } }
.dm-state.is-online { color: var(--text-strong); font-weight: var(--fw-semibold); }
@media (min-width: 420px) { .dm-who .meta > span:first-child { display: inline-flex; } }
.dm-profile { flex: none; }
@media (max-width: 599.98px) { .dm-profile { width: var(--tap); min-height: var(--tap); padding: 0; } .dm-profile span { display: none; } }

/* ---- chat log */
.dm-chatpane .chat--dm .chat__log { padding: var(--sp-3) var(--sp-3) var(--sp-4); }
@media (min-width: 700px) { .dm-chatpane .chat--dm .chat__log { padding: var(--sp-4) var(--sp-5) var(--sp-5); } }
.dm-chatpane .bubble--image { width: min(300px, 100%); }
.dm-empty-chat { display: grid; justify-items: center; gap: var(--sp-2); margin: auto; padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text-muted); font-size: var(--fs-md); }
.dm-empty-chat .icon { width: 28px; height: 28px; }
.dm-empty-chat b { color: var(--text-strong); font-weight: var(--fw-semibold); }
.dm-chatpane .chat-input { padding: var(--sp-2) var(--sp-3); }

/* ---- new-message dialog */
.dm-pick { margin: 0; padding: 0; list-style: none; max-height: min(320px, 46vh); overflow-y: auto; border: var(--bw) solid var(--border-subtle); border-radius: var(--r-md); background: var(--surface-1); }
.dm-pick > li + li { border-top: var(--bw) solid var(--border-subtle); }
.dm-pick > li[hidden] { display: none; }
.dm-pick .convo-row { grid-template-columns: auto minmax(0, 1fr); }

/* ---- locked */
.dm-locked { min-width: 0; }
.dm-locked .lock-stage { padding: 0; }
.dm-locked .lock-stage__bg { max-height: 460px; }
.dm-locked .lock-panel { margin-block: var(--sp-4); }
@media (min-width: 700px) { .dm-locked .lock-stage { padding: var(--sp-6) 0; } .dm-locked .lock-panel { margin-block: 0; } }

/* dark theme: the shared "mine" bubble (island-raised) disappears into the dark log — lift it one step */
html[data-theme="dark"] .dm-chatpane .chat { --bubble-mine-bg: var(--surface-3); --bubble-mine-fg: var(--text-strong); }
html[data-theme="dark"] .dm-chatpane .bubble-group--mine .bubble { border-color: var(--border-strong); }

/* ka: Georgian lock title is long; 18ch cap forces a 5-line wrap */
:lang(ka) .lock-panel__title { max-width: 26ch; font-size: var(--fs-xl); }
