/* Messenger: one page, and its own width decides (Build 2, section 6).  A container query on the page, not the device. */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #16181d; --soft: #5d6470; --line: #e2e5ea; --mine: #1f6feb; --mine-ink: #ffffff;
  --theirs: #eef0f3; --accent: #1f6feb; --good: #1a8f4c; --warn: #b35900; --chip: #eef1f5; --chip-on: #16181d; --chip-on-ink: #ffffff;
  --tap: 44px; --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --panel: #171a20; --ink: #e9ecf1; --soft: #9aa3b1; --line: #262b33; --theirs: #222731; --chip: #222731; --chip-on: #e9ecf1; --chip-on-ink: #0f1115; }
}
@media (pointer: coarse) { :root { --tap: 52px; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { overflow: hidden; }
#root { height: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { display: grid; place-items: center; height: 100%; }
.boot-words { color: var(--soft); }

/* the door */
.door { max-width: 380px; margin: 12vh auto 0; padding: 28px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.door h1 { margin: 0 0 6px; font-size: 24px; }
.door p { color: var(--soft); margin: 0 0 18px; line-height: 1.45; }
.door input[type=text] { width: 100%; font-size: 28px; letter-spacing: 8px; text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.door label { display: flex; gap: 8px; align-items: center; margin: 14px 0; color: var(--soft); }
.door .go { width: 100%; min-height: var(--tap); border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; }
.door .err { color: #c0352b; min-height: 1.3em; margin: 10px 0 0; }

/* the app */
.mg { container-type: inline-size; display: flex; flex-direction: column; height: 100%; background: var(--panel); }
.mg-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px 6px; }
.mg-top b { font-size: 18px; }
.mg-top .spacer { flex: 1; }
.mg-top button { min-height: 34px; border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 0 12px; color: var(--soft); }
.mg-lock { font-size: 12px; color: var(--soft); padding: 0 14px 8px; border-bottom: 1px solid var(--line); }
.mg-error { background: #fdecea; color: #8a1c13; padding: 8px 14px; font-size: 14px; }
.mg-panes { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }
.mg-left { display: flex; flex-direction: column; min-height: 0; }
.mg-chips { display: flex; gap: 6px; padding: 10px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: none; }
.mg-chips button { border: 0; background: var(--chip); border-radius: 999px; padding: 6px 12px; white-space: nowrap; min-height: 32px; }
.mg-chips button.is-on { background: var(--chip-on); color: var(--chip-on-ink); }
.mg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.mg-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 14px; min-height: 64px; border-bottom: 1px solid var(--line); }
.mg-row.is-on { background: var(--theirs); }
.mg-row.is-unread .mg-row-name { font-weight: 700; }
.mg-ava { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: hsl(var(--h, 210) 55% 45%); position: relative; }
.mg-ava.is-team { background: hsl(150 40% 38%); }
.mg-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-row-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-row-last { font-size: 14px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--soft); }
.mg-badge { background: var(--accent); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; font-weight: 700; }
.mg-tag { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 0 6px 6px 0; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; background: var(--chip); color: var(--soft); border-left: 3px solid var(--tagc, var(--soft)); }
.mg-empty { padding: 20px 16px; color: var(--soft); line-height: 1.45; }
.mg-side { display: none; min-height: 0; }
.mg-pick { display: grid; place-items: center; height: 100%; color: var(--soft); }
.mg.is-open .mg-left { display: none; }
.mg.is-open .mg-side { display: flex; }
.mg-convo { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.mg-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 56px; }
.mg-back { border: 0; background: transparent; min-width: var(--tap); min-height: var(--tap); font-size: 22px; }
.mg-head-name { font-weight: 700; font-size: 17px; }
.mg-head-sub { color: var(--soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-scroll { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.mg-b-row { display: flex; }
.mg-b-row.is-mine { justify-content: flex-end; }
.mg-bubble { max-width: min(78%, 520px); background: var(--theirs); border-radius: 16px; padding: 8px 12px; }
.is-mine .mg-bubble { background: var(--mine); color: var(--mine-ink); }
.mg-b-who { font-size: 12px; font-weight: 700; color: var(--soft); margin-bottom: 2px; }
.mg-b-text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.mg-b-foot { display: flex; gap: 8px; align-items: center; justify-content: flex-end; font-size: 11px; opacity: .75; margin-top: 3px; }
.mg-ticks { border: 0; background: transparent; color: inherit; padding: 0; font-size: 12px; }
.mg-detail { margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid rgba(255,255,255,.3); list-style: none; font-size: 12px; }
.mg-photo { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; }
.mg-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.mg-icon { flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-size: 20px; }
.mg-box { flex: 1; min-height: var(--tap); max-height: 140px; resize: none; border: 1px solid var(--line); border-radius: 22px; padding: 11px 14px; background: var(--bg); }
.mg-send { flex: none; min-height: var(--tap); border: 0; border-radius: 22px; background: var(--accent); color: #fff; font-weight: 600; padding: 0 16px; }
.mg-send:disabled, .mg-icon:disabled { opacity: .5; }

@container (min-width: 700px) {
  .mg-panes { grid-template-columns: minmax(280px, 340px) 1fr; }
  .mg-left { border-right: 1px solid var(--line); }
  .mg-side { display: flex; }
  .mg.is-open .mg-left { display: flex; }
  .mg-back { display: none; }
}
