/* ===== Base ===== */
:root {
    --bg-page: #faf9f6;
    --bg-card: #ffffff;
    --bg-hero: #4a6741;
    --text-body: #3d3d3d;
    --text-heading: #2c2c2c;
    --text-muted: #7a7a7a;
    --accent: #5c8172;
    --accent-hover: #476b5c;
    --accent-warm: #c9913e;
    --border: #e5e2dc;
    --shadow: rgba(0, 0, 0, 0.06);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-page);
    color: var(--text-body);
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.7;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand,
.nav-link,
.btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

a {
    color: var(--accent);
    transition: color 0.3s;
}

a:hover {
    color: var(--accent-hover);
}

/* ===== Navbar ===== */
.navbar {
    background: rgba(255, 255, 255, 0.97) !important;
    backdrop-filter: blur(10px);
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px var(--shadow);
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-heading) !important;
}

.nav-link {
    color: var(--text-muted) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent) !important;
}

/* ===== Hero ===== */
.hero {
    height: 35vh;
    background: linear-gradient(135deg, var(--bg-hero) 0%, #5a7a50 50%, #6b8f60 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-top: 56px;
}

.hero-overlay {
    width: 100%;
    padding: 2rem;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 0.75rem;
    color: #fff;
}

.hero-subtitle {
    font-size: 1.15rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Georgia', serif;
    font-style: italic;
}

/* ===== Page Header ===== */
.page-header {
    padding: 7rem 0 2.5rem;
    background: linear-gradient(135deg, var(--bg-hero) 0%, #5a7a50 100%);
    color: #fff;
}

.page-header h1 {
    font-weight: 300;
    letter-spacing: 1px;
    font-size: 2.2rem;
}

.page-header .lead {
    color: rgba(255, 255, 255, 0.75);
    font-family: 'Georgia', serif;
    font-style: italic;
    font-weight: 400;
}

/* Banner variant with background photo */
.page-header-banner {
    padding: 0;
    background-size: cover;
    background-position: center 40%;
    min-height: 280px;
    position: relative;
}

.page-header-overlay {
    background: linear-gradient(
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.45) 100%
    );
    padding: 8rem 0 3rem;
    min-height: 280px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 2rem;
}

.page-header-banner h1 {
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* ===== Section Titles ===== */
.section-title {
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--text-heading);
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: var(--accent-warm);
    margin: 0.6rem auto 0;
    border-radius: 2px;
}

/* ===== Feature Cards (Home) ===== */
.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    height: 100%;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 8px var(--shadow);
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.feature-card h4 {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-heading);
    margin-bottom: 0.75rem;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ===== Gallery Grid ===== */
.gallery-grid {
    columns: 3;
    column-gap: 1rem;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    cursor: pointer;
    overflow: hidden;
    border-radius: 6px;
    box-shadow: 0 2px 8px var(--shadow);
}

.gallery-item img {
    width: 100%;
    display: block;
    transition: transform 0.4s;
}

.gallery-item:hover img {
    transform: scale(1.03);
}

.filename-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.4rem 0.6rem;
    background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .filename-overlay {
    opacity: 1;
}

.caption-overlay {
    position: absolute;
    bottom: 1.4rem;
    left: 0;
    right: 0;
    padding: 0.4rem 0.6rem 0.2rem;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.7rem;
    font-style: italic;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .caption-overlay {
    opacity: 1;
}

/* Admin photo action buttons */
.admin-photo-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 2;
}

.gallery-item:hover .admin-photo-actions {
    opacity: 1;
}

.set-banner-btn,
.set-cover-btn,
.set-project-btn,
.set-collection-btn,
.delete-photo-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.set-banner-btn:hover {
    background: var(--accent);
}

.set-cover-btn:hover {
    background: var(--accent-warm);
}

.set-project-btn:hover {
    background: #6b8e5a;
}

.set-collection-btn:hover {
    background: #5b7db1;
}

.delete-photo-btn:hover {
    background: #c0392b;
}

/* Drag-and-drop reorder visuals (Sortable.js) — admin only */
.sortable-ghost {
    opacity: 0.35;
    background: var(--accent, #7b9b6e);
}
.sortable-chosen {
    cursor: grabbing;
}
.sortable-drag {
    opacity: 0.95;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.folder-card-admin {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
}

.col-md-6:hover .folder-card-admin,
.col-lg-4:hover .folder-card-admin {
    opacity: 1;
}

.gallery-item.is-current-banner {
    outline: 3px solid var(--accent-warm);
    outline-offset: -3px;
}

.copyright-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.4rem 0.6rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.65rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: right;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .copyright-overlay {
    opacity: 1;
}

.gallery-item {
    position: relative;
}

@media (max-width: 991px) {
    .gallery-grid {
        columns: 2;
    }
}

@media (max-width: 575px) {
    .gallery-grid {
        columns: 1;
    }
}

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
    transition: opacity 0.3s;
}

.lightbox-close:hover {
    opacity: 0.7;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    padding: 1rem;
    z-index: 10000;
    transition: opacity 0.3s;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 0.7;
}

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.view-toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    font-family: inherit;
}

.view-toggle-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.view-toggle-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.view-toggle-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.view-toggle-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Album / Flipbook View ===== */
#album-view {
    display: none;
}

.album-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    /* Fill the viewport minus the site nav + page header + view-toggle.
       Uses dynamic viewport height so iOS Safari's collapsing URL bar
       doesn't crop the image. */
    height: calc(100dvh - 220px);
    min-height: 420px;
}

.album-book {
    background: #f5f0e8;
    border-radius: 4px;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.05),
        inset 0 0 40px rgba(0, 0, 0, 0.03);
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    perspective: 1200px;
    overflow: hidden;
    cursor: pointer;
}

.album-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.album-page img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Page texture overlay */
.album-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.005) 3px,
        rgba(0, 0, 0, 0.005) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* Click zones for page turning */
.album-click-left,
.album-click-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    z-index: 3;
    cursor: pointer;
}

.album-click-left {
    left: 0;
}

.album-click-right {
    right: 0;
}

.album-click-left:hover {
    background: linear-gradient(90deg, rgba(0,0,0,0.03), transparent);
}

.album-click-right:hover {
    background: linear-gradient(270deg, rgba(0,0,0,0.03), transparent);
}

/* ===== 3D Page Flip ===== */
.flip-page {
    display: none;
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-in-out;
}

.flip-page-front,
.flip-page-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #f5f0e8;
    border-radius: 2px;
}

.flip-page-back {
    transform: rotateY(180deg);
}

.flip-page-front img,
.flip-page-back img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Forward flip: page turns right-to-left */
.flip-forward-start {
    transform-origin: left center;
    transform: rotateY(0deg);
}

.flip-forward-end {
    transform-origin: left center;
    transform: rotateY(-180deg);
}

/* Back flip: page turns left-to-right */
.flip-back-start {
    transform-origin: right center;
    transform: rotateY(0deg);
}

.flip-back-end {
    transform-origin: right center;
    transform: rotateY(180deg);
}

/* Shadow that follows the flip */
.flip-page::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.6s;
    pointer-events: none;
}

.flip-forward-start::after,
.flip-forward-end::after {
    left: -20px;
    background: linear-gradient(90deg, rgba(0,0,0,0.12), transparent);
}

.flip-forward-end::after {
    opacity: 1;
}

.flip-back-start::after,
.flip-back-end::after {
    right: -20px;
    background: linear-gradient(270deg, rgba(0,0,0,0.12), transparent);
}

.flip-back-end::after {
    opacity: 1;
}

/* ===== Caption Area ===== */
.album-caption-area {
    width: 100%;
    flex: 0 0 auto;
    padding: 0.5rem 3rem 0.25rem;
    position: relative;
    text-align: center;
    /* Reserve vertical space for the ~37 px edit button (positioned at top:
       0.5rem) so an empty caption doesn't let it overlap the fullscreen
       button in the controls row below. */
    min-height: 3.25rem;
    box-sizing: border-box;
}

.album-caption-text {
    font-size: 1rem;
    color: var(--text-body);
    line-height: 1.5;
    margin: 0;
    font-style: italic;
}

.album-caption-edit-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.25rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.album-caption-edit-btn:hover {
    opacity: 1;
    color: var(--accent);
    border-color: var(--accent);
}

.album-caption-editor textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    background: var(--bg-card);
    color: var(--text-body);
}

.album-caption-editor-btns {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.album-caption-editor-btns button {
    padding: 0.3rem 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    background: var(--bg-card);
    color: var(--text-body);
    transition: all 0.2s;
}

.album-caption-editor-btns button:first-child {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.album-caption-editor-btns button:hover {
    opacity: 0.85;
}

/* Controls */
.album-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.25rem;
    padding-bottom: 0.25rem;
    flex: 0 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
}
/* "⛶" expand button — tucked at the right edge of the controls row */
.album-fs-btn {
    position: absolute;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 4px var(--shadow);
}
.album-fs-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* When the album is in browser fullscreen, drop padding and let the book
   use the entire screen. The book itself already auto-sizes via dvh, so
   it expands naturally. */
.album-container:fullscreen {
    background: #1a1a1a;
    padding: 0.5rem;
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
}
.album-container:fullscreen .album-book { flex: 1; }
.album-container:fullscreen .album-caption-text { color: rgba(255, 255, 255, 0.85); }
.album-container:fullscreen .album-counter { color: rgba(255, 255, 255, 0.7); }
.album-container:fullscreen .album-fs-btn { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.album-container:fullscreen .album-nav-btn { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.25); }

/* Fallback "presentation mode" for browsers that block requestFullscreen
   on arbitrary elements (iOS Safari). Same look as :fullscreen but driven
   by a class we toggle from JS. */
.album-container.album-presenting {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #1a1a1a;
    padding: 0.5rem;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    margin: 0;
}
.album-container.album-presenting .album-book { flex: 1; }
.album-container.album-presenting .album-caption-text { color: rgba(255, 255, 255, 0.85); }
.album-container.album-presenting .album-counter      { color: rgba(255, 255, 255, 0.7); }
.album-container.album-presenting .album-fs-btn       { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.album-container.album-presenting .album-nav-btn      { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.25); }
body.album-presenting-body { overflow: hidden; }

.album-nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-body);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 4px var(--shadow);
}

.album-nav-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.album-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.album-counter {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-width: 100px;
    text-align: center;
}

@media (max-width: 767px) {
    .album-container {
        padding: 0.25rem 0;
        /* Mobile has less chrome above so allow more space for the image */
        height: calc(100dvh - 170px);
        min-height: 320px;
    }

    .album-page {
        padding: 0.25rem;
    }

    .album-caption-area {
        padding: 0.25rem 0.5rem 0.1rem;
    }

    .album-controls {
        gap: 1rem;
        margin-top: 0.1rem;
    }

    .album-nav-btn {
        width: 38px;
        height: 38px;
    }
}

/* ===== Folder Cards (Collections/Albums) ===== */
.folder-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.folder-card {
    position: relative;
    height: 260px;
    background-color: #e8e4de;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 8px var(--shadow);
}

.folder-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.folder-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.65) 100%);
    display: flex;
    align-items: flex-end;
    padding: 1.25rem;
    transition: background 0.3s;
}

.folder-card:hover .folder-card-overlay {
    background: linear-gradient(transparent 30%, rgba(0, 0, 0, 0.7) 100%);
}

.folder-card-overlay h3 {
    font-weight: 500;
    letter-spacing: 0.5px;
    font-size: 1rem;
    color: #fff;
    margin: 0;
}

/* Video folder card: letterbox the cover (fit, not fill) so title text in
   the thumbnail isn't cropped, and show a play icon in the centre. */
.folder-card.is-video {
    background-size: contain;
    background-repeat: no-repeat;
    background-color: #111;
}

.folder-card-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: background 0.3s, transform 0.3s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.folder-card-play svg {
    width: 32px;
    height: 32px;
    margin-left: 3px; /* optical centring of the triangle */
}

.folder-card:hover .folder-card-play {
    background: rgba(0, 0, 0, 0.75);
    transform: translate(-50%, -50%) scale(1.08);
}

/* ===== Breadcrumbs ===== */
.breadcrumb-nav {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.breadcrumb-nav a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb-nav a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.breadcrumb-sep {
    margin: 0 0.4rem;
    color: #bbb;
}

/* ===== Section Subtitle ===== */
.section-subtitle {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Video Gallery ===== */
.video-gallery {
    margin-bottom: 2.5rem;
}

.video-item {
    margin-bottom: 2rem;
    max-width: 900px;
}

.video-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

.video-item video {
    width: 100%;
    border-radius: 8px;
    background: #000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
}

/* Wrapper for embedded videos. Flickr's script injects an iframe that
   sizes itself from the poster image's aspect ratio, so don't force one
   here — just constrain width and let it flow. */
.video-embed {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
}
.video-embed iframe {
    display: block;
    max-width: 100%;
    border: 0;
}
.video-embed a, .video-embed a img {
    display: block;
    width: 100%;
    height: auto;
}

/* ===== Year PDF Buttons ===== */
.year-pdf-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 2rem;
}

.year-pdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.15s;
    min-width: 70px;
}

.year-pdf-btn:hover {
    background: var(--accent-dark, #3a5a28);
    color: white;
    transform: translateY(-2px);
}

.year-pdf-summary-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.year-pdf-summary-btn:hover {
    background: var(--accent);
    color: white;
}

/* ===== Document Library ===== */
.document-list {
    max-width: 750px;
    margin-bottom: 2rem;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.6rem;
    transition: box-shadow 0.2s;
}

.document-item:hover {
    box-shadow: 0 2px 10px var(--shadow);
}

.document-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8efe6;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.6rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0.5px;
}

.document-icon-pdf { background: #fce4e4; color: #c0392b; }
.document-icon-doc, .document-icon-docx { background: #dce8f7; color: #2b5797; }
.document-icon-wps { background: #e8e0f0; color: #6a4c93; }
.document-icon-xls, .document-icon-xlsx { background: #dff0d8; color: #217346; }
.document-icon-ppt, .document-icon-pptx { background: #fde8d0; color: #d04a02; }
.document-icon-rtf, .document-icon-txt { background: #f0ece4; color: #6b6050; }
.document-icon-odt { background: #d9edf7; color: #31708f; }
.document-icon-csv { background: #dff0d8; color: #217346; }

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-main);
    margin: 0 0 0.15rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.document-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.document-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-page);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
}

.document-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== About ===== */
.about-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.about-content h2 {
    font-weight: 600;
    font-size: 1.6rem;
    color: var(--text-heading);
    margin-bottom: 1.5rem;
}

.about-content p {
    color: var(--text-body);
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

/* ===== Contact Form ===== */
.contact-form .form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-body);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.contact-form .form-control {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-body);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.contact-form .form-control:focus {
    background: #fff;
    border-color: var(--accent);
    color: var(--text-body);
    box-shadow: 0 0 0 0.2rem rgba(92, 129, 114, 0.15);
}

.contact-form .form-control::placeholder {
    color: #b5b5b5;
}

/* ===== Password Toggle ===== */
.password-field {
    position: relative;
}

.password-field input {
    padding-right: 2.8rem;
}

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.25rem;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--text-body);
}

.alert-success {
    background: rgba(92, 129, 114, 0.1);
    border-color: var(--accent);
    color: var(--text-heading);
}

/* ===== Buttons ===== */
.btn-primary-custom,
.btn-outline-light {
    border: 2px solid var(--accent);
    color: var(--accent);
    background: transparent;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.6rem 1.8rem;
    border-radius: 6px;
    transition: all 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn-outline-light:hover,
.btn-primary-custom:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Hero buttons stay white-bordered */
.hero .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.7);
    color: #fff;
}

.hero .btn-outline-light:hover {
    background: #fff;
    border-color: #fff;
    color: var(--accent);
}

/* ===== Footer ===== */
footer {
    background: #f0ede8;
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 3rem;
}

footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Password Prompt ===== */
.password-prompt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2.5rem;
    box-shadow: 0 2px 12px var(--shadow);
}

.password-prompt-card h3 {
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--text-heading);
}

.password-prompt-card .text-muted {
    font-size: 0.95rem;
}

.lock-icon {
    color: var(--accent);
}

.alert-danger {
    background: rgba(200, 60, 60, 0.08);
    border-color: #c0392b;
    color: #c0392b;
}

/* ===== Lightbox Copyright ===== */
.lightbox-copyright {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10000;
}

/* ===== Lightbox Download Button ===== */
/* Hover-reveal download button on each thumbnail when downloads are enabled */
.thumb-download-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.25s, background 0.25s, transform 0.25s;
    z-index: 5;
    pointer-events: auto;
}

.gallery-item:hover .thumb-download-btn,
.thumb-download-btn:focus {
    opacity: 1;
}

.thumb-download-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.08);
    color: #fff;
}

.lightbox-download {
    position: absolute;
    bottom: 1.5rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s;
    z-index: 10000;
}

.lightbox-download:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* ===== Admin Dashboard ===== */
.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.admin-section h3 {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-heading);
    margin-bottom: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-link {
    margin-left: 1rem;
}

.admin-link a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
}

.admin-link a:hover {
    color: var(--accent);
}

.btn-outline-secondary {
    border: 1px solid var(--border);
    color: var(--text-body);
    background: transparent;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn-outline-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-danger {
    border: 1px solid #c0392b;
    color: #c0392b;
    background: transparent;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.btn-outline-danger:hover {
    background: #c0392b;
    color: #fff;
}

/* ===== Responsive ===== */
@media (max-width: 767px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero {
        height: 37vh;
    }

    .page-header h1 {
        font-size: 1.6rem;
    }

    .about-content {
        padding: 1.5rem;
    }
}

/* ===== Book Viewer ===== */
.book-viewer {
    max-width: 1200px;
    margin: 0 auto;
}

.book-chapters {
    text-align: center;
    margin-bottom: 1.5rem;
}

.book-chapters select {
    padding: 10px 20px;
    font-size: 1rem;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    min-width: 280px;
    appearance: auto;
}

.book-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1rem;
    min-height: 500px;
}

.book-display-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 1rem;
}

.book-pages-container {
    display: flex;
    background: #2a2a2a;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
    overflow: hidden;
    max-width: 900px;
}

.book-page {
    flex: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 450px;
}

.book-page img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
}

.book-spine {
    width: 6px;
    background: linear-gradient(90deg, #1a1a1a, #3a3a3a, #1a1a1a);
    flex-shrink: 0;
}

.book-page-mobile {
    flex: 1;
    max-width: 500px;
    background: white;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
}

.book-page-mobile img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
}

.book-nav-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0 12px;
    transition: background 0.3s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-nav-btn:hover {
    background: var(--accent-dark, #3a5a28);
    transform: scale(1.1);
}

.book-counter {
    text-align: center;
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.book-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.book-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.book-thumbnails::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.book-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 80px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.3s, transform 0.2s;
    opacity: 0.6;
}

.book-thumb:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.book-thumb.active {
    border-color: var(--accent);
    opacity: 1;
}

.book-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Page Zoom Overlay */
.page-zoom-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    overflow: auto;
    cursor: pointer;
}

.page-zoom-overlay.active {
    display: flex;
}

.page-zoom-overlay img {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
    cursor: default;
}

@media (max-width: 768px) {
    .book-display {
        display: none;
    }

    .book-display-mobile {
        display: flex;
    }

    .book-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        margin: 0 6px;
    }

    .book-chapters select {
        min-width: 200px;
        font-size: 0.9rem;
    }

    .book-thumb {
        width: 45px;
        height: 60px;
    }
}

/* Shared wrapper for admin / utility pages — provides clearance below the
   fixed-top navbar (56 px) and bottom breathing room. */
.content-wrap {
    padding-top: 6rem;
    padding-bottom: 2rem;
}

/* Postcards call-to-action on the home page */
.home-postcards-cta {
    max-width: 720px;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.75rem 2rem;
    background: linear-gradient(135deg, #fdfaf2 0%, #f5efe2 100%);
    border: 1px solid var(--border, #e5e2dc);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
    text-align: left;
}
.home-postcards-stamp {
    flex: 0 0 auto;
    width: 110px;
    transform: rotate(-4deg);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}
.home-postcards-stamp img { width: 100%; height: auto; display: block; }
.home-postcards-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.4rem 0;
    color: var(--text-heading, #2a2a2a);
}
.home-postcards-text {
    color: var(--text-muted, #555);
    margin: 0 0 1rem 0;
}
@@media (max-width: 600px) {
    .home-postcards-cta { flex-direction: column; text-align: center; padding: 1.5rem 1rem; }
    .home-postcards-stamp { transform: rotate(-3deg); width: 90px; }
}

/* Postcards: distraction-free presentation mode (no nav / footer) */
.pc-present-stage {
    position: fixed;
    inset: 0;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    box-sizing: border-box;
}
/* Scene fills the viewport while keeping the 3:2 postcard aspect ratio:
   constrained by whichever of width or height runs out first. */
.pc-present-scene {
    width: 100%;
    max-width: calc((100dvh - 24px) * 1.5);
    max-height: calc(100dvw - 24px);
}
.pc-present-scene .pc-card { width: 100%; }

.pc-present-close {
    position: fixed;
    top: 10px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 22px;
    line-height: 36px;
    text-align: center;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    z-index: 10;
    backdrop-filter: blur(4px);
}
.pc-present-close:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }

/* ===== Postcards ===== */
.pc-hint { font-size: 0.85rem; margin-bottom: 0.75rem; }
.pc-expiry { font-size: 0.8rem; margin-top: 0.75rem; }

.pc-scene { perspective: 1600px; }
.pc-card {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    transform-style: preserve-3d;
    transition: transform 0.75s cubic-bezier(0.4, 0.1, 0.2, 1);
    cursor: pointer;
}
.pc-card.flipped { transform: rotateY(180deg); }
.pc-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.22);
    background: #fff;
}

/* Front: photo collage */
.pc-front { padding: 0; }
.pc-photos {
    position: absolute;
    inset: 14px 14px 30px 14px;
    display: grid;
    gap: 5px;
}
.pc-layout-1 { grid-template: 1fr / 1fr; }
.pc-layout-2 { grid-template: 1fr / 1fr 1fr; }
.pc-layout-4 { grid-template: 1fr 1fr / 1fr 1fr; }
.pc-layout-6 { grid-template: 1fr 1fr / 1fr 1fr 1fr; }

/* Layout 5 — 2 photos top half, 3 photos bottom half */
.pc-layout-5 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "a a a b b b"
        "c c d d e e";
}
.pc-layout-5 > *:nth-child(1) { grid-area: a; }
.pc-layout-5 > *:nth-child(2) { grid-area: b; }
.pc-layout-5 > *:nth-child(3) { grid-area: c; }
.pc-layout-5 > *:nth-child(4) { grid-area: d; }
.pc-layout-5 > *:nth-child(5) { grid-area: e; }

/* Layout 13 — 1 panorama top, 3 photos bottom (was "5b" in the mock-ups) */
.pc-layout-13 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "a a a"
        "b c d";
}
.pc-layout-13 > *:nth-child(1) { grid-area: a; }
.pc-layout-13 > *:nth-child(2) { grid-area: b; }
.pc-layout-13 > *:nth-child(3) { grid-area: c; }
.pc-layout-13 > *:nth-child(4) { grid-area: d; }

/* Layout 9 — 3 stacked left, 1 hero centre, 4 thumbnails along the bottom */
.pc-layout-9 {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-template-areas:
        "a a d d d d d d"
        "b b d d d d d d"
        "c c d d d d d d"
        "e e f f g g h h";
}
.pc-layout-9 > *:nth-child(1) { grid-area: a; }
.pc-layout-9 > *:nth-child(2) { grid-area: b; }
.pc-layout-9 > *:nth-child(3) { grid-area: c; }
.pc-layout-9 > *:nth-child(4) { grid-area: d; }
.pc-layout-9 > *:nth-child(5) { grid-area: e; }
.pc-layout-9 > *:nth-child(6) { grid-area: f; }
.pc-layout-9 > *:nth-child(7) { grid-area: g; }
.pc-layout-9 > *:nth-child(8) { grid-area: h; }
.pc-photo {
    background-size: cover;
    background-position: center;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}
/* Rotation wrapper. The outer .pc-photo keeps the cell's layout box; the
   inner div holds the image and is what actually spins so the postcard
   grid never reflows. For 90/270 we switch to background-size:contain so
   the rotated photo letterboxes cleanly into the cell instead of clipping
   awkwardly on aspect mismatch. */
.pc-photo-inner {
    position: absolute; inset: 0;
    background-repeat: no-repeat;
    transform-origin: center center;
}
.pc-photo-rot-0   .pc-photo-inner { transform: rotate(0deg); }
.pc-photo-rot-180 .pc-photo-inner { transform: rotate(180deg); }
.pc-photo-rot-90  .pc-photo-inner { transform: rotate(90deg);  background-size: contain !important; }
.pc-photo-rot-270 .pc-photo-inner { transform: rotate(270deg); background-size: contain !important; }
/* When a rotation is active, hide the outer cell's own background so the
   inner wrapper is the only image layer (belt-and-braces — the outer cell
   no longer sets a background-image, but if a legacy view still does, this
   keeps the two layers from double-drawing). */
.pc-photo-rot-90, .pc-photo-rot-180, .pc-photo-rot-270 { background-image: none !important; }
.pc-front-credit {
    position: absolute;
    left: 0; right: 0; bottom: 8px;
    text-align: center;
    font-size: 0.72rem;
    letter-spacing: 1px;
    color: #888;
    text-transform: uppercase;
}

/* Back in SVG mode — the inline <svg> fills the entire back face,
   scales to fit, and uses its own internal coordinate system so the
   text layout is identical at every display size. */
.pc-back.pc-back-svg-mode {
    padding: 0;
    background: #fdfaf2;
    overflow: hidden;
    display: block;
}
.pc-back.pc-back-svg-mode > svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* Back: header (To + stamp) above a two-column message.
   container-type: inline-size lets the message font scale with the
   actual postcard width via cqw units, so the same card looks the
   same on desktop and phone — just smaller text on a smaller card.
   Keep .pc-face's position: absolute inset: 0 — overriding it would
   let the back resize to its content and look smaller than the front. */
.pc-back {
    transform: rotateY(180deg);
    background: #fdfaf2;
    color: #2a2a2a;
    padding: 3.5% 4% 7.5% 4%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    container-type: inline-size;
}
.pc-back-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 0.7rem;
}
.pc-stamp-wrap {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex: 0 0 auto;
}
.pc-message {
    /* Italic serif chosen for readability. Initial font-size is a
       conservative vw-based fallback for first paint; the runtime
       script then re-sizes it precisely to ~3.5 % of the postcard's
       own measured width and shrinks further if it still doesn't fit. */
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    font-style: italic;
    font-size: clamp(11px, 2vw, 22px);
    line-height: 1.25;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    flex: 1 1 auto;
    column-count: 2;
    column-gap: 1.4rem;
    column-rule: 1px solid rgba(0, 0, 0, 0.22);
    column-fill: balance;
}
.pc-postmark {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 1.5px solid rgba(60, 60, 60, 0.45);
    border-radius: 50%;
    width: clamp(48px, 13vw, 70px);
    height: clamp(48px, 13vw, 70px);
    color: rgba(60, 60, 60, 0.6);
    font-size: clamp(0.32rem, 1.1vw, 0.5rem);
    letter-spacing: 0.5px;
    transform: rotate(-9deg);
    line-height: 1.35;
}
/* "To: Name" sits top-left in the header — small because a virtual postcard
   has no real address to carry. */
.pc-address-small {
    line-height: 1.25;
    align-self: center;
}
.pc-address-small .pc-to {
    font-size: 0.7rem;
    color: #888;
    margin-right: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pc-address-small .pc-recipient {
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    font-style: italic;
    font-size: clamp(0.95rem, 2.2vw, 1.15rem);
}

/* Tiny credit anchored to the bottom-left of the back face. */
.pc-back-copyright {
    position: absolute;
    left: 10px;
    bottom: 6px;
    font-size: 0.55rem;
    letter-spacing: 0.3px;
    color: rgba(80, 80, 80, 0.7);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
}

/* Inline warning shown to anyone viewing a postcard whose message is too
   long to fit even at the 10pt floor. Subtle, not alarming. */
.pc-overflow-warn {
    font-size: 0.8rem;
    margin-top: 0.4rem;
}

.pc-missing {
    text-align: center;
    padding: 3rem 1rem;
}
.pc-missing h1 { margin-bottom: 0.5rem; }

/* Stamp component (legacy SVG variant — kept for old postcards) */
.pc-stamp.pc-stamp-svg {
    width: clamp(46px, 12vw, 66px);
    aspect-ratio: 5 / 6;
    background: #fff;
    padding: 5px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    flex: 0 0 auto;
}

/* New PNG stamps — natural aspect ratio, designed-in perforated edge.
   The PNG already contains its own white border / perforations / artwork. */
.pc-stamp.pc-stamp-img {
    flex: 0 0 auto;
    width: clamp(70px, 18vw, 110px);
    line-height: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.pc-stamp.pc-stamp-img img {
    display: block;
    width: 100%;
    height: auto;
    transform: rotate(-2deg); /* slight tilt — postage-y */
}
/* On the postcard back the stamp lives in a floated box; a tilted image
   visually overflows its layout box and made message text appear to run
   under the stamp edges. Sit straight in that context. */
.pc-back-side .pc-stamp.pc-stamp-img img { transform: none; }
.pc-back-side { margin-left: 18px; }
.pc-stamp-inner {
    width: 100%;
    height: 100%;
    border: 1.5px dotted rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3px;
}
.pc-stamp-inner svg { width: 100%; height: auto; flex: 1; }
.pc-stamp-val { font: 700 11px/1 Georgia, serif; fill: currentColor; }
.pc-stamp-label {
    font-size: 0.42rem;
    letter-spacing: 1px;
    margin-top: 2px;
    text-transform: uppercase;
}
.pc-stamp-classic { color: #8a3b3b; }
.pc-stamp-floral  { color: #7a5a86; }
.pc-stamp-coastal { color: #2f6f86; }
.pc-stamp-bird    { color: #4a6b3d; }

/* Create form */
.pc-layout-choice, .pc-stamp-choice { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.pc-layout-opt {
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    gap: 4px;
    padding: 6px;
    border: 2px solid var(--border, #ccc);
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s, background 0.15s;
}
.pc-layout-opt input { display: none; }
.pc-layout-opt:has(input:checked) {
    border-color: var(--accent, #7b9b6e);
    background: rgba(123, 155, 110, 0.07);
}
/* Mini diagram of the layout — uses the same .pc-layout-N grid rules */
.pc-layout-diagram {
    width: 72px;
    aspect-ratio: 3 / 2;
    display: grid;
    gap: 2px;
    padding: 2px;
    background: #fff;
    border: 1px solid var(--border, #d0d0d0);
    border-radius: 3px;
}
.pc-layout-cell {
    background: #bcd0b3;
    border-radius: 1px;
}
.pc-layout-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-body, #333);
}
.pc-layout-count {
    font-size: 0.72rem;
    color: var(--text-muted, #888);
}
.pc-thumbs, .pc-selected {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start;
    min-height: 90px; padding: 8px;
    border: 1px dashed var(--border, #ccc); border-radius: 8px;
}
/* Each thumb keeps a uniform height but takes the photo's natural width,
   so portrait and landscape shots are easy to tell apart at a glance. */
.pc-thumb, .pc-sel {
    height: 96px;
    line-height: 0;
    border-radius: 4px; cursor: pointer; position: relative;
    border: 3px solid transparent;
    overflow: hidden;
    background: #f0ece6;
    flex: 0 0 auto;
}
.pc-thumb img, .pc-sel img {
    height: 100%;
    width: auto;
    display: block;
    max-width: 260px;   /* very wide pans don't blow out the row */
    object-fit: cover;
}
.pc-thumb.chosen { border-color: var(--accent, #7b9b6e); }

/* Selected thumbs use a 3:2 crop preview so the creator can see — and drag
   inside — exactly what will appear on the postcard. Overrides the
   natural-ratio rules above. */
.pc-sel-crop {
    height: 96px;
    width: 144px;       /* 3:2 */
    background-color: #2a2a2a;
    cursor: grab;
    touch-action: none;  /* let our touch handlers do the panning */
    user-select: none;
    position: relative;
    overflow: hidden;
}
/* Inner layer holds the background image so we can rotate it without
   spinning the tile's overlay buttons (rotate, ✕, Fill/Fit, ‹, ›). */
.pc-sel-inner {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    transform-origin: center center;
}
.pc-mini-cell { position: relative; overflow: hidden; }
.pc-mini-inner {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: 50% 50%;
    background-repeat: no-repeat;
    transform-origin: center center;
}
.pc-sel-crop.pc-sel-dragging { cursor: grabbing; }
.pc-sel-crop img { display: none; }  /* hide the <img> if any */

.pc-sel-reset {
    position: absolute;
    top: -8px; left: -8px;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pc-sel-reset:hover { background: var(--accent, #7b9b6e); }
.pc-sel-x {
    position: absolute; top: -8px; right: -8px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: #c0392b; color: #fff;
    font-size: 14px; line-height: 1; cursor: pointer;
}
/* Reorder buttons — mid-left / mid-right on each selected thumb */
.pc-sel-move {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; border-radius: 50%;
    border: none; background: rgba(0,0,0,0.55); color: #fff;
    font-size: 18px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.pc-sel-move-l { left: -10px; }
.pc-sel-move-r { right: -10px; }
.pc-sel-move:hover { background: var(--accent, #7b9b6e); }

/* Zoom in / out — stacked bottom-right of the crop thumb */
.pc-sel-zoom {
    position: absolute; bottom: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.55); color: #fff;
    font-size: 15px; line-height: 1; cursor: pointer;
    padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.pc-sel-zoom-out { right: 30px; }
.pc-sel-zoom-in  { right: 4px; }
.pc-sel-zoom:hover { background: var(--accent, #7b9b6e); border-color: var(--accent, #7b9b6e); }

/* Fit/Fill toggle sits along the bottom-left of the crop thumb */
.pc-sel-fit {
    position: absolute; bottom: 4px; left: 4px;
    padding: 2px 8px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.55); color: #fff;
    font-size: 11px; line-height: 1.2; cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.pc-sel-fit:hover { background: var(--accent, #7b9b6e); border-color: var(--accent, #7b9b6e); }
.pc-stamp-opt {
    cursor: pointer; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.pc-stamp-opt input { display: none; }
.pc-stamp-opt { opacity: 0.55; transition: opacity 0.2s; padding: 6px; border-radius: 8px; }
.pc-stamp-opt:has(input:checked) {
    opacity: 1; background: rgba(0, 0, 0, 0.05);
    outline: 2px solid var(--accent, #7b9b6e);
}
.pc-stamp-name { font-size: 0.75rem; text-transform: capitalize; color: var(--text-muted, #666); }
.pc-list-thumb {
    width: 64px; height: 44px; border-radius: 3px;
    background-size: cover; background-position: center;
}

/* White-frame controls + live preview */
.pc-frame-controls { display: flex; flex-direction: column; gap: 0.5rem; max-width: 460px; }
.pc-frame-row { display: flex; align-items: center; gap: 0.75rem; }
.pc-frame-row label { width: 80px; font-size: 0.9rem; color: var(--text-muted, #666); }
.pc-frame-row input[type="range"] { flex: 1; }
.pc-frame-value { width: 56px; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--text-muted, #666); }

.pc-mini-preview {
    margin-top: 0.6rem; max-width: 360px;
    aspect-ratio: 3 / 2;
    background: #fff;
    border: 1px solid var(--border, #d0d0d0);
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}
.pc-mini-photos {
    width: 100%; height: 100%;
    display: grid;
    box-sizing: border-box;
}
.pc-mini-cell {
    background-size: cover; background-position: center;
    background-color: #d8e0d4;
    border-radius: 1px;
}

@media (max-width: 600px) {
    .pc-message { font-size: 1.05rem; }
    .pc-back { padding: 4% 4% 8% 4%; }
    .pc-back-copyright { font-size: 0.5rem; }
}
