.project-gallery { --gallery-canvas: #f0f0f5; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); }
html[data-theme="dark"] .project-gallery { --gallery-canvas: #10121a; }
.project-gallery [hidden], .project-gallery-dialog [hidden] { display: none !important; }
.project-gallery button, .project-gallery-dialog button { font: inherit; cursor: pointer; color: inherit; }
.project-gallery :is(button, a, [tabindex]):focus-visible, .project-gallery-dialog :is(button, a):focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.project-gallery button:disabled { cursor: default; opacity: .35; }
.project-gallery svg, .gallery-close svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.gallery-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 10px; }
.gallery-filters { display: flex; gap: 4px; min-width: 0; }
.gallery-filters button { display: flex; align-items: center; gap: 7px; min-height: 38px; padding: 7px 13px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 12px; white-space: nowrap; color: var(--muted); }
.gallery-filters button > span { font-size: 10px; font-variant-numeric: tabular-nums; opacity: .75; }
.gallery-filters button[aria-pressed="true"] { border-color: var(--line); background: var(--surface-2); color: var(--text); font-weight: 750; }
.gallery-expand { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; flex: none; font-size: 11px !important; }
.gallery-stage { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: min(620px, 65svh); min-height: 180px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--gallery-canvas); touch-action: pan-y pinch-zoom; }
.gallery-surface { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; }
.gallery-surface > img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; object-position: center; -webkit-user-drag: none; user-select: none; }
.project-gallery.is-enhanced:not(.is-dialog) .gallery-stage.is-image { cursor: zoom-in; }
.gallery-stage.is-video .gallery-surface { padding: 0; background: #080910; }
.gallery-surface > :is(video, iframe) { display: block; width: 100%; height: 100%; min-height: 0; border: 0; object-fit: contain; background: #080910; }
.gallery-surface > .gallery-video-poster { opacity: .55; }
.gallery-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 12px 20px; border: 1px solid #ffffff55; border-radius: 12px; background: #171927ed; color: #fff !important; font-size: 14px; font-weight: 700; box-shadow: 0 8px 24px #0003; white-space: nowrap; }
.gallery-play svg { fill: currentColor; stroke: none; }
.gallery-status { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 24px; background: var(--gallery-canvas); text-align: center; }
.gallery-status p { margin: 0; font-size: 13px; line-height: 1.9; color: var(--muted); }
.gallery-status button { min-height: 40px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-size: 12px; }
.gallery-spinner { display: none; width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; }
.project-gallery.is-loading .gallery-spinner { display: block; animation: gallerySpin .7s linear infinite; }
.gallery-bottomline { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 62px; padding: 9px 5px; }
.gallery-caption { min-width: 0; text-align: right; }
.gallery-caption > span { display: block; font-size: 12px; font-weight: 750; }
.gallery-caption > p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.gallery-caption > p:empty { display: none; }
.gallery-navigation { display: flex; align-items: center; gap: 8px; flex: none; }
.gallery-navigation button { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; }
.gallery-navigation button:hover:not(:disabled), .gallery-expand:hover { background: var(--surface-2); border-color: var(--line-strong); }
.gallery-navigation svg { width: 17px; height: 17px; }
.gallery-counter { min-width: 51px; text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.gallery-thumbnails { display: flex; align-items: center; gap: 9px; max-width: 100%; padding: 5px 4px 7px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; scroll-snap-type: x proximity; }
.gallery-thumb { position: relative; display: grid; place-items: center; flex: 0 0 106px; height: 70px; overflow: hidden; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--gallery-canvas); scroll-snap-align: center; isolation: isolate; }
.gallery-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.gallery-thumb.is-current { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.gallery-thumb > span { position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center; min-width: 17px; height: 17px; padding-inline: 3px; border-radius: 4px; background: #171927c9; color: #fff; font-size: 9px; font-variant-numeric: tabular-nums; }
.gallery-thumb .gallery-thumb-play { position: absolute; width: 28px; height: 28px; padding: 6px; border-radius: 50%; background: #171927df; color: #fff; fill: currentColor; stroke: none; }
.gallery-announcement { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.project-gallery-dialog { --surface: #13151e; --surface-2: #1c1f2b; --line: #ffffff1c; --line-strong: #ffffff38; --text: #f5f5fb; --muted: #aaaebf; --primary: #aaa0ff; position: fixed; inset: 0; width: min(1440px, calc(100% - 48px)); height: calc(100dvh - 40px); max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 20px 100px #0005; overscroll-behavior: contain; }
.project-gallery-dialog::backdrop { background: #080a12cf; backdrop-filter: blur(8px); }
.project-gallery-dialog[open] { display: flex; flex-direction: column; }
.gallery-dialog-head { display: flex; align-items: center; gap: 24px; flex: none; min-height: 72px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.gallery-dialog-head > div { min-width: 0; flex: 1; }
.gallery-dialog-head > div > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.gallery-dialog-head h2 { margin: 0; font-size: 15px; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-detail-link { display: inline-flex; align-items: center; gap: 9px; min-height: 38px; color: var(--muted); font-size: 12px; flex: none; }
.gallery-detail-link:hover { color: var(--primary); }
.gallery-close { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); flex: none; }
.project-gallery-dialog > .project-gallery { --gallery-canvas: #0d0f16; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 16px; border: 0; border-radius: 0; }
.project-gallery-dialog .gallery-topline { flex: none; }
.project-gallery-dialog .gallery-stage { flex: 1; min-height: 0; max-height: none; aspect-ratio: auto; }
.project-gallery-dialog .gallery-bottomline, .project-gallery-dialog .gallery-thumbnails { flex-shrink: 0; }
.project-gallery-dialog .gallery-expand { display: none !important; }
body.project-gallery-open { overflow: hidden !important; }
@keyframes gallerySpin { to { transform: rotate(360deg); } }
@media (max-width: 820px) {
  .project-gallery { padding: 7px; border-radius: 12px; }
  .gallery-topline { gap: 5px; min-height: 38px; margin-bottom: 7px; }
  .gallery-filters { gap: 1px; }
  .gallery-filters button { min-height: 36px; padding: 6px 8px; gap: 5px; font-size: 10px; border-radius: 7px; }
  .gallery-filters button > span { font-size: 9px; }
  .gallery-expand { min-height: 36px; width: 36px; padding: 7px; border-radius: 7px; }
  .gallery-expand > span { display: none; }
  .gallery-stage { aspect-ratio: 4 / 3; max-height: 60svh; border-radius: 8px; }
  .gallery-surface { padding: 5px; }
  .gallery-bottomline { gap: 9px; min-height: 56px; padding: 8px 2px; }
  .gallery-caption > span { font-size: 11px; }
  .gallery-caption > p { font-size: 10px; }
  .gallery-navigation { gap: 4px; }
  .gallery-navigation button { width: 36px; height: 36px; }
  .gallery-counter { min-width: 43px; font-size: 10px; }
  .gallery-thumbnails { gap: 7px; }
  .gallery-thumb { flex-basis: 76px; height: 54px; border-radius: 6px; }
  .project-gallery-dialog { width: 100%; height: 100dvh; margin: 0; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .gallery-dialog-head { min-height: 65px; padding: 10px 12px; gap: 12px; }
  .gallery-dialog-head h2 { font-size: 12px; }
  .gallery-dialog-head > div > span { font-size: 9px; }
  .gallery-detail-link { font-size: 10px; gap: 4px; }
  .gallery-close { width: 36px; height: 36px; }
  .project-gallery-dialog > .project-gallery { padding: 6px 7px; }
  .gallery-play { min-height: 48px; padding: 10px 16px; font-size: 12px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .project-gallery-dialog { width: 100%; height: 100dvh; border: 0; border-radius: 0; margin: 0; }
  .project-gallery-dialog .gallery-dialog-head { min-height: 44px; padding-block: 4px; }
  .project-gallery-dialog .gallery-dialog-head > div > span { display: none; }
  .project-gallery-dialog .gallery-topline { min-height: 32px; margin-bottom: 4px; }
  .project-gallery-dialog .gallery-bottomline { min-height: 40px; padding-block: 3px; }
  .project-gallery-dialog .gallery-thumb { height: 37px; flex-basis: 58px; }
  .project-gallery-dialog .gallery-thumbnails { padding-block: 3px; }
}
@media (prefers-reduced-motion: reduce) { .project-gallery *, .project-gallery-dialog { animation: none !important; scroll-behavior: auto !important; } }
