@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #b7cbe5;
    --secondary-color: #4f6b96;
    --accent-color: #8d6d4b;
    --bg-color: #edf3fa;
    --card-bg: #fbfdff;
    --text-color: #354258;
    --border-color: #d4deeb;
    --muted-color: #6b7b92;
    --shadow-color: rgba(51, 70, 105, 0.12);
}

body {
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(183, 203, 229, 0.56), transparent 32%),
        radial-gradient(circle at top right, rgba(199, 181, 154, 0.2), transparent 28%),
        var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0 0 48px;
}

body.celestial-decor-enabled::before {
    content: '';
    position: fixed;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    background-image: url('../img/celestial-decoration.svg'), url('../img/celestial-decoration.svg');
    background-repeat: no-repeat, no-repeat;
    background-position: left 12px top 18px, right 12px bottom 22px;
    background-size: 330px auto, 330px auto;
    opacity: 0.64;
}

@media (max-width: 720px) {
    body.celestial-decor-enabled::before {
        background-size: 190px auto, 190px auto;
        background-position: left -42px top -48px, right -42px bottom -48px;
        opacity: 0.44;
    }
}

h1, h2, h3 {
    font-family: 'Fraunces', serif;
    color: var(--secondary-color);
    line-height: 1.1;
}

p {
    margin: 0 0 1rem;
}

a {
    color: var(--secondary-color);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 120px;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    font: inherit;
    box-sizing: border-box;
    resize: vertical;
}

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 30px;
    background: var(--card-bg);
    border-radius: 28px;
    box-shadow: 0 24px 60px var(--shadow-color);
}

.section {
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.section:last-child { border-bottom: none; }

.section.vote-confirmation-section {
    border-bottom: 1px solid var(--border-color);
}

.vote-confirmation-section .submit-row {
    margin: 24px 0 0;
}

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 16px 0;
}

.page-shell-wide {
    max-width: 1520px;
}

.page-shell-wide .main-card {
    max-width: none;
}

.page-shell-compact {
    max-width: 680px;
    min-height: calc(100vh - 48px);
    display: flex;
    align-items: center;
}

.landing-hero,
.story-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.9fr);
    gap: 32px;
    align-items: center;
}

.story-hero-no-media {
    grid-template-columns: minmax(0, 1fr);
}

.landing-hero {
    padding: 48px 0 8px;
}

.landing-media img,
.story-hero-media img {
    width: 100%;
    display: block;
    object-fit: cover;
    border-radius: 30px;
    min-height: 320px;
    box-shadow: 0 20px 50px rgba(79, 107, 150, 0.18);
}

.landing-info-panel {
    background: linear-gradient(145deg, rgba(239, 245, 252, 0.96), rgba(252, 253, 255, 0.96) 68%, rgba(243, 236, 225, 0.7));
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(79, 107, 150, 0.12);
}

.public-info-grid {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.info-card {
    background: rgba(251, 253, 255, 0.88);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 18px 20px;
}

.info-card h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.timeline-admin-section {
    margin: 30px 0;
    padding: 22px;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    background: rgba(251, 253, 255, 0.64);
}

.timeline-admin-section > h2 {
    margin-top: 0;
}

.admin-shell h4 {
    margin: 18px 0 0;
    color: var(--secondary-color);
    font-family: 'Fraunces', serif;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--accent-color);
}

.hero-meta,
.hero-tagline,
.muted-text {
    color: var(--muted-color);
}

.hero-intro {
    font-size: 1.08rem;
}

.story-iframe-wrap {
    width: 100%;
    min-width: 0;
    margin: 24px 0 30px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(183, 203, 229, 0.24), rgba(251, 253, 255, 0.94) 68%, rgba(226, 214, 194, 0.2));
}

.story-iframe-wrap iframe {
    display: block;
    width: 100%;
    height: 640px;
    min-height: 380px;
    border: 0;
    background: transparent;
}

.auth-panel,
.main-card,
.admin-shell,
.admin-login {
    background: rgba(251, 253, 255, 0.94);
    backdrop-filter: blur(6px);
}

.auth-panel-compact {
    width: 100%;
}

.section-intro {
    max-width: 720px;
}

.timeline-section > .section-intro {
    max-width: none;
}

.privacy-note {
    margin-bottom: 0;
    color: var(--muted-color);
    font-size: 0.95rem;
}

.nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    color: var(--muted-color);
}

.stack-form {
    display: grid;
    gap: 14px;
    max-width: 440px;
}

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

.vote-copy-field-wide {
    grid-column: 1 / -1;
}

.timeline-date {
    margin-bottom: 10px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-color);
    font-weight: 800;
}

.timeline-video {
    width: 100%;
    display: block;
    border-radius: 18px;
    margin: 14px 0;
    height: auto;
    max-height: 520px;
    object-fit: contain;
    background: #000;
}

.timeline-embed {
    margin: 14px 0;
    border-radius: 18px;
    overflow: hidden;
    background: #000;
}

.timeline-embed iframe {
    display: block;
    width: 100%;
    min-height: 380px;
    border: 0;
}

.timeline-description {
    color: var(--muted-color);
    margin-bottom: 0;
}

.timeline-carousel {
    margin-top: 28px;
}

.timeline-stage {
    min-width: 0;
}

.timeline-slide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.32fr);
    align-items: center;
    gap: clamp(24px, 4vw, 56px);
    min-height: 440px;
    padding: clamp(18px, 3vw, 36px);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    background: linear-gradient(145deg, rgba(183, 203, 229, 0.3), rgba(251, 253, 255, 0.88) 70%, rgba(226, 214, 194, 0.22));
}

.timeline-slide[hidden] {
    display: none;
}

.timeline-slide-media {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 360px;
    overflow: hidden;
    border-radius: 22px;
    background: rgba(183, 203, 229, 0.22);
}

.timeline-slide-media > img,
.timeline-slide-media > video {
    display: block;
    width: 100%;
    height: min(66vh, 720px);
    min-height: 360px;
    object-fit: contain;
}

.timeline-slide-media .timeline-embed {
    width: 100%;
    margin: 0;
    border-radius: 0;
}

.timeline-slide-copy h3 {
    margin-top: 0;
    font-size: clamp(1.5rem, 2.5vw, 2.2rem);
}

.timeline-navigation {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
}

.timeline-arrow {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--secondary-color);
}

.timeline-arrow:hover {
    background: #edf3fa;
}

.timeline-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 8px 4px 14px;
    scrollbar-color: var(--primary-color) transparent;
    scrollbar-width: thin;
    cursor: grab;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.timeline-month-group {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
}

.timeline-month-heading {
    margin: 0;
    color: var(--muted-color);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: capitalize;
}

.timeline-month-thumbnails {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.timeline-rail.is-dragging {
    cursor: grabbing;
    user-select: none;
    scroll-snap-type: none;
}

.timeline-thumb {
    flex: 0 0 152px;
    display: grid;
    grid-template-rows: 88px auto;
    gap: 8px;
    min-width: 0;
    padding: 7px;
    border: 2px solid transparent;
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-color);
    text-align: left;
    box-shadow: 0 6px 18px rgba(51, 70, 105, 0.08);
    scroll-snap-align: center;
}

.timeline-thumb:hover,
.timeline-thumb.is-active {
    border-color: var(--secondary-color);
}

.timeline-thumb img,
.timeline-thumb-video {
    display: grid;
    place-items: center;
    width: 100%;
    height: 88px;
    border-radius: 10px;
    object-fit: cover;
    background: #e5edf7;
    color: var(--secondary-color);
    font-size: 0.82rem;
    font-weight: 700;
}

.timeline-thumb-label {
    overflow: hidden;
    color: var(--muted-color);
    font-size: 0.78rem;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-thumb.is-active .timeline-thumb-label {
    color: var(--secondary-color);
    font-weight: 700;
}

.assoc-intro {
    margin-top: -6px;
    margin-bottom: 22px;
    color: var(--muted-color);
}

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

.assoc-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    padding: 20px;
    border-radius: 20px;
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: stretch;
    gap: 18px;
    cursor: pointer;
    position: relative;
}

.assoc-card.selected {
    border-color: var(--secondary-color);
    background-color: #eef3fa;
    box-shadow: 0 14px 34px rgba(79, 107, 150, 0.14);
}

.assoc-card input[type="radio"] {
    display: none;
}

.assoc-card::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 15px;
    background: var(--secondary-color);
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.3s;
}

.assoc-card.selected::after {
    opacity: 1;
}

.assoc-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(51, 70, 105, 0.08);
}

.assoc-card img {
    width: 100%;
    max-width: 140px;
    height: 84px;
    object-fit: contain;
    margin: 0;
    align-self: center;
}

.assoc-card-content {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
}

.assoc-card-content h3 {
    margin: 0 28px 8px 0;
}

.site-link {
    margin-top: auto;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85em;
}

input, select {
    width: 100%;
    box-sizing: border-box;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    font-family: inherit;
    transition: border-color 0.3s;
    background: var(--card-bg);
}

input[type="checkbox"] {
    width: auto;
    accent-color: var(--secondary-color);
}

input[type="file"] {
    padding: 10px 12px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

button {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    font: inherit;
}

button:hover {
    background: #3d567e;
    transform: translateY(-1px);
}

.button-danger {
    background: #a94442;
}

.button-danger:hover {
    background: #8b3633;
}

.success-flash {
    background: #e8f0fa;
    color: #38547e;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 1px solid #c4d4e9;
}

.error-message {
    background: #fff1eb;
    color: #8a4944;
    padding: 16px 18px;
    border-radius: 15px;
    border: 1px solid #ebc8bd;
}

.unsaved-warning {
    background: #f7f0e5;
    color: #725b3d;
    padding: 16px 18px;
    border: 1px solid #e2d1b3;
    border-radius: 15px;
    margin-bottom: 22px;
}

.amount-info {
    color: var(--accent-color);
    font-weight: 700;
}

.assoc-description {
    color: var(--muted-color);
    font-size: 0.95rem;
    margin: 0 0 12px;
}

.cost-preview {
    margin-top: 16px;
    padding: 16px 18px;
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
}

.cost-preview-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 14px;
}

.cost-preview-heading > p {
    margin: 0;
}

.tax-info-tooltip {
    position: relative;
    flex: 0 0 auto;
}

.tax-info-tooltip summary {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--secondary-color);
    border-radius: 50%;
    color: var(--secondary-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 800;
    line-height: 1;
    list-style: none;
}

.tax-info-tooltip summary::-webkit-details-marker {
    display: none;
}

.tax-info-tooltip summary:focus-visible {
    outline: 3px solid rgba(183, 203, 229, 0.8);
    outline-offset: 3px;
}

.tax-info-content {
    position: absolute;
    z-index: 5;
    top: calc(100% + 10px);
    left: 50%;
    width: min(390px, calc(100vw - 48px));
    padding: 16px 18px;
    transform: translateX(-50%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
    box-shadow: 0 14px 34px var(--shadow-color);
    color: var(--text-color);
    font-size: 0.85rem;
    line-height: 1.5;
}

.tax-info-content p {
    margin: 0 0 10px;
}

.tax-info-content p:last-child {
    margin-bottom: 0;
}

.tax-info-content a {
    font-weight: 700;
}

.cost-columns {
    display: flex;
    gap: 28px;
}

.cost-label {
    display: block;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
}

.submit-row {
    text-align: center;
    margin-bottom: 32px;
}

.chart-wrapper {
    position: relative;
    height: 420px;
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 24px 0 28px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 22px;
    padding: 24px;
    box-shadow: 0 10px 22px rgba(51, 70, 105, 0.06);
}

.big-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary-color);
}

.admin-settings-form,
.inline-admin-form {
    display: grid;
    gap: 16px;
}

.inline-admin-form {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
    align-items: end;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 24px;
    background: var(--card-bg);
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
}

.timeline-upload-list {
    display: grid;
    gap: 20px;
    margin-top: 24px;
}

.timeline-upload-card {
    display: grid;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 20px;
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    background: var(--card-bg);
    box-shadow: 0 10px 22px rgba(51, 70, 105, 0.06);
}

.timeline-upload-preview img,
.timeline-upload-preview video {
    width: 100%;
    display: block;
    border-radius: 16px;
    height: auto;
    max-height: 260px;
    object-fit: contain;
    background: #000;
}

.timeline-upload-meta h3 {
    margin-top: 0;
    margin-bottom: 8px;
}

.timeline-upload-edit-form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.timeline-upload-edit-form .form-grid {
    gap: 14px;
}

.timeline-upload-edit-form textarea {
    min-height: 90px;
}

.timeline-upload-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.timeline-upload-actions form {
    margin: 0;
}

@media (max-width: 600px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 10px;
    }

    .landing-hero,
    .story-hero,
    .form-grid,
    .stats-grid,
    .inline-admin-form,
    .timeline-upload-card,
    .timeline-slide {
        grid-template-columns: 1fr;
    }

    .timeline-slide {
        min-height: 0;
        padding: 12px;
        gap: 18px;
        border-radius: 22px;
    }

    .timeline-slide-media {
        min-height: 240px;
        border-radius: 16px;
    }

    .timeline-slide-media > img,
    .timeline-slide-media > video {
        height: 42vh;
        min-height: 240px;
    }

    .nav-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-wrapper {
        height: 520px;
    }

    .timeline-embed iframe {
        min-height: 240px;
    }

    .story-iframe-wrap {
        margin: 18px 0 24px;
        border-radius: 16px;
    }

    .story-iframe-wrap iframe {
        height: 520px;
        min-height: 320px;
    }

    .timeline-navigation {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px;
    }

    .timeline-rail {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .timeline-arrow {
        grid-row: 2;
    }

    .timeline-arrow:last-child {
        justify-self: end;
    }

    .assoc-grid {
        grid-template-columns: 1fr;
    }

    .assoc-card {
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 12px;
        padding: 16px;
    }

    .assoc-card img {
        height: 72px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
