* {
    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;
}

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-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 {
    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);
    }
}

.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%);
}

@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;
    }
}
