:root {
    --gallery-ink: #111827;
    --gallery-muted: #6b7280;
    --gallery-line: #e5e7eb;
    --gallery-soft: #f9fafb;
    --gallery-white: #ffffff;
    --gallery-red: #ef4444;
    --gallery-red-dark: #dc2626;
}

[x-cloak] { display: none !important; }
.gallery-page { min-height: calc(100vh - 145px); padding: 48px 0 24px; background: #f3f4f6; color: var(--gallery-ink); }
.gallery-page *, .gallery-page *::before, .gallery-page *::after { box-sizing: border-box; }
.gallery-shell { width: min(1280px, calc(100% - 48px)); margin: 0 auto; }
.gallery-header { display: flex; align-items: center; justify-content: space-between; gap: 40px; margin-bottom: 24px; padding: 30px 34px; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); box-shadow: 0 4px 16px rgba(17, 24, 39, .05); }
.gallery-header > div { position: relative; min-width: 0; padding-left: 62px; }
.gallery-header__icon { position: absolute; top: 1px; left: 0; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 7px; background: #fee2e2; color: var(--gallery-red-dark); }
.gallery-header__icon svg { width: 25px; height: 25px; }
.gallery-header h1 { margin: 0; font-size: 2rem; line-height: 1.15; font-weight: 800; }
.gallery-header p { margin: 8px 0 0; color: var(--gallery-muted); font-size: .92rem; line-height: 1.55; }
.gallery-private-link { min-height: 44px; display: inline-flex; align-items: center; flex: 0 0 auto; gap: 9px; padding: 0 16px; border-radius: 6px; background: var(--gallery-red); color: var(--gallery-white); font-size: .82rem; font-weight: 700; box-shadow: 0 3px 8px rgba(239, 68, 68, .2); transition: background .18s ease, transform .18s ease; }
.gallery-private-link svg { width: 18px; height: 18px; }
.gallery-private-link:hover, .gallery-private-link:focus-visible { background: var(--gallery-red-dark); transform: translateY(-1px); }
.gallery-panel { min-height: 360px; padding: 0 32px 38px; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); box-shadow: 0 4px 16px rgba(17, 24, 39, .05); }
.gallery-toolbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--gallery-line); }
.gallery-breadcrumbs { min-width: 0; display: flex; align-items: center; gap: 7px; overflow-x: auto; scrollbar-width: thin; }
.gallery-breadcrumbs svg { width: 15px; height: 15px; flex: 0 0 auto; color: #9ca3af; }
.gallery-breadcrumbs button { padding: 7px 2px; border: 0; background: transparent; color: var(--gallery-muted); font-size: .8rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.gallery-breadcrumbs button:last-child, .gallery-breadcrumbs button:disabled { color: var(--gallery-ink); }
.gallery-breadcrumbs button:disabled { cursor: default; }
.gallery-counts { display: flex; flex: 0 0 auto; gap: 8px; color: var(--gallery-muted); font-size: .74rem; font-weight: 600; }
.gallery-counts span { padding: 6px 9px; border-radius: 5px; background: var(--gallery-soft); }
.gallery-counts strong { color: var(--gallery-ink); }
.gallery-back { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; margin-top: 20px; padding: 0 11px; border: 1px solid var(--gallery-line); border-radius: 5px; background: var(--gallery-white); color: #374151; font-size: .78rem; font-weight: 700; cursor: pointer; transition: border-color .18s ease, background .18s ease; }
.gallery-back svg { width: 17px; height: 17px; }
.gallery-back:hover { border-color: #d1d5db; background: var(--gallery-soft); }
.gallery-section { margin-top: 34px; }
.gallery-section__heading { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.gallery-section__heading > svg { width: 20px; height: 20px; color: var(--gallery-red-dark); }
.gallery-section__heading h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.folder-tile { min-width: 0; min-height: 66px; display: grid; grid-template-columns: 36px minmax(0,1fr) 18px; align-items: center; gap: 11px; padding: 11px 14px; border: 1px solid var(--gallery-line); border-radius: 6px; background: var(--gallery-soft); color: var(--gallery-ink); text-align: left; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.folder-tile:hover, .folder-tile:focus-visible { border-color: #fca5a5; background: #fff7f7; transform: translateY(-1px); }
.folder-tile__icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 5px; background: #fef3c7; color: #a16207; }
.folder-tile__icon svg { width: 20px; height: 20px; }
.folder-tile__name { min-width: 0; overflow: hidden; font-size: .84rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.folder-tile__arrow { width: 16px; color: #9ca3af; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 16px; }
.image-tile { min-width: 0; overflow: hidden; margin: 0; border: 1px solid var(--gallery-line); border-radius: 7px; background: var(--gallery-white); box-shadow: 0 2px 7px rgba(17, 24, 39, .05); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.image-tile:hover { border-color: #d1d5db; box-shadow: 0 9px 22px rgba(17, 24, 39, .1); transform: translateY(-2px); }
.image-tile__preview { position: relative; width: 100%; display: block; aspect-ratio: 4 / 3; overflow: hidden; padding: 0; border: 0; border-bottom: 1px solid var(--gallery-line); background: var(--gallery-soft); cursor: zoom-in; }
.image-tile__preview img { width: 100%; height: 100%; display: block; object-fit: contain; transition: transform .25s ease; }
.image-tile:hover .image-tile__preview img { transform: scale(1.02); }
.image-tile__zoom { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(209, 213, 219, .9); border-radius: 5px; background: rgba(255, 255, 255, .94); color: #374151; opacity: 0; transform: translateY(4px); transition: opacity .18s ease, transform .18s ease; }
.image-tile__zoom svg { width: 18px; height: 18px; }
.image-tile:hover .image-tile__zoom, .image-tile__preview:focus-visible .image-tile__zoom { opacity: 1; transform: none; }
.image-tile__meta { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px 11px 14px; }
.image-tile__meta > div { min-width: 0; }
.image-tile__meta strong { display: block; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.image-tile__meta span { display: block; margin-top: 3px; color: var(--gallery-muted); font-size: .65rem; font-weight: 650; }
.image-tile__meta a { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--gallery-line); border-radius: 5px; color: #374151; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.image-tile__meta a svg { width: 18px; height: 18px; }
.image-tile__meta a:hover, .image-tile__meta a:focus-visible { border-color: var(--gallery-red); background: var(--gallery-red); color: var(--gallery-white); }
.gallery-empty { min-height: 300px; display: grid; place-items: center; align-content: center; margin-top: 32px; border: 1px dashed #d1d5db; border-radius: 6px; background: var(--gallery-soft); text-align: center; }
.gallery-empty svg { width: 40px; height: 40px; color: #9ca3af; }
.gallery-empty h2 { margin: 16px 0 0; font-size: 1.15rem; }
.gallery-empty p { margin: 7px 0 0; color: var(--gallery-muted); font-size: .84rem; }
.gallery-lightbox { width: min(1120px, calc(100vw - 48px)); max-width: none; max-height: calc(100vh - 48px); overflow: hidden; padding: 0; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); color: var(--gallery-ink); box-shadow: 0 24px 70px rgba(17, 24, 39, .3); }
.gallery-lightbox::backdrop { background: rgba(17, 24, 39, .72); backdrop-filter: blur(3px); }
.gallery-lightbox__bar { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 9px 10px 9px 18px; border-bottom: 1px solid var(--gallery-line); }
.gallery-lightbox__bar strong { min-width: 0; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.gallery-lightbox__bar button { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--gallery-line); border-radius: 5px; background: var(--gallery-white); color: #374151; cursor: pointer; }
.gallery-lightbox__bar button:hover, .gallery-lightbox__bar button:focus-visible { border-color: var(--gallery-red); background: var(--gallery-red); color: var(--gallery-white); }
.gallery-lightbox__bar svg { width: 20px; height: 20px; }
.gallery-lightbox > img { width: 100%; height: calc(100vh - 106px); display: block; object-fit: contain; background: var(--gallery-soft); }

.private-gallery-page { min-height: calc(100vh - 145px); padding: 48px 0 24px; background: #f3f4f6; color: var(--gallery-ink); }
.private-gallery-page *, .private-gallery-page *::before, .private-gallery-page *::after { box-sizing: border-box; }
.private-gallery-login { width: min(460px, calc(100% - 32px)); margin: 40px auto; padding: 30px; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); box-shadow: 0 8px 24px rgba(17, 24, 39, .08); }
.private-gallery-login__icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 7px; background: #fee2e2; color: var(--gallery-red-dark); }
.private-gallery-login__icon svg { width: 25px; height: 25px; }
.private-gallery-login h1 { margin: 0; font-size: 1.65rem; }
.private-gallery-login p { margin: 10px 0 22px; color: var(--gallery-muted); font-size: .9rem; line-height: 1.55; }
.private-gallery-login label { display: block; margin-bottom: 7px; font-size: .8rem; font-weight: 700; }
.private-gallery-login input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 6px; background: var(--gallery-white); color: var(--gallery-ink); }
.private-gallery-login input:focus { border-color: var(--gallery-red); outline: 3px solid #fee2e2; }
.private-gallery-login .gallery-primary-button { width: 100%; margin-top: 14px; }
.private-gallery-login__back { display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; color: #4b5563; font-size: .8rem; font-weight: 700; }
.private-gallery-login__back svg { width: 17px; height: 17px; }
.gallery-error { margin: 8px 0 0 !important; color: #b91c1c !important; font-size: .78rem !important; }
.private-gallery-header { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 24px; padding: 27px 30px; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); box-shadow: 0 4px 16px rgba(17, 24, 39, .05); }
.private-gallery-header h1 { margin: 0; font-size: 1.8rem; }
.private-gallery-header p { margin: 7px 0 0; color: var(--gallery-muted); font-size: .88rem; }
.private-gallery-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 9px; }
.gallery-secondary-button, .gallery-primary-button, .gallery-danger-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid var(--gallery-line); border-radius: 6px; background: var(--gallery-white); color: #374151; font-size: .8rem; font-weight: 750; cursor: pointer; }
.gallery-primary-button { border-color: var(--gallery-red); background: var(--gallery-red); color: var(--gallery-white); }
.gallery-danger-button { border-color: #fecaca; background: #fff7f7; color: #b91c1c; }
.gallery-secondary-button:hover { background: var(--gallery-soft); }
.gallery-primary-button:hover { background: var(--gallery-red-dark); }
.gallery-danger-button:hover { border-color: #fca5a5; background: #fee2e2; }
.gallery-secondary-button svg, .gallery-primary-button svg, .gallery-danger-button svg { width: 18px; height: 18px; }
.private-gallery-panel { padding: 26px 30px 36px; border: 1px solid var(--gallery-line); border-radius: 8px; background: var(--gallery-white); box-shadow: 0 4px 16px rgba(17, 24, 39, .05); }
.private-gallery-nav { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.private-gallery-path { color: var(--gallery-muted); font-size: .78rem; font-weight: 650; overflow-wrap: anywhere; }
.private-folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 30px; }
.private-folder { min-height: 64px; display: flex; align-items: center; gap: 11px; padding: 12px 14px; border: 1px solid var(--gallery-line); border-radius: 6px; background: var(--gallery-soft); color: var(--gallery-ink); font-size: .84rem; font-weight: 750; }
.private-folder:hover { border-color: #fca5a5; background: #fff7f7; }
.private-folder svg { width: 22px; height: 22px; flex: 0 0 auto; color: #a16207; }
.private-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.private-photo { overflow: hidden; border: 1px solid var(--gallery-line); border-radius: 7px; background: var(--gallery-white); box-shadow: 0 2px 7px rgba(17, 24, 39, .05); }
.private-photo__preview { position: relative; width: 100%; display: block; aspect-ratio: 4 / 3; padding: 0; overflow: hidden; border: 0; border-bottom: 1px solid var(--gallery-line); background: var(--gallery-soft); cursor: zoom-in; }
.private-photo__preview img { width: 100%; height: 100%; display: block; object-fit: contain; transition: transform .25s ease; }
.private-photo__preview:hover img { transform: scale(1.02); }
.private-photo__zoom { position: absolute; right: 10px; bottom: 10px; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--gallery-line); border-radius: 5px; background: rgba(255,255,255,.94); color: #374151; }
.private-photo__zoom svg { width: 18px; height: 18px; }
.private-photo__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px 11px 14px; }
.private-photo__footer strong { min-width: 0; overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.private-photo__footer a { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--gallery-line); border-radius: 5px; color: #374151; }
.private-photo__footer a:hover { border-color: var(--gallery-red); background: var(--gallery-red); color: var(--gallery-white); }
.private-photo__footer svg { width: 18px; height: 18px; }
.private-gallery-empty { min-height: 270px; display: grid; place-items: center; align-content: center; border: 1px dashed #d1d5db; border-radius: 6px; background: var(--gallery-soft); color: var(--gallery-muted); text-align: center; }
.private-gallery-empty svg { width: 40px; height: 40px; margin-bottom: 12px; color: #9ca3af; }

@media (max-width: 720px) {
    .gallery-page, .private-gallery-page { padding-top: 24px; }
    .gallery-shell { width: min(100% - 28px, 1280px); }
    .gallery-header, .private-gallery-header { align-items: flex-start; flex-direction: column; gap: 22px; padding: 24px; }
    .gallery-header > div { padding-left: 0; }
    .gallery-header__icon { position: static; margin-bottom: 14px; }
    .gallery-header h1 { font-size: 1.65rem; }
    .gallery-private-link, .private-gallery-actions { width: 100%; }
    .private-gallery-actions { align-items: stretch; flex-direction: column; }
    .private-gallery-actions > *, .private-gallery-actions form, .private-gallery-actions form button { width: 100%; }
    .gallery-panel, .private-gallery-panel { padding: 0 18px 28px; }
    .private-gallery-panel { padding-top: 20px; }
    .gallery-toolbar, .private-gallery-nav { align-items: flex-start; flex-direction: column; gap: 11px; padding: 15px 0; }
    .gallery-counts { width: 100%; }
    .gallery-counts span { flex: 1; text-align: center; }
    .folder-grid, .image-grid, .private-folder-grid, .private-image-grid { grid-template-columns: 1fr; }
    .image-tile__preview, .private-photo__preview { aspect-ratio: 16 / 11; }
    .image-tile__zoom { opacity: 1; transform: none; }
    .gallery-lightbox { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
    .gallery-lightbox > img { height: calc(100vh - 78px); }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-page *, .gallery-page *::before, .gallery-page *::after,
    .private-gallery-page *, .private-gallery-page *::before, .private-gallery-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
