/* ==================================================
   User Layer Popup
================================================== */
.layer-popup-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
    pointer-events: none;
}
.layer-popup-root[hidden],
.layer-popup [hidden],
.layer-popup[hidden] {
    display: none !important;
}
.layer-popup {
    --layer-popup-width: 500px;
    --layer-popup-height: 600px;
    --layer-popup-x: 20px;
    --layer-popup-y: 20px;
    --layer-popup-stack: 0;
    --layer-popup-offset: calc(var(--layer-popup-stack) * 24px);
    position: fixed;
    top: calc(var(--layer-popup-y) + var(--layer-popup-offset));
    left: calc(var(--layer-popup-x) + var(--layer-popup-offset));
    display: flex;
    width: min(var(--layer-popup-width), calc(100vw - 32px));
    height: min(var(--layer-popup-height), calc(100vh - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    flex-direction: column;
    overflow: hidden;
    color: #17202b;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, .15);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    pointer-events: auto;
}
.layer-popup__header {
    display: flex;
    min-height: 46px;
    padding: 0 12px 0 17px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #e7eaf0;
    background: #fff;
}
.layer-popup__header strong {
    min-width: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.layer-popup__header button,
.layer-popup__footer button {
    border: 0;
    color: #4b5563;
    background: transparent;
    cursor: pointer;
    font: inherit;
}
.layer-popup__header button {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    font-size: 25px;
    line-height: 1;
}
.layer-popup__header button:hover,
.layer-popup__header button:focus-visible {
    color: #111827;
    background: #f0f2f5;
}
.layer-popup__content {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex: 1;
    overflow: auto;
    background: #fff;
}
.layer-popup__image,
.layer-popup__text {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 100%;
    flex: 1;
}
.layer-popup__image img {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    object-fit: contain;
}
.layer-popup--image {
    width: fit-content;
    height: auto;
    max-width: min(1200px, calc(100vw - 32px));
}
.layer-popup--image .layer-popup__content {
    flex: 0 1 auto;
    overflow: hidden;
}
.layer-popup--image .layer-popup__image {
    width: auto;
    min-height: 0;
    flex: 0 1 auto;
}
.layer-popup--image .layer-popup__image img {
    width: auto;
    height: auto;
    max-width: min(1200px, calc(100vw - 32px));
    max-height: calc(100vh - 126px);
}
.layer-popup__text {
    position: relative;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    overflow: auto;
}
.layer-popup__editor {
    display: block;
    width: 100%;
    margin: 0;
    color: inherit;
    overflow-wrap: anywhere;
}
.layer-popup__body-link {
    position: absolute;
    inset: 0;
    z-index: 2;
}
.layer-popup__editor.toastui-editor-contents {
    color: #17202b;
    background: transparent;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.7;
}
.layer-popup__text.is-style-none,
.layer-popup__text.is-style-none .layer-popup__editor {
    margin: 0;
    padding: 0;
}
.layer-popup__editor.toastui-editor-contents img {
    max-width: 100%;
    height: auto;
}
.layer-popup__text.is-style-clean .layer-popup__editor.toastui-editor-contents h1,
.layer-popup__text.is-style-clean .layer-popup__editor.toastui-editor-contents h2 {
    padding-bottom: 10px;
    color: #183f37;
    border-bottom: 2px solid rgba(40, 188, 138, .4);
}
.layer-popup__text.is-style-centered {
    align-items: stretch;
    text-align: center;
}
.layer-popup__text.is-style-centered .layer-popup__editor {
    margin-block: auto;
}
.layer-popup__text.is-style-centered .layer-popup__editor.toastui-editor-contents h1,
.layer-popup__text.is-style-centered .layer-popup__editor.toastui-editor-contents h2,
.layer-popup__text.is-style-centered .layer-popup__editor.toastui-editor-contents h3 {
    color: #174d40;
    text-align: center;
}
.layer-popup__text.is-style-centered .layer-popup__editor.toastui-editor-contents ul,
.layer-popup__text.is-style-centered .layer-popup__editor.toastui-editor-contents ol {
    display: inline-block;
    text-align: left;
}
.layer-popup__text.is-style-card .layer-popup__editor {
    padding: 26px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 18px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 16px 36px rgba(15, 23, 42, .12);
    backdrop-filter: blur(5px);
}
.layer-popup__text.is-style-card .layer-popup__editor.toastui-editor-contents h1,
.layer-popup__text.is-style-card .layer-popup__editor.toastui-editor-contents h2 {
    color: #b94f32;
}
.layer-popup__editor.toastui-editor-contents > :first-child {
    margin-top: 0;
}
.layer-popup__editor.toastui-editor-contents > :last-child {
    margin-bottom: 0;
}
.layer-popup__editor.toastui-editor-contents p,
.layer-popup__editor.toastui-editor-contents ul,
.layer-popup__editor.toastui-editor-contents ol,
.layer-popup__editor.toastui-editor-contents blockquote,
.layer-popup__editor.toastui-editor-contents table,
.layer-popup__editor.toastui-editor-contents h1,
.layer-popup__editor.toastui-editor-contents h2,
.layer-popup__editor.toastui-editor-contents h3,
.layer-popup__editor.toastui-editor-contents h4 {
    margin: 0 0 14px;
}
.layer-popup__editor.toastui-editor-contents h1 { font-size: 30px; }
.layer-popup__editor.toastui-editor-contents h2 { font-size: 25px; }
.layer-popup__editor.toastui-editor-contents h3 { font-size: 21px; }
.layer-popup__editor.toastui-editor-contents h4 { font-size: 18px; }
.layer-popup__editor.toastui-editor-contents ul,
.layer-popup__editor.toastui-editor-contents ol {
    padding-left: 24px;
}
.layer-popup__editor.toastui-editor-contents blockquote {
    padding: 10px 14px;
    color: #4b5563;
    border-left: 4px solid #9aa65a;
    background: rgba(255, 255, 255, .58);
}
.layer-popup__editor.toastui-editor-contents table {
    width: 100%;
    border-collapse: collapse;
}
.layer-popup__editor.toastui-editor-contents th,
.layer-popup__editor.toastui-editor-contents td {
    padding: 8px 10px;
    border: 1px solid rgba(71, 85, 105, .24);
}
.layer-popup__editor.toastui-editor-contents a {
    color: #53640d;
    text-decoration: underline;
}
.layer-popup__text.is-style-card  .layer-popup__editor.toastui-editor-contents {
    background: transparent;
}
.layer-popup__footer {
    display: flex;
    min-height: 48px;
    padding: 0 14px 0 17px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid #e7eaf0;
    background: #f8f9fb;
}
.layer-popup__footer label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #4b5563;
    font-size: 13px;
    cursor: pointer;
}
.layer-popup__footer input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #77851e;
}
.layer-popup__footer button {
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
}
.layer-popup__footer button:hover,
.layer-popup__footer button:focus-visible {
    color: #111827;
    background: #e9ecf1;
}


@media (max-width: 768px) {
    body.layer-popup-open {
        overflow: hidden;
    }
    .layer-popup-root {
        display: block;
        overflow: hidden;
        background: rgba(15, 23, 42, .46);
        pointer-events: auto;
    }
    .layer-popup {
        position: relative !important;
        inset: auto !important;
        width: min(var(--layer-popup-width), calc(100% - 30px));
        height: min(var(--layer-popup-height), calc(100dvh - 30px));
        max-width: calc(100% - 30px);
        max-height: calc(100dvh - 30px);
        flex: 0 0 auto;
        transform: none !important;
    }
    .layer-popup-root .layer-popup {
        position: absolute !important;
        top: 15px !important;
        left: 50% !important;
        width: calc(100% - 30px);
        transform: translateX(-50%) !important;
    }
    .layer-popup--image {
        width: fit-content;
        height: auto;
        max-width: min(1200px, calc(100% - 30px));
    }
    .layer-popup--image .layer-popup__image img {
        max-width: 100%;
        max-height: calc(100dvh - 124px);
    }
    .layer-popup-root .layer-popup--image .layer-popup__content,
    .layer-popup-root .layer-popup--image .layer-popup__image {
        width: 100%;
    }
    .layer-popup-root .layer-popup--image .layer-popup__image img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }
}

/* Preset placement keeps custom coordinates available for existing popups. */
.layer-popup {
    --popup-translate-x: 0%;
    --popup-translate-y: 0%;
}
.layer-popup[data-popup-position]:not([data-popup-position="custom"]) {
    top: calc(16px + var(--layer-popup-offset));
    left: calc(16px + var(--layer-popup-offset));
    transform: translate(var(--popup-translate-x), var(--popup-translate-y));
}
.layer-popup[data-popup-position$="_center"],
.layer-popup[data-popup-position="center"] {
    left: calc(50% + var(--layer-popup-offset)) !important;
    --popup-translate-x: -50%;
}
.layer-popup[data-popup-position$="_right"] {
    left: auto !important;
    right: calc(16px + var(--layer-popup-offset));
}
.layer-popup[data-popup-position^="center"] {
    top: calc(50% + var(--layer-popup-offset)) !important;
    --popup-translate-y: -50%;
}
.layer-popup[data-popup-position^="bottom"] {
    top: auto !important;
    bottom: calc(16px + var(--layer-popup-offset));
    animation: layer-popup-rise .36s ease-out both;
}
@keyframes layer-popup-rise {
    from { opacity: 0; translate: 0 80px; }
    to { opacity: 1; translate: 0 0; }
}
.layer-popup__header, .layer-popup__footer { flex-shrink: 0; }
.layer-popup__header { order: 0; }
.layer-popup__content { order: 1; }
.layer-popup__pagination { order: 2; }
.layer-popup__footer { order: 3; }
.layer-popup[data-hide-position="top"] > .layer-popup__footer {
    order: -1;
    border-top: 0;
    border-bottom: 1px solid #e7eaf0;
}
.layer-popup--no-title > .layer-popup__header { display: none; }
.layer-popup__floating-close {
    position: absolute;
    z-index: 5;
    top: 10px;
    right: 10px;
    display: none;
    width: 36px;
    height: 36px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 50%;
    background: rgba(17,24,39,.8);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity .16s;
}
.layer-popup--no-title > .layer-popup__floating-close { display: flex; }
.layer-popup--no-title:hover > .layer-popup__floating-close,
.layer-popup--no-title:focus-within > .layer-popup__floating-close { opacity: 1; }
.layer-popup > [hidden] { display: none !important; }
.layer-popup__close-icon {
    display: inline-block;
    position: relative;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}
.layer-popup__close-icon::before, .layer-popup__close-icon::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 1px;
    width: 16px;
    height: 2px;
    background: currentColor;
    transform: rotate(45deg);
}
.layer-popup__close-icon::after { transform: rotate(-45deg); }
.layer-popup__footer label { position: relative; }
.layer-popup__footer input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}
.layer-popup__check-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #87919c;
    border-radius: 50%;
    color: #6b7280;
}
.layer-popup__check-icon::after {
    content: "";
    width: 8px;
    height: 5px;
    margin-top: -2px;
    border-bottom: 2px solid currentColor;
    border-left: 2px solid currentColor;
    transform: rotate(-45deg);
}
.layer-popup__footer input:checked + .layer-popup__check-icon { color: #fff; background: #647516; border-color: #647516; }
.layer-popup__footer input:focus-visible + .layer-popup__check-icon { outline: 2px solid #647516; outline-offset: 3px; }
.layer-popup__gallery {
    --gallery-width: 600px;
    --gallery-ratio: 1;
    width: min(var(--gallery-width), calc(100vw - 32px));
    max-width: 100%;
    min-width: 0;
    position: relative;
}
.layer-popup__slides {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 100%;
    width: 100%;
    aspect-ratio: var(--gallery-ratio);
    max-height: calc(100dvh - 170px);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.layer-popup__slides::-webkit-scrollbar { display: none; }
.layer-popup__slide { min-width: 0; min-height: 0; scroll-snap-align: start; scroll-snap-stop: always; }
.layer-popup--image .layer-popup__slide .layer-popup__image {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}
.layer-popup--image .layer-popup__slide .layer-popup__image img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
}
.layer-popup__pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: #fff;
}
.layer-popup__pagination button { display: flex; width: 12px; height: 28px; padding: 0; align-items: center; justify-content: center; border: 0; background: transparent; cursor: pointer; }
.layer-popup__pagination button::after { content: ""; width: 5px; height: 5px; background: #b7bec7; border-radius: 5px; transition: width .15s; }
.layer-popup__pagination button[aria-current="true"] { width: 24px; }
.layer-popup__pagination button[aria-current="true"]::after { width: 20px; background: #26352f; }
@media (hover: none), (pointer: coarse) {
    .layer-popup--no-title > .layer-popup__floating-close { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .layer-popup[data-popup-position^="bottom"] { animation: none; }
    .layer-popup__floating-close, .layer-popup__pagination button::after { transition: none; }
}
@media (max-width: 768px) {
    .layer-popup-root .layer-popup[data-popup-position]:not([data-popup-position="custom"]) {
        --popup-translate-x: -50%;
        --popup-translate-y: 0%;
        left: 50% !important;
        right: auto !important;
        top: 15px !important;
        bottom: auto !important;
        transform: translate(var(--popup-translate-x), var(--popup-translate-y)) !important;
    }
    .layer-popup-root .layer-popup[data-popup-position^="center"]:not([data-popup-position="custom"]) { top: 50% !important; --popup-translate-y: -50% !important; }
    .layer-popup-root .layer-popup[data-popup-position^="bottom"]:not([data-popup-position="custom"]) { top: auto !important; bottom: 15px !important; }
    .layer-popup__gallery { width: 100%; }
    .layer-popup--no-title > .layer-popup__floating-close { opacity: 1; }
}

/* Keep slide navigation centered in the existing hide-today bar. */
.layer-popup__footer.has-pagination { position: relative; padding-right: 12px; padding-left: 12px; }
.layer-popup__footer.has-pagination > .layer-popup__pagination {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: transparent;
}
.layer-popup__footer.has-pagination > label { gap: 5px; font-size: 12px; white-space: nowrap; }
.layer-popup__footer.has-pagination .layer-popup__check-icon { width: 18px; height: 18px; }

.layer-popup--image { max-width: min(var(--gallery-max-width, 1000px), var(--gallery-natural-width, 1000px), calc(100vw - 32px)); }
.layer-popup--image .layer-popup__gallery { width: min(var(--gallery-width), var(--gallery-max-width, 1000px), 100%); }
@media (max-width: 768px) {
    .layer-popup-root .layer-popup--image { width: min(var(--gallery-natural-width, 1000px), var(--gallery-max-width, 1000px), calc(100% - 30px)); }
}

.layer-popup--image .layer-popup__slide .layer-popup__image img { max-width: min(100%, var(--image-natural-width, 100%)); max-height: min(100%, var(--image-natural-height, 100%)); }
