/* Indent the View PDF link to align with info text in project tiles */
.info .pdf-link:not(.icon-copy-btn) {
    display: flex;
    align-items: center;
    margin-top: 0.2rem;
    margin-left: 100px; /* aligns with info strong labels */
    font-size: 0.95em;
}

/* PDF button in modals should match icon button size exactly */
.pdf-link.icon-copy-btn {
    text-decoration: none;
    margin-top: 0 !important;
    margin-left: 0 !important;
    margin: 0;
    padding: 8px;
    box-sizing: border-box;
    line-height: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: top;
}
.pdf-link.icon-copy-btn svg { display: block; }

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0; /* Add background color */
}

/* Safe-area CSS variables for convenience */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --header-height: 110px;
    --footer-height: 80px;
}

/* Share / copy icon buttons */
.icon-copy-btn {
    width: 44px;
    height: 44px;
    padding: 8px;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    border: 1px solid #777;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}
.icon-copy-btn:hover,
.icon-copy-btn:focus-visible {
    background: rgba(0,0,0,0.8);
    outline: 2px solid #ff8c00;
    outline-offset: 2px;
}
.icon-copy-btn:active { transform: scale(0.92); }
.icon-copy-btn svg { width: 20px; height: 20px; pointer-events: none; display: block; }

/* High-res share button inherits icon styling; position is set inline */
.share-image-link { box-shadow: 0 2px 6px rgba(0,0,0,0.4); }

/* Fit / Reset button for mobile (high-res viewer) */
#highResModal .fit-reset-btn {
    position: fixed;
    top: calc(60px + var(--safe-top));         /* below the zoom indicator at top-left */
    left: calc(15px + var(--safe-left));
    z-index: 4100;
    display: none;     /* hidden by default; shown on mobile */
}
/* PDF controls in high-res modal */
.pdf-controls {
    position: absolute;
    top: calc(15px + var(--safe-top));
    left: calc(20px + var(--safe-left));
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 3600;
    color: #fff;
}
.pdf-controls .pdf-page-indicator { font-weight: 600; }
.pdf-controls .pdf-jump { width: 4.5rem; font-size: 0.9rem; }
.pdf-controls button { color: #fff; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.4); padding: 0.25rem 0.5rem; border-radius: 4px; }
.pdf-controls button:disabled { opacity: 0.5; }

.touch-device #highResModal .fit-reset-btn {
    display: inline-flex;
}

/* Zoom indicator (mobile & desktop). Hidden by default; shown briefly after zoom changes */
#zoom-indicator {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 15px);
    left: calc(env(safe-area-inset-left, 0px) + 15px);
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 4200;
    pointer-events: auto; /* allow clicking close button */
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    backdrop-filter: saturate(120%) blur(4px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
#zoom-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Close (dismiss) button inside zoom indicator */
#zoom-indicator .zi-close {
    background: transparent;
    color: #fff;
    border: none;
    width: 24px;
    height: 24px;
    line-height: 24px;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
}
#zoom-indicator .zi-close:focus-visible {
    outline: 2px solid #ff8c00;
    outline-offset: 2px;
}

/* On mobile, place indicator bottom-center to avoid top controls */
@media (max-width: 1024px) {
    #zoom-indicator {
        top: auto;
        left: 50%;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
        transform: translate(-50%, 6px);
    }
    #zoom-indicator.visible {
        transform: translate(-50%, 0);
    }
}

/* Visually hidden utility for a11y live regions */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Alias for consistency with common naming convention */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Floating positioning helper */
.floating-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 4500;
}

/* Simple tooltip (attribute-based) */
[data-tooltip] {
    position: relative;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -38px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 5000;
}


.pdf-thumbnail {
    width: 120px;
    height: 80px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background:#eee;
    border:1px solid #ccc;
    font-weight:600;
}

.container {
    padding: 0;/*20px;*/ /* Add padding around the container */
}

header {
    background-color: #333;
    color: #fff;
    padding: calc(1rem + var(--safe-top)) 1rem 1rem 1rem;
    text-align: left; /* Change from center to left */
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
}

header .site-title {
    font-size: 2em;
    font-weight: bold;
    margin: 0.67em 0;
}

/* Navigation layout */
nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 0.25rem;
    margin-top: 0;
    margin-right: 0.5rem;
    cursor: pointer;
}

.menu-toggle .bar {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    margin: 5px 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle[aria-expanded="true"] .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle[aria-expanded="true"] .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
}

nav a {
    color: #fff;
    margin: 0 1rem;
    text-decoration: none;
    padding-bottom: 5px;
    border-bottom: 3px solid transparent;
    transition: border-bottom-color 0.3s ease;
}

nav a:hover {
    border-bottom-color: #ff8c00;
}

nav a.active {
    border-bottom: 3px solid #ff8c00;
}

/* PDF thumbnails strip */
.pdf-thumbs {
    position: absolute;
    right: calc(10px + var(--safe-right));
    top: calc(60px + var(--safe-top));
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 120px);
    overflow: auto;
    z-index: 3500;
}
.pdf-thumb { background: transparent; border: 2px solid transparent; padding: 0; cursor: pointer; }
.pdf-thumb.active { border-color: #ff8c00; }
.pdf-thumb canvas { display: block; background: #222; border-radius: 2px; }

main {
    padding: 2rem;
    margin-top: var(--header-height);
    margin-bottom: var(--footer-height);
}

.project-index {
    margin: 0 0 2rem;
}

.project-index-title {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

.project-index-lead {
    margin: 0 0 1rem;
    color: #555;
}

.project-page {
    max-width: 1100px;
    margin: 0 auto;
    padding-top: calc(var(--header-height) + 2rem);
    padding-bottom: calc(var(--footer-height) + 2rem);
}

.project-backlink {
    margin: 0 0 1rem;
}

.project-detail {
    background: #fff;
    border: 1px solid #d8d8d8;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.project-detail h2 {
    margin-top: 0;
}

.project-hero img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
}

.project-hero-trigger,
.project-image-trigger {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.project-hero-trigger img,
.project-image-trigger img {
    display: block;
    width: 100%;
    height: auto;
}

.project-hero-trigger:focus-visible,
.project-image-trigger:focus-visible {
    outline: 2px solid #ff8c00;
    outline-offset: 3px;
    border-radius: 10px;
}

.project-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.project-facts div {
    padding: 0.75rem;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    background: #fafafa;
}

.project-facts dt {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.project-facts dd {
    margin: 0;
}

.project-info {
    white-space: pre-line;
    line-height: 1.6;
}

.project-gallery {
    margin-top: 1.5rem;
}

.project-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.project-image-card {
    margin: 0;
}

.project-image-card img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
}

.seo-project {
    display: grid;
    grid-template-columns: minmax(140px, 240px) 1fr;
    gap: 1rem;
    padding: 1rem;
    margin: 0 0 1rem;
    background: #fff;
    border: 1px solid #d8d8d8;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.seo-project-link {
    color: inherit;
    text-decoration: none;
}

.seo-project-link img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.seo-project-link h3 {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.25;
}

.seo-project-meta,
.seo-project-info,
.seo-project-release,
.seo-project-pdf {
    margin: 0 0 0.5rem;
}

.seo-project-meta strong {
    display: inline-block;
    min-width: 5rem;
}

.seo-project-info {
    white-space: pre-line;
}

@media (max-width: 760px) {
    .seo-project {
        grid-template-columns: 1fr;
    }
}

footer {
    background-color: #333;
    color: #fff;
    text-align: left; /* Change from center to left */
    padding: 1rem 1rem calc(1rem + var(--safe-bottom)) 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
}

footer p {
    margin: 0;
}

footer img {
    margin-left: 10px;
    vertical-align: middle;
}

/* Smaller footer for mobile devices */
@media (max-width: 768px) {
    :root {
        --header-height: 76px;
        --footer-height: 44px;
    }

    /* Ensure high-res modal sits above header/footer on mobile */
    #highResModal { z-index: 3500; }
    /* Position PDF UI on small screens */
    .pdf-controls { top: calc(12px + var(--safe-top)); left: calc(12px + var(--safe-left)); }
    .pdf-thumbs { top: calc(70px + var(--safe-top)); right: calc(6px + var(--safe-right)); max-height: calc(100vh - 140px); }
    nav {
        justify-content: space-between;
    }
    .menu-toggle {
        display: inline-block;
    }
    .nav-links {
        position: fixed;
        top: calc(var(--header-height, 110px));
        left: 0;
        right: 0;
        background: #333;
        display: none;
        flex-direction: column;
        padding: 0.5rem 1rem calc(0.5rem + var(--safe-bottom));
        gap: 0.25rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        z-index: 1200;
    }
    .nav-links a {
        margin: 0.25rem 0;
        padding: 0.5rem 0;
        display: block;
    }
    .nav-links.open {
        display: flex;
    }
    footer {
        padding: 0.5rem 0.5rem calc(0.5rem + var(--safe-bottom));
        font-size: 0.8rem;
    }
    
    header {
        padding: calc(0.5rem + var(--safe-top)) 0.5rem 0.5rem 0.5rem;
        font-size: 0.9rem;
    }
    
    header h1,
    header .site-title {
        font-size: 1.2rem;
        margin: 0 0 0.15rem 0;
    }
    
    nav a {
        margin: 0 0.5rem;
        font-size: 0.9rem;
    }
    
    main {
        margin-top: var(--header-height);
        margin-bottom: var(--footer-height);
        padding: 1rem;
    }
    
    /* Ensure modals are always above header/footer on mobile */
    .modal {
        z-index: 2500;
    }
    
    #highResModal {
        z-index: 3500;
    }
    
    /* Enhanced close button positioning for mobile */
    #highResModal .close {
        position: fixed;
        top: calc(20px + var(--safe-top));
        right: calc(20px + var(--safe-right));
        width: 44px;
        height: 44px;
        font-size: 20px;
        background-color: rgba(255, 255, 255, 0.2);
        border: 2px solid rgba(255, 255, 255, 0.4);
        backdrop-filter: blur(2px);
    }
    
    /* Ensure navigation buttons don't interfere */
    .nav-btn {
        z-index: 3400;
    }
    
    /* Enhanced modal responsiveness for mobile */
    .modal-content {
        width: 95vw;
        min-height: 95vh;
        max-width: 95vw;
        max-height: none;
        padding: 10px;
        margin: 0;
        overflow-y: auto;
        box-sizing: border-box;
    }
    
    .high-res-modal-content {
        padding: 0;
        margin: 0;
    }
}

/* Compact fixed chrome for phones held in landscape orientation. */
@media (orientation: landscape) and (max-height: 600px) {
    :root {
        --header-height: 64px;
        --footer-height: 36px;
    }

    header {
        padding: calc(0.25rem + var(--safe-top)) 0.75rem 0.25rem;
    }

    header h1,
    header .site-title {
        font-size: 1rem;
        margin: 0 0 0.15rem;
    }

    footer {
        padding: 0.25rem 0.5rem calc(0.25rem + var(--safe-bottom));
        font-size: 0.75rem;
    }
}

/* PDF loading indicator */
.pdf-loading {
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0,0,0,0.45);
    color: #fff; padding: 0.5rem 0.75rem; border-radius: 8px;
    z-index: 3600;
}
.pdf-loading .spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    animation: pdfspin 1s linear infinite;
}
@keyframes pdfspin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Tablet and small desktop adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .high-res-modal-content {
        padding: 0;
    }
}

/* Large desktop optimizations */
@media (min-width: 1025px) {
    .high-res-modal-content {
        padding: 0;
    }
}

.image-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Utility: make grouped images flow side-by-side with wrapping */
.image-container.image-row,
.image-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;           /* keep items in a single line */
    align-items: flex-start;
    gap: 20px;                   /* spacing between image boxes */
    overflow-x: auto;            /* enable horizontal scrolling when overflow */
    overflow-y: hidden;          /* avoid vertical scrollbar in the row */
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
    scrollbar-width: thin;       /* Firefox: thinner scrollbar */
}

/* Prevent flex items from stretching; keep each image box sized to its content */
.image-container.image-row .image-box,
.image-row .image-box {
    flex: 0 0 auto;              /* don't stretch; size to content */
}

/* Optional: add a little padding so content isn't flush against edges when scrollable */
.image-row {
    padding-bottom: 4px;
}

.image-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /*border: 1px solid #ccc;*/
    padding: 10px;
    box-sizing: border-box;
    text-align: left;
}

.category-break {
    position: relative;
    margin-top: 24px;
    padding-top: 24px;
}

.category-break::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10px;
    width: 120px;
    border-top: 1px solid #777;
}

.image {
    height: 250px;
    width: auto;
    display: block;
    margin: 0;
}

.caption {
    margin: 10px 0 0 0;
    padding: 0;
    text-align: left;
    font-family: Arial, sans-serif;
    /* Use rem for consistency across devices; ~0.875rem approximates 'small' */
    font-size: 0.875rem;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.record {
    border: 1px solid #ddd;
    padding: 1rem;
    text-align: left;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    font-size: 10pt;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    cursor: pointer;
}

.record.is-selected,
.record:focus-visible {
    outline: 1px solid #ff8c00;
    outline-offset: 0;
}

.album-cover {
    width: calc(100% - 2rem);
    height: 180px;
    max-width: none;
    margin: 0 1rem 1rem 1rem;
    align-self: center;
    object-fit: contain;
    object-position: center;
    background-color: #f9f9f9;
}

.info p {
    margin: 0.2rem 0;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    display: flex;
    flex-wrap: wrap;
}

.info {
    width: calc(100% - 2rem);
    margin: 0 1rem;
}

.project-description {
    width: calc(100% - 2rem);
    margin-top: 0;
    margin-left: 1rem;
    margin-right: 1rem;
    padding: 0;
}

.project-description summary {
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
}

.project-description summary::-webkit-details-marker {
    display: none;
}

.description-arrow {
    width: 1rem;
    height: 1.2rem;
    flex: 0 0 auto;
    position: relative;
    transition: color 0.15s ease, transform 0.15s ease;
}

.description-arrow::before {
    content: "";
    position: absolute;
    top: 0.3rem;
    left: 0;
    border-top: 0.3rem solid transparent;
    border-bottom: 0.3rem solid transparent;
    border-left: 0.4rem solid currentColor;
    transform-origin: center;
}

.description-arrow:hover,
.project-description summary:focus-visible .description-arrow {
    color: #ff8c00;
}

.project-description[open] .description-arrow {
    transform: none;
}

.project-description[open] .description-arrow::before {
    transform: rotate(90deg);
}

.project-description p {
    max-width: 75ch;
    margin: 0.75rem 0 0;
    line-height: 1.6;
    white-space: pre-line;
}

.info h3 {
    margin: 0 0 0.3rem 0;
    padding: 0;
    font-size: 1em;
    line-height: 1.2;
}

.info strong {
    width: 4.5rem;
    display: inline-block;
    vertical-align: top;
    flex-shrink: 0;
}

.info span {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0,0,0);
    background-color: rgba(0,0,0,0.4);
}

/* High-resolution modal needs to be above everything */
#highResModal {
    z-index: 3000;
    background-color: rgba(0, 0, 0, 1); /* Solid black background */
    overflow: hidden;
    touch-action: pan-x pan-y;
}

/* Prevent body scrolling when modal is open */
body.modal-open {
    overflow: hidden;
}

.modal-content-p {
    text-align: justify; /* Justify text alignment */
    margin: 0 0 1rem 0; /* Adjust the margin as needed */
    word-break: break-word; /* Ensure long words break properly */
    font-size: small;
}

.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    text-align: left; /* CHECK */
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    background-color: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 4000;
}

/* Enhanced close button for high-res modal */
#highResModal .close {
    position: fixed;
    top: calc(15px + var(--safe-top));
    right: calc(15px + var(--safe-right));
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 4000;
    backdrop-filter: blur(2px);
    transition: all 0.3s ease;
}

/* Position the high-res share button to the LEFT of the close button */
#highResModal .share-image-link {
    position: fixed; /* match the close button so they align on scroll */
    top: calc(15px + var(--safe-top));      /* align vertically with close button (desktop) */
    /* Place it to the left: close button right(15px) + width(40px) + gap(10px) = 65px */
    right: calc(65px + var(--safe-right));
    z-index: 4100;  /* slightly above close so it is always clickable */
}

@media (max-width: 768px) {
    /* Mobile alignment mirrors the mobile close button sizing */
    #highResModal .share-image-link {
        top: calc(20px + var(--safe-top));   /* mobile close top */
        /* close right(20px) + width(44px) + gap(10px) = 74px */
        right: calc(74px + var(--safe-right));
        width: 44px; /* ensure same hit target size */
        height: 44px;
    }
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

#highResModal .close:hover,
#highResModal .close:focus {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.thumbnails {
    display: flex;
    flex-wrap: wrap;
    cursor: pointer;
}

.thumbnail {
    /*max-width: 150px;*/
    margin: 10px;
    height: 150px;
    width: auto;
    object-fit: contain;
    /*cursor: pointer;*/
}

.thumbnail.is-selected,
.thumbnail:focus-visible {
    outline: 1px solid #ff8c00;
    outline-offset: 0;
}

.touch-device .record.is-selected,
.touch-device .record:focus-visible {
    outline: 1px solid #ff8c00;
    outline-offset: 0;
}

.touch-device .thumbnail.is-selected,
.touch-device .thumbnail:focus-visible {
    outline: none;
}

/* High-Resolution Image Modal Styles */
.high-res-modal-content {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    background-color: transparent;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

#highResImage {
    width: 100%;
    height: 100%;
    pointer-events: auto;
    overflow: auto;
    position: relative;
    touch-action: pan-x pan-y;
    cursor: grab;
    display: block;
    overscroll-behavior: contain; /* prevent scroll chaining to page */
    -webkit-user-select: none;
    user-select: none;
    box-sizing: border-box;
    padding: 0;
}

/* When at baseline (100%) we center content vertically/horizontally */
#highResImage.center-fit {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
}

.high-res-caption {
    position: fixed;
    left: calc(15px + var(--safe-left));
    bottom: calc(15px + var(--safe-bottom));
    z-index: 3500;
    max-width: min(34rem, calc(100vw - 30px));
    padding: 0.55rem 0.75rem 0.6rem 2rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.85rem;
    line-height: 1.35;
    text-align: left;
    pointer-events: auto;
}

.high-res-caption-close {
    position: absolute;
    top: 0.15rem;
    left: 0.25rem;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    padding: 0;
    color: #fff;
    background: transparent;
    font-size: 1.2rem;
    line-height: 1;
}

.high-res-caption-close:hover,
.high-res-caption-close:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

.high-res-caption-text {
    margin: 0;
}

.high-res-metadata {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.1rem 0.6rem;
    margin: 0.25rem 0 0;
}

.high-res-metadata dt {
    font-weight: 700;
}

.high-res-metadata dd {
    margin: 0;
}

#highResImage:active {
    cursor: grabbing;
}

#highResImage img {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
    touch-action: manipulation;
    display: block;
    margin: 0 auto;
}

#highResImage img:active {
    cursor: grabbing;
}

#highResImage canvas {
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
    cursor: grab;
    touch-action: manipulation;
    display: block;
    margin: 0 auto;
}

#highResImage canvas:active {
    cursor: grabbing;
}

#highResImage.scrollable {
    padding-bottom: 40px;
}

#highResImage.center-fit img,
#highResImage.center-fit canvas {
    margin: 0;
    min-width: auto;
    min-height: auto;
    max-width: 100%;
    max-height: 100%;
}

form {
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 0 auto;
}

label {
    margin-top: 1rem;
}

input, textarea {
    padding: 0.5rem;
    margin-top: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

button {
    margin-top: 1rem;
    padding: 0.5rem;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #555;
}

#formResponse {
    margin-top: 1rem;
    font-weight: bold;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    border-radius: 50%;
    font-size: 24px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3100;
    backdrop-filter: blur(2px);
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-50%) scale(1.1);
}

/* Navigation buttons with proper safe-area support */
#prevImage { left: calc(10px + var(--safe-left)); }
#nextImage { right: calc(10px + var(--safe-right)); }
#prevImage:focus-visible, #nextImage:focus-visible, .zoom-btn:focus-visible, .pdf-thumbnail:focus-visible { outline:3px solid #ff8c00; outline-offset:2px; }

/* Zoom Controls */
.zoom-controls {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 25px;
    padding: 8px 15px;
    backdrop-filter: blur(4px);
    z-index: 4000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: grab;
    touch-action: none;
    user-select: none;
    transition: box-shadow 0.2s ease;
}

.zoom-controls:active {
    cursor: grabbing;
    box-shadow: 0 6px 16px rgba(255, 140, 0, 0.4);
}

.zoom-controls.dragging {
    cursor: grabbing;
}

.zoom-btn {
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: white;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.zoom-btn.fit-btn {
    border-radius: 15px;
    width: auto;
    height: 35px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.zoom-select {
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: white;
    border-radius: 15px;
    padding: 5px 10px;
    font-size: 14px;
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    text-align: center;
    backdrop-filter: blur(2px);
    flex-shrink: 0;
    flex-grow: 0;
}

.zoom-select option {
    background-color: #222;
    color: white;
}

/* Hide zoom controls for touch devices - use native touch gestures instead */
.touch-device .zoom-controls {
    display: none !important;
}

/* Hybrid devices (desktop/laptop with touch) keep zoom controls AND get native touch support */
.hybrid-device .zoom-controls {
    display: flex !important;
}

/* Add a subtle indicator for hybrid devices that touch gestures are also available */
.hybrid-device .zoom-controls::after {
    content: "👆";
    font-size: 12px;
    margin-left: 8px;
    opacity: 0.7;
    pointer-events: none;
}

/* Mobile and tablet zoom controls adjustments */
@media (max-width: 1024px) {
    /* Hide zoom controls on mobile and tablet - use native touch gestures instead */
    .zoom-controls {
        display: none !important;
    }
    
    /* Enable scroll/pan within the viewer on mobile; zoom handled by custom pinch */
    #highResImage {
        overflow: auto; /* allow panning when zoomed */
        touch-action: pan-x pan-y; /* allow native one-finger scrolling; pinch controlled dynamically */
        width: 100%;
        height: 100%;
        padding: 0; /* container itself spans safe-area via modal content padding */
        margin: 0;
    }
    #highResImage.scrollable {
        padding-bottom: 0;
    }
    
    #highResImage img,
    #highResImage canvas {
        touch-action: pan-x pan-y;
        user-select: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
    }
    
    /* Optimize thumbnails for mobile */
    .thumbnails {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .thumbnail {
        width: 100%;
        max-width: 100%;
        height: auto;
        margin: 0;
        object-fit: contain;
    }
}

/* While an active pinch gesture is detected, disable UA gestures to avoid page zoom conflicts */
#highResImage.pinching,
#highResImage.pinching canvas,
#highResImage.pinching img {
    touch-action: none !important;
}

