:root {
    --bg: #f7f1e3;
    --bg-deep: #e7dcc6;
    --surface: rgba(255, 249, 239, 0.84);
    --ink: #1f2a30;
    --muted: #5e6d73;
    --border: rgba(15, 76, 92, 0.12);
    --accent: #0f4c5c;
    --danger: #8d3b2f;
    --shadow: 0 24px 60px rgba(15, 45, 57, 0.12);
    --radius: 24px;
    --font-body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
    --font-ui: "Avenir Next", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top, rgba(217, 235, 232, 0.8), transparent 32%),
        linear-gradient(180deg, var(--bg) 0%, #f0e7d8 100%);
    font-family: var(--font-body);
}

button,
input,
textarea {
    font: inherit;
}

.hidden {
    display: none !important;
}

.app-shell {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 16px 64px;
}

.topbar,
.composer,
.post-card,
.auth-card {
    backdrop-filter: blur(20px);
    background: rgba(255, 249, 239, 0.84);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar {
    border-radius: 28px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
.post-author {
    margin: 0;
    font-weight: 600;
}

h1 {
    font-size: clamp(28px, 7vw, 42px);
}

h2 {
    font-size: clamp(28px, 8vw, 44px);
    line-height: 1.02;
}

.topbar-actions,
.user-bar,
.composer-actions,
.post-actions,
.comment-meta,
.comments-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-bar {
    flex-wrap: wrap;
    justify-content: flex-end;
    text-align: right;
}

.pill-button,
.ghost-button,
.close-button,
.auth-tab,
.comment-form button {
    border: 0;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease;
}

.pill-button {
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    padding: 12px 18px;
    font-family: var(--font-ui);
    font-weight: 700;
}

.pill-button.wide {
    width: 100%;
}

.ghost-button,
.auth-tab,
.comment-form button {
    border-radius: 999px;
    background: rgba(15, 76, 92, 0.08);
    color: var(--accent);
    padding: 10px 14px;
    font-family: var(--font-ui);
    font-weight: 600;
}

.ghost-button.tiny {
    padding: 6px 10px;
    font-size: 13px;
}

.ghost-button.danger {
    color: var(--danger);
}

.pill-button:hover,
.ghost-button:hover,
.close-button:hover,
.auth-tab:hover,
.comment-form button:hover {
    transform: translateY(-1px);
}

.feed-shell {
    margin-top: 24px;
}

.feed {
    display: grid;
    gap: 18px;
}

.feed-state,
.comment-empty,
.comment-cta,
.composer-status,
.form-error,
small,
.post-date {
    color: var(--muted);
    font-family: var(--font-ui);
}

.post-date-link {
    color: inherit;
    text-decoration: none;
}

.post-date-link:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.post-card {
    border-radius: var(--radius);
    padding: 18px;
}

.post-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.post-gallery {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 84%;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-bottom: 16px;
}

.post-gallery img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 20px;
    scroll-snap-align: start;
    background: var(--bg-deep);
}

.post-preview-image {
    display: block;
    margin-bottom: 16px;
}

.post-preview-image img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    border-radius: 20px;
    background: var(--bg-deep);
}

.post-body {
    margin: 0 0 18px;
    font-size: 19px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.rich-text strong {
    font-weight: 700;
}

.rich-text a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.14em;
    word-break: break-word;
}

.post-preview-link {
    margin: -6px 0 18px;
    font-family: var(--font-ui);
}

.post-preview-link a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.comments {
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.comments-header {
    justify-content: space-between;
    margin-bottom: 12px;
}

.comment-list {
    display: grid;
    gap: 10px;
}

.comment-lockout {
    display: grid;
    gap: 4px;
    margin-top: 6px;
}

.comment-count-label {
    margin: 0;
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--ink);
}

.comment-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(15, 76, 92, 0.08);
}

.comment-author,
.comment-body {
    margin: 0;
}

.comment-author {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.comment-form,
.composer-form,
.auth-form {
    display: grid;
    gap: 14px;
}

.comment-form {
    grid-template-columns: 1fr auto;
    margin-top: 12px;
}

label {
    display: grid;
    gap: 8px;
    font-family: var(--font-ui);
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(15, 76, 92, 0.16);
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink);
}

textarea {
    min-height: 128px;
    resize: vertical;
}

.composer {
    margin-top: 18px;
    padding: 20px;
    border-radius: 28px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.toolbar-label {
    margin-right: 4px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
}

.composer-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.existing-images {
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.composer-preview {
    padding: 14px 16px;
    border: 1px solid rgba(15, 76, 92, 0.12);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.45);
}

.post-preview-empty {
    min-height: 24px;
}

.post-preview-body {
    margin: 0;
    font-size: 17px;
    line-height: 1.6;
}

.existing-image {
    position: relative;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

.existing-image img {
    width: 110px;
    height: 120px;
    object-fit: cover;
    border-radius: 18px;
    border: 2px solid transparent;
}

.existing-image span {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(15, 76, 92, 0.78);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
}

.existing-image.marked-for-removal img {
    opacity: 0.45;
    border-color: var(--danger);
}

.existing-image.marked-for-removal span {
    background: rgba(141, 59, 47, 0.82);
}

.auth-drawer {
    position: fixed;
    inset: 0;
    padding: 16px;
    background: rgba(31, 42, 48, 0.35);
    display: grid;
    align-items: end;
    z-index: 10;
}

.auth-card {
    border-radius: 32px 32px 20px 20px;
    padding: 22px 18px 18px;
    position: relative;
}

.close-button {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 76, 92, 0.08);
    color: var(--accent);
    font-size: 22px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.auth-tab.active {
    background: var(--accent);
    color: #fff;
}

@media (min-width: 760px) {
    .app-shell {
        padding-top: 32px;
    }

    .post-gallery {
        grid-auto-columns: calc(50% - 6px);
    }

    .auth-drawer {
        align-items: center;
        justify-items: center;
    }

    .auth-card {
        width: min(420px, 100%);
        border-radius: 28px;
    }
}
