/* Chat media: the full-screen viewer and the on-device photo editor. */

/* ---------- viewer ---------- */
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 420;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  opacity: 0;
  transition: opacity .2s cubic-bezier(.23, 1, .32, 1);
  touch-action: none;
  overflow: hidden;
}
.photo-viewer.in { opacity: 1; }
.photo-viewer.out { opacity: 0; }
.photo-viewer-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  height: calc(54px + var(--safe-top));
  padding: var(--safe-top) 14px 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  background: linear-gradient(#000, transparent);
}
.photo-viewer-bar .safety-close { justify-self: start; }
.photo-viewer-bar .photo-viewer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: .9em;
  font-weight: 650;
}
.photo-viewer-bar-space { width: 44px; height: 44px; }
.photo-viewer-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.photo-viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center;
}
.photo-viewer-controls {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: rgba(28, 28, 30, .76);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.photo-viewer-controls .photo-viewer-edit {
  width: auto;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .76em;
  font-weight: 700;
  white-space: nowrap;
}
.photo-viewer-edit .icon { width: 16px; height: 16px; }
.photo-viewer-divider { width: 1px; height: 25px; background: rgba(255,255,255,.16); }
.photo-viewer-controls button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.12);
  font-size: 1.15em;
  transition: transform .14s cubic-bezier(.23, 1, .32, 1), background .14s ease;
}
.photo-viewer-controls button:active { transform: scale(.94); background: rgba(255,255,255,.22); }
.photo-viewer-controls .photo-zoom-level {
  width: auto;
  min-width: 56px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  text-align: center;
  font-size: .78em;
  font-variant-numeric: tabular-nums;
}

/* ---------- editor ---------- */
.photo-editor {
  position: fixed;
  inset: 0;
  z-index: 430;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  opacity: 0;
  transform: scale(.985);
  transition: opacity .22s cubic-bezier(.23, 1, .32, 1),
              transform .28s cubic-bezier(.23, 1, .32, 1);
  overflow: hidden;
}
.photo-editor.in { opacity: 1; transform: none; }
.photo-editor.out { opacity: 0; transform: scale(.985); }
.pe-top {
  min-height: calc(54px + var(--safe-top));
  padding: var(--safe-top) 14px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
}
.pe-top b { font-size: .96em; }
.pe-top-btn { justify-self: start; min-height: 44px; color: #fff; }
.pe-top-btn.send { justify-self: end; font-weight: 700; color: #0a84ff; }
.pe-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050505;
}
.pe-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
}
.pe-stage canvas.drawing { cursor: crosshair; }
.pe-tools {
  flex-shrink: 0;
  padding: 8px 0 calc(var(--safe-bottom) + 8px);
  background: #101012;
  border-top: 1px solid rgba(255,255,255,.12);
}
.pe-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0 10px 8px;
}
.pe-actions button {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: rgba(255,255,255,.82);
  border-radius: var(--radius);
  transition: transform .14s cubic-bezier(.23, 1, .32, 1), background .14s ease;
}
.pe-actions button:active { transform: scale(.94); }
.pe-actions button.on { color: #0a84ff; background: rgba(10,132,255,.14); }
.pe-actions button:disabled { opacity: .28; }
.pe-actions .icon { width: 21px; height: 21px; }
.pe-actions button > small { font-size: .62em; }
.pe-colours {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 2px 12px 10px;
}
.pe-colours[hidden], .pe-text-pop[hidden] { display: none; }
.pe-colour {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.pe-colour[data-colour="#ffffff"] { background: #fff; }
.pe-colour[data-colour="#111111"] { background: #111; }
.pe-colour[data-colour="#ff375f"] { background: #ff375f; }
.pe-colour[data-colour="#ff9f0a"] { background: #ff9f0a; }
.pe-colour[data-colour="#ffd60a"] { background: #ffd60a; }
.pe-colour[data-colour="#30d158"] { background: #30d158; }
.pe-colour[data-colour="#0a84ff"] { background: #0a84ff; }
.pe-colour[data-colour="#bf5af2"] { background: #bf5af2; }
.pe-colour.on { outline: 2px solid #fff; outline-offset: 3px; }
.pe-adjusts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px 9px;
}
.pe-adjusts label { font-size: .64em; color: rgba(255,255,255,.68); text-align: center; }
.pe-adjusts input { display: block; width: 100%; margin-top: 4px; accent-color: #fff; }
.pe-filters {
  display: flex;
  gap: 11px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px 4px;
}
.pe-filters::-webkit-scrollbar { display: none; }
.pe-filter { flex: 0 0 58px; color: rgba(255,255,255,.65); text-align: center; }
.pe-filter > span {
  display: block;
  width: 52px;
  height: 52px;
  margin: 0 auto 4px;
  border-radius: 12px;
  background-position: center;
  background-size: cover;
  border: 2px solid transparent;
}
.pe-filter small { font-size: .62em; }
.pe-filter.on { color: #fff; }
.pe-filter.on > span { border-color: #fff; }
.pe-text-pop {
  position: absolute;
  z-index: 5;
  top: calc(var(--safe-top) + 66px);
  left: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-lg);
  background: rgba(28,28,30,.9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.pe-text-pop input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 10px; background: rgba(255,255,255,.12); }
.pe-text-pop button { padding: 0 14px; border-radius: 10px; color: #fff; background: #0a84ff; font-weight: 700; }

/* ---------- online GIF search ---------- */
.gif-search {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 0 10px 0 13px;
  border-radius: var(--radius);
  background: var(--fill);
}
.gif-search .icon { width: 17px; height: 17px; color: var(--text-2); }
.gif-search input { flex: 1; min-width: 0; height: 44px; }
.gif-search button { min-width: 44px; height: 36px; font-weight: 700; font-size: .82em; }
.gif-tabs { display: flex; gap: 8px; padding: 0 16px 10px; }
.gif-tabs button { padding: 7px 13px; border-radius: var(--radius-pill); background: var(--fill); color: var(--text-2); font-size: .78em; }
.gif-tabs button.on { background: var(--accent); color: var(--on-accent); }
.gif-provider-note { padding: 0 18px 9px; color: var(--text-3); font-size: .65em; line-height: 1.35; }
.gif-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 0 16px 10px; }
.gif-result { position: relative; aspect-ratio: 1.35; overflow: hidden; border-radius: var(--radius); background: var(--fill); transition: transform .14s cubic-bezier(.23, 1, .32, 1); }
.gif-result img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-result:active { transform: scale(.975); }
.gif-loading, .gif-search-empty { grid-column: 1 / -1; padding: 28px 12px; text-align: center; color: var(--text-2); font-size: .84em; line-height: 1.45; }

@media (max-height: 720px) {
  .pe-adjusts { display: none; }
  .pe-filter > span { width: 42px; height: 42px; }
  .pe-actions button { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .photo-viewer, .photo-editor { transition: opacity .12s ease; transform: none; }
  .photo-viewer-stage img, .pe-actions button, .photo-viewer-controls button { transition: none; }
}
