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

:root {
    --page-bg: #ffe4a6;
    --grid-bg: #c7b07b;
    --text: #1a1208;
    --muted: #6b5a38;
    --input-bg: #ffffff;
    --border: rgba(0, 0, 0, 0.22);
    --btn-bg: #1a1208;
    --btn-text: #ffffff;
}

html {
    font-size: 16px;
    overflow-x: hidden;
}

body {
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ── Header ── */
header {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
}

header h1 {
    line-height: 1;
    font-size: 0;
}

header h1 a {
    text-decoration: none;
    display: inline-block;
}

.site-logo {
    height: clamp(3rem, 10vw, 6rem);
    width: auto;
    display: block;
    margin: 0 auto;
}

.tagline {
    margin-top: 0.6rem;
    line-height: 1.5;
}

.tagline .line1 {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    color: var(--text);
    font-weight: 400;
}

.tagline .line2 {
    display: block;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.78rem;
    color: black;
    font-style: italic;
    margin-top: 0.2rem;
}

/* ── Search ── */
.search-box {
    display: flex;
    gap: 6px;
    max-width: 520px;
    margin: 1.4rem auto 0;
    padding: 0 1rem;
}

.search-box input {
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    color: #555;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: Arial, Helvetica, sans-serif;
    font-style: italic;
    outline: none;
    transition: border-color 0.15s;
    border-radius: 2px;
}

.search-box input:focus {
    border-color: #8a6f3a;
    font-style: normal;
    color: var(--text);
}

.search-box input::placeholder {
    color: #aaa;
    font-style: italic;
}

.search-box button {
    background: var(--btn-bg);
    border: 1px solid var(--btn-bg);
    color: #ffffff;
    padding: 0.5rem 0;
    width: 110px;
    min-height: 38px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 400;
    cursor: pointer;
    border-radius: 2px;
    transition: opacity 0.15s;
    white-space: nowrap;
    text-align: center;
}

.search-box button:hover {
    opacity: 0.8;
}

.search-box button:disabled {
    opacity: 0.4;
    cursor: default;
}

.bookmarks-shortcut {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    flex-shrink: 0;
    background: var(--btn-bg);
    border: 1px solid var(--btn-bg);
    color: #ffffff;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 2px;
    transition: opacity 0.15s;
}
.bookmarks-shortcut:hover {
    opacity: 0.8;
}

/* ── Grid section ── */
.grid-section {
    flex: 1;
    background: var(--grid-bg);
    margin: 1.5rem 2rem 0;
    padding: 1.5rem 1.5rem 3.5rem;
    border-radius: 3px;
}

/* ── Status bar ── */
.status {
    text-align: center;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 1rem;
    min-height: 1rem;
    font-style: italic;
}

.status.error {
    color: #8b2020;
    font-style: normal;
}

/* ── Masonry grid ── */
.photo-grid {
    columns: 240px;
    column-gap: 10px;
}

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

.photo-card {
    break-inside: avoid;
    margin-bottom: 10px;
    background: #b09060;
    overflow: hidden;
    border-radius: 2px;
    position: relative;
    animation: card-in 0.45s ease both;
}

.photo-card a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.photo-card img {
    width: 100%;
    display: block;
    transition: opacity 0.2s;
}

.photo-card:hover img {
    opacity: 0.88;
}

.card-bookmark-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(20, 14, 4, 0.65);
    border: none;
    color: var(--page-bg);
    font-size: 0.8rem;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}
.photo-card:hover .card-bookmark-btn {
    opacity: 1;
}

.photo-meta {
    padding: 0.35rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.4rem;
}

.photo-year {
    font-size: 0.72rem;
    color: var(--input-bg);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    opacity: 0.85;
}

.photo-title {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Empty / loading states ── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--input-bg);
}

.empty-state h2 {
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 0.4rem;
}

.empty-state p {
    font-size: 0.85rem;
    opacity: 0.7;
    line-height: 1.6;
}

/* ── Random modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 4, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
    cursor: pointer;
}

.modal-box {
    position: relative;
    max-width: min(90vw, 900px);
    cursor: default;
}

.modal-box img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.modal-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0 0;
    gap: 1rem;
}

.modal-year {
    color: var(--page-bg);
    font-size: 0.8rem;
}
.modal-title {
    color: rgba(245, 208, 122, 0.6);
    font-size: 0.8rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-info a {
    color: rgba(245, 208, 122, 0.7);
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
}
.modal-info a:hover {
    color: var(--page-bg);
}

.modal-show-another {
    background: none;
    border: 1px solid rgba(245, 208, 122, 0.4);
    color: rgba(245, 208, 122, 0.7);
    font-size: 0.78rem;
    font-family: Arial, Helvetica, sans-serif;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    border-radius: 2px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.modal-show-another:hover {
    color: var(--page-bg);
    border-color: rgba(245, 208, 122, 0.8);
}

.modal-close {
    position: absolute;
    top: -2.2rem;
    right: 0;
    background: none;
    border: none;
    color: rgba(245, 208, 122, 0.6);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.modal-close:hover {
    color: var(--page-bg);
}

/* ── Footer — fixed overlay at bottom ── */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.55rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    background: rgba(255, 228, 166, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 50;
}

footer a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.78rem;
    font-style: italic;
    transition: color 0.15s;
}
footer a:hover {
    color: var(--text);
}

.footer-disclaimer {
    position: absolute;
    left: 1.2rem;
    font-size: 0.7rem;
    color: var(--muted);
    font-style: italic;
    pointer-events: none;
}

.footer-back-top {
    position: absolute;
    right: 1.2rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
    text-decoration: none;
}

.footer-back-top:hover {
    color: var(--text);
}

.footer-back-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.footer-version {
    position: absolute;
    right: 1.2rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    font-weight: 400;
    opacity: 1;
    transition: opacity 0.4s;
    pointer-events: none;
}

.footer-back-top.visible + .footer-version {
    opacity: 0;
}

.grid-refresh a {
    display: block;
    text-align: center;
    margin-top: 2rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(107, 90, 56, 0.4);
    transition: color 0.15s;
    cursor: pointer;
}

.grid-refresh a:hover {
    color: var(--text);
    text-decoration-color: var(--muted);
}

/* ── Secondary pages ── */
.page-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.page-header h1 {
    line-height: 1;
    font-size: 0;
}

.page-header h1 a {
    text-decoration: none;
    display: inline-block;
}

.page-back {
    display: inline-block;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 0.6rem;
    transition: color 0.15s;
}
.page-back:hover {
    color: var(--text);
}

.page-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.page-content h2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    margin-top: 2.2rem;
}
.page-content h2:first-child {
    margin-top: 0;
}

.page-content p,
.page-content a.donate-option {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 400;
}

.page-content p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.75;
    margin-bottom: 0.75rem;
}

.page-content a {
    color: #7a5c20;
    text-decoration: none;
}
.page-content a:hover {
    text-decoration: underline;
}

.contact-form {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-form input,
.contact-form textarea {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    border-radius: 2px;
    transition: border-color 0.15s;
    width: 100%;
}
.contact-form input:focus,
.contact-form textarea:focus {
    border-color: #8a6f3a;
}
.contact-form input::placeholder,
.contact-form textarea::placeholder {
    color: #a08650;
}

.contact-form button {
    align-self: flex-start;
    background: var(--btn-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.15s;
}
.contact-form button:hover {
    background: #dfc88a;
}

#share-btn {
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 2px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s;
}
#share-btn:hover {
    background: #ebd9a8;
}

.donate-option {
    display: inline-block;
    border: 1px solid var(--border);
    background: var(--input-bg);
    padding: 0.55rem 1.1rem;
    margin-top: 0.6rem;
    text-decoration: none;
    color: var(--text);
    font-size: 0.875rem;
    border-radius: 2px;
    transition: background 0.15s;
}
.donate-option:hover {
    background: #ebd9a8;
    text-decoration: none;
}
.donate-option span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.2rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: var(--page-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--grid-bg);
}

/* ── Bookmark button in modal ── */
.modal-bookmark {
    background: none;
    border: none;
    color: rgba(245, 208, 122, 0.4);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.15rem;
    flex-shrink: 0;
    transition: color 0.15s;
}
.modal-bookmark:hover {
    color: var(--page-bg);
}
.modal-bookmark.bookmarked {
    color: var(--page-bg);
}

/* ── Paywall modal box ── */
.paywall-box {
    background: var(--page-bg);
    border-radius: 4px;
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.paywall-box .modal-close {
    top: 0.8rem;
    right: 0.8rem;
    font-size: 1.4rem;
    color: var(--muted);
}
.paywall-box .modal-close:hover {
    color: var(--text);
}

.paywall-icon {
    font-size: 2.2rem;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.8rem;
}

.paywall-title {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.paywall-desc {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.65;
    margin-bottom: 1.3rem;
}

.paywall-kofi-btn,
.page-content .paywall-kofi-btn {
    display: inline-block;
    background: #ff5e5b;
    color: #fff !important;
    text-decoration: none;
    padding: 0.6rem 1.5rem;
    border-radius: 3px;
    font-size: 0.88rem;
    font-family: Arial, Helvetica, sans-serif;
    transition: opacity 0.15s;
    margin-bottom: 1.4rem;
}
.paywall-kofi-btn:hover {
    opacity: 0.88;
    color: #fff;
    text-decoration: none;
}

.paywall-divider {
    color: var(--muted);
    font-size: 0.75rem;
    margin-bottom: 0.65rem;
}

.paywall-form {
    display: flex;
    gap: 6px;
    margin-bottom: 0.5rem;
}

.paywall-email {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    font-family: Arial, Helvetica, sans-serif;
    border-radius: 2px;
    outline: none;
    transition: border-color 0.15s;
}
.paywall-email::placeholder {
    color: #aaa;
    font-style: italic;
}
.paywall-email:focus {
    border-color: #8a6f3a;
}

.paywall-unlock-btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-bg);
    color: #fff;
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    font-family: Arial, Helvetica, sans-serif;
    cursor: pointer;
    border-radius: 2px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.paywall-unlock-btn:hover {
    opacity: 0.8;
}

.paywall-note {
    font-size: 0.75rem;
    color: var(--muted);
    min-height: 1.1em;
}

/* ── Account / Bookmarks page ── */
.bookmarks-page {
    max-width: 960px;
}

.acct-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.acct-header h2 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 0;
}

.acct-dropdown-wrap {
    position: relative;
}

.acct-dropdown-toggle {
    background: none;
    border: none;
    font-size: 0.82rem;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: color 0.15s;
}
.acct-dropdown-toggle:hover {
    color: var(--text);
}

.acct-caret {
    font-size: 0.6rem;
}

.acct-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--page-bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 0.75rem 1rem;
    min-width: max-content;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.acct-dropdown-wrap.open .acct-dropdown-menu {
    display: block;
}

.acct-dropdown-email {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
    line-height: 1.5;
}
.acct-dropdown-email strong {
    color: var(--text);
    font-weight: 400;
    word-break: break-all;
}

.acct-dropdown-reset {
    display: block;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.3);
    text-decoration: none;
    font-style: italic;
    transition: color 0.15s;
    margin-top: 0.4rem;
}
.acct-dropdown-reset:hover {
    color: #8b2020;
}

.acct-count {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.acct-clear-btn {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.18);
    color: var(--muted);
    font-size: 0.72rem;
    font-family: Arial, Helvetica, sans-serif;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.15s, border-color 0.15s;
}
.acct-clear-btn:hover {
    color: #8b2020;
    border-color: #8b2020;
}

.acct-card {
    position: relative;
}

.acct-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(20, 14, 4, 0.65);
    border: none;
    color: var(--page-bg);
    font-size: 0.8rem;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}
.acct-card:hover .acct-remove-btn {
    opacity: 1;
}

.acct-empty {
    padding: 4rem 1rem;
    text-align: center;
}
.acct-empty p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.acct-empty a {
    color: #7a5c20;
    font-size: 0.85rem;
    text-decoration: none;
}
.acct-home-link,
.paywall-home {
    margin-top: 2rem;
    font-size: 0.85rem;
}
.acct-home-link a,
.paywall-home a {
    color: #7a5c20;
    text-decoration: none;
}

/* Account page paywall — just needs padding since base styles already match */
.acct-paywall {
    padding: 4rem 1rem;
    text-align: center;
}

/* ── Touch devices: show card actions that are normally hover-only ── */
@media (hover: none) {
    .card-bookmark-btn,
    .acct-remove-btn {
        opacity: 1;
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .photo-card {
        animation: none;
    }
}

/* ── Mobile ── */
@media (max-width: 600px) {
    /* Grid: fill edge to edge, 2 columns, tighter gap */
    .grid-section {
        margin: 0.5rem 0 0;
        border-radius: 0;
        padding: 0.75rem 0.5rem 3.5rem;
    }

    .photo-grid {
        columns: 2;
        column-gap: 6px;
    }

    .bookmarks-page {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .photo-card {
        margin-bottom: 6px;
    }

    /* Footer: wrap links, reduce gap, safe-area inset */
    footer {
        gap: 0.9rem;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0.55rem 1rem;
        padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
    }

    .footer-back-top {
        position: static;
        order: 99;
    }

    .footer-disclaimer {
        display: none;
    }

    .footer-version {
        display: none;
    }

    /* Modal: anchor to bottom, full width */
    .modal-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }

    .modal-box {
        max-width: 100%;
        width: 100%;
    }

    .modal-box img {
        max-height: 70vh;
    }

    .modal-close {
        top: -2.8rem;
        font-size: 1.8rem;
        padding: 0.5rem 0.5rem 0.5rem 1rem;
        min-width: 3rem;
        min-height: 3rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .modal-info {
        flex-wrap: wrap;
        gap: 0.4rem 0.8rem;
        padding: 0.5rem 0 0;
    }

    .modal-title {
        flex-basis: 100%;
    }

    /* Paywall */
    .paywall-box {
        padding: 2rem 1.25rem 1.5rem;
        border-radius: 0;
        max-height: 85svh;
        overflow-y: auto;
        width: 100%;
        margin-top: auto;
    }

    .paywall-box .modal-close {
        top: 0.6rem;
        right: 0.6rem;
        font-size: 2rem;
        min-width: 3rem;
        min-height: 3rem;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Search box — wrap so input gets its own full-width row */
    .search-box {
        padding: 0 0.75rem;
        flex-wrap: wrap;
        gap: 6px;
    }

    .search-box input {
        flex-basis: 100%;
    }

    .search-box button {
        flex: 1;
        width: auto;
    }

    .bookmarks-shortcut {
        height: 44px;
        width: 44px;
    }

    /* Page content — extra bottom padding so footer doesn't overlap */
    .page-content {
        padding: 2rem 1rem 5rem;
    }

    /* Paywall padding for fixed footer */
    .acct-paywall {
        padding-bottom: 5rem;
    }
}

/* ── SEO-only text (visible to crawlers, hidden visually) ── */
.seo-description {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── iOS Safari tap highlight removal ── */
a, button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
