/* v16 Messages: an original messaging look */

:root {
  --ink: #171512;
  --paper: #fbf8f2;
  --bone: #efe8db;
  --muted: #7b746a;
  --line: rgba(23, 21, 18, 0.1);
  --ver: #e0452a;
  --ver-ink: #1a0f0b;
  --steven: #1c1a17;
  --steven-ink: #f6f1e7;
  --font: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;
  --marker: "Permanent Marker", "Marker Felt", "Comic Sans MS", cursive;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.18 0 0 0 0 0.1 0 0 0 0.32 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; height: 100%; }

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--ver); outline-offset: 2px; }

/* ---------- App frame ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  overflow: hidden;
}

@media (min-width: 960px) {
  body {
    padding: 20px;
    background-color: #1d1b18;
    background-image: var(--grain), radial-gradient(ellipse 80% 70% at 30% 20%, #2a2723, #161411);
  }
  .app {
    max-width: 1320px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    margin: 0 auto;
    grid-template-columns: 380px minmax(0, 1fr);
    border-radius: 24px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 40px 80px -30px rgba(0, 0, 0, 0.7);
  }
}

@media (max-width: 959px) {
  .home .main { display: none; }
  .chat .side { display: none; }
}
@media (min-width: 960px) {
  .phone-only { display: none !important; }
}

/* ---------- Thread list ---------- */

.side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 6px;
}
.me {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.me-text { min-width: 0; display: flex; flex-direction: column; }
.me-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.me-line {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 10px;
}
.side-title h2 {
  margin: 0;
  font-size: clamp(34px, 9vw, 42px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 96;
}
.side-count {
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.threads {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0 8px calc(18px + env(safe-area-inset-bottom));
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.thread {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 10px;
  border-radius: 18px;
  color: inherit;
  text-decoration: none;
  transition: background 0.2s;
}
a.thread:hover { background: #f2ece1; }
.thread.current { background: var(--ink); color: var(--paper); }
.thread.current .th-prev, .thread.current .th-meta { color: rgba(251, 248, 242, 0.7); }
.th-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.th-top, .th-bottom {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.th-bottom { align-items: center; }
.th-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-meta { flex: none; font: 400 12px/1 var(--mono); color: var(--muted); }
.th-prev {
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  flex: none;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--ver);
  color: var(--ver-ink);
  font: 500 12px/22px var(--mono);
  text-align: center;
}
.thread.empty .th-title { color: var(--muted); }
.thread.empty .typing { color: var(--muted); }

/* ---------- Avatars ---------- */

.av {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border-radius: 17px;
  background: #e7dfd0;
  color: var(--ink);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
}
.av img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.av-sb {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  letter-spacing: 0.03em;
}
.av-q { background: var(--ver); color: var(--ink); font-size: 32px; }
.av-m { background: linear-gradient(135deg, #f4f6f7, #c4cacd 55%, #e9ecee); }
.av-m span { display: inline-block; transform: scaleX(-1); }
.av-s {
  background: #fffdf5;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(0, 0, 0, 0.08);
}
.av-s span { display: inline-block; font-family: var(--marker); font-weight: 400; transform: rotate(-6deg); }
.av-empty { background: transparent; box-shadow: inset 0 0 0 2px transparent; border: 2px dotted #b4ab9c; }
.av-head { width: 40px; height: 40px; border-radius: 13px; font-size: 18px; }
.av-head.av-q { font-size: 24px; }

/* ---------- Basket ---------- */

.bag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 40px;
  padding: 0 12px 0 10px;
  border-radius: 14px;
  background: var(--bone);
  color: var(--ink);
}
.bag svg { width: 20px; height: 20px; }
.count { font: 500 13px/1 var(--mono); }
.count.bump { animation: bump 0.5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.6); color: var(--ver); } 100% { transform: scale(1); } }

/* ---------- Profile pane (home, wide screens) ---------- */

.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.profile { background: #efe9de; }
.pf-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 56px 32px 48px;
}
.pf { width: min(640px, 100%); text-align: center; }
.av-xl { width: 116px; height: 116px; margin: 0 auto; border-radius: 34px; font-size: 40px; }
.pf-name { margin: 20px 0 4px; font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.pf-line { margin: 0; font-size: 16px; color: var(--muted); }
.pf-count {
  margin: 12px 0 0;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.pf-h {
  margin: 44px 0 14px;
  text-align: left;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.media {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.tile-link {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
}
.av-tile { width: 100%; height: 100%; border-radius: 16px; font-size: 44px; }
.av-tile.av-q { font-size: 64px; }
.tile-link:hover .av-tile img { transform: scale(1.06); }
.tl-no {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 5px 7px;
  border-radius: 8px;
  background: rgba(251, 248, 242, 0.94);
  font: 500 11px/1 var(--mono);
  color: var(--ink);
}

/* ---------- Conversation ---------- */

.convo { background-color: #ebe5d9; }
.convo-head {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.back {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: -4px;
  border-radius: 14px;
  color: var(--ink);
}
.back svg { width: 24px; height: 24px; }
.back:hover { background: var(--bone); }
@media (min-width: 960px) { .back { display: none; } }
#headAv { display: contents; }
.who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.who h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.status.live { color: var(--ver); }
.flipall {
  flex: none;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font: 600 14px/1 var(--font);
  cursor: pointer;
}
.flipall[aria-pressed="true"] { background: var(--ver); color: var(--ver-ink); }
.flipall[hidden] { display: none; }

.msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px clamp(12px, 3.4vw, 48px) 28px;
  outline: none;
}
.msgs:focus-visible { box-shadow: inset 0 0 0 3px var(--ver); }

.row { display: flex; flex-direction: column; max-width: 100%; min-width: 0; }
.row.in { align-items: flex-start; }
.row.out { align-items: flex-end; }
.row.sys { align-items: center; margin: 12px 0; }
.row.out + .row.in, .row.in + .row.out { margin-top: 8px; }

.bubble {
  position: relative;
  max-width: min(80%, 560px);
  padding: 10px 14px 9px;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
  color: var(--steven-ink);
  font-size: 16px;
  line-height: 1.42;
  overflow-wrap: break-word;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  transform-origin: 0 100%;
  animation: pop 0.34s cubic-bezier(.2, .9, .3, 1.2) both;
}
.row.out .bubble {
  border-radius: 20px 20px 6px 20px;
  background: var(--ver);
  color: var(--ver-ink);
  font-weight: 600;
  transform-origin: 100% 100%;
}
.row.in + .row.in .bubble { border-top-left-radius: 9px; }
.row.out + .row.out .bubble { border-top-right-radius: 9px; }
.t {
  float: right;
  margin: 7px 0 0 12px;
  font: 400 10.5px/1 var(--mono);
  opacity: 0.55;
}
.rcpt {
  display: none;
  margin-top: 4px;
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(23, 21, 18, 0.6);
}
.row.out.seen .rcpt { display: block; }
.dark .rcpt { color: rgba(239, 232, 219, 0.7); }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

.sys span {
  display: inline-block;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(251, 248, 242, 0.9);
  color: rgba(23, 21, 18, 0.72);
  font: 500 11.5px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.dark .sys span { background: rgba(255, 255, 255, 0.1); color: #e9e2d4; box-shadow: none; }

.typing { display: inline-flex; align-items: center; gap: 4px; height: 14px; }
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.typing-b { padding: 13px 16px; }

/* Photo messages */
.ph {
  display: block;
  width: min(78vw, 420px);
  max-width: 100%;
  aspect-ratio: 3 / 2;
  padding: 4px;
  border: 0;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
  cursor: zoom-in;
  transform-origin: 0 100%;
  animation: pop 0.4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.ph img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px 16px 16px 3px;
}

.dump {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  width: min(80vw, 440px);
  max-width: 100%;
  padding: 4px;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
}
.tile {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background-color: #2a2622;
  background-repeat: no-repeat;
  cursor: zoom-in;
  animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.2) both;
  animation-delay: calc(var(--i, 0) * 110ms);
}
.tile.wide {
  grid-column: span 2;
  aspect-ratio: 3 / 2;
  background-size: cover;
  background-position: center;
  border-radius: 16px 16px 12px 12px;
}
.dump .tile:last-child { border-bottom-right-radius: 16px; }
.dump .tile:nth-last-child(2) { border-bottom-left-radius: 3px; }

.card-t {
  display: grid;
  place-items: center;
  width: min(78vw, 420px);
  max-width: 100%;
  aspect-ratio: 4 / 3;
  padding: 22px;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
  color: var(--steven-ink);
  font-size: clamp(30px, 8vw, 50px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.025em;
  text-align: center;
  transform-origin: 0 100%;
  animation: pop 0.4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.card-t span { display: inline-block; }
.card-t.q { color: var(--ver); font-size: clamp(140px, 42vw, 240px); line-height: 0.8; font-variation-settings: "opsz" 96; }
.card-t.mir { background: linear-gradient(135deg, #f7f9f9, #c8ced1 55%, #eef1f2); color: var(--ink); }
.card-t.mir span { transform: scaleX(-1); }

/* Stickers */
.stk {
  display: grid;
  place-items: center;
  width: clamp(150px, 44vw, 220px);
  aspect-ratio: 3 / 2;
  padding: 12px;
  border-radius: 6px;
  background: #fffdf5;
  color: #191714;
  font-family: var(--marker);
  font-size: clamp(18px, 4.6vw, 25px);
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 0 0 4px #fff, 0 8px 18px -6px rgba(0, 0, 0, 0.4);
  transform: rotate(var(--r, -3deg));
  animation: slap 0.45s cubic-bezier(.3, 1.4, .5, 1) both;
}
.stk-row { margin: 8px 6px; }
@keyframes slap { from { opacity: 0; transform: scale(1.7) rotate(-16deg); } }
.pack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(86vw, 460px);
  max-width: 100%;
  padding: 16px;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
}
.pack .stk {
  width: 100%;
  font-size: clamp(14px, 3.6vw, 19px);
  box-shadow: 0 0 0 3px #fff, 0 6px 12px -6px rgba(0, 0, 0, 0.5);
  animation-delay: calc(var(--i, 0) * 120ms);
}

/* Details list */
.bubble.list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bubble.list li { display: flex; align-items: baseline; gap: 10px; }
.bubble.list li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ver);
  transform: translateY(-2px);
}

/* Posters */
.pgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(86vw, 560px);
  max-width: 100%;
  padding: 10px;
  border-radius: 20px 20px 20px 6px;
  background: var(--steven);
  color: var(--steven-ink);
  animation: pop 0.4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.pt { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pt-img {
  display: block;
  aspect-ratio: 29 / 51;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2622;
  cursor: zoom-in;
}
.pt-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pt-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.pt-meta { font: 400 11.5px/1.35 var(--mono); opacity: 0.78; }
.pt-add {
  min-height: 38px;
  margin-top: 2px;
  border: 0;
  border-radius: 12px;
  background: var(--ver);
  color: var(--ver-ink);
  font: 700 14px/1 var(--font);
  cursor: pointer;
}
.pt-add.added { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px currentColor; cursor: default; }

/* Payment request */
.pay {
  width: min(82vw, 360px);
  max-width: 100%;
  overflow: hidden;
  border-radius: 22px 22px 22px 6px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 20px 34px -18px rgba(0, 0, 0, 0.5);
  transform-origin: 0 100%;
  animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.pay-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.pay-body { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0; min-width: 0; }
.pay-text { min-width: 0; }
.pay-thumb { width: 56px; height: 56px; border-radius: 15px; }
.pay-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; }
.pay-ed { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.pay-price {
  margin: 16px 16px 0;
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 96;
}
.pay-btn {
  display: block;
  width: calc(100% - 32px);
  min-height: 52px;
  margin: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--ver);
  color: var(--ver-ink);
  font: 700 16px/1 var(--font);
  cursor: pointer;
  transition: transform 0.15s;
}
.pay-btn:active { transform: scale(0.98); }
.pay-btn.added { background: var(--ink); color: var(--paper); cursor: default; }
.pay.done .pay-top { background: var(--ver); color: var(--ver-ink); }

/* Reactions */
.react-row { margin-top: 2px; }
.reacts {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 8px 18px -10px rgba(0, 0, 0, 0.4);
  animation: pop 0.3s both;
}
.react {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.react svg { width: 22px; height: 22px; }
.react:hover { transform: scale(1.12); }
.react[aria-pressed="true"] { background: var(--ver); color: var(--ver-ink); }
.bubble.has-r { margin-bottom: 14px; }
.rbadges { position: absolute; right: -8px; bottom: -16px; display: flex; gap: 3px; }
.rbadge {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ver);
  box-shadow: 0 0 0 2px var(--steven);
  animation: slap 0.35s both;
}
.rbadge svg { width: 15px; height: 15px; }

/* End of a thread */
.endnav-row { margin-top: 18px; }
.endnav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 540px);
}
.navcard {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s;
}
.navcard:hover { transform: translateY(-2px); }
.navcard .av { width: 42px; height: 42px; border-radius: 13px; font-size: 18px; }
.nc-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.nc-dir { font: 500 10.5px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.nc-title { font-size: 14px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Composer ---------- */

.composer {
  position: relative;
  z-index: 3;
  min-height: 66px;
  padding: 11px 12px calc(11px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.tr-mirror .chips { justify-content: flex-start; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 44px;
  padding: 9px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  font: 700 15px/1.15 var(--font);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  animation: chipin 0.35s cubic-bezier(.2, .9, .3, 1.2) both;
  transition: background 0.15s, border-color 0.15s;
}
.chip.go { background: var(--ink); color: var(--paper); }
.chip.go:hover { background: var(--ver); border-color: var(--ver); color: var(--ver-ink); }
.chip.ghost {
  border-color: transparent;
  background: var(--bone);
  font: 500 13px/1 var(--mono);
  letter-spacing: 0.04em;
}
.chip.ghost:hover { border-color: var(--ink); }
.chip small {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}
@keyframes chipin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.tray {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 4px 4px 14px;
}
.tray[hidden] { display: none; }
.tray-stk {
  aspect-ratio: 3 / 2;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: #fffdf5;
  color: #191714;
  font: 400 15px/1.1 var(--marker);
  box-shadow: 0 0 0 2px #fff, 0 4px 10px -4px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--r, 0deg));
  cursor: pointer;
}
.tray-stk:hover { transform: rotate(0deg) scale(1.05); }

/* ---------- Photo viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 12px calc(48px + env(safe-area-inset-bottom));
  background: rgba(14, 13, 11, 0.96);
}
.viewer[hidden] { display: none; }
.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  animation: zoomin 0.3s cubic-bezier(.2, .9, .3, 1.1) both;
}
@keyframes zoomin { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.vclose {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  font: 700 14px/1 var(--font);
  cursor: pointer;
}
.vcap {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  margin: 0;
  color: #cfc8bb;
  font-size: 13px;
  text-align: center;
}

/* ---------- Reflecting on Art: the mirrored thread ---------- */

.tr-mirror .row.in { align-items: flex-end; }
.tr-mirror .row.out { align-items: flex-start; }
.tr-mirror .row.in .bubble,
.tr-mirror .row.in .card-t { border-radius: 20px 20px 6px 20px; transform-origin: 100% 100%; }
.tr-mirror .row.out .bubble { border-radius: 20px 20px 20px 6px; transform-origin: 0 100%; }
.tr-mirror .row.in + .row.in .bubble { border-top-left-radius: 20px; border-top-right-radius: 9px; }
.tr-mirror .row.out + .row.out .bubble { border-top-right-radius: 20px; border-top-left-radius: 9px; }
.bubble.mir {
  display: block;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bubble.mir .tx {
  display: block;
  transform: scaleX(-1);
  transition: transform 0.55s cubic-bezier(.45, 1.5, .5, 1);
}
.bubble.mir.flipped .tx { transform: scaleX(1); }
.tr-mirror .rcpt { align-self: flex-start; }

/* ---------- Wallpapers ---------- */

[data-wall="paper"] {
  background-color: #efe9de;
  background-image: radial-gradient(rgba(23, 21, 18, 0.09) 1px, rgba(0, 0, 0, 0) 1.6px);
  background-size: 18px 18px;
}
[data-wall="kraft"] {
  background-color: #c6a06e;
  background-image:
    var(--grain),
    repeating-linear-gradient(90deg, rgba(90, 60, 25, 0.08) 0 2px, rgba(0, 0, 0, 0) 2px 10px),
    radial-gradient(ellipse 70% 50% at 20% 10%, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 70%);
}
[data-wall="smoke"] {
  background-color: #1b1a18;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(222, 178, 86, 0.5) 0 1.4px, rgba(0, 0, 0, 0) 2px),
    radial-gradient(circle at 70% 60%, rgba(222, 178, 86, 0.35) 0 1px, rgba(0, 0, 0, 0) 1.6px),
    radial-gradient(ellipse 60% 40% at 30% 20%, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 70%),
    radial-gradient(ellipse 50% 50% at 80% 85%, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 70%);
  background-size: 70px 90px, 53px 61px, 100% 100%, 100% 100%;
}
[data-wall="coins"] {
  background-color: #22252a;
  background-image:
    radial-gradient(circle, rgba(0, 0, 0, 0) 0 12px, rgba(205, 210, 216, 0.16) 12.5px 15px, rgba(0, 0, 0, 0) 15.5px),
    radial-gradient(circle, rgba(0, 0, 0, 0) 0 12px, rgba(205, 210, 216, 0.1) 12.5px 15px, rgba(0, 0, 0, 0) 15.5px);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
}
[data-wall="clay"] {
  background-color: #e6d6c0;
  background-image:
    radial-gradient(ellipse 3px 4px at 50% 50%, rgba(110, 82, 50, 0.4), rgba(0, 0, 0, 0) 80%),
    radial-gradient(ellipse 2px 3px at 50% 50%, rgba(110, 82, 50, 0.3), rgba(0, 0, 0, 0) 80%);
  background-size: 38px 38px, 27px 27px;
  background-position: 0 0, 11px 17px;
}
[data-wall="query"] {
  background-color: #f1ede5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cg font-family='Georgia,serif' font-weight='700' fill='%23e0452a' fill-opacity='0.1'%3E%3Ctext x='18' y='76' font-size='70'%3E%3F%3C/text%3E%3Ctext x='96' y='148' font-size='52' transform='rotate(14 110 130)'%3E%3F%3C/text%3E%3C/g%3E%3C/svg%3E");
  background-size: 160px 160px;
}
[data-wall="chrome"] {
  background-color: #d8dcde;
  background-image:
    linear-gradient(115deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.5) 52%, rgba(255, 255, 255, 0) 64%),
    linear-gradient(180deg, #e8ebec, #c7ccce);
}
[data-wall="concrete"] {
  background-color: #bcb5aa;
  background-image:
    var(--grain),
    radial-gradient(ellipse 80% 60% at 70% 20%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 70%);
}
[data-wall="velvet"] {
  background-color: #1a1219;
  background-image: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.26) 0px, rgba(255, 255, 255, 0.045) 26px, rgba(0, 0, 0, 0.26) 52px);
}
[data-wall="brick"] {
  background-color: #4a2419;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.05) 40%, rgba(0, 0, 0, 0.3)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='64'%3E%3Crect width='96' height='64' fill='%234a2419'/%3E%3Crect x='2' y='2' width='92' height='28' rx='2' fill='%237a3b2a'/%3E%3Crect x='-46' y='34' width='92' height='28' rx='2' fill='%23703526'/%3E%3Crect x='50' y='34' width='92' height='28' rx='2' fill='%23824130'/%3E%3C/svg%3E");
  background-size: 100% 100%, 96px 64px;
}
[data-wall="street"] {
  background-color: #e8e4db;
  background-image:
    var(--grain),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg fill='%23ffffff' fill-opacity='0.6' stroke='%23000000' stroke-opacity='0.07'%3E%3Crect x='20' y='30' width='72' height='48' rx='4' transform='rotate(-8 56 54)'/%3E%3Crect x='140' y='110' width='72' height='48' rx='4' transform='rotate(6 176 134)'/%3E%3Crect x='40' y='170' width='60' height='40' rx='4' transform='rotate(-3 70 190)'/%3E%3C/g%3E%3C/svg%3E");
}

.dark { --steven: #f1ebde; --steven-ink: #1a1815; }
.dark .rbadge { box-shadow: 0 0 0 2px var(--steven); }

/* ---------- Narrow ---------- */

@media (max-width: 520px) {
  .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tray { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bubble { max-width: 86%; }
  .endnav { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
