/* ══════════════════════════════════════════════════════════════
   Files, camera and library (v5.0.5)
   ══════════════════════════════════════════════════════════════ */

/* Composer: "+", drop target, file chips */
.chat-composer__attach {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-left: 0.125rem;
}
.chat-composer__row--grown .chat-composer__attach {
  align-self: flex-end;
  padding-bottom: 0.375rem;
}
.chat-composer--dictating .chat-composer__attach {
  opacity: 0;
  pointer-events: none;
}
.chat-composer--drop {
  border-color: var(--brand-primary) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}
.chat-composer--drop::after {
  content: "Drop to attach";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-primary);
  background: color-mix(in srgb, var(--surface-card) 88%, transparent);
  pointer-events: none;
  animation: fileFadeIn 140ms ease-out both;
}
@keyframes fileFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.composer-files {
  padding: 0.25rem 0.375rem 0.375rem;
}
.composer-files__row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.375rem 0.25rem 0.125rem;
}
.composer-files__row::-webkit-scrollbar {
  display: none;
}
.composer-files__item {
  flex-shrink: 0;
  animation: composerFileIn 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes composerFileIn {
  from { opacity: 0; transform: translateY(6px) scale(0.9); }
  to { opacity: 1; transform: none; }
}
.composer-files__notice {
  margin: 0.25rem 0.375rem 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.composer-file {
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 0.875rem;
  background: var(--surface-card);
}
.composer-file--image {
  width: 3.5rem;
  height: 3.5rem;
  justify-content: center;
}
.composer-file--image .composer-file__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(0.875rem - 1px);
}
.composer-file--pdf {
  gap: 0.625rem;
  width: 14rem;
  height: 3.5rem;
  padding: 0.375rem 0.625rem 0.375rem 0.375rem;
}
.composer-file__page {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.75rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 0.375rem;
  border: 1px solid var(--border-subtle);
  background: #fff;
}
.composer-file__page .composer-file__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.composer-file--error {
  border-color: color-mix(in srgb, var(--feedback-danger) 55%, transparent);
}
.composer-file__veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
}
.composer-file__veil--error {
  background: color-mix(in srgb, var(--feedback-danger) 60%, rgba(0, 0, 0, 0.3));
}
.composer-file__ring {
  flex-shrink: 0;
  color: currentColor;
}
.composer-file--pdf .composer-file__ring {
  color: var(--brand-primary);
}
.composer-file__ring--spin {
  animation: composerRingSpin 900ms linear infinite;
}
@keyframes composerRingSpin {
  to { transform: rotate(360deg); }
}
.composer-file__remove {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  color: var(--text-inverse);
  background: var(--text-primary);
  box-shadow: 0 0 0 2px var(--surface-subtle);
  opacity: 0.92;
  transition: transform 150ms ease-out, opacity 150ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .composer-file__remove:hover {
    transform: scale(1.1);
    opacity: 1;
  }
}
@media (pointer: coarse) {
  /* A bigger target without a bigger badge. */
  .composer-file__remove::before {
    content: "";
    position: absolute;
    inset: -0.5rem;
  }
}

/* Files in a sent message */
.msg-files {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  max-width: 100%;
}
.msg-files--enter > * {
  animation: msgFileIn 360ms cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes msgFileIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.msg-files__images {
  display: grid;
  gap: 0.375rem;
  max-width: min(20rem, 100%);
}
.msg-files__images--2,
.msg-files__images--3,
.msg-files__images--4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.msg-file-image {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 1;
  min-width: 6rem;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  transition: transform 180ms ease-out;
}
.msg-file-image--single {
  aspect-ratio: auto;
  max-height: 20rem;
}
.msg-file-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.msg-file-image--single img {
  max-height: 20rem;
  object-fit: contain;
}
@media (hover: hover) and (pointer: fine) {
  .msg-file-image:hover {
    transform: scale(1.015);
  }
}
.msg-file-image.is-loading {
  width: 10rem;
  height: 10rem;
  background: linear-gradient(90deg, var(--skeleton-shimmer-from), var(--skeleton-shimmer-via), var(--skeleton-shimmer-to));
  background-size: 200% 100%;
  animation: fileShimmer 1.4s linear infinite;
}
@keyframes fileShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.msg-file-pdf {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: min(17rem, 100%);
  padding: 0.625rem 0.875rem 0.625rem 0.625rem;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  text-align: start;
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .msg-file-pdf:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-card);
  }
}
.msg-file-pdf__stack {
  position: relative;
  width: 3.25rem;
  height: 4rem;
  flex-shrink: 0;
  /* Room for the pages leaning left, so the fan stays inside the card. */
  margin-left: 0.625rem;
}
.msg-file-pdf__page {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 0.375rem;
  border: 1px solid var(--border-subtle);
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transform-origin: 50% 100%;
  transition: transform 280ms cubic-bezier(0.22, 0.8, 0.24, 1);
  /* backwards, not both: a held animation owns `transform`, and the hover
     spread would then jump instead of easing. */
  animation: pdfPageDeal 420ms cubic-bezier(0.2, 0.9, 0.3, 1.1) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.msg-file-pdf__page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.msg-file-pdf__page--blank {
  background: var(--surface-subtle);
}
@keyframes pdfPageDeal {
  from { opacity: 0; transform: translateY(8px) rotate(0deg); }
}
/* Fanned: the pages behind lean out to the left, away from the name; on
   hover they spread a little further, within the card's padding. */
.msg-file-pdf__stack--fan .msg-file-pdf__page {
  transform: rotate(calc(var(--i, 0) * -4deg)) translateX(calc(var(--i, 0) * -1px));
}
.msg-file-pdf:focus-visible .msg-file-pdf__stack--fan .msg-file-pdf__page {
  transform: rotate(calc(var(--i, 0) * -7deg)) translateX(calc(var(--i, 0) * -2px));
}
@media (hover: hover) and (pointer: fine) {
  .msg-file-pdf:hover .msg-file-pdf__stack--fan .msg-file-pdf__page {
    transform: rotate(calc(var(--i, 0) * -7deg)) translateX(calc(var(--i, 0) * -2px));
  }
}
.msg-file-pdf__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.msg-file-pdf__name {
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file-pdf__sub {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* "[p. 12]" in a reply */
.chat-prose .page-cite {
  display: inline-flex;
  align-items: center;
  margin: 0 0.125rem;
  padding: 0 0.4rem;
  border-radius: 0.375rem;
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: 0.08em;
  color: var(--brand-primary);
  background: var(--brand-primary-subtle);
  cursor: pointer;
  transition: background-color 150ms ease-out;
}
.chat-prose .page-cite:hover {
  background: color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

/* Camera: a framed viewfinder between a top tool row and the shutter deck. */
.camera-sheet {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: cameraIn 280ms cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes cameraIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: none; }
}
.camera-sheet__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.625rem) 1rem 0.625rem;
}
.camera-sheet__tools {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.camera-sheet__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 160ms ease-out;
}
.camera-sheet__icon:active {
  transform: scale(0.92);
}
.camera-sheet__icon.is-on {
  color: #111;
  background: #ffd24a;
}
.camera-sheet__icon:disabled {
  opacity: 0.35;
}
.camera-sheet__icon--large {
  width: 3.25rem;
  height: 3.25rem;
}
.camera-sheet__badge {
  position: absolute;
  right: -0.25rem;
  bottom: -0.125rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1rem;
  color: #111;
  background: #fff;
}
.camera-sheet__done {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #000;
  background: #fff;
  animation: cameraPop 260ms cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
@keyframes cameraPop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

/* The viewfinder keeps the photo's own shape, so the shot is exactly what was framed. */
.camera-sheet__middle {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0 0.5rem;
}
.camera-sheet__frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 1.5rem;
  background: #111;
  isolation: isolate;
  /* Safari clips transformed video to the rounded frame only with this. */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  transition: box-shadow 240ms ease-out;
}
@media (orientation: portrait) {
  .camera-sheet__frame {
    width: min(100%, calc((100dvh - 13.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 0.75));
  }
}
@media (orientation: landscape) {
  .camera-sheet__frame {
    width: auto;
    height: 100%;
  }
}
.camera-sheet__frame.is-document {
  box-shadow: 0 0 0 2px rgba(255, 210, 74, 0.7);
}
.camera-sheet__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform-origin: center;
  transition: opacity 420ms cubic-bezier(0.4, 0, 0.2, 1), transform 120ms linear;
}
.camera-sheet__video.is-live {
  opacity: 1;
}
/* The last frame, blurred, held while the other camera starts: no black flash. */
.camera-sheet__freeze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: blur(18px) saturate(1.2);
  transform: scale(1.12);
  pointer-events: none;
  transition: opacity 360ms ease-out;
}
.camera-sheet__freeze.is-mirrored {
  transform: scale(1.12) scaleX(-1);
}
.camera-sheet__freeze.is-on {
  opacity: 1;
  transition: none;
  animation: cameraTurn 520ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes cameraTurn {
  0% { filter: blur(0) saturate(1); }
  40% { filter: blur(22px) saturate(1.3) brightness(0.8); }
  100% { filter: blur(18px) saturate(1.2); }
}
.camera-sheet__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px)),
    linear-gradient(to bottom, transparent calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% - 0.5px), rgba(255, 255, 255, 0.35) calc(33.33% + 0.5px), transparent calc(33.33% + 0.5px), transparent calc(66.66% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.66% - 0.5px), rgba(255, 255, 255, 0.35) calc(66.66% + 0.5px), transparent calc(66.66% + 0.5px));
  animation: fileFadeIn 200ms ease-out both;
}
/* Document mode: four corner brackets that breathe, a hint to fill the frame. */
.camera-sheet__guide {
  position: absolute;
  inset: 7%;
  pointer-events: none;
  animation: cameraGuide 2.4s ease-in-out infinite;
}
.camera-sheet__guide span {
  position: absolute;
  width: 2rem;
  height: 2rem;
  border: 3px solid #ffd24a;
}
.camera-sheet__guide span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 0.75rem; }
.camera-sheet__guide span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 0.75rem; }
.camera-sheet__guide span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 0.75rem; }
.camera-sheet__guide span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 0.75rem; }
@keyframes cameraGuide {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(0.97); opacity: 0.6; }
}
.camera-sheet__hint {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  pointer-events: none;
}
/* Before the first frame: a soft shimmer, then (only if it's slow) a word. It
   fades out on the same curve the picture fades in, so the swap is seamless. */
.camera-sheet__starting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 45%, #1d1d1f 0%, #111 60%, #0b0b0b 100%);
  opacity: 1;
  transition: opacity 420ms cubic-bezier(0.4, 0, 0.2, 1), filter 420ms cubic-bezier(0.4, 0, 0.2, 1);
}
.camera-sheet__starting::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.05) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: cameraShimmer 1.6s ease-in-out infinite;
}
@keyframes cameraShimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
.camera-sheet__starting.is-gone {
  opacity: 0;
  filter: blur(8px);
}
.camera-sheet__starting-ring {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 2.5px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.85);
  opacity: 0;
  animation: cameraSpin 0.9s linear infinite, cameraLate 300ms ease-out 350ms forwards;
}
.camera-sheet__starting-text {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.75);
  opacity: 0;
  animation: cameraLate 300ms ease-out 700ms forwards;
}
@keyframes cameraSpin {
  to { transform: rotate(360deg); }
}
@keyframes cameraLate {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.camera-sheet__starting.is-gone .camera-sheet__starting-ring,
.camera-sheet__starting.is-gone .camera-sheet__starting-text,
.camera-sheet__starting.is-gone::after {
  animation-play-state: paused;
}
.camera-sheet__status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.85);
}
.camera-sheet__status p {
  margin: 0;
  max-width: 18rem;
}
.camera-sheet__countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 6rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: cameraCount 1s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes cameraCount {
  0% { opacity: 0; transform: scale(1.6); }
  25% { opacity: 1; transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: scale(0.8); }
}
.camera-sheet__zoom {
  position: absolute;
  left: 50%;
  bottom: 0.875rem;
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(-50%);
}
.camera-sheet__zoom-stop {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 160ms ease-out;
}
.camera-sheet__zoom-stop.is-on {
  color: #ffd24a;
  background: rgba(0, 0, 0, 0.55);
  transform: scale(1.08);
}
.camera-sheet__shutter-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease-out;
}
.camera-sheet__shutter-flash.is-on {
  opacity: 0.8;
  transition: none;
}
/* The front "flash": the whole screen turns white for a moment. */
.camera-sheet__screen-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: #fff8ec;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
}
.camera-sheet--screen-flash .camera-sheet__screen-flash {
  opacity: 1;
  transition: opacity 80ms ease-in;
}

.camera-sheet__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1.5rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
}
.camera-sheet__modes {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.camera-sheet__mode {
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
  transition: color 180ms ease-out, background-color 180ms ease-out;
}
.camera-sheet__mode.is-on {
  color: #ffd24a;
  background: rgba(255, 255, 255, 0.12);
}
.camera-sheet__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 22rem;
}
.camera-sheet__shutter {
  display: grid;
  place-items: center;
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 999px;
  border: 4px solid #fff;
  background: transparent;
  transition: transform 140ms ease-out, opacity 160ms ease-out;
}
.camera-sheet__shutter span {
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 999px;
  background: #fff;
  transition: transform 140ms cubic-bezier(0.3, 1.4, 0.5, 1), background-color 180ms ease-out, border-radius 180ms ease-out;
}
.camera-sheet__shutter.is-document span {
  border-radius: 0.875rem;
  background: #ffd24a;
  transform: scale(0.82);
}
.camera-sheet__shutter:active span {
  transform: scale(0.86);
}
.camera-sheet__shutter:disabled {
  opacity: 0.4;
}
.camera-sheet__flip svg {
  transition: transform 520ms cubic-bezier(0.4, 0, 0.2, 1);
}
.camera-sheet__flip.is-turning svg {
  transform: rotate(-180deg);
}
.camera-sheet__tray {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border-radius: 0.75rem;
  border: 2px solid #fff;
  overflow: visible;
  background: #222;
  animation: cameraPop 260ms cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.camera-sheet__tray img {
  width: 100%;
  height: 100%;
  border-radius: 0.625rem;
  object-fit: cover;
}
.camera-sheet__count {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.25rem;
  color: #111;
  background: #ffd24a;
}
/* The photo just taken shrinks from the viewfinder into the tray. */
.camera-sheet__flying {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: 60vmin;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 1rem;
  pointer-events: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: cameraFly 500ms cubic-bezier(0.5, 0, 0.3, 1) both;
}
@keyframes cameraFly {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(calc(-50% + var(--fly-x)), calc(-50% + var(--fly-y))) scale(0.09); opacity: 0.6; }
}
.camera-sheet__notice {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 4rem);
  left: 50%;
  z-index: 4;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(-50%);
  pointer-events: none;
  animation: fileFadeIn 180ms ease-out both;
}
.camera-sheet__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

/* Review: every photo taken, one large, the rest in a strip. */
.camera-sheet__review {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.625rem) 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
  background: #000;
  animation: fileFadeIn 180ms ease-out both;
}
.camera-sheet__review-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.camera-sheet__review-image {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border-radius: 1rem;
}
.camera-sheet__review-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem;
}
.camera-sheet__review-thumb {
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border-radius: 0.625rem;
  border: 2px solid transparent;
  overflow: hidden;
  opacity: 0.6;
  transition: opacity 160ms ease-out, border-color 160ms ease-out;
}
.camera-sheet__review-thumb.is-on {
  border-color: #ffd24a;
  opacity: 1;
}
.camera-sheet__review-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-sheet__delete {
  flex: none;
  margin-left: auto;
}

/* Viewer */
.file-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Full width before any page is drawn (an undrawn canvas is only 300px). */
  width: 100%;
  height: min(92dvh, 100%);
  min-height: 60dvh;
}
.file-viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.75rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.file-viewer__body {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1rem 5rem;
  background: var(--surface-sunken, var(--surface-subtle));
}
.file-viewer__page {
  width: min(100%, 56rem);
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 0.375rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.06);
  animation: msgFileIn 320ms ease-out both;
}
.file-viewer__page canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 240ms ease-out;
}
.file-viewer__page canvas.is-drawn {
  opacity: 1;
}
.file-viewer__image {
  max-width: 100%;
  max-height: calc(92dvh - 7rem);
  margin: auto;
  border-radius: 0.5rem;
  object-fit: contain;
  cursor: zoom-in;
  animation: msgFileIn 260ms ease-out both;
}
.file-viewer__image.is-zoomed {
  max-width: none;
  max-height: none;
  width: 200%;
  cursor: zoom-out;
}
.file-viewer__body.is-zoomed {
  align-items: flex-start;
}
.file-viewer__loading {
  width: min(100%, 36rem);
  aspect-ratio: 3 / 4;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, var(--skeleton-shimmer-from), var(--skeleton-shimmer-via), var(--skeleton-shimmer-to));
  background-size: 200% 100%;
  animation: fileShimmer 1.4s linear infinite;
}
.file-viewer__missing {
  margin: auto;
  max-width: 28rem;
  padding: 2rem;
  text-align: center;
}
.file-viewer__actions {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  transform: translateX(-50%);
}
.file-viewer__ask {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-inverse);
  background: var(--text-primary);
  box-shadow: var(--shadow-modal);
  transition: transform 150ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .file-viewer__ask:hover {
    transform: translateY(-1px);
  }
}

/* Library */
.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  /* Clear of the header's divider above, same space below. */
  padding: 0.875rem 1.5rem 0.75rem;
}
/* Search, filters and "Add files" share one height, radius and surface. */
.library-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 14rem;
  min-width: 0;
  height: 2.25rem;
  padding: 0 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: var(--surface-subtle);
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.library-search:focus-within {
  border-color: var(--border-default);
  background: var(--surface-card);
}
.library-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  background: transparent;
  /* 16px keeps iOS from zooming the page on focus. */
  font-size: 16px;
  color: var(--text-primary);
}
@media (min-width: 640px) {
  .library-search input {
    font-size: 0.875rem;
  }
}
.library-filters {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 2.25rem;
  padding: 0.1875rem;
  border-radius: 0.75rem;
  background: var(--surface-subtle);
}
.library-filter {
  height: 100%;
  padding: 0 0.75rem;
  border-radius: 0.5625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.library-filter.is-active {
  color: var(--text-primary);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}
.library-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  border-radius: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-inverse);
  background: var(--text-primary);
}
.library-meter {
  padding: 0 1.5rem 0.75rem;
}
.library-meter__track {
  height: 0.375rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-subtle);
}
.library-meter__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand-primary);
  transition: width 400ms ease-out;
}
.library-meter__label {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.library-body {
  padding: 0.25rem 1.5rem 1.5rem;
}
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.875rem;
}
.library-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  animation: msgFileIn 320ms ease-out both;
  animation-delay: calc(min(var(--i, 0), 12) * 35ms);
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out, transform 180ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .library-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
  }
}
.library-card--skeleton {
  aspect-ratio: 4 / 5;
  background: linear-gradient(90deg, var(--skeleton-shimmer-from), var(--skeleton-shimmer-via), var(--skeleton-shimmer-to));
  background-size: 200% 100%;
  animation: fileShimmer 1.4s linear infinite;
}
.library-card__preview {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface-subtle);
}
.library-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease-out;
}
@media (hover: hover) and (pointer: fine) {
  .library-card:hover .library-card__preview img {
    transform: scale(1.04);
  }
}
.library-card__badge {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.125rem 0.4rem;
  border-radius: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
}
.library-card__meta {
  padding: 0.625rem 0.75rem 0.75rem;
  min-width: 0;
}
.library-card__name {
  overflow: hidden;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-card__sub {
  margin-top: 0.125rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.library-card__summary {
  margin-top: 0.375rem;
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.library-card__rename {
  width: 100%;
  padding: 0.125rem 0.375rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border-focus);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface-subtle);
  outline: none;
}
.library-card__actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}
.library-card:focus-within .library-card__actions {
  opacity: 1;
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .library-card:hover .library-card__actions {
    opacity: 1;
    transform: none;
  }
}
@media (pointer: coarse) {
  .library-card__actions {
    opacity: 1;
    transform: none;
  }
}
.library-card__actions button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.625rem;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--surface-card) 88%, transparent);
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem;
  text-align: center;
}
.library-empty__art {
  position: relative;
  width: 4.5rem;
  height: 4rem;
  margin-bottom: 1rem;
}
.library-empty__art span {
  position: absolute;
  inset: 0 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-default);
  background: var(--surface-card);
  animation: libraryFan 2.8s ease-in-out infinite;
}
.library-empty__art span:nth-child(1) { --r: -12deg; }
.library-empty__art span:nth-child(2) { --r: 0deg; animation-delay: 120ms; }
.library-empty__art span:nth-child(3) { --r: 12deg; animation-delay: 240ms; }
@keyframes libraryFan {
  0%, 100% { transform: rotate(calc(var(--r) * 0.5)); }
  50% { transform: rotate(var(--r)) translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .composer-files__item,
  .msg-files--enter > *,
  .msg-file-pdf__page,
  .camera-sheet,
  .camera-sheet__done,
  .camera-sheet__tray,
  .camera-sheet__guide,
  .camera-sheet__countdown,
  .camera-sheet__flying,
  .camera-sheet__freeze.is-on,
  .camera-sheet__starting::after,
  .file-viewer__page,
  .file-viewer__image,
  .library-card,
  .library-empty__art span,
  .msg-file-image.is-loading,
  .library-card--skeleton,
  .file-viewer__loading {
    animation: none;
  }
  .composer-file__ring--spin {
    animation-duration: 2.4s;
  }
  .camera-sheet__starting-ring,
  .camera-sheet__starting-text {
    animation: none;
    opacity: 1;
  }
  .msg-file-pdf__page,
  .library-card,
  .library-card__preview img {
    transition: none;
  }
}
