/* Chat PWA shell. Keep colors from app.css. Full-height on a phone, column on a desk. */
.chat-body {
  min-height: 100dvh;
}
/* First paint: restoring shell, never the sign-in form, until JS knows. */
#screen-restore { display: none; }
html.boot #screen-signin,
html.boot #screen-talk,
html.boot #screen-down,
html.boot #screen-chats {
  display: none !important;
}
html.boot:not(.has-session) #screen-restore {
  display: flex !important;
}
html.boot.has-session #screen-chats {
  display: flex !important;
}
.keep-app {
  width: min(480px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #1a0f08;
  background-image: url("/tile-stone.png");
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top);
  overflow: hidden;
}
.drill {
  margin: 0;
  flex: none;
  background: #000;
  color: #9cff9c;
  text-align: center;
  font-size: 13px;
  padding: 4px 8px;
}
.gate {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 28px;
}
.chat-crest {
  border: 3px double #d4af37;
  margin-bottom: 12px;
}
.chat-crest img.logo {
  width: min(94%, 560px);
  height: auto;
}
.chat-crest h1 {
  font-size: 28px;
}
.chat-body input[type="text"],
.chat-body input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  font-size: 16px;
  padding: 8px;
}
.chat-body #signin button[type="submit"],
.chat-body .name-card button[type="submit"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 18px;
}
.install-tip p {
  margin: 0;
}
.install-tip p + p {
  margin-top: 6px;
}
.keep-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  background: #3d1f0f;
  color: #ffd700;
  padding: 8px 10px;
  border-bottom: 4px ridge #d4af37;
}
.keep-bar h2 {
  margin: 0;
  font-size: 20px;
  font-family: "Times New Roman", Times, serif;
  color: #ffd700;
}
.keep-bar .who {
  margin: 0;
  color: rgba(243, 226, 184, 0.8);
  font-size: 13px;
}
.keep-bar .spacer { flex: 1; }
.logo-sm {
  width: 36px;
  height: 36px;
  border: 2px double #d4af37;
  background: #111;
  border-radius: 4px;
  object-fit: cover;
  flex: none;
}
.chat-body .keep-bar button,
.chat-body a.bar-link {
  background: #444;
  color: #fff;
  border: 3px outset #888;
  padding: 4px 8px;
  font-size: 14px;
  font-family: "Comic Sans MS", "Times New Roman", cursive;
  font-weight: bold;
  text-decoration: none;
}
.chat-list, .thread {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.chat-list {
  padding-bottom: 88px;
}
.chat-body button.chat-row {
  display: flex;
  width: 100%;
  gap: 14px;
  align-items: center;
  text-align: left;
  background: transparent;
  color: #f3e2b8;
  border: 0;
  border-bottom: 1px solid rgba(138, 106, 42, 0.45);
  border-radius: 0;
  padding: 12px 16px;
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  font-weight: normal;
}
.chat-row .meta { min-width: 0; flex: 1; }
.chat-row .title {
  font-weight: bold;
  color: #f3e2b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row .kind { color: #ffd700; font-size: 12px; font-weight: bold; }
.chat-row .preview {
  color: rgba(243, 226, 184, 0.7);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid #c9a227;
  background: #3d1f0f;
  color: #ffd700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex: none;
}
.avatar.group { background: #990000; }
.chat-body button.fab {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #c9a227;
  color: #1a0f08;
  border: 3px outset #f6e27a;
  font-size: 32px;
  line-height: 1;
  padding: 0;
  z-index: 2;
}
.empty-keep {
  text-align: center;
  color: #f3e2b8;
  padding: 32px 16px;
}
.empty-keep img, .empty-talk img {
  width: 56px;
  height: 56px;
  border: 2px double #d4af37;
  background: #111;
}
.empty-talk {
  margin: auto;
  text-align: center;
  color: #f3e2b8;
  padding: 28px 16px;
}
.bubble-wrap { margin: 6px 12px; display: flex; }
.bubble-wrap.mine { justify-content: flex-end; }
.bubble-col { max-width: 78%; }
.bubble {
  padding: 8px 13px;
  font-family: "Times New Roman", Times, serif;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble img.media,
.bubble video.media {
  display: block;
  max-width: min(240px, 70vw);
  max-height: 240px;
  border-radius: 8px;
}
.bubble.sticker {
  background: transparent;
  padding: 0;
}
.bubble.sticker img.media {
  width: 128px;
  height: 128px;
  object-fit: contain;
}
.bubble-wrap.mine .bubble {
  background: #c9a227;
  color: #1a0f08;
  border-radius: 18px 18px 4px 18px;
}
.bubble-wrap.mine .bubble.sticker { background: transparent; }
.bubble-wrap.theirs .bubble {
  background: #f3e2b8;
  color: #2a1608;
  border-radius: 18px 18px 18px 4px;
}
.stamp {
  font-size: 11px;
  color: rgba(243, 226, 184, 0.65);
  margin: 2px 6px 0;
}
.bubble-wrap.mine .stamp { text-align: right; }
.composer {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: none;
  background: #3d1f0f;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 4px ridge #d4af37;
}
.composer input { flex: 1; margin: 0; }
.chat-body .composer button {
  background: #c9a227;
  color: #1a0f08;
  border: 3px outset #f6e27a;
  padding: 8px 10px;
  flex: none;
}
.sticker-tray {
  flex: none;
  max-height: 196px;
  overflow: auto;
  background: #1a0f08;
  border-top: 4px ridge #d4af37;
  padding: 8px;
}
.sticker-packs { display: flex; gap: 6px; margin-bottom: 8px; }
.chat-body .sticker-packs button.pack {
  background: #3d1f0f;
  color: #ffd700;
  border: 2px outset #d4af37;
  padding: 4px 8px;
}
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.chat-body button.sticker {
  background: #2a1608;
  border: 1px solid #c9a227;
  padding: 2px;
}
.sticker-grid img {
  width: 100%;
  height: 48px;
  object-fit: contain;
  display: block;
}
.chat-body .error { padding: 4px 12px; margin: 0; }
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  padding: 16px;
}
.name-card {
  width: min(360px, 100%);
  margin: 0;
}
.name-card h2 { font-size: 22px; }
.chat-body .name-card button.ghost { width: auto; margin-top: 8px; }
