/* Mem Messenger. Window chrome comes from win95.css; everything here is scoped
   to messenger windows (.mm) so it can't leak into the rest of the desktop. */
:root {
  --me: #d00000;
  --them: #0000d0;
}

.mm { max-width: 100%; max-height: calc(100% - 4px); min-width: 220px; }
.mm .window-body { gap: 6px; padding: 6px; }
.mm input, .mm textarea, .transcript { user-select: text; -webkit-user-select: text; }

/* ---- Controls --------------------------------------------------------- */
.mm .window-body button {
  background: var(--face);
  border: 2px solid;
  border-color: var(--hilite) var(--dark) var(--dark) var(--hilite);
  box-shadow: inset -1px -1px var(--shadow), inset 1px 1px var(--light);
  padding: 3px 12px;
  min-height: 24px;
  cursor: pointer;
  touch-action: manipulation;
}
.mm .window-body button:active:not(:disabled) {
  border-color: var(--dark) var(--hilite) var(--hilite) var(--dark);
  box-shadow: inset 1px 1px var(--shadow);
}
.mm .window-body button:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.mm .window-body button:disabled { color: var(--shadow); text-shadow: 1px 1px #fff; cursor: default; }
.mm input[type=text], .mm input[type=password], .mm input[type=number], .mm textarea, .mm select {
  border: 2px solid;
  border-color: var(--shadow) var(--hilite) var(--hilite) var(--shadow);
  box-shadow: inset 1px 1px var(--dark);
  background: #fff;
  padding: 3px 4px;
  width: 100%;
}
.mm textarea { resize: none; }
.mm input:focus, .mm textarea:focus, .mm select:focus { outline: none; }
.mm label { display: block; }
.mm p { margin: 0; }
.mm .field { display: flex; flex-direction: column; gap: 2px; }
.mm .check { display: flex; align-items: center; gap: 6px; }
.mm .row { display: flex; gap: 6px; align-items: center; }
.mm .row.end { justify-content: flex-end; }
.mm .row.wrap { flex-wrap: wrap; }
.mm .grow { flex: 1; }
.mm .muted { color: #555; }
.mm .small { font-size: 11px; }
.mm .error { color: #b00000; }
.mm .ok { color: #006000; }
.mm .hint { font-size: 11px; color: #333; line-height: 1.35; }
.mm .window-body .linkish { background: none; border: none; box-shadow: none; color: #00e; text-decoration: underline; padding: 0; min-height: 0; }
.mm .window-body .linkish:active:not(:disabled) { border: none; box-shadow: none; }
.mm fieldset { border: 2px groove var(--hilite); margin: 0; padding: 6px 8px 8px; }
.mm legend { padding: 0 3px; }

/* ---- Sign on ---------------------------------------------------------- */
.mm.signon { width: 270px; }
.signon .hero { background: #fff; text-align: center; padding: 14px 8px 10px; }
.signon .hero img { width: 76px; height: 76px; image-rendering: auto; }
.signon .hero .brand { font: italic bold 20px Georgia, "Times New Roman", serif; color: var(--title-a); margin-top: 4px; }
.signon .hero .tag { font-size: 11px; color: #444; }
.signon form { display: flex; flex-direction: column; gap: 7px; }
.signon .steps { display: flex; gap: 4px; justify-content: center; min-height: 18px; }
.signon .steps span { padding: 1px 6px; color: var(--shadow); }
.signon .steps span.on { color: #000; font-weight: bold; }
.signon .status-line { min-height: 16px; text-align: center; }

/* ---- Buddy list ------------------------------------------------------- */
.mm.buddylist { width: 250px; height: 540px; }
.bl-head { background: #fff; padding: 6px; display: flex; gap: 8px; align-items: center; }
.bl-head img { width: 36px; height: 36px; image-rendering: auto; }
.bl-head .me { font-weight: bold; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.away-banner { background: #ffffe1; border: 1px solid #000; padding: 4px 6px; display: flex; gap: 6px; align-items: center; }
.away-banner span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-tree { flex: 1; overflow-y: auto; padding: 2px 0; }
.bl-group { font-weight: bold; padding: 2px 4px; cursor: pointer; }
.bl-group::before { content: "\25BE"; display: inline-block; width: 12px; }
.bl-group.collapsed::before { content: "\25B8"; }
.bl-item { padding: 1px 4px 1px 18px; cursor: default; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 4px; align-items: center; }
.bl-item:focus { outline: 1px dotted #000; outline-offset: -1px; }
.bl-item.sel { background: var(--sel); color: #fff; }
.bl-item.offline { color: var(--shadow); }
.bl-item.away .name { font-style: italic; }
.bl-item.fresh .name { font-weight: bold; }
.bl-item .tag { font-size: 10px; color: inherit; opacity: .8; }
.bl-item .warn { color: #c00; font-weight: bold; }
.bl-item.sel .warn { color: #ff8080; }
.mm .window-body .bl-item button { min-height: 18px; padding: 0 6px; font-size: 11px; }
.bl-item .badge {
  margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: #d00000; color: #fff; font: bold 11px/16px Tahoma, sans-serif; text-align: center;
}
.bl-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.mm .window-body .bl-buttons button { padding: 3px 0; white-space: nowrap; }
.conn { font-size: 11px; text-align: center; }

/* ---- IM window -------------------------------------------------------- */
.mm.im { width: 420px; height: 380px; min-height: 260px; }
.im-bar { display: flex; gap: 6px; align-items: center; }
.lock { display: inline-flex; gap: 4px; align-items: center; padding: 2px 6px; background: #efffef; border: 1px solid #6a6; min-height: 22px; }
.mm .window-body button.lock { padding: 2px 6px; min-height: 22px; border: 1px solid #6a6; box-shadow: none; background: #efffef; }
.lock.verified, .mm .window-body button.lock.verified { background: #dfffdf; border-color: #080; font-weight: bold; }
.lock.changed, .mm .window-body button.lock.changed { background: #ffe0e0; border-color: #c00; color: #900; font-weight: bold; }
.transcript { flex: 1; overflow-y: auto; padding: 4px 6px; min-height: 60px; font-size: 13px; line-height: 1.35; }
.line { white-space: pre-wrap; overflow-wrap: anywhere; margin: 1px 0; }
.who { font-weight: bold; }
.who.me { color: var(--me); }
.who.them { color: var(--them); }
.ts { color: var(--shadow); font-size: 11px; }
.hide-ts .ts { display: none; }
.line.sys { color: #666; font-style: italic; font-size: 12px; }
.line.warn { color: #a00000; font-weight: bold; font-style: normal; }
.line.auto .text { color: #555; }
.mm .statusbar { min-height: 18px; padding: 1px 4px; font-size: 11px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose { display: flex; gap: 6px; align-items: stretch; }
.mm .compose textarea { height: 56px; font-size: 13px; }
.mm .window-body .compose button { min-width: 64px; }

/* ---- Chat rooms ------------------------------------------------------ */
.mm.room { width: 560px; height: 430px; min-height: 280px; }
.room .topic { padding: 2px 4px; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-main { flex: 1; display: flex; gap: 6px; min-height: 0; position: relative; }
.room-main .transcript { flex: 1; }
.people { width: 150px; overflow-y: auto; padding: 2px 0; display: flex; flex-direction: column; }
.people-head { font-weight: bold; padding: 2px 6px 4px; }
.mm .window-body .person {
  display: block; width: 100%; text-align: left; border: none; box-shadow: none; background: none;
  padding: 2px 6px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mm .window-body .person:hover, .mm .window-body .person:focus-visible { background: var(--sel); color: #fff; outline: none; }
.mm .window-body .person:active:not(:disabled) { border: none; box-shadow: none; }
.person.offline, .person.invited { color: var(--shadow); }
.person.invited { font-style: italic; }
.mm .window-body .people-btn { display: none; }
.lock.public { background: #eef3ff; border-color: #88a; }
.line.mention { background: #ffff9c; }
.bl-item.mention .name { font-weight: bold; }
.rooms-list { max-height: 220px; }
.room-row { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border-bottom: 1px solid #e4e4e4; }
.room-row:last-child { border-bottom: none; }
.room-name { font-weight: bold; }

/* ---- Dialogs ---------------------------------------------------------- */
.mm.mm-dialog { width: 320px; }
.mm.mm-dialog.wide { width: 380px; }
.safety { display: grid; grid-template-columns: repeat(4, auto); justify-content: center; gap: 4px 12px; font: bold 15px "Courier New", monospace; padding: 8px; }
.mm .code { font: bold 17px "Courier New", monospace; text-align: center; padding: 8px; letter-spacing: 1px; user-select: all; -webkit-user-select: all; }
.mm .list { max-height: 120px; overflow-y: auto; padding: 2px; }
.mm .list .row { padding: 2px 4px; }
.banner-warn { background: #ffe0e0; border: 1px solid #c00; padding: 6px; }

/* ---- Admin tools ----------------------------------------------------- */
.campaigns { max-height: 200px; }
.campaign { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-bottom: 1px solid #e4e4e4; }
.campaign:last-child { border-bottom: none; }
.campaign-code { font: bold 13px "Courier New", monospace; }
.campaign.expired, .campaign.full { color: var(--shadow); }
.mm form.row input { flex: 1; }

/* ---- New-message notice (phones) --------------------------------------- */
.toast {
  position: absolute; z-index: 100000;
  top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px;
  min-height: 48px; padding: 10px 12px;
  background: #ffffe1; color: #000; text-align: left;
  border: 1px solid #000; box-shadow: 2px 2px 0 #000;
  font: 15px Tahoma, sans-serif;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  animation: toast-in .15s ease-out;
}
@keyframes toast-in { from { transform: translateY(-20px); opacity: 0; } }

/* ---- Phones: every window is full-screen; switch with the taskbar or Back.
   Keep in sync with PHONE_QUERY in dom.js. ------------------------------ */
@media (max-width: 640px), (max-height: 500px) and (pointer: coarse) {
  .mm .window-body { overflow-y: auto; padding: 8px; gap: 8px; }
  .mm.im .window-body, .mm.room .window-body { overflow: hidden; }

  .mm .window-body button { min-height: 40px; }
  .mm .window-body .linkish { min-height: 32px; }
  .mm input[type=text], .mm input[type=password], .mm input[type=number], .mm textarea, .mm select { font-size: 16px; padding: 6px; } /* 16px stops iOS zooming */
  .mm .check { min-height: 36px; }
  .mm .check input { width: 20px; height: 20px; }

  .signon .hero { padding: 18px 8px 14px; }

  .bl-head { padding: 8px; }
  .bl-group { padding: 10px 8px; font-size: 14px; }
  .bl-item { padding: 0 10px 0 26px; min-height: 46px; font-size: 16px; gap: 8px; }
  .bl-item .tag { font-size: 12px; }
  .mm .window-body .bl-item button { min-height: 36px; min-width: 44px; font-size: 16px; }
  .bl-item .badge { font-size: 13px; line-height: 22px; min-width: 24px; border-radius: 11px; }
  .bl-buttons { gap: 6px; }
  .away-banner { padding: 6px 8px; }

  .transcript { font-size: 16px; padding: 6px 8px; }
  .line { margin: 3px 0; }
  .ts { font-size: 12px; }
  .mm .statusbar { font-size: 12px; }
  .mm .compose textarea { height: auto; min-height: 44px; max-height: 120px; font-size: 16px; }
  .mm .window-body .compose button { min-width: 72px; }

  .mm .window-body .people-btn { display: inline-block; }
  .people {
    display: none; position: absolute; inset: 0 0 0 auto; width: min(260px, 75%); z-index: 2;
    box-shadow: -3px 0 0 rgba(0,0,0,.25), inset 1px 1px var(--dark);
  }
  .room.show-people .people { display: flex; }
  .mm .window-body .person { min-height: 44px; font-size: 16px; padding: 0 12px; }
  .people-head { padding: 8px 12px; font-size: 14px; }
  .room-row { padding: 8px; }
  .rooms-list { max-height: none; }

  .safety { font-size: 16px; gap: 6px 10px; }
  .mm .list { max-height: none; }
}
