/* =========================================================
   dumaguete.uk — messages.css
   Two-pane on desktop, one pane at a time on mobile.
   Builds on profile.css for .pf-btn, .pf-note, .pf-404.
   ========================================================= */

.page--messages {
  padding-top: 12px;
  padding-bottom: 16px;
}

.dm-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 12px;
  height: calc(100dvh - var(--bar-h) - 92px);
  min-height: 420px;
}

/* ---------- Side list ---------- */
.dm-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.dm-side__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.dm-side__title {
  margin: 0;
  flex: 1 1 auto;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.dm-select {
  padding: 5px 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
}
.dm-badge {
  min-width: 20px;
  padding: 1px 7px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}
.dm-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ---------- Conversation row ---------- */
.dm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.dm-row:hover { background: var(--surface-alt); }
.dm-row.is-on { background: var(--accent-wash); }
.dm-row__avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-wash);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 0.86rem;
  color: var(--accent);
}
.dm-row__avatar img { width: 100%; height: 100%; object-fit: cover; }
.dm-row__text { flex: 1 1 auto; min-width: 0; }
.dm-row__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.dm-row__name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-row__when {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.dm-row__preview {
  display: block;
  margin-top: 2px;
  font-size: 0.79rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-row__preview em { color: var(--accent); font-style: normal; font-weight: 600; }
.dm-row__unread {
  flex: 0 0 auto;
  min-width: 19px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

/* ---------- Main pane ---------- */
.dm-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.dm-thread {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dm-placeholder {
  margin: auto;
  padding: 32px 24px;
  max-width: 40ch;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.dm-placeholder p { margin: 0 0 10px; }

/* ---------- Thread head ---------- */
.dm-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.dm-back {
  display: none;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.dm-head__who {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
}
.dm-head__who:hover { text-decoration: none; }
.dm-head__name {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.dm-head__sub {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.dm-head__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.dm-tool {
  padding: 4px 9px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.dm-tool:hover { color: var(--accent); background: var(--surface-alt); }

/* ---------- Messages ---------- */
.dm-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
}
.dm-msg { margin-bottom: 12px; }
.dm-msg--mine { text-align: right; }
.dm-bubble {
  display: inline-block;
  max-width: 78%;
  padding: 9px 13px;
  font-size: 0.89rem;
  line-height: 1.5;
  text-align: left;
  color: var(--ink);
  background: var(--surface-alt);
  border-radius: 14px 14px 14px 4px;
  white-space: pre-wrap;
  word-break: break-word;
}
.dm-msg--mine .dm-bubble {
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 14px 14px 4px 14px;
}
.dm-quote {
  display: block;
  margin-bottom: 5px;
  padding-left: 8px;
  border-left: 2px solid currentColor;
  font-size: 0.78rem;
  opacity: 0.7;
}
.dm-msg__meta {
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.dm-msg__act {
  padding: 0 3px;
  font: inherit;
  font-size: 0.75rem;
  color: var(--ink-faint);
  background: none;
  border: 0;
  cursor: pointer;
}
.dm-msg__act:hover { color: var(--accent); }

/* ---------- Notices + requests ---------- */
.dm-notice {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: var(--surface-alt);
  border-top: 1px solid var(--line);
}
.dm-request {
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--accent-wash);
}
.dm-request p {
  margin: 0 0 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.dm-request__actions { display: flex; gap: 8px; }

/* ---------- Composer ---------- */
.dm-composer {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.dm-hint {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.dm-composer__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.dm-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 120px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s var(--ease);
}
.dm-input:focus { border-color: var(--accent); }
.dm-sendbtn {
  flex: 0 0 auto;
  padding: 9px 18px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dm-sendbtn:hover { filter: brightness(0.95); }

.dm-empty {
  margin: 24px 14px;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-faint);
}

/* ---------- Mobile: one pane at a time ---------- */
@media (max-width: 780px) {
  .dm-shell {
    grid-template-columns: 1fr;
    height: calc(100dvh - var(--bar-h) - 78px);
  }
  .dm-main { display: none; }
  .dm-back { display: inline-block; }
  body.dm-open .dm-side { display: none; }
  body.dm-open .dm-main { display: flex; }
  .dm-head__tools { display: none; }
  .dm-bubble { max-width: 86%; }
}

/* The introduction rule has to be read before it is spent, so it
   carries more weight than a passing notice. */
.dm-notice--intro {
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--accent-wash);
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.dm-notice--intro strong { display: block; margin-bottom: 3px; }
