:root {
    color-scheme: light dark;
    --bg-color: #050505;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --icon-color: #ffffff;
    --icon-bg: rgba(255, 255, 255, 0.05);
    --icon-border: rgba(255, 255, 255, 0.1);
    --icon-hover-bg: rgba(255, 255, 255, 0.18);
    --tooltip-bg: rgba(0, 0, 0, 0.85);
    --tooltip-color: #ffffff;
    --gallery-outline: rgba(255, 255, 255, 0.75);
    --gallery-outline-hover: #ffffff;
    --gallery-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --gallery-shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.8);
    --thumb-title-color: #ffffff;
    --thumb-title-shadow: 0px 2px 4px rgba(0, 0, 0, 0.8);
    --dock-bg: rgba(255, 255, 255, 0.05);
    --dock-border: rgba(255, 255, 255, 0.1);
    --dock-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --modal-bg: rgba(20, 20, 20, 0.65);
    --modal-border: rgba(255, 255, 255, 0.15);
    --modal-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.2);
    --input-text: #ffffff;
    --bg-overlay-color: rgba(5, 5, 5, 0.6);
    --bg-filter: blur(10px) brightness(0.6);
    --indicator-color: rgba(255, 255, 255, 0.2);
    --indicator-active: #ffffff;
    --indicator-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    --close-btn-color: rgba(255, 255, 255, 0.6);
    --close-btn-hover: #ffffff;
    --title-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    --icon-expand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E");
    --icon-compress: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7'/%3E%3C/svg%3E");
}

[data-theme="light"],
:root:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
    --bg-color: #f7f7f9;
    --text-primary: #0a0a0a;
    --text-secondary: #222222;
    --accent: #000000;
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.7);
    --glass-shadow: 0 12px 35px 0 rgba(0, 0, 0, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.9);
    --icon-color: #0a0a0a;
    --icon-bg: rgba(255, 255, 255, 0.45);
    --icon-border: rgba(255, 255, 255, 0.7);
    --icon-hover-bg: rgba(255, 255, 255, 0.85);
    --tooltip-bg: rgba(18, 18, 18, 0.92);
    --tooltip-color: #ffffff;
    --gallery-outline: rgba(0, 0, 0, 0.75);
    --gallery-outline-hover: #000000;
    --gallery-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    --gallery-shadow-hover: 0 20px 42px rgba(0, 0, 0, 0.32);
    --thumb-title-color: #0a0a0a;
    --thumb-title-shadow: 0px 1px 4px rgba(255, 255, 255, 0.95), 0px 0px 8px rgba(255, 255, 255, 0.9);
    --dock-bg: rgba(255, 255, 255, 0.45);
    --dock-border: rgba(255, 255, 255, 0.75);
    --dock-shadow: 0 12px 35px 0 rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.95);
    --modal-bg: rgba(255, 255, 255, 0.62);
    --modal-border: rgba(255, 255, 255, 0.8);
    --modal-shadow: 0 20px 50px 0 rgba(0, 0, 0, 0.14), inset 0 1px 2px rgba(255, 255, 255, 0.95);
    --input-bg: rgba(255, 255, 255, 0.65);
    --input-border: rgba(0, 0, 0, 0.18);
    --input-text: #0a0a0a;
    --bg-overlay-color: rgba(247, 247, 249, 0.55);
    --bg-filter: blur(12px) brightness(1.05) saturate(1.1);
    --indicator-color: rgba(0, 0, 0, 0.25);
    --indicator-active: #000000;
    --indicator-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
    --close-btn-color: rgba(0, 0, 0, 0.6);
    --close-btn-hover: #000000;
    --title-shadow: 0 1px 8px rgba(255, 255, 255, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-color);
    overflow: hidden; /* Prevent scrolling, full screen app */
    height: 100vh;
    width: 100vw;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* Background Animation */
.background {
    position: fixed;
    top: -20%; left: -20%;
    width: 140%; height: 140%;
    z-index: -2;
}

.bg-image {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    filter: var(--bg-filter);
    transition: filter 0.5s ease, opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    animation: drift 25s ease-in-out infinite alternate;
}

.bg-image-dark {
    background-image: url('assets/bg.png');
    opacity: 1;
    z-index: 1;
}

.bg-image-light {
    background-image: url('assets/bg2.png');
    opacity: 0;
    z-index: 1;
}

[data-theme="light"] .bg-image-dark,
:root:has(> head > meta[name="color-scheme"][content="light"]) .bg-image-dark {
    opacity: 0;
}

[data-theme="light"] .bg-image-light,
:root:has(> head > meta[name="color-scheme"][content="light"]) .bg-image-light {
    opacity: 1;
}

.bg-scratches {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    background-image: linear-gradient(
        to right,
        transparent 0%,
        transparent 12%,
        rgba(0, 0, 0, 0.2) 12.1%,
        transparent 12.2%,
        transparent 35%,
        rgba(0, 0, 0, 0.15) 35.1%,
        transparent 35.2%,
        transparent 65%,
        rgba(255, 255, 255, 0.1) 65.1%,
        transparent 65.2%,
        transparent 88%,
        rgba(0, 0, 0, 0.2) 88.1%,
        transparent 88.2%,
        transparent 100%
    );
    background-size: 150% 100%;
    animation: scratches 0.5s steps(4) infinite alternate;
}

.bg-flicker {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    background-color: rgba(0,0,0,0.1);
    animation: projectorFlicker 0.15s infinite;
}

.bg-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at center, transparent 0%, var(--bg-overlay-color) 110%);
    pointer-events: none;
    transition: background 0.5s ease;
}

@keyframes drift {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    100% { transform: scale(1.15) translate(-2%, -2%) rotate(3deg); }
}

@keyframes scratches {
    0% { background-position: 0% 0; opacity: 0.7; }
    33% { background-position: 20% 0; opacity: 1; }
    66% { background-position: -15% 0; opacity: 0.6; }
    100% { background-position: 5% 0; opacity: 0.9; }
}

@keyframes projectorFlicker {
    0% { opacity: 0.9; }
    50% { opacity: 1; }
    100% { opacity: 0.85; }
}

/* Main Layout */
.main-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Site Title */
.site-title {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 10px;
    color: var(--text-secondary);
    text-shadow: var(--title-shadow);
    z-index: 10;
    text-transform: uppercase;
    transition: color 0.4s ease, text-shadow 0.4s ease;
}

/* Category Indicators (Scroll tracking) */
.category-indicators {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 50;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--indicator-color);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.indicator-dot:hover {
    background: var(--indicator-active);
    transform: scale(1.5);
}

.indicator-dot.active {
    background: var(--indicator-active);
    transform: scale(1.5);
    box-shadow: var(--indicator-shadow);
}

/* Scroll Hint */
.scroll-hint {
    position: absolute;
    bottom: 30px;
    left: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 10;
    animation: pulseHint 3s infinite alternate;
    transition: opacity 0.5s ease, color 0.4s ease;
}

.scroll-hint.hidden {
    opacity: 0;
    pointer-events: none;
}

.mouse-icon {
    width: 20px;
    height: 20px;
    animation: mouseScroll 2s infinite;
}

@keyframes mouseScroll {
    0% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
    100% { transform: translateY(0); }
}

@keyframes pulseHint {
    0% { opacity: 0.4; }
    100% { opacity: 0.9; }
}

.arrow-keys-icon {
    display: flex;
    gap: 4px;
}

.key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--icon-border);
    border-radius: 4px;
    font-size: 10px;
    background: var(--icon-bg);
    color: var(--text-primary);
    transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease;
}

/* Category Title (Above Dock) */
.category-title {
    position: absolute;
    bottom: 110px; /* Just above the dock */
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 6px;
    color: var(--text-primary);
    text-shadow: var(--title-shadow);
    text-align: center;
    z-index: 10;
    transition: opacity 0.3s ease, transform 0.3s ease, color 0.4s ease, text-shadow 0.4s ease;
}

/* Canvas for Thumbnails */
.canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through empty space */
}

/* Thumbnails */
.thumbnail {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center;
    opacity: 0;
    scale: 0;
    translate: -50% -50%;
}

.thumbnail.visible {
    opacity: 1;
    scale: 1;
    animation: bobbing 6s ease-in-out infinite;
}

.thumbnail img {
    border-radius: 6px;
    box-shadow: var(--gallery-shadow);
    border: 1.5px solid var(--gallery-outline);
    width: auto;
    height: auto;
    max-width: 120px; /* Made slightly smaller like reference */
    max-height: 160px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    object-fit: cover;
}

.thumbnail:hover {
    z-index: 100 !important;
}

.thumbnail:hover img {
    transform: scale(1.15) translateY(-5px);
    box-shadow: var(--gallery-shadow-hover);
    border-color: var(--gallery-outline-hover);
}

.thumbnail-title {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
    color: var(--thumb-title-color);
    text-shadow: var(--thumb-title-shadow);
    transition: opacity 0.3s ease, color 0.4s ease, text-shadow 0.4s ease;
}

.thumbnail:hover .thumbnail-title {
    opacity: 1;
}

@keyframes bobbing {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

/* Liquid Glass Dock */
.dock {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dock-bg);
    backdrop-filter: blur(24px) saturate(190%);
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    border: 1px solid var(--dock-border);
    border-radius: 24px;
    padding: 10px 20px;
    box-shadow: var(--dock-shadow);
    z-index: 20;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.dock ul {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 30px;
}

.dock-item {
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.dock-item a {
    color: inherit;
    text-decoration: none;
    display: block;
}

.icon {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--icon-bg);
    border: 1px solid var(--icon-border);
    transition: all 0.3s ease;
    color: var(--icon-color);
}

.icon svg {
    width: 18px;
    height: 18px;
}

.dock-item:hover .icon {
    transform: translateY(-8px) scale(1.1);
    background: var(--icon-hover-bg);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
    color: var(--icon-color);
}

[data-theme="light"] .dock-item:hover .icon {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12), inset 0 1px 1px rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.95);
}

.tooltip {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: var(--tooltip-bg);
    color: var(--tooltip-color);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dock-item:hover .tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Theme Toggle Icon Switching */
.theme-icon .sun-icon {
    display: block;
}
.theme-icon .moon-icon {
    display: none;
}

[data-theme="light"] .theme-icon .sun-icon {
    display: none;
}
[data-theme="light"] .theme-icon .moon-icon {
    display: block;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 1000;
}

[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.glass-panel {
    background: var(--modal-bg);
    backdrop-filter: blur(35px) saturate(190%);
    -webkit-backdrop-filter: blur(35px) saturate(190%);
    border: 1px solid var(--modal-border);
    border-radius: 20px;
    box-shadow: var(--modal-shadow);
    padding: 2rem;
    position: relative;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    max-width: 90vw;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    color: var(--text-primary);
}

.modal.active .glass-panel {
    transform: translateY(0) scale(1);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--close-btn-color);
    transition: color 0.3s;
    line-height: 1;
}

.close-btn:hover {
    color: var(--close-btn-hover);
}

/* Image Detail Modal */
.image-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
    min-width: min(320px, 92dvw);
    max-width: min(92vw, 1100px);
    max-width: min(92dvw, 1100px);
    padding: 2.75rem 2rem 1.75rem;
}

.image-modal-content .close-btn {
    top: 8px;
    right: 14px;
    font-size: 1.85rem;
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    max-width: 100%;
}

.image-container {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px;
    position: relative;
    width: fit-content;
    max-width: 100%;
    min-width: min(260px, 80dvw);
    min-height: clamp(220px, 38dvh, 360px);
    margin-inline: auto;
    overflow: hidden;
}

.image-container.is-loaded {
    min-height: 164px;
}

.image-container img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 62vh;
    max-height: 62dvh;
    object-fit: contain;
    border-radius: 8px;
    margin-inline: auto;
    transition: opacity 0.22s ease;
}

#detail-img.is-loading,
#detail-img:not([src]) {
    opacity: 0;
    visibility: hidden;
}

#detail-img.is-loaded {
    opacity: 1;
    visibility: visible;
}

.detail-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    z-index: 2;
}

.detail-loader-text {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.detail-img-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 2;
}

/* Indeterminate Buffering Spinner (<progress>) */
@property --arc-start {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

@property --arc-end {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

@property --progress-dash-animation {
    syntax: "*";
    inherits: false;
    initial-value: , progress-dash 2.4s ease-in-out infinite;
}

progress.loading-spinner:indeterminate::-webkit-progress-bar {
    display: none;
    background: none;
}

progress.loading-spinner:indeterminate::-webkit-progress-value {
    display: none;
    background: none;
}

progress.loading-spinner:indeterminate::-moz-progress-bar {
    display: none;
    background: none;
}

progress.loading-spinner:indeterminate::slider-fill {
    display: none;
    background: none;
}

progress.loading-spinner:indeterminate {
    --_from: calc(90deg + var(--arc-start, 0deg));
    --_to: calc(90deg + var(--arc-end, 158deg));
    --size: 40px;
    --thickness: 2.5px;
    --spinner-color: #ffffff;
    --track-color: rgba(255, 255, 255, 0.18);
    --spinner-duration: 1.3s;
    --_used-spinner-duration: var(--spinner-duration);

    position: relative;
    display: block;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    background-color: transparent;
    background: conic-gradient(
        from var(--_from),
        var(--spinner-color) calc(var(--_to) - var(--_from)),
        transparent 0
    ) var(--track-color);

    animation: progress-spin var(--_used-spinner-duration) linear infinite var(--progress-dash-animation, );
}

@supports (background-clip: border-area) {
    progress.loading-spinner:indeterminate {
        background-clip: border-area;
        border: var(--thickness) solid transparent;
        background-origin: border-box;
    }
}

@supports not (background-clip: border-area) {
    progress.loading-spinner:indeterminate {
        --clip-boundary: calc(100% - var(--thickness));
        -webkit-mask-image: radial-gradient(
            farthest-side,
            transparent var(--clip-boundary),
            black var(--clip-boundary)
        );
        mask-image: radial-gradient(
            farthest-side,
            transparent var(--clip-boundary),
            black var(--clip-boundary)
        );
        border: 0;
    }
}

[data-theme="light"] progress.loading-spinner:indeterminate {
    --spinner-color: #111111;
    --track-color: rgba(0, 0, 0, 0.14);
}

@keyframes progress-spin {
    to {
        rotate: 1turn;
    }
}

@keyframes progress-dash {
    from {
        --arc-start: 0deg;
        --arc-end: 8deg;
    }
    50% {
        --arc-start: 100deg;
        --arc-end: 356deg;
    }
    to {
        --arc-start: 360deg;
        --arc-end: 368deg;
    }
}

@media (prefers-reduced-motion: reduce) {
    progress.loading-spinner:indeterminate {
        --_used-spinner-duration: 6s;
    }
}

.details-container {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.45rem;
    width: 0;
    min-width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.details-container h2 {
    font-size: clamp(1.35rem, 2.5vw, 2.25rem);
    margin: 0;
    color: var(--text-primary);
}

.meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.meta .label {
    color: var(--text-primary);
    font-weight: 600;
}

.details-container p {
    margin: 0.25rem 0 0;
    max-width: 65ch;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Carousel controls */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(18, 18, 22, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.24);
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    z-index: 4;
}

.carousel-arrow:hover {
    background: rgba(35, 35, 42, 0.85);
    transform: translateY(-50%) scale(1.08);
}

.carousel-arrow:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

[data-theme="light"] .carousel-arrow {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(0, 0, 0, 0.16);
    color: #0a0a0a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}

[data-theme="light"] .carousel-arrow:hover {
    background: rgba(255, 255, 255, 0.96);
}

.carousel-arrow.left-arrow { left: 12px; }
.carousel-arrow.right-arrow { right: 12px; }

.carousel-indicators {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 4;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.45);
    transition: transform 0.2s ease, background 0.2s ease;
}

.carousel-dot.active {
    background: #ffffff;
    transform: scale(1.25);
}

/* Enlarge & Full-Screen Viewer Controls (CSS-Driven Icon Engine) */
@property --icon-start {
    syntax: "*";
    inherits: false;
}

:where(.icon-btn:empty)::before {
    --icon-start: inherit;
    content: image-set(linear-gradient(transparent 0 100%), var(--icon-start)) / var(--icon-style-alt, "");
    display: inline-block;
    width: var(--icon-style-size, 18px);
    height: var(--icon-style-size, 18px);
    background-color: var(--icon-style-color, currentColor);
    -webkit-mask: var(--icon-start) no-repeat center / contain;
    mask: var(--icon-start) no-repeat center / contain;
    flex: none;
    pointer-events: none;
    forced-color-adjust: none;
}

@container style(--icon-start) {
    :where(.icon-btn:empty)::before {
        --icon-start: inherit;
        content: "" / var(--icon-style-alt, "");
    }
}

@keyframes webkit-301609 {}

@supports ((-webkit-nbsp-mode: normal) or (-webkit-touch-callout: none) or (font: -apple-system-body)) and (content-visibility: auto) {
    @property --icon-start {
        syntax: "*";
        inherits: true;
    }

    @layer webkit-301609-fix {
        .icon-btn::before {
            animation: webkit-301609 0s;
        }
    }

    @layer webkit-325900-fix {
        @container style(--icon-start) {
            .icon-btn * {
                --icon-start: initial;
            }
        }
    }
}

.detail-zoom-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(14, 14, 18, 0.72);
    color: #ffffff;
    --icon-style-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.detail-zoom-btn:hover {
    background: rgba(35, 35, 42, 0.9);
    transform: scale(1.08);
}

.detail-zoom-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

[data-theme="light"] .detail-zoom-btn {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(0, 0, 0, 0.24);
    color: #0a0a0a;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}

[data-theme="light"] .detail-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.98);
}

/* Native Top-Layer Full-Screen Image Viewer */
.fullscreen-dialog {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    padding: calc(14px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px));
    background: rgba(8, 8, 11, 0.95);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    color: var(--text-primary);
    touch-action: pan-x pan-y pinch-zoom;
    z-index: 2000;
}

[data-theme="light"] .fullscreen-dialog {
    background: rgba(244, 244, 248, 0.96);
}

.fullscreen-dialog[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-dialog:modal {
    overscroll-behavior: contain;
}

.fullscreen-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
    overflow: hidden;
    overscroll-behavior: contain;
}

.fullscreen-collapse-btn {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    --icon-style-size: 20px;
    z-index: 6;
}

.fullscreen-stage {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    container-type: size;
    display: grid;
    place-items: center;
    touch-action: pan-x pan-y pinch-zoom;
}

.fullscreen-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.52);
    transition: opacity 0.22s ease;
}

@supports (width: 1cqw) {
    .fullscreen-img.has-ratio {
        width: min(100cqw, calc(100cqh * var(--img-ratio, 1)));
        height: auto;
        aspect-ratio: var(--img-ratio, auto);
    }
}

[data-theme="light"] .fullscreen-img {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

#fullscreen-img.is-loading,
#fullscreen-img:not([src]) {
    opacity: 0;
    visibility: hidden;
}

#fullscreen-img.is-loaded {
    opacity: 1;
    visibility: visible;
}

.fullscreen-arrow {
    position: fixed;
    width: 44px;
    height: 44px;
    z-index: 5;
}

.fullscreen-arrow.left-arrow {
    left: calc(14px + env(safe-area-inset-left, 0px));
}

.fullscreen-arrow.right-arrow {
    right: calc(14px + env(safe-area-inset-right, 0px));
}

.fullscreen-indicators {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 5;
}

/* About Modal */
.about-modal-content {
    width: min(860px, 94vw);
    width: min(860px, 94dvw);
    max-height: min(90vh, 850px);
    max-height: min(90dvh, 850px);
}

.about-grid {
    display: flex;
    gap: 2.2rem;
    align-items: flex-start;
}

.about-photo {
    flex-shrink: 0;
}

.about-photo img {
    width: 280px;
    height: 380px;
    object-fit: cover;
    border-radius: 16px;
    border: 1.5px solid var(--gallery-outline);
    box-shadow: var(--gallery-shadow);
}

.about-text {
    flex-grow: 1;
    min-width: 0;
}

.about-text h2 {
    font-size: 2.4rem;
    margin-bottom: 0.85rem;
    color: var(--text-primary);
}

.about-bio-text {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
}

.about-bio-text p,
.about-text p {
    margin-bottom: 0.85rem;
    line-height: 1.65;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

/* Skills & Software in Profile Modal */
.about-skills-container {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--glass-border);
}

.skills-categories-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skills-group {
    display: flex;
    flex-direction: column;
}

.skills-group-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.skills-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
    opacity: 0.45;
}

[data-theme="light"] .skills-group-title {
    color: #4b5563;
}

[data-theme="light"] .skills-group-title::after {
    background: rgba(0, 0, 0, 0.08);
}

.skills-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.skill-badge {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--icon-bg);
    border: 1px solid var(--icon-border);
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.25, 1, 0.5, 1),
                box-shadow 0.22s ease,
                border-color 0.22s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.skill-badge:hover,
.skill-badge:focus-visible,
.skill-badge.active-touch {
    transform: translateY(-2px) scale(1.08);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    z-index: 10;
}

[data-theme="light"] .skill-badge:hover,
[data-theme="light"] .skill-badge:focus-visible,
[data-theme="light"] .skill-badge.active-touch {
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.skill-badge:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

.skill-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    pointer-events: none;
}

.skill-badge svg,
.skill-badge img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 5px;
    pointer-events: none;
}

.skill-fallback-icon {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tooltip on hover & focus */
.skill-tooltip {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(4px) scale(0.92);
    background: var(--modal-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--modal-border);
    color: var(--text-primary);
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.25, 1, 0.5, 1),
                transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.35);
    z-index: 25;
}

[data-theme="light"] .skill-tooltip {
    background: rgba(255, 255, 255, 0.96);
    color: #111111;
    border-color: rgba(0, 0, 0, 0.16);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.12);
}

.skill-badge:hover .skill-tooltip,
.skill-badge:focus-visible .skill-tooltip,
.skill-badge.active-touch .skill-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* Hello Modal */
.hello-modal-content {
    width: 500px;
    text-align: center;
}

.hello-modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.contact-info {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.contact-info p {
    margin-bottom: 0.5rem;
}

.contact-info a {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--text-secondary);
    transition: border-color 0.3s;
}

.contact-info a:hover {
    border-color: var(--text-primary);
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
    text-align: left;
}

.contact-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
    letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--input-text);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s, background 0.3s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--text-primary);
}

.form-group input:focus-visible,
.form-group textarea:focus-visible,
.submit-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

.contact-form input:user-invalid,
.contact-form textarea:user-invalid,
.contact-form input.user-invalid-fallback,
.contact-form textarea.user-invalid-fallback {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

.field-error-msg {
    display: none;
    color: #fca5a5;
    font-size: 0.8rem;
    margin-top: 5px;
    line-height: 1.35;
}

.contact-form :is(input, textarea):user-invalid + .field-error-msg,
.contact-form :is(input, textarea).user-invalid-fallback + .field-error-msg {
    display: block;
}

.contact-form-status {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: center;
    background: rgba(74, 222, 128, 0.14);
    border: 1px solid rgba(74, 222, 128, 0.38);
    color: #bbf7d0;
}

.contact-form-status.is-error {
    background: rgba(248, 113, 113, 0.14);
    border-color: rgba(248, 113, 113, 0.4);
    color: #fecaca;
}

.contact-form-status a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.submit-btn {
    background: var(--accent);
    color: var(--bg-color);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.3s;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    opacity: 0.9;
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Light Mode Readability & Contrast Enhancements */
[data-theme="light"] .about-text h2,
[data-theme="light"] .hello-modal-content h2,
[data-theme="light"] .details-container h2 {
    color: #000000;
    font-weight: 700;
}

[data-theme="light"] .about-text p {
    color: #1a1a1a;
    font-weight: 450;
    line-height: 1.75;
}

[data-theme="light"] .contact-info {
    color: #1a1a1a;
}

[data-theme="light"] .contact-info a {
    color: #000000;
    font-weight: 600;
    border-bottom: 1.5px solid rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .contact-info a:hover {
    border-color: #000000;
}

[data-theme="light"] .contact-label {
    color: #1f1f1f;
    font-weight: 600;
}

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group textarea {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 0, 0, 0.22);
    color: #000000;
    font-weight: 450;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .form-group input::placeholder,
[data-theme="light"] .form-group textarea::placeholder {
    color: rgba(0, 0, 0, 0.52);
}

[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group textarea:focus {
    background: rgba(255, 255, 255, 0.96);
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .contact-form input:user-invalid,
[data-theme="light"] .contact-form textarea:user-invalid,
[data-theme="light"] .contact-form input.user-invalid-fallback,
[data-theme="light"] .contact-form textarea.user-invalid-fallback {
    border-color: #b91c1c;
    background: rgba(254, 226, 226, 0.8);
}

[data-theme="light"] .field-error-msg {
    color: #b91c1c;
    font-weight: 500;
}

[data-theme="light"] .contact-form-status {
    background: rgba(220, 252, 231, 0.9);
    border-color: rgba(22, 163, 74, 0.45);
    color: #14532d;
    font-weight: 500;
}

[data-theme="light"] .contact-form-status.is-error {
    background: rgba(254, 226, 226, 0.92);
    border-color: rgba(185, 28, 28, 0.45);
    color: #7f1d1d;
}

[data-theme="light"] .submit-btn {
    background: #000000;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .submit-btn:hover:not(:disabled) {
    background: #222222;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] .image-container {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.75);
}

[data-theme="light"] .meta .label {
    color: #000000;
    font-weight: 600;
}

[data-theme="light"] .meta {
    color: #2a2a2a;
}

[data-theme="light"] .details-container p {
    color: #1a1a1a;
    font-weight: 450;
    line-height: 1.65;
}

[data-theme="light"] .admin-lock-icon {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.85);
    color: #000000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .admin-login-subtitle {
    color: #333333;
}

/* Responsive */
@media (max-width: 900px) {
    .image-modal-content {
        padding: 2.75rem 1.15rem 1.35rem;
        max-width: 94vw;
        max-width: 94dvw;
    }
    .about-grid {
        flex-direction: column;
    }
    .image-container {
        min-height: clamp(200px, 32dvh, 320px);
    }
    .image-container.is-loaded {
        min-height: 166px;
    }
    .image-container img {
        max-height: 42vh;
        max-height: 42dvh;
    }
    .carousel-arrow {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    .image-container .detail-zoom-btn {
        top: 8px;
        right: 8px;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .fullscreen-dialog {
        padding: calc(10px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
    }
    .fullscreen-collapse-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .fullscreen-arrow {
        width: 42px;
        height: 42px;
    }
    .about-photo img {
        width: 100%;
        max-height: 280px;
        height: auto;
    }
    .about-text h2 {
        font-size: 1.85rem;
    }
    .skill-badge {
        width: 40px;
        height: 40px;
    }
    .skill-badge svg,
    .skill-badge img {
        width: 28px;
        height: 28px;
    }
}

@media (pointer: coarse) {
    .image-container .detail-zoom-btn {
        top: 8px;
        right: 8px;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

/* Admin Access Login Modal */
.admin-login-modal-content {
    max-width: 420px;
    width: 90%;
    padding: 35px 30px;
    text-align: center;
}

.admin-login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.admin-lock-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--icon-bg);
    border: 1px solid var(--icon-border);
    border-radius: 50%;
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.admin-login-card h2 {
    font-size: 1.5rem;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-transform: uppercase;
}

.admin-login-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

#admin-login-form {
    width: 100%;
}

#admin-login-form .form-group {
    margin-bottom: 22px;
}

#admin-login-form .form-group input {
    text-align: center;
    letter-spacing: 2px;
    padding: 12px 16px;
}

.admin-unlock-btn {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    padding: 13px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 6px;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.admin-unlock-btn:hover {
    background: #181818 !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.admin-forgot-wrap {
    text-align: right;
    margin-bottom: 16px;
}

.forgot-password-link {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s ease;
    padding: 0;
}

.forgot-password-link:hover {
    color: var(--text-primary);
}

.forgot-password-link:disabled {
    color: var(--text-secondary);
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: none;
}

.admin-gate-error {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-bottom: 14px;
    min-height: 1.2rem;
    display: none;
}

.admin-gate-error.visible {
    display: block;
    animation: shakeErr 0.3s ease;
}

.admin-gate-status {
    color: #4ade80;
    font-size: 0.85rem;
    margin-bottom: 14px;
    line-height: 1.4;
    display: none;
    text-align: center;
}

.admin-gate-status.visible {
    display: block;
    animation: fadeInStatus 0.3s ease;
}

@keyframes fadeInStatus {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shakeErr {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ==========================================================
   Performance + mobile fixes
   ========================================================== */
html, body { height: 100%; }
body { height: 100vh; height: 100dvh; width: 100%; }
.main-container { height: 100vh; height: 100dvh; }

/* Thumbnail size is set per page from JS so nothing overlaps */
.thumbnail img {
    display: block;
    max-width: var(--thumb-w, 120px);
    max-height: var(--thumb-h, 160px);
}
/* Only animate what is needed (was "all") */
.thumbnail {
    transition: opacity 0.5s ease, scale 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: opacity, scale;
}
.thumbnail.visible { will-change: transform; }
.bg-image { will-change: transform; }
.site-title { white-space: nowrap; }

@media (max-width: 700px) {
    /* 1. Title on one line */
    .site-title {
        font-size: 0.85rem;
        letter-spacing: 6px;
        top: calc(22px + env(safe-area-inset-top, 0px));
        padding-left: 6px; /* offsets trailing letter-spacing so it looks centred */
    }

    /* 2. Category title sits directly above the dock */
    .dock {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        padding: 8px 14px;
    }
    .dock ul { gap: 18px; }
    .category-title {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + 66px);
        font-size: 1rem;
        letter-spacing: 5px;
        white-space: nowrap;
    }

    .category-indicators { right: 10px; gap: 16px; }
    .scroll-hint { display: none; }
    .thumbnail-title { font-size: 0.55rem; bottom: -16px; line-height: 1.1; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

    /* 3. Lag: stop the always-running animations that repaint the screen */
    .background { top: 0; left: 0; width: 100%; height: 100%; }
    .bg-image, .bg-scratches, .bg-flicker { animation: none !important; }
    .bg-flicker, .bg-scratches { display: none; }
    .thumbnail.visible { animation: none; }
    .thumbnail img { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
    .thumbnail:hover img { transform: none; }
}

/* Desktop: drop the filter-on-animation cost too */
@media (prefers-reduced-motion: reduce) {
    .bg-image, .bg-scratches, .bg-flicker, .thumbnail.visible { animation: none !important; }
}

/* Lock the page to the screen so swiping never scrolls/resizes it
   (this is what made the page jump and pushed the title under the dock) */
html, body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}
.main-container { position: fixed; inset: 0; height: auto; }
.dock { position: fixed; }
.glass-panel { touch-action: pan-y pinch-zoom; overscroll-behavior: contain; }

/* Locked chrome: title, category name and dock never move with a swipe */
.canvas { overflow: hidden; contain: layout paint; }
.site-title, .category-title, .dock { position: fixed; }
.category-title { transition: opacity 0.3s ease, color 0.4s ease, text-shadow 0.4s ease; }
@media (hover: none) {
    .dock-item:hover .icon { transform: none; box-shadow: none; }
    .dock-item:hover .tooltip { opacity: 0; transform: translateX(-50%) scale(0); }
}

/* No keyboard hint on touch devices */
@media (hover: none) and (pointer: coarse) {
    .scroll-hint { display: none !important; }
}

/* ===== Phone landscape: dock on the right; category name + dots along the bottom ===== */
@media (orientation: landscape) and (max-height: 520px) {
    .site-title {
        font-size: 0.8rem;
        letter-spacing: 6px;
        top: calc(14px + env(safe-area-inset-top, 0px));
        padding-left: 6px;
    }
    .dock {
        left: auto;
        bottom: auto;
        top: 50%;
        right: calc(14px + env(safe-area-inset-right, 0px));
        transform: translateY(-50%);
        padding: 14px 8px;
        border-radius: 22px;
    }
    .dock ul { flex-direction: column; gap: 12px; }
    .category-title {
        bottom: calc(30px + env(safe-area-inset-bottom, 0px));
        font-size: 0.95rem;
        letter-spacing: 5px;
        white-space: nowrap;
    }
    .category-indicators {
        flex-direction: row;
        top: auto;
        right: auto;
        left: 50%;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        transform: translateX(-50%);
        gap: 16px;
    }
    .thumbnail-title { font-size: 0.55rem; bottom: -16px; line-height: 1.1; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

    /* same performance savings as portrait phones */
    .background { top: 0; left: 0; width: 100%; height: 100%; }
    .bg-image, .bg-scratches, .bg-flicker { animation: none !important; }
    .bg-flicker, .bg-scratches { display: none; }
    .thumbnail.visible { animation: none; }
    .thumbnail img { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
}

/* Gentle floating on phones too (transform-only, cheap) */
@media (orientation: landscape) and (max-height: 520px) {
    .thumbnail.visible { animation: bobbing 6s ease-in-out infinite; }
}

/* Portrait phones: gentle floating, a smaller drift so tiles never touch their neighbours */
@keyframes bobbingSoft {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}
@media (max-width: 700px) {
    .thumbnail.visible { animation: bobbingSoft 6s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) {
    .thumbnail.visible { animation: none !important; }
}

/* Laptop / desktop: a clearly visible but calm float (about 18px, with a slight sway) */
@keyframes bobbingLarge {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(4px, -9px) rotate(0.6deg); }
    50%  { transform: translate(0, -18px) rotate(0deg); }
    75%  { transform: translate(-4px, -9px) rotate(-0.6deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
@media (min-width: 701px) and (min-height: 521px) {
    .thumbnail.visible { animation: bobbingLarge 7s ease-in-out infinite; }
    .thumbnail.visible:nth-child(3n)   { animation-duration: 8.5s; }
    .thumbnail.visible:nth-child(3n+1) { animation-duration: 6s; }
}
@media (prefers-reduced-motion: reduce) {
    .thumbnail.visible { animation: none !important; }
}

/* Landscape phones and tablets use the mosaic too, so use the small drift (no touching) */
@media (orientation: landscape) and (max-height: 520px) {
    .thumbnail.visible { animation: bobbingSoft 6s ease-in-out infinite; }
}
@media (hover: none) and (pointer: coarse) and (min-width: 701px) and (min-height: 521px) {
    .thumbnail.visible { animation: bobbingSoft 7s ease-in-out infinite; }
    .scroll-hint { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
    .thumbnail.visible { animation: none !important; }
}

/* ==========================================================
   Floating effect that scales with the screen
   --bob is the drift distance; each device class sets it from the screen size
   ========================================================== */
:root { --bob: clamp(6px, 1.8vmin, 9px); }                       /* phone, portrait   */
@media (hover: hover) and (min-width: 701px) {
    :root { --bob: clamp(9px, 1.3vmin, 15px); }                  /* laptop / desktop  */
}
@media (hover: none) and (pointer: coarse) and (min-width: 701px) and (min-height: 521px) {
    :root { --bob: clamp(9px, 1.4vmin, 14px); }                  /* tablet / iPad     */
}
@media (orientation: landscape) and (max-height: 520px) {
    :root { --bob: clamp(6px, 1.9vmin, 9px); }                   /* phone, landscape  */
}

@keyframes floatY {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(calc(var(--bob) * 0.22), calc(var(--bob) * -0.5)) rotate(0.6deg); }
    50%  { transform: translate(0, calc(var(--bob) * -1)) rotate(0deg); }
    75%  { transform: translate(calc(var(--bob) * -0.22), calc(var(--bob) * -0.5)) rotate(-0.6deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}
.thumbnail.visible { animation: floatY 7s ease-in-out infinite; }
.thumbnail.visible:nth-child(3n)   { animation-duration: 8.5s; }
.thumbnail.visible:nth-child(3n+1) { animation-duration: 6s; }
@media (prefers-reduced-motion: reduce) {
    .thumbnail.visible { animation: none !important; }
}


/* ==========================================================
   Smoothness: cheaper effects on touch devices
   ========================================================== */
/* Hidden pop-up windows should cost nothing (their blur was still being kept ready) */
.modal:not(.active) { visibility: hidden; backdrop-filter: none; -webkit-backdrop-filter: none; transition: opacity 0.4s ease, visibility 0s linear 0.4s; }
.modal.active { visibility: visible; transition: opacity 0.4s ease, visibility 0s; }

@media (hover: none) and (pointer: coarse) {
    /* Blur behind the dock is recalculated every frame while tiles float past: lighten it */
    .dock { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
    /* Tablets: also stop the animated background effects (phones already did) */
    .background { top: 0; left: 0; width: 100%; height: 100%; }
    .bg-image, .bg-scratches, .bg-flicker { animation: none !important; }
    .bg-scratches, .bg-flicker { display: none; }
}
