:root {
    --bg: #f3eee6;
    --bg-deep: #e7dfd2;
    --paper: #fbf7f1;
    --ink: #2b2723;
    --muted: #6f675e;
    --line: #d8cec0;
    --accent: #7a6248;
    --gold: #c4a574;
    --hero-ink: #f7f1e8;
    --shadow: 0 18px 50px rgba(43, 39, 35, 0.08);
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
    --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--accent);
}

.emoji {
    font-family: var(--emoji);
    font-style: normal;
    font-weight: 400;
    line-height: 1;
}

.flash-wrap {
    position: sticky;
    top: 0;
    z-index: 20;
}

.flash {
    margin: 0;
    padding: 0.85rem 1.2rem;
    text-align: center;
    background: #efe4d2;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 0.7rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--gold);
}

h1,
h2,
h3 {
    font-family: var(--serif);
    font-weight: 500;
    letter-spacing: 0.01em;
}

button,
input,
textarea,
a,
.file-button,
.gallery-item,
.comment-toggle,
.react-toggle {
    touch-action: manipulation;
}

button,
input,
textarea {
    font: inherit;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

textarea {
    resize: vertical;
    min-height: 8rem;
}

input:focus,
textarea:focus {
    outline: 2px solid rgba(122, 98, 72, 0.35);
    outline-offset: 1px;
}

label {
    display: block;
    margin: 1.1rem 0 0.4rem;
    font-size: 0.92rem;
    color: var(--muted);
}

button[type="submit"] {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: var(--ink);
    color: var(--hero-ink);
    padding: 0.9rem 1.4rem;
    min-height: 44px;
    border-radius: 999px;
    cursor: pointer;
}

button[type="submit"]:hover {
    background: #3d3731;
}

.page-login {
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(circle at 20% 10%, rgba(196, 165, 116, 0.18), transparent 42%),
        linear-gradient(180deg, #efe8dc, var(--bg) 55%);
}

.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 2rem 1.2rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.login-card {
    width: min(460px, 100%);
    text-align: center;
}

.login-card h1 {
    margin: 0;
    font-size: clamp(2.1rem, 6vw, 3rem);
}

.login-name {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-family: var(--serif);
    font-size: 1.15rem;
}

.login-lead {
    margin: 1.2rem 0 2rem;
    color: var(--muted);
}

.login-form {
    text-align: left;
}

.login-form button {
    width: 100%;
    margin-top: 1.3rem;
}

.hero {
    position: relative;
    min-height: 72vh;
    min-height: 72dvh;
    display: grid;
    place-items: end center;
    overflow: hidden;
    background:
        linear-gradient(180deg, #6d6256, #3d3731);
    color: var(--hero-ink);
}

.hero-has-image {
    background: #1f1c19;
}

.hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(24, 21, 18, 0.72) 12%, rgba(24, 21, 18, 0.18) 58%, rgba(24, 21, 18, 0.28));
}

.hero-inner {
    position: relative;
    z-index: 1;
    width: min(820px, calc(100% - 2.4rem));
    padding: 0 0 4.5rem;
    text-align: center;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.6rem, 8vw, 5.2rem);
    line-height: 1.08;
    font-weight: 400;
}

.dates {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.1rem 0 0;
    font-family: var(--serif);
    font-size: 1.05rem;
    letter-spacing: 0.04em;
    color: rgba(247, 241, 232, 0.86);
}

.dates-sep {
    width: 28px;
    border-top: 1px solid var(--gold);
    align-self: center;
}

.tribute {
    margin: 1.4rem auto 0;
    max-width: 34rem;
    font-family: var(--serif);
    font-style: italic;
    font-size: 1.18rem;
    line-height: 1.7;
    color: rgba(247, 241, 232, 0.92);
}

.page {
    width: min(760px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 3.5rem 0 5rem;
}

.compose,
.memory {
    background: var(--paper);
    border: 1px solid rgba(216, 206, 192, 0.8);
    box-shadow: var(--shadow);
    border-radius: 18px;
    padding: 1.7rem 1.6rem 1.8rem;
}

.compose {
    margin-bottom: 3.4rem;
}

h2 {
    margin: 0;
    font-size: 1.7rem;
    text-align: center;
}

.section-lead,
.empty {
    text-align: center;
    color: var(--muted);
}

.section-lead {
    margin: 0.6rem auto 0.4rem;
    max-width: 34rem;
}

.compose-form button[type="submit"] {
    margin-top: 1.3rem;
}

.file-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.2rem;
}

.file-button {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    margin: 0;
}

.file-button-quiet {
    background: transparent;
}

.file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-hint {
    margin: 0.7rem 0 0;
    font-size: 0.88rem;
    color: var(--muted);
}

.feed h2 {
    margin-bottom: 1.6rem;
}

.memory + .memory {
    margin-top: 1.3rem;
}

.memory-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
    margin-bottom: 0.85rem;
}

.memory-head h3 {
    margin: 0;
    font-size: 1.25rem;
}

.memory-head time {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.memory-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.memory-edited {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.gallery {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.1rem;
}

.gallery-1 {
    grid-template-columns: 1fr;
}

.gallery-2,
.gallery-4 {
    grid-template-columns: 1fr 1fr;
}

.gallery-3 {
    grid-template-columns: 1fr 1fr;
}

.gallery-3 .gallery-item:first-child {
    grid-column: 1 / -1;
}

.gallery-item {
    padding: 0;
    border: 0;
    background: #ebe4d8;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    max-height: 520px;
    object-fit: cover;
}

.attachments {
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.attachments li {
    margin: 0.35rem 0 0;
}

.attachments a {
    display: inline-block;
    padding: 0.2rem 0;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.delete-form {
    margin: 0;
}

.delete-form button {
    background: transparent;
    color: var(--muted);
    padding: 0;
    border-radius: 0;
    font-size: 0.88rem;
    text-decoration: underline;
}

.delete-form button:hover {
    background: transparent;
    color: var(--ink);
}

.memory-actions {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    margin-top: 0.85rem;
}

.reactions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.45rem 0.55rem;
    margin-top: 1.15rem;
}

.reaction-form {
    margin: 0;
}

.reaction-btn[type="submit"] {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 40px;
    padding: 0.15rem 0.55rem 0.15rem 0.4rem;
    border: 0;
    border-radius: 999px;
    background: #f2f2f7;
    color: #1c1c1e;
    cursor: pointer;
    font-size: 1.35rem;
}

.reaction-btn[type="submit"]:hover,
.reaction-btn.is-mine[type="submit"] {
    background: #e5e5ea;
}

.reaction-btn.is-mine[type="submit"] {
    box-shadow: none;
}

.reaction-count {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1c1c1e;
}

.react-wrap {
    position: relative;
}

.react-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
}

.react-caption {
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    color: #8e8e93;
}

.react-fab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f2f2f7;
    font-size: 1.35rem;
}

.react-plus {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #007aff;
    color: #fff;
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
}

.react-toggle[aria-expanded="true"] .react-fab {
    background: #e5e5ea;
}

.react-picker {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 8;
    align-items: center;
    gap: 0.05rem;
    padding: 0.2rem 0.3rem;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.react-wrap.is-open .react-picker {
    display: flex;
}

.picker-emoji[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    min-height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 1.85rem;
    color: inherit;
}

.picker-emoji[type="submit"]:hover,
.picker-emoji.is-mine[type="submit"] {
    background: transparent;
    transform: scale(1.18);
}

.comments {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0.15rem 0 0 0.9rem;
    border-left: 1px solid var(--line);
}

.comment {
    position: relative;
    margin: 0 0 0.85rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.comment:last-child {
    margin-bottom: 0;
}

.comment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.comment-meta strong {
    font-weight: 500;
    color: #5d564e;
}

.comment-meta time {
    font-size: 0.78rem;
}

.comment p {
    margin: 0.15rem 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.comment-delete {
    margin-top: 0.15rem;
}

.comment-delete button {
    font-size: 0.78rem;
}

.comment-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 0.45rem;
    padding: 0.15rem 0;
    border: 0;
    background: transparent;
    color: #b0a598;
    font-size: 0.88rem;
    cursor: pointer;
}

.comment-toggle:hover {
    color: var(--muted);
}

.comment-toggle[hidden] {
    display: none !important;
}

.comment-form label {
    margin-top: 0.7rem;
    font-size: 0.85rem;
}

.comment-form {
    display: none;
    margin-top: 0.7rem;
    padding-top: 0.2rem;
}

.comment-form.is-open {
    display: block;
}

.comment-form textarea {
    min-height: 4.5rem;
}

.button-small[type="submit"] {
    margin-top: 0;
    padding: 0.55rem 1.05rem;
    font-size: 0.9rem;
    background: #6f675e;
}

.comment-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.9rem;
}

.comment-cancel {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0.4rem 0;
    min-height: 44px;
    cursor: pointer;
    font-size: 0.9rem;
}

.memory-actions a,
.text-link {
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: underline;
}

.memory-actions a:hover,
.text-link:hover {
    color: var(--ink);
}

.page-edit {
    padding-top: 3rem;
}

.existing-label {
    margin: 1.3rem 0 0.6rem;
    font-size: 0.92rem;
    color: var(--muted);
}

.existing-files {
    list-style: none;
    margin: 0;
    padding: 0;
}

.existing-files li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}

.existing-files img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
}

.existing-files label {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.existing-files input[type="checkbox"] {
    width: auto;
    padding: 0;
}

.edit-buttons {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-top: 1.3rem;
}

.empty {
    margin: 0;
    padding: 0.4rem 0 2rem;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: min(760px, calc(100% - 2rem));
    margin: 0 auto;
    padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
    color: var(--muted);
    font-size: 0.92rem;
}

.site-footer p {
    margin: 0;
}

.site-footer button {
    background: transparent;
    color: var(--muted);
    padding: 0.4rem 0;
    border-radius: 0;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    place-items: center;
    padding: max(2rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
    background: rgba(24, 21, 18, 0.9);
}

.lightbox:not([hidden]) {
    display: grid;
}

.lightbox[hidden] {
    display: none !important;
}

.lightbox img {
    max-width: min(1100px, 100%);
    max-height: 88vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    color: var(--hero-ink);
    border: 0;
    cursor: pointer;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 700px) {
    .hero {
        min-height: 64vh;
    }

    .hero-inner {
        padding-bottom: 3rem;
    }

    .page {
        padding-top: 2.2rem;
    }

    .compose,
    .memory {
        padding: 1.3rem 1.1rem 1.4rem;
        border-radius: 14px;
    }

    .memory-head {
        flex-direction: column;
        gap: 0.2rem;
    }

    .gallery-2,
    .gallery-3,
    .gallery-4 {
        grid-template-columns: 1fr;
    }

    .gallery-3 .gallery-item:first-child {
        grid-column: auto;
    }

    .site-footer {
        flex-direction: column;
        text-align: center;
    }
}
