/* A photo library uses its own familiar system palette and typography. */
#page-gallery, .photos-viewer, #modal-gallery-edit {
    --photos-blue: #007aff;
    --photos-bg: #fff;
    --photos-ink: #111114;
    --photos-secondary: #85858b;
    --photos-fill: #f2f2f7;
    --photos-line: #3c3c431f;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', 'Noto Sans CJK SC', sans-serif;
    letter-spacing: 0;
}
[data-theme="dark"] :is(#page-gallery, .photos-viewer, #modal-gallery-edit) {
    --photos-blue: #0a84ff;
    --photos-bg: #000;
    --photos-ink: #f5f5f7;
    --photos-secondary: #98989f;
    --photos-fill: #1c1c1e;
    --photos-line: #ffffff26;
}
#page-gallery { background: var(--photos-bg); color: var(--photos-ink); }
#page-gallery [hidden], .photos-viewer[hidden], .photos-viewer [hidden] { display: none !important; }
#page-gallery button, .photos-viewer button { -webkit-tap-highlight-color: transparent; }
#page-gallery button:focus-visible, .photos-viewer button:focus-visible { outline: 3px solid var(--photos-blue); outline-offset: -3px; }
#page-gallery button:disabled, .photos-viewer button:disabled { opacity: .3; cursor: default; }
.photos-toolbar { position: relative; z-index: 3; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; min-height: calc(54px + env(safe-area-inset-top, 0px)); gap: 8px; padding: env(safe-area-inset-top, 0px) 18px 0 12px; background: var(--photos-bg); }
.photos-back { display: flex; gap: 1px; align-items: center; min-height: 44px; color: var(--photos-blue); font-size: 16px; }
.photos-back svg { width: 24px; height: 24px; }
.photos-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.photos-select { min-height: 34px; padding: 6px 14px; border-radius: 22px; color: var(--photos-ink); background: var(--photos-fill); font-size: 14px; font-weight: 500; }
.photos-round { display: grid; place-items: center; width: 36px; height: 36px; padding: 7px; border-radius: 50%; color: var(--photos-blue); background: var(--photos-fill); flex-shrink: 0; }
.photos-round svg { width: 23px; height: 23px; }
.photos-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overflow-anchor: none; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); scrollbar-width: none; }
.photos-scroll::-webkit-scrollbar { display: none; }
.photos-heading { padding: 10px 22px 27px; }
.photos-heading h1 { font-size: 36px; font-weight: 750; line-height: 1.18; letter-spacing: -.04em; }
.photos-heading p { margin-top: 5px; color: var(--photos-secondary); font-size: 13px; }
.photos-library-heading { position: sticky; top: 0; z-index: 2; background: var(--photos-bg); min-height: 48px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 20px 9px; }
.photos-library-heading h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.photos-library-meta > span { color: var(--photos-secondary); font-size: 12px; }
#page-gallery .gallery-grid { display: grid; grid-template-columns: repeat(var(--photos-columns, 3), minmax(0, 1fr)); gap: 2px; padding: 0; }
#page-gallery .gallery-item { transform-origin: 0 0; position: relative; display: block; width: 100%; min-width: 0; padding: 0; aspect-ratio: 1; overflow: hidden; border: 0; border-radius: 0; background: var(--photos-fill); }
#page-gallery .gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease, opacity 180ms ease; }
#page-gallery .gallery-item:active img { transform: scale(.96); }
.photos-favorite-mark { position: absolute; left: 7px; bottom: 6px; display: block; width: 15px; height: 15px; color: #fff; filter: drop-shadow(0 1px 2px #0008); }
.photos-favorite-mark svg { display: block; width: 100%; height: 100%; }
.photos-check { display: none; position: absolute; right: 7px; bottom: 7px; width: 23px; height: 23px; border: 1.5px solid #fff; border-radius: 50%; color: transparent; background: #0002; box-shadow: 0 1px 3px #0003; }
.photos-check svg { width: 100%; height: 100%; }
.photos-selecting .photos-check { display: block; }
#page-gallery .gallery-item.selected img { opacity: .72; }
.photos-selecting .gallery-item.selected .photos-check { color: #fff; background: var(--photos-blue); border-color: #fff; }
.photos-total { padding: 24px 16px 8px; color: var(--photos-secondary); text-align: center; font-size: 13px; }
.photos-navigation { position: absolute; z-index: 4; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; gap: 10px; pointer-events: none; }
.photos-nav-tabs, .photos-nav-search { border: 1px solid color-mix(in srgb, var(--photos-line) 70%, #ffffff66); background: color-mix(in srgb, var(--photos-bg) 83%, transparent); box-shadow: 0 4px 24px #00000012, inset 0 1px #ffffff66; -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); pointer-events: auto; }
.photos-nav-tabs { display: flex; gap: 3px; padding: 5px; border-radius: 34px; }
.photos-nav-tabs button { display: flex; gap: 7px; align-items: center; justify-content: center; min-width: 100px; min-height: 44px; padding: 10px 14px; border-radius: 26px; font-size: 14px; font-weight: 600; }
.photos-nav-tabs button svg { width: 22px; height: 22px; }
.photos-nav-tabs button.active { color: var(--photos-blue); background: color-mix(in srgb, var(--photos-blue) 9%, transparent); }
.photos-nav-search { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; }
.photos-nav-search svg { width: 24px; height: 24px; }
.photos-nav-search.active { color: var(--photos-blue); }
.photos-selection-bar { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px)); background: color-mix(in srgb, var(--photos-bg) 94%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 1px solid var(--photos-line); }
.photos-selection-bar > button:first-child { min-height: 40px; color: var(--photos-blue); font-size: 14px; }
.photos-selection-bar > span { flex: 1; text-align: center; font-size: 13px; }
.photos-selection-bar .photos-round { background: none; }
#gallery-selection-favorite[aria-pressed="true"] svg { fill: currentColor; }
.photos-search { display: flex; align-items: center; gap: 12px; margin: -10px 20px 24px; }
.photos-search label { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; min-height: 38px; padding: 8px 10px; background: var(--photos-fill); border-radius: 11px; }
.photos-search label svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--photos-secondary); }
#gallery-search { min-width: 0; width: 100%; color: var(--photos-ink); font-size: 16px; }
#gallery-search::placeholder { color: var(--photos-secondary); font-size: 14px; }
.photos-search > button { min-height: 44px; color: var(--photos-blue); font-size: 15px; }
.photos-album-context { padding: 0 20px 18px; }
.photos-album-context button { color: var(--photos-blue); font-size: 14px; min-height: 32px; }
.photos-albums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 16px; padding: 3px 20px 24px; }
.photos-album { display: grid; gap: 5px; min-width: 0; text-align: left; }
.photos-album-cover { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-rows: repeat(2,minmax(0,1fr)); gap: 1px; width: 100%; aspect-ratio: 1; margin-bottom: 4px; overflow: hidden; border-radius: 12px; background: var(--photos-fill); }
.photos-album-cover img { width: 100%; height: 100%; object-fit: cover; }
.photos-album-cover img:only-child { grid-column: 1/-1; grid-row: 1/-1; }
.photos-album-cover.empty { display: grid; place-items: center; color: var(--photos-blue); font-size: 45px; }
.photos-album-cover.empty > span { grid-column: 1/-1; grid-row: 1/-1; }
.photos-album > strong { font-size: 16px; font-weight: 500; }
.photos-album > small { color: var(--photos-secondary); font-size: 13px; }
.photos-empty { min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.photos-empty > svg { width: 58px; height: 58px; color: #b8b8be; margin-bottom: 5px; }
.photos-empty h2 { font-size: 22px; font-weight: 650; }
.photos-empty p { max-width: 260px; color: var(--photos-secondary); font-size: 14px; line-height: 1.6; }
.photos-empty button { margin-top: 7px; padding: 10px 20px; border-radius: 22px; color: #fff; background: var(--photos-blue); font-size: 15px; }
.photos-status { position: absolute; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); left: 20px; right: 20px; z-index: 5; width: fit-content; max-width: calc(100% - 40px); margin-inline: auto; padding: 10px 16px; border-radius: 22px; color: var(--photos-ink); background: var(--photos-fill); box-shadow: 0 3px 18px #0001; font-size: 13px; text-align: center; }
/* Large, uncropped viewing with native-style controls. */
.photos-viewer { position: fixed; z-index: 95; inset: 0; display: grid; grid-template-rows: auto minmax(0,1fr) 66px auto; color: #fff; background: #000; animation: photos-viewer-in 220ms ease both; }
.photos-viewer-header { display: grid; grid-template-columns: 64px minmax(0,1fr) 64px; align-items: center; min-height: calc(66px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 10px 0; }
.photos-viewer-header > button { display: grid; place-items: center; min-height: 44px; font-size: 16px; color: #fff; }
.photos-viewer-header svg { width: 25px; height: 25px; }
.photos-viewer-header > div { display: grid; gap: 3px; justify-items: center; min-width: 0; }
.photos-viewer-header strong { max-width: 100%; font-size: 14px; font-weight: 600; }
.photos-viewer-header small { font-size: 11px; color: #999; }
.photos-viewer-stage { position: relative; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: pan-y pinch-zoom; }
#gallery-viewer-image { display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-select: none; user-select: none; }
.photos-viewer-prev, .photos-viewer-next { position: absolute; top: calc(50% - 23px); width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: #16161699; color: #fff; font-size: 30px; opacity: 0; transition: opacity 180ms; }
.photos-viewer-prev { left: 16px; }
.photos-viewer-next { right: 16px; }
.photos-viewer-stage:hover button, .photos-viewer-stage button:focus-visible { opacity: 1; }
.photos-filmstrip { display: flex; align-items: center; justify-content: safe center; gap: 3px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.photos-filmstrip button { height: 42px; width: 28px; flex: 0 0 28px; border-radius: 3px; overflow: hidden; opacity: .6; transition: width 180ms, opacity 180ms; }
.photos-filmstrip button.active { width: 38px; flex-basis: 38px; margin-inline: 5px; opacity: 1; box-shadow: 0 0 0 2px #fff; }
.photos-filmstrip img { width: 100%; height: 100%; object-fit: cover; }
.photos-viewer-tools { display: flex; align-items: center; justify-content: space-around; padding: 0 18px calc(8px + env(safe-area-inset-bottom, 0px)); }
.photos-viewer-tools > button { display: grid; place-items: center; width: 52px; height: 48px; color: #fff; }
.photos-viewer-tools svg { width: 24px; height: 24px; }
#gallery-viewer-favorite[aria-pressed="true"] { color: #ff453a; }
#gallery-viewer-favorite[aria-pressed="true"] svg { fill: currentColor; }
#gallery-viewer-info[aria-expanded="true"] { color: #0a84ff; }
.photos-info { position: absolute; z-index: 2; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom, 0px)); max-height: 55dvh; overflow-y: auto; padding: 20px 22px; border-radius: 22px 22px 0 0; color: var(--photos-ink); background: var(--photos-bg); box-shadow: 0 -12px 50px #0005; }
.photos-info-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.photos-info-head h2 { font-size: 19px; }
.photos-info-head button { width: 30px; height: 30px; border-radius: 50%; color: var(--photos-secondary); background: var(--photos-fill); font-size: 22px; }
.photos-info dl > div { display: grid; grid-template-columns: 72px minmax(0,1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--photos-line); font-size: 14px; line-height: 1.5; }
.photos-info dt { color: var(--photos-secondary); }
.photos-info dd { overflow-wrap: anywhere; }
#gallery-info-edit { margin-top: 10px; min-height: 40px; color: var(--photos-blue); font-size: 15px; }
/* Editing is an optional sheet, rather than the default response to a tap. */
#modal-gallery-edit { z-index: 100; }
#modal-gallery-edit .modal-sheet { padding: 0 0 calc(22px + env(safe-area-inset-bottom, 0px)); width: min(520px,100%); max-width: 520px; max-height: 92dvh; border: 0; border-radius: 24px 24px 0 0; color: var(--photos-ink); background: var(--photos-fill); }
.photos-edit-header { display: grid; grid-template-columns: 64px minmax(0,1fr) 64px; align-items: center; min-height: 62px; padding: 0 12px; flex-shrink: 0; }
.photos-edit-header button { min-height: 44px; color: var(--photos-blue); font-size: 16px; }
.photos-edit-header button:last-child { font-weight: 600; }
.photos-edit-header h2 { text-align: center; font-size: 17px; font-weight: 600; }
#modal-gallery-edit .edit-sheet-content { padding: 0 18px; gap: 16px; }
#modal-gallery-edit .gallery-edit-preview { display: block; max-height: 180px; min-height: 80px; width: 100%; object-fit: contain; border-radius: 12px; background: transparent; }
.photos-edit-fields { padding-inline: 14px; background: var(--photos-bg); border-radius: 12px; }
#modal-gallery-edit .edit-sheet-row { display: flex; align-items: center; flex-direction: row; gap: 12px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--photos-line); }
#modal-gallery-edit .edit-sheet-row:last-child { border: 0; }
#modal-gallery-edit .edit-sheet-label { width: 68px; flex-shrink: 0; margin: 0; font-size: 14px; color: var(--photos-ink); }
#modal-gallery-edit .edit-sheet-input { flex: 1; min-width: 0; width: 100%; padding: 4px 0; border: 0; border-radius: 0; color: var(--photos-ink); background: transparent; font-size: 16px; box-shadow: none; }
#modal-gallery-edit .edit-sheet-input::placeholder { color: var(--photos-secondary); font-size: 14px; }
.photos-edit-note { padding-inline: 12px; font-size: 12px; line-height: 1.6; color: var(--photos-secondary); }
.photos-edit-delete { min-height: 46px; color: #ff3b30; background: var(--photos-bg); border-radius: 12px; font-size: 16px; }
@keyframes photos-viewer-in { from { opacity: 0; transform: scale(.98); } }
@media (hover: none) { .photos-viewer-prev, .photos-viewer-next { display: none; } }
@media (min-width: 700px) { #page-gallery .gallery-grid { grid-template-columns: repeat(var(--photos-columns, 5),minmax(0,1fr)); } .photos-albums { grid-template-columns: repeat(3,minmax(0,220px)); } }
@media (min-width: 1100px) { #page-gallery .gallery-grid { grid-template-columns: repeat(var(--photos-columns, 7),minmax(0,1fr)); } }
@media (max-height: 500px) { .photos-viewer-header { min-height: 46px; } .photos-viewer { grid-template-rows: auto minmax(0,1fr) 48px auto; } .photos-filmstrip { padding-block: 5px; } .photos-filmstrip button { height: 32px; } .photos-viewer-tools > button { height: 36px; } }
@media (prefers-reduced-motion: reduce) { #page-gallery *, .photos-viewer, .photos-viewer * { animation: none !important; transition: none !important; } }

/* Keep pinch density announcements available without adding visible controls. */
.photos-library-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.photos-zoom-status { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#page-gallery .gallery-grid { touch-action: pan-y; }
#page-gallery .gallery-grid.is-pinching { will-change: transform; }
#page-gallery .gallery-grid.is-pinching .gallery-item img { transition: none; }
#page-gallery .gallery-grid.is-pinching, #page-gallery .gallery-grid.is-pinching * { -webkit-user-select: none; user-select: none; }
