:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --ink: #17233a;
    --muted: #62708a;
    --line: #dfe5ee;
    --accent: #1d8b8b;
    --accent-dark: #146f71;
    --soft: #e9f6f4;
    --shadow: 0 12px 30px rgba(23, 35, 58, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

body.viewer-open {
    overflow: hidden;
}

button {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(18px, 4vw, 54px);
    background:
        linear-gradient(90deg, rgba(29, 139, 139, 0.12), rgba(29, 139, 139, 0.03) 42%, rgba(255, 255, 255, 0)),
        var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: 0 8px 26px rgba(23, 35, 58, 0.06);
}

.topbar::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 6px;
    background: var(--accent);
}

.topbar p,
.viewer-header p {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.topbar small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}

.brand-block {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-mark {
    flex: 0 0 126px;
    width: 126px;
    height: 108px;
    display: grid;
    place-items: center;
    border-radius: 0;
    color: white;
    background: transparent;
    border: 0;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: none;
    overflow: hidden;
    text-decoration: none;
    cursor: pointer;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: scale-down;
    padding: 0;
}

.brand-mark img + span {
    display: none;
}

.brand-mark span {
    color: white;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.brand-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-line span {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--accent-dark);
    background: var(--soft);
    font-size: 12px;
    font-weight: 800;
}

.topbar h1,
.month-group h2,
.event-item h3,
.viewer h2 {
    margin: 0;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1.05;
}

.stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stats span {
    padding: 9px 13px;
    border-radius: 8px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(23, 35, 58, 0.05);
}

.layout {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 54px;
    flex: 1;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.filter-bar strong {
    display: block;
    margin-bottom: 3px;
    color: var(--accent-dark);
    font-size: 18px;
}

.filter-bar span {
    color: var(--muted);
    font-size: 14px;
}

.filter-bar form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-bar label {
    color: var(--muted);
    font-weight: 700;
}

.filter-bar select {
    min-width: 108px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    background: #fff;
    font-weight: 800;
}

.month-group {
    margin-bottom: 18px;
}

.month-group h2 {
    margin-bottom: 10px;
    color: var(--accent-dark);
    font-size: 18px;
}

.event-list {
    display: grid;
    gap: 10px;
}

.event-item {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    transition: opacity 160ms ease, filter 160ms ease;
}

.cover {
    width: 92px;
    aspect-ratio: 16 / 10;
    padding: 0;
    border: 0;
    border-radius: 7px;
    overflow: hidden;
    background: var(--soft);
    color: var(--accent-dark);
    cursor: pointer;
    text-decoration: none;
}

.cover.is-disabled {
    cursor: default;
}

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

.cover span {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
}

.event-info {
    min-width: 0;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.event-date {
    color: var(--accent-dark);
    font-weight: 800;
}

.event-item h3 {
    font-size: 18px;
    line-height: 1.25;
}

.event-item h3 a {
    color: inherit;
    text-decoration: none;
}

.event-item h3 a:hover {
    color: var(--accent-dark);
}

.lunar-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    color: #7c2d12;
    background: #ffedd5;
    font-size: 12px;
    font-weight: 800;
}

.event-item p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 14px;
}

.open-button,
.viewer-actions button,
.viewer-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 7px;
    padding: 10px 14px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

.open-button:hover,
.viewer-actions button:hover,
.viewer-download:hover {
    background: var(--accent-dark);
}

.event-actions {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-upcoming {
    color: #075985;
    background: #e0f2fe;
}

.status-scheduled {
    color: #475569;
    background: #f1f5f9;
}

.status-today {
    color: #166534;
    background: #dcfce7;
}

.status-past {
    color: #6b7280;
    background: #eef0f3;
}

.event-item.is-past {
    opacity: 0.48;
    filter: grayscale(0.35);
}

.event-item.is-past h3,
.event-item.is-past p,
.event-item.is-past .event-date {
    color: #7b8494;
}

.open-button.is-disabled {
    background: #c7ced8;
    color: #667085;
    cursor: not-allowed;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent-dark);
    background: #f6f8fb;
    font-weight: 700;
    text-decoration: none;
}

.event-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.event-detail h2 {
    margin: 0;
    color: var(--accent-dark);
    font-size: 34px;
}

.detail-date-line {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-date-line span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--accent-dark);
    background: var(--soft);
    font-weight: 800;
}

.event-detail p {
    margin: 4px 0 0;
    color: var(--muted);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.photo-card {
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
    box-shadow: var(--shadow);
    position: relative;
}

.photo-card button {
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

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

.photo-card a {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 8px 10px;
    border-radius: 7px;
    color: white;
    background: rgba(20, 111, 113, 0.92);
    font-weight: 800;
    font-size: 13px;
    text-decoration: none;
}

.empty-note {
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 26px;
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.site-footer strong {
    color: var(--accent-dark);
}

.locked-event {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.locked-event section {
    width: min(520px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.locked-event p {
    margin: 0 0 4px;
    color: var(--muted);
}

.locked-event h1 {
    margin: 0 0 14px;
    font-size: 34px;
}

.locked-event h2 {
    margin: 10px 0 18px;
    font-size: 22px;
}

.locked-event span {
    color: var(--accent-dark);
    font-weight: 800;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(29, 139, 139, 0.14), transparent 42%),
        var(--bg);
}

.login-shell {
    width: min(420px, calc(100% - 32px));
}

.login-card {
    display: grid;
    gap: 14px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-card p {
    margin: 0;
    color: var(--accent-dark);
    font-weight: 800;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: 0;
}

.login-card label {
    color: var(--muted);
}

.login-card input {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    font-size: 18px;
}

.login-card button {
    height: 46px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.login-error {
    padding: 10px 12px;
    border-radius: 7px;
    color: #9f1239;
    background: #ffe4e6;
}

.viewer {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #111827;
    color: white;
    overflow: hidden;
}

.viewer:modal {
    max-width: none;
    max-height: none;
}

.viewer::backdrop {
    background: rgba(0, 0, 0, 0.72);
}

.viewer-shell {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: #111827;
    z-index: 3;
}

.viewer-actions {
    display: flex;
    gap: 8px;
}

.viewer-actions button {
    background: rgba(255, 255, 255, 0.12);
}

.viewer-stage {
    min-height: 0;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.viewer-stage figure {
    height: 100%;
    margin: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    place-items: center;
    position: relative;
    overflow: hidden;
}

.viewer-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.viewer-stage figcaption {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    min-height: 0;
    max-width: calc(100% - 32px);
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.72);
    color: rgba(255, 255, 255, 0.72);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-button {
    width: 44px;
    height: 68px;
    border: 0;
    border-radius: 8px;
    color: white;
    background: rgba(255, 255, 255, 0.12);
    font-size: 42px;
    cursor: pointer;
    justify-self: center;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.thumb-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 18px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: #111827;
}

.thumb-strip button {
    flex: 0 0 84px;
    height: 54px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
}

.thumb-strip button.is-active {
    border-color: #38bdf8;
}

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

@media (max-width: 760px) {
    .topbar,
    .viewer-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .event-item {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .brand-block {
        align-items: flex-start;
    }

    .brand-mark {
        flex-basis: 88px;
        width: 88px;
        height: 76px;
    }

    .cover {
        width: 78px;
    }

    .event-info {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .open-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .event-actions {
        grid-column: 1 / -1;
        justify-items: stretch;
    }

    .status-badge {
        justify-content: center;
    }

    .event-detail {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar form {
        justify-content: space-between;
    }

    .site-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .viewer-stage {
        grid-template-columns: 1fr;
    }

    .nav-button {
        position: absolute;
        z-index: 2;
        width: 42px;
        height: 62px;
        font-size: 34px;
        background: rgba(17, 24, 39, 0.78);
    }

    .nav-button.prev {
        left: 8px;
    }

    .nav-button.next {
        right: 8px;
    }

    .viewer {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }

    .viewer-shell {
        height: 100dvh;
        grid-template-rows: auto minmax(0, 1fr) auto;
    }

    .viewer-header {
        padding: 12px;
        gap: 10px;
    }

    .viewer-header h2 {
        font-size: 20px;
        line-height: 1.2;
    }

    .viewer-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }

    .viewer-actions button {
        min-height: 42px;
        padding: 9px 8px;
    }

    .viewer-stage figure {
        width: 100%;
        padding: 0 4px;
    }

    .viewer-stage img {
        width: 100%;
        max-height: calc(100dvh - 112px);
    }

    .thumb-strip {
        padding: 10px 12px 12px;
    }

    .thumb-strip button {
        flex-basis: 76px;
        height: 48px;
    }

    .viewer.is-rotated .viewer-stage figure {
        transform: rotate(90deg);
        width: calc(100dvh - 118px);
        height: 100vw;
    }

    .viewer.is-rotated .viewer-stage img {
        width: calc(100dvh - 118px);
        max-width: calc(100dvh - 118px);
        max-height: calc(100vw - 16px);
    }
}

@media (max-height: 520px) {
    .viewer-shell {
        grid-template-rows: auto minmax(0, 1fr);
    }

    .viewer-header {
        padding: 8px 12px;
        flex-direction: row;
        align-items: center;
    }

    .viewer-header h2 {
        font-size: 18px;
        line-height: 1.15;
    }

    .viewer-header p {
        display: none;
    }

    .viewer-actions {
        flex: 0 0 auto;
    }

    .viewer-actions button {
        min-height: 38px;
        padding: 8px 12px;
    }

    .viewer-stage {
        grid-template-columns: 1fr;
    }

    .viewer-stage img {
        width: 100%;
        max-height: calc(100dvh - 58px);
    }

    .thumb-strip {
        display: none;
    }

    .nav-button {
        position: absolute;
        z-index: 2;
        width: 46px;
        height: 68px;
        background: rgba(17, 24, 39, 0.78);
    }

    .nav-button.prev {
        left: 12px;
    }

    .nav-button.next {
        right: 12px;
    }

    .viewer-stage figcaption {
        bottom: 8px;
    }
}
