:root {
    --background: #f6f5f1;
    --surface: #ffffff;
    --surface-soft: #eef4f3;
    --text: #19211f;
    --muted: #66736f;
    --line: #d9dfdc;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #d97706;
    --danger: #b91c1c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-header {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 16px clamp(18px, 5vw, 56px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand,
.app-header nav {
    align-items: center;
    display: flex;
    gap: 14px;
}

.brand {
    font-weight: 800;
}

.brand-mark {
    align-items: center;
    background: var(--primary);
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.app-header nav a {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 700;
}

.project-switch {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    gap: 4px;
    padding: 4px;
}

.project-switch a {
    border-radius: 999px;
    color: var(--muted);
    padding: 7px 11px;
}

.project-switch a.active {
    background: var(--surface);
    color: var(--primary-dark);
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 34px clamp(18px, 5vw, 56px) 56px;
}

.hero {
    background:
        linear-gradient(120deg, rgba(25, 33, 31, 0.78), rgba(15, 118, 110, 0.42)),
        var(--hero-image);
    background-position: center;
    background-size: cover;
    border-radius: 8px;
    color: #fff;
    margin-bottom: 34px;
    min-height: 430px;
    padding: clamp(28px, 6vw, 64px);
}

.hero .muted,
.hero p {
    color: rgba(255, 255, 255, 0.88);
    max-width: 760px;
}

.hero h1 {
    max-width: 860px;
}

.project-intro,
.building-section {
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    margin-bottom: 34px;
}

.building-section-single {
    grid-template-columns: 1fr;
}

.project-intro > div,
.building-section > div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(20px, 4vw, 34px);
}

.building-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.building-list a,
.building-list span {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    font-weight: 800;
    padding: 8px 12px;
}

.building-list a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.building-list.historic a,
.building-list.historic span {
    background: #fff7ed;
    color: var(--accent);
}

.tipeee-support {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid #e7512e;
    border-radius: 8px;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 34px;
    padding: clamp(20px, 4vw, 34px);
}

.tipeee-support > div {
    max-width: 700px;
}

.tipeee-support > div p:last-child {
    margin-bottom: 0;
}

.filter-note {
    color: var(--primary-dark);
    font-weight: 800;
    margin: 10px 0 0;
}

.reading-header {
    align-items: flex-start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.reading-tabs {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    gap: 4px;
    padding: 4px;
}

.reading-tabs button {
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    min-height: 34px;
    padding: 0 12px;
}

.reading-tabs button.active {
    background: var(--surface);
    color: var(--primary-dark);
}

.map-panel {
    display: grid;
    gap: 14px;
}

.map-panel[hidden] {
    display: none;
}

.map-shell {
    aspect-ratio: 16 / 7;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.map-shell iframe {
    border: 0;
    display: block;
    height: 100%;
    width: 100%;
}

.map-meta {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.map-meta p {
    margin-bottom: 0;
}

.page-heading {
    align-items: flex-end;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 26px;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: 0;
    line-height: 1;
    margin: 0;
}

h2,
h3,
p {
    margin-top: 0;
}

.hero p,
.project-intro p,
.article-body > p,
.rich-text,
.article-content,
.empty-state p {
    hyphens: auto;
    text-align: justify;
    text-wrap: pretty;
}

.rich-text {
    line-height: 1.55;
    white-space: pre-wrap;
}

.rich-text p,
.rich-text div {
    margin-bottom: 1rem;
}

.rich-text img {
    border-radius: 8px;
    display: block;
    height: auto;
    margin: 14px auto;
    max-height: 460px;
    max-width: min(100%, 760px);
    object-fit: contain;
}

.rich-text-summary img {
    max-height: 220px;
    max-width: min(100%, 420px);
}

.muted {
    color: var(--muted);
}

.button,
button {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 800;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
}

.button-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff !important;
}

.button-danger {
    background: #fff;
    border-color: #efb2b2;
    color: var(--danger);
}

.button-rental {
    background: #fff;
    border-color: #fff;
    color: var(--primary-dark);
}

.button-disabled {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.78);
    cursor: not-allowed;
}

.article-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.article-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.article-card {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    overflow: hidden;
}

.article-media {
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--surface-soft), #fff5df);
    overflow: hidden;
}

.article-media img {
    display: block;
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.article-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

.article-meta,
.stats {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
}

.pill {
    background: var(--surface-soft);
    border-radius: 999px;
    color: var(--primary-dark);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 800;
    padding: 5px 10px;
}

.article-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.panel {
    padding: clamp(20px, 4vw, 34px);
}

.article-detail {
    display: grid;
    gap: 28px;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
}

.article-sidebar {
    align-content: start;
    display: grid;
    gap: 18px;
}

.justification-panel {
    border-left: 4px solid var(--primary);
}

.justification-panel .button {
    width: 100%;
}

.social-publication-panel {
    border-left: 4px solid var(--primary);
}

.social-publication-panel details {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.social-publication-panel summary {
    cursor: pointer;
    font-weight: 900;
}

.social-summary {
    background: var(--surface-soft);
    line-height: 1.45;
    margin-top: 12px;
    min-height: 150px;
    resize: vertical;
}

.social-summary-long {
    min-height: 240px;
}

.social-publication-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
}

.social-publication-actions .button {
    width: 100%;
}

.share-panel {
    border-left: 4px solid var(--primary);
}

.share-actions {
    display: grid;
    gap: 10px;
}

.share-actions .button {
    color: #fff;
    width: 100%;
}

.share-facebook {
    background: #1877f2;
    border-color: #1877f2;
}

.share-linkedin {
    background: #0a66c2;
    border-color: #0a66c2;
}

.share-instagram {
    background: #c13584;
    border-color: #c13584;
}

.share-tipeee {
    background: #f06a32;
    border-color: #f06a32;
    margin-top: 8px;
}

.article-content {
    white-space: pre-line;
}

.article-summary {
    color: var(--muted);
    font-size: 1.12rem;
    margin-bottom: 24px;
}

.article-summary img {
    max-height: 260px;
}

.form-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid > div:nth-child(6),
.form-grid > div:nth-child(7) {
    grid-column: 1 / -1;
}

form label {
    display: block;
    font-weight: 800;
    margin-bottom: 7px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    padding: 11px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.form-help {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 7px 0 0;
    overflow-wrap: anywhere;
}

.rich-editor {
    display: grid;
    gap: 0;
    max-height: 560px;
}

.rich-editor-toolbar {
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    position: sticky;
    top: 72px;
    z-index: 2;
}

.rich-editor-toolbar button {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    font-weight: 900;
    min-height: 34px;
    min-width: 38px;
    padding: 0 10px;
}

.rich-editor-surface {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0 0 6px 6px;
    max-height: 460px;
    min-height: 150px;
    outline: none;
    overflow: auto;
    padding: 12px;
    text-align: justify;
    white-space: pre-wrap;
}

.rich-editor-surface:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.rich-editor-surface img {
    border-radius: 8px;
    display: block;
    height: auto;
    margin: 12px auto;
    max-height: 360px;
    max-width: min(100%, 680px);
    object-fit: contain;
}

input[type="radio"],
input[type="checkbox"] {
    width: auto;
}

.form-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.social-links {
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
    padding-top: 20px;
}

.flash {
    border-radius: 6px;
    font-weight: 700;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.flash-success {
    background: #dcfce7;
    color: #14532d;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 34px;
    text-align: center;
}

@media (max-width: 760px) {
    .app-header,
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .article-detail,
    .project-intro,
    .building-section,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .app-header nav {
        display: grid;
        grid-template-columns: 1fr;
    }

    .reading-header,
    .map-meta,
    .tipeee-support {
        align-items: stretch;
        flex-direction: column;
    }

    .reading-tabs {
        border-radius: 8px;
        display: grid;
        grid-template-columns: 1fr;
    }

    .map-shell {
        aspect-ratio: 4 / 3;
    }

    .project-switch {
        border-radius: 8px;
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media print {
    @page {
        margin: 16mm;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
    }

    .app-header,
    .page-heading .article-actions,
    .article-sidebar,
    .social-links,
    .sf-toolbar {
        display: none !important;
    }

    .page {
        max-width: none;
        padding: 0;
    }

    .page-heading {
        display: block;
        margin-bottom: 18px;
    }

    .page-heading h1 {
        color: #000;
        font-size: 24pt;
        line-height: 1.15;
    }

    .article-detail {
        display: block;
    }

    .article-detail > article.panel {
        border: 0;
        padding: 0;
    }

    .article-media {
        max-height: 110mm;
        page-break-inside: avoid;
    }

    .rich-text {
        color: #000;
    }

    .rich-text img {
        max-height: 100mm;
        page-break-inside: avoid;
    }
}
