/* Review PDF / Template Gallery V2 */
:root {
    --gallery-topbar-offset: calc(var(--sheetgenie-topbar-offset, 82px) + 10px);
    --gallery-bg: color-mix(in srgb, var(--sgv2-bg, #f7fbff) 78%, #ffffff);
    --gallery-bg-soft: color-mix(in srgb, var(--sgv2-bg, #f7fbff) 52%, #eef5fb);
    --gallery-text: var(--sgv2-ink, #10233f);
    --gallery-muted: var(--sgv2-muted, #5e718c);
    --gallery-line: color-mix(in srgb, var(--sgv2-accent, #2587e8) 16%, rgba(86, 114, 148, 0.2));
    --gallery-line-strong: color-mix(in srgb, var(--sgv2-accent, #2587e8) 32%, rgba(86, 114, 148, 0.24));
    --gallery-surface: rgba(255, 255, 255, 0.9);
    --gallery-surface-strong: rgba(255, 255, 255, 0.97);
    --gallery-blue: var(--sgv2-accent, #2587e8);
    --gallery-blue-deep: color-mix(in srgb, var(--sgv2-accent, #2587e8) 78%, #14305c);
    --gallery-aqua: var(--sgv2-accent-3, #1fa98d);
    --gallery-warm: var(--sgv2-accent-2, #ee6a5f);
    --gallery-radius: 8px;
    --gallery-shadow-lg: 0 26px 68px rgba(45, 76, 112, 0.16);
    --gallery-shadow-md: 0 16px 40px rgba(45, 76, 112, 0.12);
    --gallery-shadow-sm: 0 10px 24px rgba(45, 76, 112, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.template-gallery-body {
    min-height: 100vh;
    color: var(--gallery-text);
    font-family: "Plus Jakarta Sans", "Kanit", Arial, sans-serif;
    background:
        linear-gradient(135deg, var(--gallery-bg), var(--gallery-bg-soft));
    background-size: auto;
    overflow-x: hidden;
    position: relative;
    -webkit-text-size-adjust: 100%;
}

body.template-gallery-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(115deg, color-mix(in srgb, var(--gallery-blue) 13%, transparent), transparent 28%),
        linear-gradient(295deg, color-mix(in srgb, var(--gallery-warm) 10%, transparent), transparent 34%);
    opacity: 0.9;
    z-index: -2;
}

.background-scene {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.background-scene .blob,
.background-scene .geo-ring,
.background-scene .geo-triangle {
    display: none;
}

.curve {
    position: absolute;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--gallery-blue) 16%, transparent);
}

.curve-a {
    width: 680px;
    height: 680px;
    left: -340px;
    top: 170px;
    transform: rotate(-20deg);
}

.curve-b {
    width: 860px;
    height: 520px;
    right: -430px;
    top: 260px;
    transform: rotate(8deg);
}

.geo {
    position: absolute;
    pointer-events: none;
    opacity: 0.18;
}

.geo-square {
    border: 1px solid color-mix(in srgb, var(--gallery-aqua) 28%, transparent);
    border-radius: var(--gallery-radius);
}

.geo-square-a {
    width: 72px;
    height: 72px;
    top: 28%;
    right: 32%;
    transform: rotate(16deg);
}

.geo-square-b {
    width: 46px;
    height: 46px;
    bottom: 31%;
    right: 10%;
    transform: rotate(-22deg);
}

.geo-line {
    height: 1px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gallery-blue) 34%, transparent), transparent);
}

.geo-line-a {
    width: 180px;
    top: 22%;
    left: 22%;
    transform: rotate(26deg);
}

.geo-line-b {
    width: 140px;
    bottom: 20%;
    right: 28%;
    transform: rotate(-20deg);
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 10000;
    transform: translateY(-140%);
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    padding: 9px 12px;
    background: var(--gallery-surface-strong);
    color: var(--gallery-text);
    font-weight: 800;
    text-decoration: none;
    box-shadow: var(--gallery-shadow-sm);
}

.skip-link:focus {
    transform: translateY(0);
}

.template-gallery-page {
    width: min(1240px, calc(100vw - 32px));
    margin: 0 auto;
    padding: var(--gallery-topbar-offset) 0 34px;
}

.gallery-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
}

.gallery-hero-copy,
.gallery-hero-panel,
.gallery-toolbar,
.gallery-status,
.gallery-empty,
.template-gallery-footer,
.worksheet-download-guide {
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    background: var(--gallery-surface);
    box-shadow: var(--gallery-shadow-md);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}

.gallery-hero-copy::before,
.gallery-hero-panel::before,
.gallery-toolbar::before,
.gallery-status::before,
.gallery-empty::before,
.template-gallery-footer::before,
.worksheet-download-guide::before,
.template-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--gallery-blue), var(--gallery-warm), var(--gallery-aqua));
    pointer-events: none;
}

.gallery-hero-copy {
    min-height: 236px;
    padding: clamp(24px, 4.6vw, 42px);
    display: grid;
    align-content: center;
}

.gallery-kicker {
    width: fit-content;
    margin: 0 0 14px;
    padding: 7px 10px;
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    background: color-mix(in srgb, var(--gallery-blue) 8%, #ffffff);
    color: color-mix(in srgb, var(--gallery-blue) 82%, var(--gallery-text));
    font-size: 0.78rem;
    font-weight: 900;
}

.gallery-hero h1 {
    max-width: 820px;
    margin: 0;
    color: var(--gallery-text);
    font-family: "Plus Jakarta Sans", "Kanit", sans-serif;
    font-size: clamp(2.2rem, 4.5vw, 4.25rem);
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: 0;
}

.gallery-hero p {
    max-width: 780px;
    margin: 16px 0 0;
    color: var(--gallery-muted);
    font-size: clamp(0.98rem, 1.25vw, 1.08rem);
    line-height: 1.75;
}

.gallery-hero-panel {
    padding: 24px;
    display: grid;
    place-items: center;
    text-align: center;
    background:
        linear-gradient(155deg, color-mix(in srgb, var(--gallery-blue) 10%, #ffffff), var(--gallery-surface-strong));
}

.gallery-hero-count {
    color: color-mix(in srgb, var(--gallery-blue) 88%, var(--gallery-text));
    font-size: clamp(3rem, 6vw, 4.9rem);
    line-height: 1;
    font-weight: 900;
}

.gallery-hero-label {
    color: var(--gallery-muted);
    font-size: 0.92rem;
    font-weight: 900;
}

.gallery-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.15fr);
    gap: 14px;
    align-items: end;
    padding: 16px;
    margin-bottom: 14px;
}

.gallery-search {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.gallery-search span {
    color: var(--gallery-text);
    font-size: 0.82rem;
    font-weight: 900;
}

.gallery-search input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    padding: 0 14px;
    color: var(--gallery-text);
    background: rgba(255, 255, 255, 0.82);
    font: inherit;
    font-weight: 700;
    outline: none;
}

.gallery-search input:focus {
    border-color: var(--gallery-line-strong);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--gallery-blue) 14%, transparent);
}

.gallery-search input::placeholder {
    color: color-mix(in srgb, var(--gallery-muted) 70%, #ffffff);
}

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.gallery-filter {
    min-height: 40px;
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    padding: 0 13px;
    background: color-mix(in srgb, var(--gallery-blue) 7%, #ffffff);
    color: var(--gallery-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.gallery-filter:hover,
.gallery-filter:focus-visible {
    border-color: var(--gallery-line-strong);
    background: color-mix(in srgb, var(--gallery-blue) 12%, #ffffff);
    outline: none;
    transform: translateY(-1px);
}

.gallery-filter.is-active {
    border-color: transparent;
    background: linear-gradient(135deg, var(--gallery-blue), color-mix(in srgb, var(--gallery-blue) 72%, var(--gallery-aqua)));
    color: #ffffff;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--gallery-blue) 22%, transparent);
}

.gallery-status {
    min-height: 46px;
    margin-bottom: 16px;
    padding: 13px 16px;
    color: var(--gallery-muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: stretch;
}

.template-card {
    min-width: 0;
    border: 1px solid var(--gallery-line);
    border-radius: var(--gallery-radius);
    background: var(--gallery-surface-strong);
    box-shadow: var(--gallery-shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.template-card:hover {
    border-color: var(--gallery-line-strong);
    box-shadow: var(--gallery-shadow-lg);
    transform: translateY(-2px);
}

.template-card[hidden] {
    display: none !important;
}

.template-preview {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 308px;
    padding: 18px;
    background:
        linear-gradient(155deg, #f9fcff, color-mix(in srgb, var(--gallery-blue) 9%, #ffffff));
    background-size: auto;
    overflow: hidden;
}

.template-preview-shell {
    width: 220px;
    height: 311px;
    border: 1px solid color-mix(in srgb, var(--gallery-blue) 18%, rgba(80, 110, 140, 0.18));
    border-radius: 7px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 18px 36px rgba(45, 76, 112, 0.2);
}

.template-preview-scaler {
    width: 210mm;
    height: 297mm;
    transform: scale(0.277);
    transform-origin: top left;
}

.template-preview-scaler .review-template-page {
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

.template-fallback-sheet {
    width: 100%;
    height: 100%;
    padding: 22px 18px;
    background: #ffffff;
    display: grid;
    gap: 12px;
    align-content: start;
}

.template-fallback-title {
    height: 20px;
    border-radius: 999px;
    background: #cfe0f7;
}

.template-fallback-line {
    height: 10px;
    border-radius: 999px;
    background: #e4edf8;
}

.template-fallback-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.template-fallback-box {
    height: 48px;
    border: 1px solid #d9e5f4;
    border-radius: 6px;
    background: #f8fbff;
}

.template-card-body {
    display: grid;
    gap: 12px;
    padding: 18px;
    flex: 1 1 auto;
}

.template-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-mode-pill,
.template-category-pill,
.template-source-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: var(--gallery-radius);
    font-size: 0.76rem;
    font-weight: 900;
}

.template-mode-pill {
    color: color-mix(in srgb, var(--gallery-blue) 84%, var(--gallery-text));
    background: color-mix(in srgb, var(--gallery-blue) 9%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--gallery-blue) 22%, transparent);
}

.template-category-pill {
    color: color-mix(in srgb, var(--gallery-aqua) 78%, var(--gallery-text));
    background: color-mix(in srgb, var(--gallery-aqua) 10%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--gallery-aqua) 24%, transparent);
}

.template-source-pill {
    color: color-mix(in srgb, var(--gallery-warm) 82%, var(--gallery-text));
    background: color-mix(in srgb, var(--gallery-warm) 11%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--gallery-warm) 24%, transparent);
    letter-spacing: 0;
}

.template-source-pill--counting,
.template-source-pill--compare {
    color: color-mix(in srgb, var(--gallery-aqua) 80%, var(--gallery-text));
    background: color-mix(in srgb, var(--gallery-aqua) 10%, #ffffff);
    border-color: color-mix(in srgb, var(--gallery-aqua) 24%, transparent);
}

.template-card h2 {
    margin: 0;
    color: var(--gallery-text);
    font-size: 1.12rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.template-card p {
    margin: 0;
    color: var(--gallery-muted);
    font-size: 0.93rem;
    line-height: 1.6;
}

.template-card-source {
    color: color-mix(in srgb, var(--gallery-blue) 70%, var(--gallery-text));
    font-size: 0.86rem;
    font-weight: 900;
}

.template-card-action {
    min-height: 46px;
    margin-top: auto;
    border: 0;
    border-radius: var(--gallery-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--gallery-blue), color-mix(in srgb, var(--gallery-blue) 72%, var(--gallery-aqua)));
    color: #ffffff;
    text-decoration: none;
    font-weight: 900;
    box-shadow: 0 14px 28px color-mix(in srgb, var(--gallery-blue) 22%, transparent);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.template-card-action:hover,
.template-card-action:focus-visible {
    transform: translateY(-1px);
    outline: none;
    box-shadow: 0 18px 32px color-mix(in srgb, var(--gallery-blue) 28%, transparent);
}

.worksheet-download-hero .gallery-hero-copy {
    min-height: 250px;
}

.worksheet-download-count-panel {
    background:
        linear-gradient(155deg, color-mix(in srgb, var(--gallery-aqua) 10%, #ffffff), var(--gallery-surface-strong));
}

.worksheet-download-grid {
    margin-bottom: 22px;
}

.worksheet-card-preview {
    min-height: 336px;
}

.worksheet-card-preview-link {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.worksheet-card-preview-link img {
    width: min(238px, 82%);
    aspect-ratio: 210 / 297;
    object-fit: cover;
    border-radius: 7px;
    box-shadow: 0 18px 36px rgba(45, 76, 112, 0.2);
    background: #ffffff;
}

.worksheet-sheet-preview {
    width: 220px;
    min-height: 311px;
    padding: 18px 16px;
    border: 1px solid color-mix(in srgb, var(--gallery-blue) 18%, rgba(80, 110, 140, 0.18));
    border-radius: 7px;
    color: #13233e;
    background: linear-gradient(180deg, #ffffff 0%, #ffffff 72%, #f3f8ff 100%);
    box-shadow: 0 18px 36px rgba(45, 76, 112, 0.2);
    display: grid;
    gap: 14px;
    align-content: start;
}

.worksheet-sheet-preview__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #d9e5f4;
    color: #31506f;
    font-size: 0.72rem;
    font-weight: 900;
}

.worksheet-sheet-preview strong {
    min-height: 44px;
    color: #0f2a48;
    font-size: 1rem;
    line-height: 1.3;
}

.worksheet-sheet-preview__lines {
    display: grid;
    gap: 10px;
    color: #203d5a;
    font-family: "Plus Jakarta Sans", "Kanit", sans-serif;
    font-size: 0.9rem;
    font-weight: 800;
}

.worksheet-sheet-preview__lines span {
    padding: 9px 10px;
    border: 1px solid #d9e5f4;
    border-radius: 6px;
    background: #f8fbff;
}

.worksheet-sheet-preview__answer {
    height: 42px;
    border-radius: 7px;
    border: 1px dashed #b8cbe3;
    background:
        repeating-linear-gradient(180deg, transparent 0 12px, rgba(49, 104, 223, 0.1) 12px 13px),
        #ffffff;
}

.worksheet-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: auto;
}

.worksheet-card-actions .template-card-action {
    grid-column: 1 / -1;
}

.worksheet-card-secondary {
    min-height: 42px;
    border-radius: var(--gallery-radius);
    border: 1px solid var(--gallery-line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--gallery-text);
    background: color-mix(in srgb, var(--gallery-blue) 6%, #ffffff);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 900;
}

.worksheet-card-secondary:hover,
.worksheet-card-secondary:focus-visible {
    border-color: var(--gallery-line-strong);
    background: color-mix(in srgb, var(--gallery-blue) 12%, #ffffff);
    outline: none;
}

.worksheet-download-guide {
    display: grid;
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
    gap: 18px;
    align-items: stretch;
    margin: 4px 0 24px;
    padding: 22px;
}

.worksheet-download-guide-copy h2 {
    margin: 0;
    color: var(--gallery-text);
    font-size: clamp(1.45rem, 2.6vw, 2.3rem);
    line-height: 1.1;
}

.worksheet-download-guide-copy p {
    margin: 12px 0 0;
    color: var(--gallery-muted);
    line-height: 1.7;
}

.worksheet-download-guide-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.worksheet-download-guide-grid article {
    padding: 16px;
    border-radius: var(--gallery-radius);
    border: 1px solid var(--gallery-line);
    background: color-mix(in srgb, var(--gallery-blue) 5%, #ffffff);
    display: grid;
    gap: 8px;
}

.worksheet-download-guide-grid strong {
    color: var(--gallery-text);
    font-size: 0.96rem;
}

.worksheet-download-guide-grid span {
    color: var(--gallery-muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.gallery-empty {
    margin-top: 18px;
    padding: 34px 24px;
    text-align: center;
}

.gallery-empty h2 {
    margin: 0 0 8px;
    color: var(--gallery-text);
    font-size: 1.3rem;
}

.gallery-empty p {
    margin: 0 auto;
    max-width: 620px;
    color: var(--gallery-muted);
    line-height: 1.7;
}

.template-gallery-footer {
    width: min(1240px, calc(100vw - 32px));
    margin: 0 auto 26px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.template-gallery-footer div {
    display: grid;
    gap: 3px;
}

.template-gallery-footer strong {
    color: var(--gallery-text);
}

.template-gallery-footer span,
.template-gallery-footer a {
    color: var(--gallery-muted);
    font-size: 0.9rem;
}

.template-gallery-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 14px;
}

.template-gallery-footer a {
    font-weight: 900;
    text-decoration: none;
}

.template-gallery-footer a:hover,
.template-gallery-footer a[aria-current="page"] {
    color: color-mix(in srgb, var(--gallery-blue) 82%, var(--gallery-text));
}

@media (max-width: 1040px) {
    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .worksheet-download-guide {
        grid-template-columns: 1fr;
    }

    .gallery-toolbar {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .gallery-filters {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    :root {
        --gallery-topbar-offset: calc(var(--sheetgenie-topbar-offset, 70px) + 10px);
    }

    .template-gallery-page {
        width: min(100% - 20px, 680px);
        padding-bottom: 28px;
    }

    .gallery-hero {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .gallery-hero-copy {
        min-height: 0;
        padding: 22px 18px;
    }

    .gallery-kicker {
        font-size: 0.74rem;
    }

    .gallery-hero h1 {
        font-size: clamp(1.86rem, 9.4vw, 3.05rem);
    }

    .gallery-hero-panel {
        display: flex;
        justify-content: space-between;
        text-align: left;
        gap: 16px;
    }

    .gallery-toolbar {
        padding: 12px;
    }

    .gallery-filter {
        flex: 1 1 calc(50% - 8px);
    }

    .template-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .template-preview {
        min-height: 278px;
    }

    .worksheet-card-preview {
        min-height: 302px;
    }

    .worksheet-sheet-preview {
        width: 198px;
        min-height: 280px;
    }

    .worksheet-download-guide {
        padding: 18px;
    }

    .worksheet-download-guide-grid {
        grid-template-columns: 1fr;
    }

    .template-preview-shell {
        width: 194px;
        height: 274px;
    }

    .template-preview-scaler {
        transform: scale(0.244);
    }

    .template-gallery-footer {
        width: min(100% - 20px, 680px);
        align-items: flex-start;
        flex-direction: column;
    }

    .template-gallery-footer nav {
        justify-content: flex-start;
    }
}

@media (max-width: 420px) {
    .gallery-filter {
        flex: 1 1 calc(50% - 8px);
    }

    .template-card-body {
        padding: 16px;
    }

    .worksheet-card-actions {
        grid-template-columns: 1fr;
    }

    .worksheet-card-actions .template-card-action {
        grid-column: auto;
    }
}

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

/* Index V2 surface alignment */
body.template-gallery-body {
    --gallery-blue: var(--accent, var(--sgv2-accent, #2587e8));
    --gallery-blue-deep: color-mix(in srgb, var(--gallery-blue) 76%, #07152c);
    --gallery-aqua: var(--sgv2-accent-3, #1fa98d);
    --gallery-warm: var(--accent-2, var(--sgv2-accent-2, #ee6a5f));
    --gallery-bg: color-mix(in srgb, var(--gallery-blue) 14%, #07152c);
    --gallery-bg-soft: color-mix(in srgb, var(--gallery-aqua) 16%, #123267);
    --gallery-text: #f3f8ff;
    --gallery-muted: #aec6e9;
    --gallery-line: color-mix(in srgb, var(--gallery-blue) 24%, rgba(184, 213, 255, 0.16));
    --gallery-line-strong: color-mix(in srgb, var(--gallery-blue) 42%, rgba(184, 213, 255, 0.22));
    --gallery-surface: var(--index-v2-panel-bg, linear-gradient(165deg, color-mix(in srgb, var(--gallery-blue) 22%, rgba(14, 30, 50, 0.76)), color-mix(in srgb, var(--gallery-aqua) 12%, rgba(16, 36, 58, 0.64)) 48%, color-mix(in srgb, var(--gallery-warm) 15%, rgba(14, 28, 47, 0.7))));
    --gallery-surface-strong: var(--index-v2-card-bg, linear-gradient(165deg, color-mix(in srgb, var(--gallery-blue) 20%, rgba(14, 30, 50, 0.82)), rgba(255, 255, 255, 0.08) 48%, color-mix(in srgb, var(--gallery-warm) 14%, rgba(13, 25, 42, 0.78))));
    --gallery-shadow-lg: 0 26px 68px rgba(3, 10, 18, 0.42);
    --gallery-shadow-md: 0 22px 56px rgba(0, 0, 0, 0.24);
    --gallery-shadow-sm: 0 18px 44px rgba(4, 18, 36, 0.2);
    background:
        radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--gallery-blue) 42%, transparent), transparent 34%),
        radial-gradient(circle at 86% 82%, color-mix(in srgb, var(--gallery-aqua) 28%, transparent), transparent 28%),
        linear-gradient(140deg, var(--gallery-bg) 0%, color-mix(in srgb, var(--gallery-blue) 16%, #0b2143) 46%, var(--gallery-bg-soft) 100%);
    background-size: auto;
}

body.template-gallery-body::before {
    background:
        radial-gradient(circle at 20% 12%, color-mix(in srgb, var(--gallery-blue) 18%, transparent), transparent 32%),
        radial-gradient(circle at 78% 72%, color-mix(in srgb, var(--gallery-aqua) 16%, transparent), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 58%);
    background-size: auto;
    opacity: 0.72;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.86), transparent 78%);
}

body.template-gallery-body .background-scene .blob {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
}

body.template-gallery-body .background-scene .blob-a {
    width: 260px;
    height: 260px;
    left: 8%;
    top: 6%;
    background: var(--gallery-blue);
}

body.template-gallery-body .background-scene .blob-b {
    width: 320px;
    height: 320px;
    right: 10%;
    bottom: 6%;
    background: var(--gallery-aqua);
}

body.template-gallery-body .background-scene .blob-c {
    width: 190px;
    height: 190px;
    left: 52%;
    top: 50%;
    background: color-mix(in srgb, var(--gallery-blue) 62%, #ffffff);
}

body.template-gallery-body .background-scene .geo-ring,
body.template-gallery-body .background-scene .geo-triangle {
    display: block;
}

body.template-gallery-body .curve {
    border-color: color-mix(in srgb, var(--gallery-blue) 22%, transparent);
}

body.template-gallery-body .geo {
    opacity: 0.28;
}

body.template-gallery-body .gallery-hero-copy,
body.template-gallery-body .gallery-hero-panel,
body.template-gallery-body .gallery-toolbar,
body.template-gallery-body .gallery-status,
body.template-gallery-body .gallery-empty,
body.template-gallery-body .template-gallery-footer,
body.template-gallery-body .worksheet-download-guide {
    background: var(--gallery-surface);
}

body.template-gallery-body .template-card,
body.template-gallery-body .worksheet-download-guide-grid article {
    background: var(--gallery-surface-strong);
}

body.template-gallery-body .gallery-hero-panel,
body.template-gallery-body .worksheet-download-count-panel {
    background: var(--gallery-surface-strong);
}

body.template-gallery-body .gallery-kicker,
body.template-gallery-body .template-mode-pill,
body.template-gallery-body .template-category-pill,
body.template-gallery-body .template-source-pill {
    background: color-mix(in srgb, var(--gallery-blue) 13%, transparent);
    color: color-mix(in srgb, var(--gallery-blue) 62%, #ffffff);
}

body.template-gallery-body .template-category-pill,
body.template-gallery-body .template-source-pill--counting,
body.template-gallery-body .template-source-pill--compare {
    color: color-mix(in srgb, var(--gallery-aqua) 64%, #ffffff);
    background: color-mix(in srgb, var(--gallery-aqua) 12%, transparent);
}

body.template-gallery-body .template-source-pill {
    color: color-mix(in srgb, var(--gallery-warm) 64%, #ffffff);
    background: color-mix(in srgb, var(--gallery-warm) 12%, transparent);
}

body.template-gallery-body .gallery-search input,
body.template-gallery-body .gallery-filter,
body.template-gallery-body .worksheet-card-secondary {
    border-color: color-mix(in srgb, var(--gallery-blue) 24%, rgba(162, 205, 255, 0.18));
    background: color-mix(in srgb, var(--gallery-blue) 12%, rgba(255, 255, 255, 0.08));
    color: var(--gallery-text);
}

body.template-gallery-body .gallery-filter:hover,
body.template-gallery-body .gallery-filter:focus-visible,
body.template-gallery-body .worksheet-card-secondary:hover,
body.template-gallery-body .worksheet-card-secondary:focus-visible {
    background: color-mix(in srgb, var(--gallery-blue) 20%, rgba(255, 255, 255, 0.1));
}

body.template-gallery-body .gallery-filter.is-active,
body.template-gallery-body .template-card-action {
    background: linear-gradient(135deg, var(--gallery-blue), color-mix(in srgb, var(--gallery-blue) 68%, var(--gallery-warm)));
    box-shadow: 0 14px 28px color-mix(in srgb, var(--gallery-blue) 24%, rgba(4, 12, 24, 0.32));
}

body.template-gallery-body .template-preview {
    background:
        radial-gradient(circle at 24% 18%, color-mix(in srgb, var(--gallery-blue) 18%, transparent), transparent 34%),
        linear-gradient(155deg, rgba(255, 255, 255, 0.1), color-mix(in srgb, var(--gallery-blue) 12%, rgba(255, 255, 255, 0.06)));
    background-size: auto;
}

body.template-gallery-body .gallery-hero-count {
    color: #ffffff;
}

body.template-gallery-body .template-card-body {
    background:
        linear-gradient(180deg, rgba(8, 18, 32, 0.1), rgba(8, 18, 32, 0.28)),
        color-mix(in srgb, var(--gallery-bg) 38%, rgba(255, 255, 255, 0.04));
}

body.template-gallery-body .template-card h2 {
    color: #ffffff;
    font-size: 1.18rem;
    font-weight: 900;
    line-height: 1.32;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

body.template-gallery-body .template-card p {
    color: color-mix(in srgb, var(--gallery-muted) 88%, #ffffff);
    font-size: 0.96rem;
    font-weight: 750;
    line-height: 1.72;
}

body.template-gallery-body .template-card-source {
    color: color-mix(in srgb, var(--gallery-blue) 42%, #ffffff);
    font-size: 0.9rem;
    font-weight: 900;
}

body.template-gallery-body .template-mode-pill,
body.template-gallery-body .template-category-pill,
body.template-gallery-body .template-source-pill {
    border-color: var(--gallery-line-strong);
    font-size: 0.78rem;
}

body.template-gallery-body .template-card-action {
    color: #ffffff;
    font-size: 0.96rem;
    letter-spacing: 0;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}
