/* Pinbox — dark gallery theme. Warm near-black so shared pins pop like prints in a darkroom. */

:root {
  --bg: #141013;
  --panel: #1c1619;
  --raised: #262024;
  --hairline: #352b30;
  --bubble-in: #2a2226;
  --red: #e60023;
  --red-deep: #b8001c;
  --text: #f4ecea;
  --muted: #a5959a;
  --faint: #6f6167;
  --radius: 16px;
}

/* touch-action is NOT inherited, so it must be set on every element — putting it
   only on <body> leaves double-tap zoom live on inputs, buttons and the message
   list. `manipulation` kills double-tap-to-zoom while keeping scrolling and
   pinch-to-zoom, unlike user-scalable=no. */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

/* The page canvas is panel-coloured, not the dark chat background, so that any
   safe-area bleed above the header or below the composer blends into them
   invisibly instead of showing as a dark band. */
html, body { height: 100%; background: var(--panel); }

body {
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ---------- wordmark ---------- */

.wordmark {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wordmark.small { font-size: 19px; gap: 8px; }
.pin-dot {
  width: 0.62em; height: 0.62em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff3352, var(--red) 60%, var(--red-deep));
  box-shadow: 0 0 12px rgba(230, 0, 35, 0.55);
  flex: none;
}

/* ---------- setup screen ---------- */

.setup {
  position: fixed;
  inset: 0;
  background: var(--bg);   /* body is panel-coloured now, so state it explicitly */
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}
.setup-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 36px;
}
.setup-lede { color: var(--muted); margin: 14px 0 22px; }
.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}
.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  align-items: baseline;
  color: var(--text);
}
.steps li::before {
  content: counter(step);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--red);
  border: 1px solid var(--hairline);
  border-radius: 50%;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  flex: none;
  transform: translateY(4px);
}
.steps b { color: #fff; }

#cookie-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font: 13px/1.5 Consolas, monospace;
  resize: vertical;
}
#cookie-input:focus { outline: 2px solid var(--red); outline-offset: -1px; }

.login-card { max-width: 420px; }
.text-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 16px;
  font-size: 16px; /* >=16px stops iOS from zooming on focus */
  margin-bottom: 12px;
}
.text-field:focus { outline: 2px solid var(--red); outline-offset: -1px; }

.setup-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.setup-status { color: var(--muted); font-size: 14px; }
.setup-status.err { color: #ff6b81; }
.setup-status.ok { color: #7ddb9a; }

/* ---------- buttons ---------- */

.btn-primary {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 500;
  font-size: 15px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #ff1a3d; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 16px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }

.icon-btn {
  background: none;
  border: 0;
  color: var(--faint);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.icon-btn:hover { color: var(--text); background: var(--raised); }

button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

/* ---------- app layout ---------- */

/* Pinned to the viewport rather than sized with vh/dvh — iOS standalone PWAs
   report those inconsistently, which left a dead strip under the composer. */
.app {
  display: grid;
  grid-template-columns: 330px 1fr;
  position: fixed;
  inset: 0;
}

/* ---------- sidebar ---------- */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
}
.search-wrap { padding: 0 14px 12px; }
#search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--text);
  padding: 9px 16px;
  font-size: 14px;
}
#search::placeholder { color: var(--faint); }

.convo-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }

.convo {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
}
.convo:hover { background: var(--raised); }
.convo.active { background: var(--raised); box-shadow: inset 3px 0 0 var(--red); }

.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--raised);
  flex: none;
}

/* avatar slot: holds a single photo or a group mosaic, always a clean circle */
.avatar-slot {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--raised);
  flex: none;
  display: block;
}
.avatar-slot > * { width: 100%; height: 100%; }
.avatar-img { object-fit: cover; display: block; }
.avatar-mosaic { display: flex; gap: 1px; background: var(--panel); }
.avatar-mosaic .col { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.avatar-mosaic img { flex: 1; width: 100%; min-height: 0; object-fit: cover; display: block; background: var(--raised); }

.convo .avatar-slot { width: 46px; height: 46px; }
.thread-avatar-slot {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--raised);
  flex: none;
  display: block;
}
.thread-avatar-slot > * { width: 100%; height: 100%; }

.convo-meta { min-width: 0; flex: 1; }
.convo-name {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.convo-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.convo-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  flex: none;
}
.convo-time { color: var(--faint); font-size: 11.5px; }
.unread-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(230, 0, 35, 0.6);
}
.convo-more { padding: 10px; text-align: center; }

/* ---------- thread ---------- */

/* Opaque: on mobile this pane slides over the conversation list, so it must
   fully cover it rather than letting the list show through. */
.thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.thread-empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--faint);
}
.empty-pin {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px dashed var(--hairline);
  position: relative;
}
.empty-pin::after {
  content: "";
  position: absolute; inset: 18px;
  border-radius: 50%;
  background: var(--raised);
}

.thread-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
  background: var(--panel);
}
.thread-name { font-family: "Space Grotesk", sans-serif; font-weight: 500; font-size: 17px; }
.thread-sub { color: var(--faint); font-size: 12px; text-decoration: none; }
.thread-sub:hover { color: var(--muted); text-decoration: underline; }

/* ---------- messages ---------- */

.messages-wrap {
  flex: 1;
  position: relative;   /* anchors the "new message" pill */
  min-height: 0;
  display: flex;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 12px;
  /* No scroll-behavior:smooth here — programmatic position restores must be
     instant and invisible. jumpToMessage animates explicitly instead. */
  overflow-anchor: none;
}

/* Floating "new message" pill — appears instead of yanking you to the bottom */
.new-msg-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  font: 500 13.5px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  animation: pill-in 0.22s ease;
}
.new-msg-pill:hover { background: #ff1a3d; }
.pill-arrow { font-size: 15px; line-height: 1; }
@keyframes pill-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.load-older {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-bottom: 14px;
  color: var(--faint);
  font-size: 12.5px;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--hairline);
  border-top-color: var(--red);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* reply quote shown above a message that answered another */
.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 300px;
  padding: 6px 12px;
  margin-bottom: -4px;      /* tuck it against the bubble below */
  border-left: 3px solid var(--red);
  background: var(--raised);
  border-radius: 10px 10px 4px 4px;
  font-size: 12.5px;
}
.reply-quote.linked { cursor: pointer; }
.reply-quote.linked:hover { background: #2f272b; }
.reply-head { display: flex; align-items: center; gap: 5px; }
.reply-arrow { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.reply-who { color: #ff6b81; font-weight: 700; }
.reply-text {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
/* the reply bubble itself gets a matching left accent so it reads as "a reply" at a glance */
.msg-row.is-reply .bubble { box-shadow: inset 3px 0 0 var(--red); }
.msg-row.mine.is-reply .bubble { box-shadow: inset -3px 0 0 rgba(255, 255, 255, 0.6); }
.msg-row.mine .reply-quote { border-left: 0; border-right: 3px solid var(--red); align-items: flex-end; }
.msg-row.mine .reply-head { flex-direction: row-reverse; }
.msg-row.flash .bubble, .msg-row.flash .pin-card { animation: flash 1.2s ease; }
@keyframes flash {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 3px rgba(230, 0, 35, 0.55); }
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 14px;
  color: var(--faint);
  font-size: 12px;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.day-sep::before, .day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.msg-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  max-width: 72%;
}
.msg-row.grouped { margin-top: 2px; }
.msg-row.mine { margin-left: auto; flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--raised);
  flex: none;
  align-self: flex-end;
}
.msg-avatar.spacer { visibility: hidden; height: 0; }
.msg-row.mine .msg-avatar { display: none; }

.msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-row.mine .msg-col { align-items: flex-end; }

.bubble {
  background: var(--bubble-in);
  border-radius: var(--radius);
  border-bottom-left-radius: 5px;
  padding: 9px 14px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  width: fit-content;
  max-width: 100%;
}
.msg-row.mine .bubble {
  background: linear-gradient(160deg, #ff1a3d, var(--red) 55%, var(--red-deep));
  color: #fff;
  border-radius: var(--radius);
  border-bottom-right-radius: 5px;
}
.bubble a { color: inherit; }
.msg-row.pending { opacity: 0.55; }
.msg-row.failed .bubble { outline: 1px solid #ff6b81; }

.msg-time {
  color: var(--faint);
  font-size: 11px;
  padding: 0 4px;
}

/* shared pins render as prints */
.pin-card {
  display: block;
  width: 240px;
  max-width: 100%;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease;
}
.pin-card:hover { transform: translateY(-2px); }
.pin-card img { width: 100%; display: block; background: var(--bubble-in); min-height: 80px; }
.pin-card-caption {
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pin-card-caption b { color: var(--text); font-weight: 600; display: block; white-space: normal; }

/* ---------- composer ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--hairline);
  background: var(--panel);
}
#composer-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 22px;
  color: var(--text);
  padding: 11px 18px;
  font: 15px/1.4 "Segoe UI", system-ui, sans-serif;
  resize: none;
  max-height: 140px;
}
#composer-input::placeholder { color: var(--faint); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
  transition: background 0.15s, transform 0.1s;
}
.send-btn:hover { background: #ff1a3d; }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { background: var(--raised); color: var(--faint); cursor: default; }

.composer-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.composer-btn:hover { background: var(--raised); color: var(--text); }

/* ---------- reply affordance + reply bar ---------- */

/* Tap a message to reveal this. Lives inside the message column (not floating
   beside it) so it can never run off the edge of a phone screen. */
.reply-btn {
  display: none;
  align-self: flex-start;
  margin-top: 5px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font: 500 12.5px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.msg-row { position: relative; }
.msg-row.mine .reply-btn { align-self: flex-end; }
.msg-row.show-reply .reply-btn { display: inline-flex; }
.reply-btn:hover { color: var(--text); border-color: var(--faint); }

/* On a mouse, hovering is enough — no click needed. */
@media (hover: hover) {
  .msg-row:hover .reply-btn { display: inline-flex; }
}

.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--panel);
  border-top: 1px solid var(--hairline);
}
.reply-bar-body { flex: 1; min-width: 0; border-left: 3px solid var(--red); padding-left: 10px; }
.reply-bar-label { font-size: 12px; color: var(--muted); }
.reply-bar-label b { color: #ff6b81; }
.reply-bar-text {
  display: block;
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- embeds inside messages ---------- */

/* Embeds live INSIDE the bubble (Discord/iMessage style), so the player reads as
   part of the message rather than a detached card floating beneath it. */
.bubble .msg-embed { margin-top: 8px; }
.bubble:has(.msg-embed) { padding-bottom: 10px; }

.msg-embed {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  width: 300px;
}
.msg-embed.video {
  width: 300px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
}
.msg-embed.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.yt-title {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--muted);
  background: var(--raised);
  display: flex;
  align-items: center;
  gap: 6px;
}
.yt-title b { color: var(--text); font-weight: 600; }
.yt-facade {
  position: relative;
  width: 100%; height: 100%;
  cursor: pointer;
  background-size: cover;
  background-position: center;
}
.yt-facade::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 62px; height: 44px;
  border-radius: 12px;
  background: rgba(230, 0, 35, 0.92);
}
.yt-facade:hover::after { background: #e60023; }
.yt-facade .yt-play {
  position: absolute; inset: 0; margin: auto;
  width: 20px; height: 22px;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
  background: #fff;
  z-index: 1;
}
.link-card {
  display: block;
  margin-top: 6px;
  padding: 10px 14px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  max-width: 320px;
}
.link-card .link-domain { color: var(--red); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.link-card .link-url { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble a { color: #ff9bab; text-decoration: underline; }
.msg-row.mine .bubble a { color: #fff; }

/* ---------- modals (pin picker, upload) ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 16px;
}
.modal-card {
  width: min(560px, 100%);
  max-height: 86vh;
  max-height: 86dvh;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.modal-tabs { display: flex; gap: 6px; }
.tab {
  background: none; border: 0; color: var(--muted);
  font: 500 14px "Space Grotesk", sans-serif;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.tab.active { background: var(--raised); color: var(--text); }

.pin-search-wrap { padding: 12px 16px 0; }
#pin-search-input {
  width: 100%;
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 999px; color: var(--text);
  padding: 10px 16px; font-size: 16px;
}
.pin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
}
.pin-tile {
  display: block;
  position: relative;   /* anchors the image so it can never overflow */
  width: 100%;
  height: 0;
  padding-top: 100%;    /* square box — works everywhere, unlike aspect-ratio */
  border: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  background: var(--raised);
}
.pin-tile img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.pin-tile:hover { outline: 2px solid var(--red); }
.pin-grid .empty, .pin-grid .spinner-row { grid-column: 1 / -1; text-align: center; color: var(--faint); padding: 24px; }

.upload-card { width: min(440px, 100%); }
.upload-preview { width: 100%; max-height: 300px; object-fit: contain; background: var(--bg); }
.upload-note { color: var(--muted); font-size: 12.5px; padding: 12px 16px 4px; }
.upload-board-label { display: block; color: var(--muted); font-size: 13px; padding: 8px 16px; }
.upload-board {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 10px; font-size: 15px;
}
#upload-caption { margin: 0 16px; width: calc(100% - 32px); }
.upload-actions { display: flex; align-items: center; gap: 12px; padding: 14px 16px 18px; }

/* ---------- pin lightbox ---------- */

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; z-index: 50; padding: 24px;
}
.lightbox-img { max-width: 100%; max-height: 78vh; object-fit: contain; border-radius: 10px; }
.lightbox-close { position: absolute; top: 16px; right: 16px; font-size: 26px; color: #fff; }
.lightbox-link { color: var(--text); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #2e2226;
  border: 1px solid #58343c;
  color: #ffb3bf;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  max-width: 80vw;
  z-index: 50;
}

/* ---------- scrollbars ---------- */

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--hairline); }

/* ---------- small screens ---------- */

/* back button: only on mobile */
.thread-back { display: none; font-size: 30px; line-height: 1; padding: 0 6px; }

@media (max-width: 760px) {
  /* Do NOT set position here — .app must stay `fixed; inset: 0` so it keeps its
     full-viewport height. Its panes are absolutely positioned and contribute no
     height, so a `relative` .app would collapse to zero and render nothing. */
  .app { grid-template-columns: 1fr; overflow: hidden; }
  /* Both panes fill the screen and are stacked; the thread slides in from the
     right over the list, like a native chat app. */
  .sidebar, .thread {
    position: absolute;
    inset: 0;
    display: flex;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }
  .thread { transform: translateX(100%); z-index: 2; }
  .sidebar { transform: translateX(0); z-index: 1; }
  .app.viewing-thread .thread { transform: translateX(0); }
  .app.viewing-thread .sidebar { transform: translateX(-24%); } /* subtle parallax */

  .thread-back { display: inline-flex; }
  .msg-row { max-width: 86%; }
  .convo { padding: 12px; }
  /* max(), not addition — the home-indicator inset already IS the clearance we
     need. Adding padding on top of it created a dead band under the composer. */
  .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .sidebar-head { padding-top: calc(18px + env(safe-area-inset-top)); }
  .thread-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  /* 16px+ keeps iOS from zooming the page when a field is focused */
  #composer-input, #search { font-size: 16px; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .sidebar, .thread { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pin-card, .send-btn { transition: none; }
  .spinner { animation-duration: 1.6s; }
  .msg-row.flash .bubble, .msg-row.flash .pin-card { animation: none; }
}
