:root {
    --notice-navy: #172f43;
    --notice-navy-light: #25475d;
    --notice-orange: #e77d32;
    --notice-orange-dark: #c96320;
    --notice-ink: #263746;
    --notice-muted: #6e7d88;
    --notice-line: #e1e7eb;
    --notice-paper: #ffffff;
    --notice-ground: #f2f5f6;
    --notice-bubble: #eef2f4;
    --notice-star: #f2b300;
    --notice-danger: #d23b2f;
    --feed-width: 720px;
}

body.public-page {
    box-sizing: border-box;
    max-width: none;
    margin: 0;
    padding: 0;
    background: var(--notice-ground);
    color: var(--notice-ink);
    font-family: system-ui, sans-serif;
    font-weight: 400;
}

body.public-page.noticeboard-page {
    --notice-ground: #e6ebee;
}

.public-page *,
.public-page *::before,
.public-page *::after {
    box-sizing: border-box;
}

/* ----- Icons and icon buttons ----- */

.public-page .icon {
    width: 1.35em;
    height: 1.35em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.public-page .icon-star,
.public-page .icon-flag {
    fill: currentColor;
    stroke: none;
}

.public-page .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 36px;
    min-height: 36px;
    margin: 0;
    padding: 4px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.public-page .icon-button:hover {
    background: rgb(23 47 67 / 8%);
}

.public-page .icon-button:focus-visible,
.public-page .chip:focus-visible,
.public-page .account-link:focus-visible {
    outline: 3px solid rgb(231 125 50 / 45%);
    outline-offset: 1px;
}

.public-page .icon-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.public-page .icon-button--danger {
    color: var(--notice-danger);
}

/* ----- Header ----- */

.public-page .feed-sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--notice-ground);
    box-shadow: 0 5px 14px rgb(29 52 68 / 8%);
}

.public-page .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 10px max(16px, calc((100vw - var(--feed-width)) / 2));
    border: 0;
    background: var(--notice-navy);
    color: #fff;
}

.public-page .topbar h1 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
    font-weight: 600;
}

.public-page .topbar h1 a {
    color: #fff;
    text-decoration: none;
}

/* Version label ("v2.1") after the site name: much smaller and quieter than the title. */
.public-page .topbar h1 .app-version {
    font-size: 0.5em;
    font-weight: 400;
    opacity: 0.75;
    vertical-align: super;
}

.public-page .user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #fff;
}

.public-page .user-info .icon-button:hover {
    background: var(--notice-navy-light);
}

/* Day / night switch: shows the mode it switches to (moon by day, sun by night; theme.js). */
.public-page .theme-toggle .icon-sun,
[data-theme="dark"] .public-page .theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .public-page .theme-toggle .icon-sun {
    display: inline;
}

.public-page .account-link {
    max-width: 220px;
    margin-right: 4px;
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    line-height: 1.25;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ----- Chips and filters ----- */

.public-page .feed-filters {
    width: min(var(--feed-width), calc(100% - 24px));
    margin: 0 auto;
    padding: 10px 0;
}

/* Chips scroll sideways; ↻ stays at the end, twice the chip gap away. */
.public-page .chips-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.public-page .chips {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.public-page .chips::-webkit-scrollbar {
    display: none;
}

/* Icon-only chips in their own colour (--cat); the active one adds its label. */
.public-page .chip {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 34px;
    min-height: 34px;
    padding: 5px 6px;
    border: 1px solid #d3dce1;
    border-radius: 999px;
    background: #fff;
    color: var(--cat, #435565);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.public-page .chip .icon {
    width: 20px;
    height: 20px;
}

.public-page .chip:hover {
    border-color: var(--cat, #f0b184);
    background: color-mix(in srgb, var(--cat, #e77d32) 8%, #fff);
}

.public-page .chip.active {
    padding: 5px 12px 5px 8px;
    border-color: var(--cat, var(--notice-orange));
    background: color-mix(in srgb, var(--cat, #e77d32) 16%, #fff);
}

.public-page .chip-label {
    color: var(--notice-ink);
}

/* Category colours: feed chips, post cards, post form. */
.public-page .cat-all { --cat: #2f6fb0; }
.public-page .cat-favourite { --cat: var(--notice-star); }
.public-page .cat-mine { --cat: #0f8b8d; }
.public-page .cat-event { --cat: #8e44ad; }
.public-page .cat-service { --cat: #5f7383; }
.public-page .cat-sell { --cat: #2e8b57; }
.public-page .cat-free { --cat: #d6336c; }
.public-page .cat-lost { --cat: #d23b2f; }
.public-page .cat-announce { --cat: #e77d32; }

.public-page .category-icon {
    display: inline-flex;
    color: var(--cat, currentColor);
}

.public-page .search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

/* Deliberately short: searches are a few characters; longer text scrolls inside the box. */
.public-page .search-field {
    display: flex;
    flex: none;
    gap: 6px;
    min-width: 0;
}

.public-page .search-bar input,
.public-page .search-bar select {
    min-height: 36px;
    border: 1px solid #d3dce1;
    border-radius: 8px;
    background: #fff;
    color: var(--notice-ink);
    font: inherit;
    font-size: 14px;
}

.public-page .search-bar input {
    flex: 1 1 auto;
    width: 9em;
    min-width: 0;
    padding: 0 10px;
}

.public-page .search-bar select {
    padding: 0 8px;
}

.public-page .search-bar input:focus,
.public-page .search-bar select:focus,
.public-page .comment-form textarea:focus,
.public-page .comment-edit-form textarea:focus {
    border-color: var(--notice-orange);
    outline: 3px solid rgb(231 125 50 / 17%);
}

.public-page .go-button {
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid var(--notice-orange);
    border-radius: 8px;
    background: var(--notice-orange);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.public-page .go-button:hover {
    border-color: var(--notice-orange-dark);
    background: var(--notice-orange-dark);
}

.public-page .filter-select {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #435565;
    font-size: 13px;
    font-weight: 600;
}

.public-page .reset-button {
    flex: none;
    min-width: 34px;
    min-height: 34px;
    border: 1px solid #d3dce1;
    background: #fff;
    color: #435565;
}

/* ----- Shared buttons and counters (form pages use these too) ----- */

.public-page .post-button {
    padding: 4px 10px;
    border: 1px solid #d6dfe4;
    border-radius: 7px;
    background: #f8fafb;
    color: #344b5a;
    font: inherit;
    font-size: 13px;
    line-height: 1.1;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.public-page .post-button:hover {
    border-color: #bac8d0;
    background: #edf2f4;
}

.public-page .inline-form {
    display: inline-flex;
    margin: 0;
}

.public-page .character-count {
    display: block;
    color: var(--notice-muted);
    font-size: 0.8em;
    line-height: 1.2;
    text-align: right;
}

/* ----- Feed and post cards ----- */

.public-page .feed {
    width: min(var(--feed-width), calc(100% - 24px));
    margin: 14px auto 24px;
}

.public-page .post {
    margin: 0 0 10px;
    padding: 12px 16px 6px;
    border: 1px solid var(--notice-line);
    border-radius: 12px;
    background: var(--notice-paper);
    box-shadow: 0 4px 14px rgb(29 52 68 / 5%);
}

.public-page .post-title {
    margin: 0;
    color: #203747;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.public-page .post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 12px;
    margin: 4px 0 6px;
    color: var(--notice-muted);
    font-size: 12px;
}

.public-page .favourite-button {
    display: inline-flex;
    min-width: 30px;
    min-height: 30px;
    margin-left: -6px;
    padding: 3px;
    color: #9aa7b0;
}

.public-page .favourite-button.is-favourite {
    color: var(--notice-star);
}

.public-page .post-meta-item {
    display: inline-flex;
    align-items: center;
}

.public-page .post-body {
    margin: 0;
    color: #394d5a;
    font-size: 15px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

/* Description HTML (utils/rich_text.py): p, strong / em / u, ul / ol. */
.public-page .rich-text p,
.public-page .rich-text ul,
.public-page .rich-text ol {
    margin: 0 0 0.35em;
}

.public-page .rich-text > :last-child {
    margin-bottom: 0;
}

.public-page .rich-text ul,
.public-page .rich-text ol {
    padding-left: 1.4em;
}

.public-page .rich-text li {
    margin: 0.1em 0;
}

.public-page .post-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 480px;
    margin-top: 10px;
    border-radius: 8px;
    background: var(--notice-ground);
    object-fit: contain;
}

.public-page .post-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-top: 6px;
    color: #536b79;
}

.public-page .comment-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    justify-self: start;
    margin-left: -6px;
    padding: 4px 6px;
    font-size: 13px;
}

.public-page .post-footer .owner-actions {
    grid-column: 2;
}

.public-page .flag-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    grid-column: 3;
    justify-self: end;
    margin-right: -6px;
    padding: 4px 6px;
    color: #8a98a2;
    font-size: 13px;
}

.public-page .flag-button.is-flagged {
    color: var(--notice-danger);
}

/* Shown by feed.js in place of a post / comment deleted while the page was open. */
.public-page .gone-note {
    margin: 4px 0;
    color: var(--notice-muted);
    font-size: 13px;
    font-style: italic;
}

.public-page .gone-note.post-gone {
    margin: 0 0 10px;
    padding: 12px 16px;
    border: 1px dashed var(--notice-line);
    border-radius: 12px;
}

.public-page .flag-choice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    font-size: 13px;
}

.public-page .flag-choice-heading {
    color: var(--notice-danger);
    font-weight: 600;
}

.public-page .flag-reason {
    padding: 3px 10px;
    border: 1px solid #d5dde2;
    border-radius: 999px;
    background: #fff;
    color: #33434d;
    font: inherit;
    cursor: pointer;
}

.public-page .flag-reason:hover,
.public-page .flag-reason:focus-visible {
    border-color: var(--notice-danger);
    color: var(--notice-danger);
}

.public-page .owner-actions {
    display: inline-flex;
    align-items: center;
    gap: 40px;
}

.public-page .confirm-delete,
.public-page .confirm-prompt {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.public-page .confirm-prompt > span {
    color: var(--notice-danger);
    font-size: 13px;
    font-weight: 600;
}

.public-page .feed-empty,
.public-page .feed-message {
    margin: 16px 0;
    color: var(--notice-muted);
    text-align: center;
}

.public-page .feed-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 1px;
}

.public-page .load-more-button {
    min-width: 56px;
    border: 1px solid #d3dce1;
    background: #fff;
    color: var(--notice-ink);
}

/* ----- Comments ----- */

.public-page .comments-panel {
    margin: 4px 0 8px 16px;
}

.public-page .comment {
    margin: 0 0 6px;
    padding: 8px 12px 2px;
    border-radius: 10px;
    background: var(--notice-bubble);
}

.public-page .comment-body {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.public-page .comment-meta,
.public-page .comment-form-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 14px;
    min-height: 30px;
    color: var(--notice-muted);
    font-size: 12px;
}

.public-page .comment-meta .owner-actions {
    gap: 24px;
    margin-left: auto;
}

.public-page .comment-meta .icon-button,
.public-page .comment-form-footer .icon-button {
    min-width: 30px;
    min-height: 30px;
    padding: 3px;
}

.public-page .comment-form,
.public-page .comment-edit-form {
    margin: 0;
}

.public-page .comment-form {
    padding: 8px 12px 2px;
    border-radius: 10px;
    background: var(--notice-bubble);
}

.public-page .comment-edit-form {
    padding-bottom: 4px;
}

.public-page .comment-form textarea,
.public-page .comment-edit-form textarea {
    display: block;
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid #b9c6ce;
    border-radius: 8px;
    background: #fff;
    color: var(--notice-ink);
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

.public-page .comment-form-footer .send-button,
.public-page .comment-edit-form .character-count {
    margin-left: auto;
}

.public-page .comment-form-footer .character-count {
    min-width: 58px;
}

/* Brain button (AI reword) sits just before send; it takes over the push to the right. */
.public-page .comment-form-footer .ai-button {
    margin-left: auto;
}

.public-page .comment-form-footer .ai-button + .send-button {
    margin-left: 0;
}

.public-page .comment-form-footer .ai-button[aria-busy="true"] {
    opacity: 0.5;
}

.public-page .comment-form .ai-suggestion {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 2px 0 6px;
    padding: 6px 10px;
    border: 1px solid #f0b184;
    border-radius: 8px;
    background: #fff5ed;
}

.public-page .comment-form .ai-suggestion[hidden] {
    display: none;
}

.public-page .comment-form .ai-suggestion-text {
    flex: 1;
    margin: 0;
    color: var(--notice-ink);
    font-size: 14px;
}

.public-page .comment-form .ai-suggestion-actions {
    display: flex;
    gap: 4px;
}

.public-page .comment-form .ai-suggestion-actions .icon-button {
    min-width: 30px;
    min-height: 30px;
    padding: 3px;
}

.public-page .form-message {
    margin: 2px 0 6px;
    color: var(--notice-danger);
    font-size: 13px;
}

.public-page .comment-limit,
.public-page .comments-closed {
    margin: 4px 0;
    color: var(--notice-muted);
    font-size: 13px;
}

/* ----- Phones ----- */

@media (max-width: 650px) {
    /* Only the header stays pinned; chips and filters scroll away. */
    .public-page .feed-sticky-header {
        display: contents;
    }

    .public-page .topbar {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 8px 12px;
    }

    .public-page .topbar h1 {
        font-size: 17px;
    }

    .public-page .account-link {
        max-width: 34vw;
        font-size: 12px;
    }

    .public-page .feed-filters {
        padding-top: 8px;
    }

    /* Search takes what the filters leave, up to about 13 characters, so the row
       stays on one line; the small basis lets it shrink instead of wrapping. */
    .public-page .search-field {
        flex: 1 1 64px;
        max-width: 160px;
    }

    .public-page .search-bar input {
        width: auto;
    }

    .public-page .post {
        padding: 10px 12px 4px;
    }

    .public-page .post-title {
        font-size: 20px;
    }

    .public-page .owner-actions {
        gap: 28px;
    }

    .public-page .comments-panel {
        margin-left: 8px;
    }
}
