/* Media library v2 + photos spread across the app (hero photos, covers, login slideshow). Light & dark, RTL & LTR. */

/* ---------- soft photo behind a .hero (home, activity, event) ---------- */
.hero:has(> .hero-photo) { isolation: isolate; overflow: hidden; }
.hero > .hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; opacity: .38;
  mix-blend-mode: luminosity; pointer-events: none; animation: heroPhotoIn .9s ease both; border-radius: inherit; }
.hero:has(> .hero-photo)::before { z-index: -1; }
:root[data-theme="dark"] .hero > .hero-photo { opacity: .32; }
.hero.photo-strong > .hero-photo { opacity: .62; mix-blend-mode: normal; }
.hero.photo-strong { text-shadow: 0 1px 12px rgba(0,0,0,.35); }
.hero.photo-strong::after { background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.45)) !important; animation: none !important; }
@keyframes heroPhotoIn { from { opacity: 0; transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .hero > .hero-photo { animation: none; } }

/* ---------- event list cover tiles ---------- */
.tile.photo-tile { position: relative; overflow: hidden; isolation: isolate; color: #fff; }
.tile.photo-tile > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.tile.photo-tile::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.55)); }
.tile.photo-tile b { text-shadow: 0 1px 6px rgba(0,0,0,.5); }

/* ---------- staff home: three recent photos ---------- */
.home-moments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.home-moments img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 16px; box-shadow: var(--e1, var(--shadow)); }

/* ---------- full-screen background slideshow (partials/media_bg) ---------- */
.media-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #111; pointer-events: none; }
.media-bg > img, .media-bg > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.media-bg > :first-child { opacity: 1; }
.media-bg.slides > img { opacity: 0; animation: 14s mbg2 infinite both; animation-delay: calc(var(--i) * 7s); }
.media-bg.n3 > img { animation-name: mbg3; animation-duration: 21s; }
.media-bg.n4 > img { animation-name: mbg4; animation-duration: 28s; }
.media-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.55)); }
:root[data-theme="dark"] .media-bg::after { background: linear-gradient(180deg, rgba(0,0,0,.45), rgba(0,0,0,.75)); }
@keyframes mbg2 { 0% { opacity: 0; transform: scale(1.06); } 6% { opacity: 1; } 50% { opacity: 1; } 58% { opacity: 0; transform: scale(1); } 100% { opacity: 0; } }
@keyframes mbg3 { 0% { opacity: 0; transform: scale(1.06); } 4% { opacity: 1; } 33% { opacity: 1; } 39% { opacity: 0; transform: scale(1); } 100% { opacity: 0; } }
@keyframes mbg4 { 0% { opacity: 0; transform: scale(1.06); } 3% { opacity: 1; } 25% { opacity: 1; } 30% { opacity: 0; transform: scale(1); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .media-bg.slides > img { animation: none; opacity: 0; } .media-bg.slides > img:first-child { opacity: 1; } }

/* ---------- library (/media) ---------- */
.mlib-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.mlib-actions form { display: contents; }
.mlib-search { margin: 8px 0 4px; }
.mlib-search label { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px; background: var(--fill, rgba(120,120,128,.12)); color: var(--label-2); }
.mlib-search input { flex: 1; border: 0; background: none; outline: none; font: inherit; color: var(--label); min-width: 0; }
.mlib-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px 10px; }
.mlib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .mlib-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.mlib-item { position: relative; display: grid; gap: 6px; }
.mlib-item.off .mlib-thumb { opacity: .4; filter: grayscale(.6); }
.mlib-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 5; padding: 0; border: 0; border-radius: 18px; overflow: hidden; cursor: pointer;
  background: var(--fill, #8883); box-shadow: var(--e1, var(--shadow)); transition: transform .2s; }
.mlib-thumb:active { transform: scale(.97); }
.mlib-thumb img, .mlib-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mlib-badges { position: absolute; inset-inline-start: 6px; bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.mlib-badges .mb { display: inline-flex; align-items: center; gap: 3px; padding: 3px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.mlib-badges .mb .ic { width: 12px; height: 12px; }
.mlib-badges .mb.star { background: #f59e0b; }
.mlib-badges .mb.ph { background: rgba(124,58,237,.85); }
.mlib-badges .mb.ig { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af); }
.mlib-pick { position: absolute; top: 8px; inset-inline-end: 8px; z-index: 2; width: 28px; height: 28px; cursor: pointer; }
.mlib-pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.mlib-pick i { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); color: transparent; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.mlib-pick i .ic { width: 15px; height: 15px; }
.mlib-pick input:checked + i { background: var(--tint); color: #fff; }
.mlib-pick input:focus-visible + i { outline: 3px solid var(--tint); outline-offset: 2px; }
.mlib-item:has(.mlib-pick input:checked) .mlib-thumb { outline: 3px solid var(--tint); outline-offset: 2px; }
.mlib-meta { display: grid; gap: 1px; padding: 0 4px; min-width: 0; }
.mlib-meta small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mlib-tl { color: var(--tint); font-weight: 700; }
.mlib-pages { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }
.mlib-note { font-size: 13px; margin: 10px 2px 0; }
.mlib-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.mlib-tag { position: relative; cursor: pointer; }
.mlib-tag input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mlib-tag span { display: inline-block; padding: 7px 13px; border-radius: 99px; font-size: 13.5px; font-weight: 650; background: var(--fill, #8882); color: var(--label); transition: .15s; }
.mlib-tag input:checked + span { background: var(--tint); color: #fff; }
.mlib-tag input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: 2px; }
.mlib-bulk { display: none; position: fixed; z-index: 40; inset-inline: 12px; bottom: calc(var(--tabbar-h, 64px) + 14px + env(safe-area-inset-bottom)); max-width: 720px; margin-inline: auto;
  padding: 12px; border-radius: 22px; background: var(--bg-elev, #fff); box-shadow: 0 18px 50px -12px rgba(0,0,0,.45); gap: 10px; flex-direction: column; }
.mlib.picking .mlib-bulk { display: flex; animation: mbUp .25s ease; }
@keyframes mbUp { from { transform: translateY(20px); opacity: 0; } }
.mlib-bulk-top { display: flex; align-items: center; gap: 8px; }
.mlib-bulk-top b { white-space: nowrap; }
.mlib-bulk-top select { flex: 1; min-width: 0; padding: 9px 10px; border-radius: 12px; border: 0; background: var(--fill, #8882); color: var(--label); font: inherit; }
.mlib-bulk-opt select { width: 100%; padding: 9px 10px; border-radius: 12px; border: 0; background: var(--fill, #8882); color: var(--label); font: inherit; }
.mlib-preview { border-radius: 18px; overflow: hidden; background: #000; margin-bottom: 4px; }
.mlib-preview img, .mlib-preview video { display: block; width: 100%; max-height: 46vh; object-fit: contain; }
.mlib-preview:not(:has(:not([hidden]))) { display: none; }
.row-switch { display: flex !important; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Instagram import ---------- */
.ig-steps ol { margin: 8px 0 0; padding-inline-start: 22px; display: grid; gap: 6px; color: var(--label-2); font-size: 14.5px; }
.ig-run { margin-top: 16px; }
.ig-cli { display: block; padding: 10px 12px; border-radius: 12px; background: var(--fill, #8882); font-size: 12.5px; overflow-wrap: anywhere; text-align: left; }
.ig-form .kpis { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .ig-form .kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---------- readability first: text over photos (v2) ----------
   Every hero that carries a photo gets a scrim strong enough for white text on ANY picture, light or dark. */
.hero:has(> .hero-photo) { text-shadow: 0 1px 2px rgba(0,0,0,.25), 0 2px 14px rgba(0,0,0,.28); }
.hero:has(> .hero-photo) > .hero-photo { opacity: .30; filter: saturate(1.05) contrast(1.05); }
.hero.photo-strong > .hero-photo { opacity: 1; mix-blend-mode: normal; filter: saturate(1.08); }
.hero.photo-strong::after {
  background: linear-gradient(180deg, rgba(10,8,20,.62) 0%, rgba(10,8,20,.38) 45%, rgba(10,8,20,.66) 100%) !important;
  z-index: -1 !important; animation: none !important; }
.hero.photo-strong { color: #fff !important; text-shadow: 0 1px 2px rgba(0,0,0,.45), 0 2px 18px rgba(0,0,0,.4); }
.hero.photo-strong .eyebrow, .hero.photo-strong p { color: rgba(255,255,255,.92) !important; opacity: 1; }
.hero.photo-strong .btn.glass { background: rgba(0,0,0,.28); border-color: rgba(255,255,255,.35); }
:root[data-theme="dark"] .hero:has(> .hero-photo) > .hero-photo { opacity: .24; }
:root[data-theme="dark"] .hero.photo-strong > .hero-photo { opacity: .9; }
/* event tiles and gallery cards with captions */
.tile.photo-tile::after { background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.6)); }

/* ---- type / hotel photos in lists, hotel banner, credits (appended by the media/attribution task) ---- */
.tile.tile-photo { position: relative; overflow: hidden; padding: 0; }
.tile.tile-photo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.tile-photo::before { display: none; }
.kpi:has(> .kpi-cover) { position: relative; overflow: hidden; padding-top: 0; }
.kpi-cover { display: block; margin: 0 -14px; height: 96px; overflow: hidden; }
.kpi-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hotel-banner { position: relative; overflow: hidden; border-radius: var(--r-lg, 18px); aspect-ratio: 16 / 6; margin: 4px 0 14px; box-shadow: var(--shadow); }
.hotel-banner > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hotel-banner-credit, .hero-credit { position: absolute; inset-inline-end: 10px; bottom: 6px; z-index: 2; font-size: 10px; line-height: 1.3; opacity: .75; direction: ltr; }
.hotel-banner-credit, .hotel-banner-credit a, .hero-credit, .hero-credit a { color: #fff; text-decoration: none; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.hotel-banner-credit a:hover, .hero-credit a:hover { text-decoration: underline; }
.media-credit { font-size: 11px; opacity: .7; direction: ltr; }

/* ---------------------------------------------------------------- v3: tabs, quota, tools, item page, albums, shares, uploader */
.mlib-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; }
.mlib-tabs a { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--fill); color: var(--label); text-decoration: none; white-space: nowrap; font-size: .9em; }
.mlib-tabs a.on { background: var(--tint); color: #fff; }
.mlib-quota { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: .85em; color: var(--label-2); }
.mlib-quota progress { flex: 1; max-width: 240px; height: 8px; accent-color: var(--tint); }
.mlib-quota.full progress { accent-color: var(--red); }
.mlib-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin: 0 0 10px; color: var(--orange); text-decoration: none; }
.mlib-alert form.inline { margin-inline-start: auto; }
.mlib-search { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mlib-date { display: inline-flex; align-items: center; gap: 4px; font-size: .85em; color: var(--label-2); }
.mlib-date input { max-width: 150px; }
.mlib-tools { display: flex; gap: 2px; justify-content: flex-end; margin-top: 2px; }
.mlib-tools form { margin: 0; }
.mlib-tools .icon-btn.on, [data-mlib-fav] .on { color: var(--red); }
.mb.warn { background: var(--orange); color: #fff; }
.mlib-detail { display: grid; gap: 14px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 860px) { .mlib-detail { grid-template-columns: 1fr; } }
.mlib-stage { padding: 0; overflow: hidden; }
.mlib-stage img, .mlib-stage video { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; background: var(--fill); }
.mlib-zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.mlib-stage-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px; }
.mlib-stage-bar form { margin: 0; }
.mlib-side { display: grid; gap: 12px; }
.mlib-side .card { padding: 12px; }
.mlib-side h3 { margin: 0 0 8px; font-size: 1em; }
.mlib-usage { margin: 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.mlib-share-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mlib-check { display: inline-flex; gap: 4px; align-items: center; font-size: .9em; }
.mlib-share-new { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; padding: 8px; }
.mlib-share-new input { flex: 1; min-width: 0; font-family: monospace; }
.mlib-shares { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.mlib-shares li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mlib-shares form { margin-inline-start: auto; }
.mlib-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.mlib-mini img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.mlib-albums { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.mlib-album { display: grid; gap: 4px; padding: 8px; color: var(--label); text-decoration: none; }
.mlib-album-cover { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--fill); }
.mlib-album-cover img { width: 100%; height: 100%; object-fit: cover; }
.mlib-progress { margin-top: 12px; }
.mlib-progress progress { width: 100%; height: 10px; accent-color: var(--tint); }
.mlib-files { list-style: none; margin: 6px 0 0; padding: 0; max-height: 200px; overflow: auto; font-size: .85em; }
.mlib-files li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--sep); }
.mlib-files li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mlib-files .st-ok small { color: var(--green); }
.mlib-files .st-dupe small { color: var(--orange); }
.mlib-files .st-bad small, .mlib-files .st-quota small { color: var(--red); }

/* lightbox (keyboard: arrows / Home / End / Esc) */
.mlb { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(0, 0, 0, .92); color: #fff; }
.mlb::backdrop { background: rgba(0, 0, 0, .6); }
.mlb-stage { position: absolute; inset: 48px 56px 64px; display: grid; place-items: center; }
.mlb-stage img, .mlb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.mlb-cap { position: absolute; bottom: 16px; inset-inline: 16px; margin: 0; text-align: center; font-size: .9em; }
.mlb-n { position: absolute; top: 14px; inset-inline-start: 16px; font-size: .85em; opacity: .8; }
.mlb-btn { position: absolute; border: 0; background: rgba(255, 255, 255, .14); color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; cursor: pointer; }
.mlb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.mlb-x { top: 8px; inset-inline-end: 8px; }
.mlb-prev, .mlb-next { top: 50%; transform: translateY(-50%); }
.mlb-prev { inset-inline-start: 6px; }
.mlb-next { inset-inline-end: 6px; }

/* public share page */
.mshare { margin: 0; font-family: system-ui, sans-serif; background: #111; color: #eee; }
.mshare-head { padding: 20px 16px 8px; max-width: 1100px; margin: 0 auto; }
.mshare-head h1 { margin: 0 0 4px; font-size: 1.4em; }
.mshare-head small { opacity: .7; }
.mshare-grid { display: grid; gap: 10px; padding: 12px 16px 32px; max-width: 1100px; margin: 0 auto; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.mshare-grid figure { margin: 0; }
.mshare-grid button { display: block; width: 100%; padding: 0; border: 0; background: #222; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.mshare-grid img, .mshare-grid video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.mshare-grid figcaption, .mshare-dl { font-size: .75em; opacity: .75; color: inherit; }

/* album photo order: drag and drop + move buttons (chevron points left; earlier = reading start) */
.mlib-sortable .mlib-item[draggable="true"] { cursor: grab; }
.mlib-sortable .mlib-item.dragging { opacity: .45; }
.mlib-sortable .mlib-item.drop-before { box-shadow: inset 3px 0 0 var(--accent, #3b82f6); }
[dir="rtl"] .mlib-sortable .mlib-item.drop-before { box-shadow: inset -3px 0 0 var(--accent, #3b82f6); }
.mlib-sortable.saving { opacity: .8; }
[dir="rtl"] .mlib-tools .ord-prev .ic, html:not([dir="rtl"]) .mlib-tools .ord-next .ic { transform: scaleX(-1); }
.mlib-tools .icon-btn[disabled] { opacity: .3; pointer-events: none; }
/* possible duplicates (perceptual hash) */
.mlib-near-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.mlib-near-list a { display: grid; gap: 4px; width: 96px; font-size: .75em; text-decoration: none; text-align: center; }
.mlib-near-list img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
