/* test-bridge — one dark panel in a black room. Tokens and rules follow the UI design spec. */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: block;
  src: url("/fonts/figtree-var-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: block;
  src: url("/fonts/figtree-var-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;

  /* colour */
  --page: #000000;  --canvas: #1B1C20;  --raised: #26272D;
  --text: #E6E7EC;  --text-dim: #8B8C90;  --muted: #9A9FAB;
  --accent: #7A8BFF;   /* j: initial, name, every control, links, focus ring, caret */
  --friend: #EFB36A;   /* the friend: initial and name, and the lit header/intro disc */
  --danger: #F27C7C;   /* the only colour that is not a person */
  --hover: rgb(255 255 255 / .04);
  --line:  rgb(255 255 255 / .08);
  --focus: var(--accent);
  --dim: .55;          /* preview image of a sending row only */

  /* type */
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --fs-xs: .75rem;   --lh-xs: 1rem;        /* 12/16 */
  --fs-md: .875rem;  --lh-md: 1.25rem;     /* 14/20 */
  --fs-base: 1rem;   --lh-base: 1.375rem;  /* 16/22 */
  --fs-lg: 1.25rem;  --lh-lg: 1.625rem;    /* 20/26 */

  /* space and size */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-12: 48px;
  --pad-x: 12px;  --gap: 12px;
  --disc: 32px; --disc-sm: 24px; --disc-lg: 56px; --hit: 44px;
  --header-h: 48px; --banner-h: 32px; --panel-max: 680px; --block-max: 360px;
  --gate-w: min(320px, 100% - 48px);
  --img-max-w: 400px; --img-max-h: 320px;

  /* radii (no shadow token: nothing casts one) */
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-pill: 999px;

  /* layers */
  --z-jump: 10; --z-sheet: 15; --z-viewer: 20; --z-lock: 30; --z-black: 40;

  /* motion */
  --ease: cubic-bezier(.2, 0, 0, 1);
  --t-fast: 120ms; --t-base: 150ms;
}
@media (min-width: 720px) and (min-height: 480px) { :root { --disc: 40px; --pad-x: 16px; --gap: 16px; } }
@media (prefers-reduced-motion: reduce) { :root { --t-fast: 0ms; --t-base: 0ms; } }

html, body { margin: 0; height: 100%; background: var(--page); color: var(--text);
  font: 400 var(--fs-base) / var(--lh-base) var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; }
::selection { background: rgb(122 139 255 / .35); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.black, .black:focus { outline: none; }
.panel img, .panel canvas, .viewer img, .viewer canvas { -webkit-user-drag: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; }
[hidden] { display: none !important; }

/* reset the controls we build; every colour and shape below is deliberate */
button, input, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
h1, p, ol, figure { margin: 0; }
a { color: inherit; }

/* ---------- the sprite and the black layer ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.black { position: fixed; inset: 0; background: var(--page); z-index: var(--z-black); touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; cursor: default; outline: none; }

/* ---------- gate layers: sign in, create, vault password, vault down ---------- */
.gate { position: fixed; inset: 0; height: var(--vvh, 100dvh); background: var(--page);
  z-index: var(--z-lock); display: flex; flex-direction: column; overflow-y: auto;
  overscroll-behavior: contain; padding: 16px 0; box-sizing: border-box; }
.gate, .gate:focus { outline: none; }
.gate__col { width: var(--gate-w); margin: auto; display: flex; flex-direction: column; align-items: stretch; }
.gate .btn { width: 100%; }

.signin__error, .lock__error, .lock__status, .create__error, .change__error, .vaultdown__line {
  font-size: var(--fs-md); line-height: var(--lh-md); }
.signin__error, .lock__error, .create__error, .change__error, .vaultdown__line { color: var(--danger); }
.lock__status { color: var(--muted); }
.signin__error, .lock__error, .lock__status { margin-top: 12px; }

.create__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.create__lede { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); margin: 8px 0 24px; }
.create__warn { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); margin-bottom: 12px; }
.create__hint { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); margin-top: 8px; }
.create__error { margin-top: 8px; }
.create__error--words { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: center; }
.create__error--words .textbtn { margin: -12px -4px; }
.create__pw2, .create__typed-words { margin-top: 12px; }
.create__words .create__typed-words { margin-top: 0; }
.create__go, .create__written { margin-top: 16px; }
.create__alt { margin-top: 16px; align-self: flex-start; margin-left: -4px; }
.pass__words { background: var(--raised); border-radius: var(--r-md); padding: 12px 16px; list-style: none;
  display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pass__word { font-weight: 500; color: var(--text); }

/* change vault password (UI spec §12.6): the current field, then the create screen's component under one label */
.change__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.change__current { margin-top: 24px; }
.change__new { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 500; color: var(--text); margin: 24px 0 8px; }
.change__error { margin-top: 8px; }
.change__go { margin-top: 16px; }
.change__cancel { margin-top: 16px; align-self: flex-start; margin-left: -4px; }

/* ---------- fields and buttons: one shape ---------- */
.field { display: block; width: 100%; box-sizing: border-box; height: 44px; background: var(--raised);
  border: 0; border-radius: var(--r-md); padding: 0 16px; font-size: var(--fs-base); line-height: var(--lh-base);
  color: var(--text); caret-color: var(--accent); }
.field::placeholder { color: var(--muted); opacity: 1; }
.field[type="password"]:not(:placeholder-shown) { letter-spacing: .12em; }
.field:-webkit-autofill, .field:-webkit-autofill:hover, .field:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--raised) inset; -webkit-text-fill-color: var(--text); caret-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; height: 44px;
  padding: 0 16px; border-radius: var(--r-md); font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 500;
  width: 100%; }
.btn--primary { background: var(--accent); color: var(--canvas); }
.btn--primary:active { filter: brightness(.94); }
.btn--primary:disabled { background: var(--raised); color: var(--muted); filter: none; }
.btn--secondary { background: var(--raised); color: var(--text); }
.btn--secondary:active { filter: brightness(.94); }
@media (min-width: 720px) and (min-height: 480px) {
  .panel .btn { width: auto; min-width: 120px; }
}

.textbtn { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 4px;
  color: var(--accent); font-weight: 500; font-size: inherit; line-height: inherit; }
.textbtn:active { opacity: .7; }

.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  flex: none; color: var(--muted); }
.iconbtn:focus-visible { color: var(--text); }
.iconbtn:active { opacity: .7; }
.iconbtn:disabled { color: var(--muted); opacity: 1; }

/* ---------- the panel ---------- */
.panel { position: relative; background: var(--canvas); overflow: hidden; display: flex; flex-direction: column;
  height: 100vh; height: var(--vvh, 100dvh); box-sizing: border-box; }
@media (min-width: 720px) and (min-height: 480px) {
  .panel { max-width: var(--panel-max); margin: 16px auto; height: calc(var(--vvh, 100dvh) - 32px); border-radius: var(--r-md); }
}

.top { position: relative; z-index: 1; flex: none; height: var(--header-h); background: var(--raised); display: flex;
  align-items: center; gap: 12px; padding: 0 var(--pad-x); }
.top--scrolled { box-shadow: 0 1px 0 var(--page); }
.top__name { flex: 1; min-width: 0; font-size: var(--fs-base); line-height: var(--lh-base); font-weight: 600;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top__tools { flex: none; width: var(--hit); height: var(--hit); margin-left: auto; display: flex; align-items: center;
  justify-content: flex-end; }
/* the vault button: nothing appears during the hold that opens its sheet; the back control is the chevron turned left */
.top__vault, .top__back { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.top__back svg { transform: rotate(90deg); }

/* the vault button's sheet (UI spec §12.2): one item under the button; a 1 px black seam, because raised on canvas is 1.14:1 */
.sheet { position: absolute; top: calc(var(--header-h) + 4px); right: var(--pad-x); z-index: var(--z-sheet);
  min-width: 200px; padding: 4px 0; background: var(--raised); border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--page); }
.sheet__item { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 16px; box-sizing: border-box;
  font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 500; color: var(--text); text-align: left; }
.sheet__item:active { filter: brightness(.94); }
.sheet__item:focus-visible { outline-offset: -2px; }

.disc { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--disc);
  height: var(--disc); border-radius: var(--r-pill); background: var(--raised); font-weight: 600; font-size: 14px;
  line-height: 1; }
@media (min-width: 720px) and (min-height: 480px) { .disc { font-size: 16px; } }
.disc--them { color: var(--friend); }
.disc--me { color: var(--accent); }
.disc--sm { width: var(--disc-sm); height: var(--disc-sm); font-size: 12px; }
.disc--lg { width: var(--disc-lg); height: var(--disc-lg); font-size: 24px; }
.disc--lit { background: var(--friend); color: var(--canvas); }

.banner { flex: none; min-height: var(--banner-h); background: var(--raised); padding: 0 var(--pad-x); display: flex;
  flex-wrap: wrap; align-items: center; gap: 0 12px; }
.banner__text { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); padding: 6px 0; }
.banner__retry { font-size: var(--fs-md); line-height: var(--lh-md); margin: -6px -4px; }

/* ---------- the list ---------- */
.list-wrap { flex: 1; min-height: 0; position: relative; }
.list { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  scrollbar-color: var(--raised) transparent; padding: 0 var(--pad-x) 8px; box-sizing: border-box; display: flex;
  flex-direction: column; overflow-anchor: none; }
.list:focus-visible { outline-offset: -2px; }
.list__inner { margin-top: auto; }
.list__older { height: 32px; display: flex; justify-content: center; align-items: center; gap: 12px;
  font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500; letter-spacing: .01em; color: var(--muted); }
.list__older .textbtn { font-size: var(--fs-xs); line-height: var(--lh-xs); margin: -6px -4px; }

.day { margin: 24px 0 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 8px; }
.day::before, .day::after { content: ""; display: block; height: 1px; background: var(--line); }
.day__label { font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 600; letter-spacing: .01em; color: var(--muted); }

.intro { padding: 24px 0 16px; }
.intro .disc { margin-bottom: 12px; }
.intro__line { font-size: var(--fs-base); line-height: var(--lh-base); color: var(--text); }
.intro__note { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); }

.group { position: relative; margin-top: 16px; }
.day + .group { margin-top: 0; }
.group > .disc { position: absolute; left: 0; top: 2px; }
.group__head { padding-left: calc(var(--disc) + var(--gap)); display: flex; align-items: baseline; gap: 8px;
  line-height: var(--lh-base); }
.group__name { font-size: var(--fs-base); font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.group--in .group__name { color: var(--friend); }
.group--out .group__name { color: var(--accent); }
.group__time, .msg__gutter time, .msg__metatext { font-variant-numeric: tabular-nums; }
.group__time { flex: none; font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500; letter-spacing: .01em;
  color: var(--muted); }

.msg { display: grid; grid-template-columns: var(--disc) 1fr; column-gap: var(--gap); padding: 2px 0;
  border-radius: var(--r-xs); }
.msg__gutter { display: flex; justify-content: flex-end; align-items: center; min-width: 0; }
.msg__gutter time { visibility: hidden; font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500;
  letter-spacing: .01em; color: var(--muted); white-space: nowrap; }
.msg__body { min-width: 0; }
.msg__text { font-size: var(--fs-base); line-height: var(--lh-base); color: var(--text); white-space: pre-wrap;
  overflow-wrap: anywhere; transition: color var(--t-base) var(--ease); }
.msg[data-status="sending"] .msg__text { color: var(--text-dim); }
.msg__text--file, .msg__text--other, .msg__text--deleted { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); }
.msg__text--deleted { font-size: var(--fs-base); line-height: var(--lh-base); }
.msg__text--file svg { vertical-align: -3px; margin-right: 6px; }
.msg__link { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.msg__state { display: inline-block; margin-left: 6px; vertical-align: -1px; color: var(--muted); line-height: 0; }
.msg__state svg { display: inline-block; vertical-align: top; }
.msg[data-status="failed"] .msg__state { color: var(--danger); }
.msg__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; min-height: 24px; font-size: var(--fs-xs);
  line-height: var(--lh-xs); font-weight: 500; letter-spacing: .01em; }
.msg__metatext { color: var(--muted); }
.msg__fail { display: flex; align-items: center; gap: 12px; height: 24px; font-size: var(--fs-xs); line-height: var(--lh-xs);
  font-weight: 500; letter-spacing: .01em; }
.msg__fail span { color: var(--danger); }
.msg__fail .textbtn { font-size: var(--fs-xs); line-height: var(--lh-xs); margin: -10px -4px; }
/* Keep, after the time on an image row's meta line: a word in the line's type with 44 px of hit area. */
.msg__keep { font-size: var(--fs-xs); line-height: var(--lh-xs); margin: -10px -4px; }
.msg__keep:disabled, .msg__keep:disabled:hover { color: var(--muted); opacity: 1; cursor: default; }
.msg__kept { color: var(--muted); }
.msg__keepfail { color: var(--danger); }

@media (hover: hover) and (pointer: fine) {
  .msg:hover { background: var(--hover); }
  .msg:hover .msg__gutter time { visibility: visible; }
  .msg__link:hover { color: var(--text); }
  .btn--primary:hover { filter: brightness(1.06); }
  .btn--secondary:hover { background-image: linear-gradient(var(--hover), var(--hover)); }
  .textbtn:hover { color: var(--text); }
  .iconbtn:hover { color: var(--text); }
  .sheet__item:hover { background: var(--hover); }
}

/* ---------- images ---------- */
.msg__image { display: block; max-width: 100%; }
.msg__open { position: relative; display: inline-block; vertical-align: top; max-width: 100%; min-height: 44px;
  min-width: 44px; border-radius: var(--r-sm); overflow: hidden; background: var(--raised); cursor: default;
  text-align: center; }
.msg__image[data-state="ready"] .msg__open { cursor: zoom-in; }
.msg__image[data-state="failed"] .msg__open { cursor: pointer; }
.msg__preview { display: block; max-width: 100%; height: auto; margin: 0 auto; transition: opacity var(--t-base) var(--ease); }
.msg[data-status="sending"] .msg__preview { opacity: var(--dim); }
.msg__full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.msg__image--blank .msg__open { width: 240px; height: 180px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); }
.msg__imgnote { position: absolute; left: 0; right: 0; bottom: 0; background: var(--raised); color: var(--text);
  font-size: var(--fs-md); line-height: var(--lh-md); padding: 8px 12px; text-align: left; }
.msg__caption { display: block; font-size: var(--fs-base); line-height: var(--lh-base); color: var(--text); margin-top: 4px;
  white-space: pre-wrap; overflow-wrap: anywhere; transition: color var(--t-base) var(--ease); }
.msg[data-status="sending"] .msg__caption { color: var(--text-dim); }

/* ---------- jump pill ---------- */
.jump { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: var(--z-jump);
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 14px 0 16px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--canvas); font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 500;
  white-space: nowrap; animation: jump-in var(--t-fast) var(--ease); }
.jump::before { content: ""; position: absolute; inset: -2px 0; }
@keyframes jump-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- composer ---------- */
.composer { flex: none; background: var(--canvas); padding: 8px var(--pad-x) calc(8px + env(safe-area-inset-bottom)); }
.composer__note { font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500; letter-spacing: .01em; color: var(--danger);
  padding: 0 12px 6px; }
.composer__box { background: var(--raised); border-radius: var(--r-md); display: flex; flex-direction: column; }
.composer__tray { padding: 12px 12px 0; }
.chip { position: relative; width: 64px; height: 64px; }
.chip__thumb { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); }
.chip__remove { position: absolute; top: -20px; right: -20px; width: 44px; height: 44px; display: flex; align-items: center;
  justify-content: center; color: var(--canvas); }
.chip__remove::before { content: ""; position: absolute; inset: 10px; background: var(--text); border-radius: var(--r-pill); }
.chip__remove svg { position: relative; }
.composer__row { display: flex; align-items: flex-end; min-height: 44px; }
.composer__input { flex: 1; min-width: 0; font-size: var(--fs-base); line-height: var(--lh-base); color: var(--text);
  background: none; border: 0; outline: 0; resize: none; padding: 11px 0; max-height: 154px; caret-color: var(--accent);
  overflow-y: auto; field-sizing: content; box-sizing: border-box; }
.composer__input::placeholder { color: var(--muted); opacity: 1; }
.composer__send { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  color: var(--muted); }
.composer__disc { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--canvas); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.composer[data-state="empty"] .composer__send { visibility: hidden; opacity: 0; }
.composer[data-state="empty"] .composer__disc { opacity: 0; transform: scale(.9); }
.composer[data-offline] .composer__disc { background: none; color: var(--muted); }
.composer[data-offline] .composer__attach { color: var(--muted); }

/* ---------- connect screen ---------- */
.connect { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 16px var(--pad-x);
  box-sizing: border-box; overscroll-behavior: contain; }
.connect__block { width: 100%; max-width: var(--block-max); margin: auto; text-align: left; box-sizing: border-box; }
.connect__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.connect__lede { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); margin: 8px 0 24px; }
.qr { width: 264px; height: 264px; padding: 12px; box-sizing: border-box; background: #FFFFFF; border-radius: var(--r-md); }
.qr svg { display: block; }
.connect__link { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); background: var(--raised);
  border-radius: var(--r-sm); padding: 8px 12px; margin: 12px 0; overflow-wrap: anywhere; max-height: calc(5 * var(--lh-md) + 16px);
  overflow-y: auto; user-select: all; -webkit-user-select: all; box-sizing: border-box; }
.connect__copy { min-width: 120px; }
.connect__wait { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); margin-top: 12px; }
.connect__error { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--danger); margin-top: 8px; }
.connect__pastelabel { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: 500; color: var(--text); margin: 32px 0 8px; }
.connect__go { margin-top: 8px; }
.connect__accepted { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); }

/* ---------- vault screen: one scroller, one grid ---------- */
.vault { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vault__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  scrollbar-color: var(--raised) transparent; padding: 4px var(--pad-x) calc(8px + env(safe-area-inset-bottom));
  box-sizing: border-box; display: flex; flex-direction: column; }
.vault__scroll:focus-visible { outline-offset: -2px; }
.vault__note, .vault__status { flex: none; min-height: 32px; display: flex; flex-wrap: wrap; justify-content: center;
  align-items: center; gap: 0 12px; text-align: center; font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 500;
  letter-spacing: .01em; color: var(--muted); }
.vault__status .textbtn { font-size: var(--fs-xs); line-height: var(--lh-xs); margin: -6px -4px; }
.vault__grid { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-1); list-style: none; margin: 0; padding: 0; }
@media (min-width: 720px) and (min-height: 480px) { .vault__grid { grid-template-columns: repeat(5, 1fr); } }
.tile__open { display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; background: var(--raised);
  border-radius: var(--r-xs); overflow: hidden; position: relative; cursor: default; color: var(--muted); }
.tile[data-state="ready"] .tile__open { cursor: zoom-in; }
.tile[data-state="failed"] .tile__open { cursor: pointer; }
.tile[data-state="blank"] .tile__open, .tile[data-state="failed"] .tile__open { display: inline-flex; align-items: center;
  justify-content: center; }
.tile__canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile__note { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: var(--fs-xs); line-height: var(--lh-xs);
  font-weight: 500; letter-spacing: .01em; color: var(--text); }
.vault__empty { width: 100%; max-width: var(--block-max); margin: auto; text-align: left; padding: 24px 0; box-sizing: border-box; }
.vault__empty-line { font-size: var(--fs-base); line-height: var(--lh-base); color: var(--text); }
.vault__empty-note { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); margin-top: 8px; }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; background: var(--page); z-index: var(--z-viewer); display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: zoom-out; animation: viewer-in var(--t-base) var(--ease); }
@keyframes viewer-in { from { opacity: 0; } to { opacity: 1; } }
.viewer__close { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; cursor: pointer; }
.viewer__img { display: block; object-fit: contain; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); }
@media (min-width: 720px) and (min-height: 480px) {
  .viewer__img { max-width: calc(100vw - 96px); max-height: calc(100dvh - 96px); }
}
.viewer__caption { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); text-align: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); max-width: 60ch; }

/* the vault's viewer on the same layer: a canvas where the <img> is, a foot that says who, when, how far, and Delete */
.viewer[data-source="vault"] { justify-content: flex-start; padding-top: max(16px, env(safe-area-inset-top)); box-sizing: border-box; }
.viewer__canvas { display: block; flex: 1 1 auto; min-height: 0; width: calc(100% - 32px); object-fit: contain; }
@media (min-width: 720px) and (min-height: 480px) { .viewer__canvas { width: calc(100% - 96px); } }
.viewer__foot { flex: none; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); cursor: default; }
.viewer__foot .viewer__caption { padding: 0; }
.viewer__meta { display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-md); line-height: var(--lh-md); }
.viewer__who { font-weight: 500; }
.viewer__who[data-dir="in"] { color: var(--friend); }
.viewer__who[data-dir="out"] { color: var(--accent); }
.viewer__when { color: var(--muted); font-variant-numeric: tabular-nums; }
.viewer__progress { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--muted); }
.viewer__error { display: flex; align-items: center; gap: 12px; font-size: var(--fs-md); line-height: var(--lh-md); color: var(--danger); }
.viewer__error .textbtn { font-size: var(--fs-md); line-height: var(--lh-md); margin: -12px -4px; }
.viewer__actions { display: flex; justify-content: center; min-height: 44px; }
.viewer__delete { min-height: 44px; min-width: 44px; padding: 0 12px; font-size: var(--fs-md); line-height: var(--lh-md); cursor: pointer; }
.viewer__confirm { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.viewer__confirm-text { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--text); text-align: center; }
.viewer__confirm-error { font-size: var(--fs-md); line-height: var(--lh-md); color: var(--danger); }
.viewer__confirm-row { display: flex; gap: 12px; }
.viewer__confirm-row .btn { width: auto; min-width: 120px; cursor: pointer; }
.viewer__confirm-row .btn:disabled { cursor: default; }

/* a full image with no preview under it sizes its own box */
.msg__full--solo { position: static; width: auto; height: auto; max-width: 100%; display: block; object-fit: contain; }
