* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", system-ui, sans-serif;
}

html {
    background: var(--bg);
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 4rem
}

/* -------------------------------------------------
   Header & Global Elements
   ------------------------------------------------- */

header {
    background: var(--card);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 {
    text-decoration: none;
    color: inherit;
    font-size: 1.4rem;
    font-weight: 700;
}

a,
a:link,
a:visited,
a:hover,
a:active {
    text-decoration: none;
    color: inherit;
}

/* -------------------------------------------------
   Profile menu
   ------------------------------------------------- */

.profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.profile-menu {
    position: relative;
    z-index: 1400;
}

.profile-menu summary {
    list-style: none;
}

.profile-menu summary::-webkit-details-marker {
    display: none;
}

.profile-menu[open] .profile-btn {
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.35);
}

.profile-menu .profile-btn::after {
    content: "◂";
    margin-left: 0.45rem;
    font-size: 0.85em;
    line-height: 1;
}

.profile-menu[open] .profile-btn::after {
    content: "▾";
}

.profile-menu__content {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 210px;
    max-width: min(260px, calc(100vw - 2rem));
    border-radius: 12px;
    background: var(--card);
    border: 1px solid rgba(128, 128, 128, 0.25);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
    padding: 0.45rem;
    display: grid;
    gap: 0.25rem;
    z-index: 1200;
}

.profile-menu:not([open]) .profile-menu__content {
    display: none;
}

.profile-menu__link,
.profile-menu__logout {
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    font: inherit;
    color: var(--text);
    background: transparent;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.profile-menu__link:hover,
.profile-menu__logout:hover {
    background: rgba(128, 128, 128, 0.18);
}

.profile-menu__logout-form {
    margin: 0;
}

/* -------------------------------------------------
   Site messages
   ------------------------------------------------- */

.site-messages {
    width: min(920px, calc(100% - 2rem));
    margin: 0.9rem auto 0;
    display: grid;
    gap: 0.65rem;
}

.site-message {
    --msg-bg: var(--card);
    --msg-border: var(--primary);
    --msg-text: var(--text);
    --msg-accent: var(--primary);
    --msg-icon-bg: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--msg-border);
    border-left: 5px solid var(--msg-accent);
    background: var(--msg-bg);
    padding: 0.75rem 0.9rem;
    font-size: 0.95rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--msg-text);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: 0.65rem;
    position: relative;
    overflow: hidden;
    transform: translateY(0);
    opacity: 1;
    transition: transform 180ms ease, opacity 180ms ease;
}

.site-messages .site-message {
    display: grid;
    grid-template-columns: auto 1fr auto;
}

.site-message.is-hiding {
    opacity: 0;
    transform: translateY(-4px);
}

.site-message__icon {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--msg-icon-bg);
    color: var(--msg-accent);
    display: grid;
    place-items: center;
    font-size: 0.82rem;
    font-weight: 700;
    margin-top: 0.05rem;
}

.site-message__text {
    margin: 0.02rem 0 0;
    color: var(--msg-text);
    font-size: 0.95rem;
}

.site-message__dismiss {
    border: 0;
    background: transparent;
    color: rgba(20, 20, 20, 0.5);
    font-size: 1.15rem;
    line-height: 1;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    cursor: pointer;
}

.site-message__dismiss:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(20, 20, 20, 0.85);
}

.site-message__dismiss:focus-visible {
    outline: 2px solid var(--msg-accent);
    outline-offset: 1px;
}

.site-message__timer {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--msg-accent);
    transform-origin: left center;
    transform: scaleX(1);
}

.site-message.is-timed .site-message__timer {
    animation: message-timer linear forwards;
    animation-duration: var(--dismiss-duration, 6000ms);
}

@keyframes message-timer {
    to {
        transform: scaleX(0);
    }
}

/* -------------------------------------------------
   Message type overrides
   ------------------------------------------------- */

.site-message.success {
    --msg-border: color-mix(in srgb, var(--primary) 82%, var(--text) 18%);
    --msg-accent: color-mix(in srgb, var(--primary) 90%, var(--text) 10%);
    --msg-icon-bg: color-mix(in srgb, var(--bg) 80%, var(--primary) 20%);
}

.site-message.info {
    --msg-border: color-mix(in srgb, var(--primary) 74%, var(--bg) 26%);
    --msg-accent: var(--primary);
    --msg-icon-bg: color-mix(in srgb, var(--bg) 84%, var(--primary) 16%);
}

.site-message.warning {
    --msg-border: color-mix(in srgb, var(--text) 45%, var(--primary) 55%);
    --msg-accent: color-mix(in srgb, var(--text) 40%, var(--primary) 60%);
    --msg-icon-bg: color-mix(in srgb, var(--bg) 78%, var(--text) 22%);
}

.site-message.error {
    --msg-border: color-mix(in srgb, var(--text) 60%, var(--primary) 40%);
    --msg-accent: color-mix(in srgb, var(--text) 55%, var(--primary) 45%);
    --msg-icon-bg: color-mix(in srgb, var(--bg) 72%, var(--text) 28%);
}

/* -------------------------------------------------
   Popups
   ------------------------------------------------- */

.popup-big {
    display: none;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    z-index: 2100;
    padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
}

.popup-big::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.popup--open {
    display: grid;
    align-items: start;
    justify-items: center;
    overflow-y: auto;
}

.popup-content {
    width: min(720px, 100%);
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.3rem;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.2);
}

.popup-content header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

/* -------------------------------------------------
   Buttons
   ------------------------------------------------- */

.btn {
    border: 0;
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 0.12s ease,
        opacity 0.12s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

.btn-link,
.btn-link:visited {
    background: transparent;
    color: var(--primary);
    text-decoration: none;
}

/* -------------------------------------------------
   Details & Forms
   ------------------------------------------------- */

.details-header-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.details-header-action form {
    margin: 0;
}

.details-participation-state {
    font-size: 0.9rem;
    color: var(--muted);
    background: var(--bg);
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
}

.popup__content h3 {
    margin-top: 1rem;
    margin-bottom: 0.6rem;
}

.popup__content p {
    color: var(--text);
}

/* -------------------------------------------------
   Description & Schedule blocks
   ------------------------------------------------- */

.details-description,
.details-schedule {
    background: var(--bg);
    border-radius: 12px;
    padding: 0.85rem 0.9rem;
    margin-bottom: 1rem;
}

.details-description h3,
.details-schedule h3 {
    margin: 0 0 0.45rem;
}

.details-description p,
.details-schedule p {
    margin: 0;
    color: var(--text);
    line-height: 1.45;
}

.details-schedule p {
    margin: 0.3rem 0;
    color: var(--muted);
}

.details-schedule strong {
    color: var(--text);
}

/* -------------------------------------------------
   Participants list
   ------------------------------------------------- */

.details-participants {
    list-style: none;
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.details-participants li {
    background: var(--bg);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
}

/* -------------------------------------------------
   Popup actions & form elements
   ------------------------------------------------- */

.popup__actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1rem;
}

.popup__content p {
    margin-bottom: 0.9rem;
}

.popup__content label {
    display: inline-block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.popup__content input[type="text"],
.popup__content input[type="datetime-local"],
.popup__content textarea,
.popup__content select {
    width: 100%;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font: inherit;
}

.popup__content textarea {
    min-height: 120px;
    resize: vertical;
}

.popup__content ul.errorlist {
    list-style: none;
    color: #b00020;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.popup__content ul.errorlist li {
    margin-bottom: 0.2rem;
}

/* -------------------------------------------------
   Header – logo
   ------------------------------------------------- */
header img.logo {
    height: 2.5rem;
    /* matches the original h1 font‑size */
    vertical-align: middle;
}

/* -------------------------------------------------
   Footer – fixed (sticky) at the bottom
   ------------------------------------------------- */
footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    padding: 1rem 1.5rem;
    text-align: center;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    /* Ensure the footer sits above normal page content */
    z-index: 900;
}

/* Make the link unmistakably a link */
footer a {
    color: var(--primary);
    text-decoration: underline;
}

footer a:hover,
footer a:focus {
    opacity: 0.85;
}

/* -------------------------------------------------
   Dark‑mode tweak – white logo
   ------------------------------------------------- */
header img.logo {
    filter: none;
    /* light‑mode: keep original colours */
}

@media (prefers-color-scheme: dark) {
    header img.logo {
        /* Invert the monochrome SVG so it appears white on a dark bg */
        filter: invert(1) brightness(2);
    }
}

/* -------------------------------------------------
   Responsive tweaks
   ------------------------------------------------- */

@media (max-width: 720px) {

    .btn-link,
    .btn-primary {
        text-align: center;
        flex: 1;
    }

    .popup__content header {
        flex-direction: column;
        align-items: flex-start;
    }

    .details-header-action {
        width: 100%;
    }

    .popup__actions {
        flex-direction: column;
    }

    .popup-big {
        padding: calc(0.75rem + env(safe-area-inset-top)) 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 600px) {
    header {
        padding: 0.85rem 1rem;
    }

    header h1 {
        font-size: 1.2rem;
    }

    .profile-btn {
        padding: 0.45rem 0.8rem;
        font-size: 0.92rem;
    }

    .profile-menu__content {
        right: 0;
        left: auto;
    }

    .site-messages {
        width: calc(100% - 1.25rem);
        margin-top: 0.75rem;
    }

    .site-message {
        gap: 0.55rem;
        grid-template-columns: auto 1fr auto;
        padding: 0.7rem 0.78rem;
    }
}

/* -------------------------------------------------
   Utility Classes – a simple foundation you can
   extend in your own custom CSS files.
   ------------------------------------------------- */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Flex helpers */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text helpers */
.text-muted {
    color: var(--muted);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Spacing helpers */
.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.ml-1 {
    margin-left: 0.5rem;
}

.mr-1 {
    margin-right: 0.5rem;
}

.mx-1 {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
}

.my-1 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.p-1 {
    padding: 0.5rem;
}

.p-2 {
    padding: 1rem;
}

.pt-1 {
    padding-top: 0.5rem;
}

.pb-1 {
    padding-bottom: 0.5rem;
}

/* Display helpers */
.d-block {
    display: block;
}

.d-inline {
    display: inline;
}

.d-inline-block {
    display: inline-block;
}

.d-flex {
    display: flex;
}

.d-grid {
    display: grid;
}

/* Width helpers */
.w-100 {
    width: 100%;
}

.w-auto {
    width: auto;
}

.max-w-full {
    max-width: 100%;
}

/* Background helpers */
.bg-primary {
    background: var(--primary) !important;
}

.bg-muted {
    background: var(--muted) !important;
}

.bg-card {
    background: var(--card) !important;
}

/* Border helpers */
.border {
    border: 1px solid var(--muted);
}

.border-primary {
    border-color: var(--primary);
}

/* Rounded & shadow helpers */
.rounded {
    border-radius: var(--radius);
}

.rounded-sm {
    border-radius: 4px;
}

.shadow-sm {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.shadow-md {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (max-width: 720px) {
    .container {
        padding: 0 0.75rem;
    }
}
