@font-face {
    font-family: 'Balsamiq Sans';
    src: url('./BalsamiqSans-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap; /* Prevent invisible text during font load */
}

@font-face {
    font-family: 'More Sugar';
    src:
        url('./more_sugar_font/MoreSugar-Regular.woff2') format('woff2'),
        url('./more_sugar_font/MoreSugar-Regular.woff') format('woff'),
        url('./more_sugar_font/MoreSugar-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, h1, .tool-link, .button-description {
    font-family: 'Balsamiq Sans', Arial, sans-serif;
}

body {
    background: #62CECC;
    min-height: 100vh;
    position: relative;
}

/* Use flex layout only at large desktop size: width > 1200px AND height > 1100px */
@media (min-width: 1201px){
    body {
        display: flex;
        flex-direction: column;
    }
}

/* Personalizer pages: different background and always flex */
body:has(.back-button),
body:has(.container) {
    font-family: 'Balsamiq Sans', sans-serif;
    background: #42d1cd;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

@media (min-width: 1201px) {
    body:has(.back-button),
    body:has(.container) {
        display: flex;
        flex-direction: column;
    }
}

/* Page Header */
.page-header {
    text-align: center;
    margin: 20px auto 30px;
    max-width: 500px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Personalizer page header */
.page-header.page-form-header {
    margin-bottom: 20px;
    padding: 0;
}

@media (min-width: 768px) {
    .page-header.page-form-header {
        margin: 20px auto;
    }
}

/* Header/H1 Styles - Index page */
.page-header h1 {
    position: relative;
    width: 100%;
    text-align: center;
    color: #333;
    font-size: 2.2em;
    background-image: url('./images/bugs-mega-pack-personalized-pre-k-worksheets.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    min-height: 122px;
}

/* Personalizer h1 styles */
body:has(.back-button) .page-header h1,
body:has(.container) .page-header h1 {
    position: relative;
    color: #000;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 700;
    font-family: 'Balsamiq Sans', sans-serif;
    background-image: none;
    min-height: auto;
}

h1 span {
    opacity: 0;
    height: 90px;
    font-size: 1.2em;
    line-height: 1;
    display: block;
    overflow: hidden;
}

/* Animation for title bug icons - 3 degree step rotation */
@keyframes rotateStep {
    0%, 49.99% { transform: translateY(-50%) rotate(0deg); }
    50%, 100% { transform: translateY(-50%) rotate(3deg); }
}

/* Mobile version without translateY */
@keyframes rotateStepMobile {
    0%, 49.99% { transform: rotate(0deg); }
    50%, 100% { transform: rotate(3deg); }
}

/* Desktop/Tablet: Show bugs on both sides - Index page */
@media (min-width: 768px) {
    .page-header{
        margin: 45px auto 30px;
    }

    .page-header h1::before {
        content: '';
        position: absolute;
        left: -183px;
        top: 53px;
        transform: translateY(-50%);
        width: 233px;
        height: 143px;
        background-image: url('./images/title-bug-2.png');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStep 1400ms steps(2) infinite;
    }
    .page-header h1::after {
        content: '';
        position: absolute;
        right: -130px;
        top: 47px;
        transform: translateY(-50%);
        width: 178px;
        height: 139px;
        background-image: url('./images/title-bug.png');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStep 1400ms steps(2) infinite;
    }
}

/* Desktop/Tablet: Show bugs on both sides - Personalizer pages */
@media (min-width: 768px) {
    body:has(.back-button) h1::before,
    body:has(.container) h1::before {
        content: '';
        position: absolute;
        left: -100px;
        top: 50%;
        transform: translateY(-50%);
        width: 60px;
        height: 60px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStep 1400ms steps(2) infinite;
    }
    body:has(.back-button) h1::after,
    body:has(.container) h1::after {
        content: '';
        position: absolute;
        right: -100px;
        top: 50%;
        transform: translateY(-50%);
        width: 60px;
        height: 60px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStep 1400ms steps(2) infinite;
    }
}

@media (min-width: 1201px) {
    .page-header{
        margin: 90px auto 30px;
    }
}

/* Mobile: Show only one bug before title - Index page */
@media (max-width: 767px) {
    .page-header h1 {
        font-size: 1.3em;
        min-height: 120px;
    }

    .page-header h1 span{
        height: 19vw;
    }

    .page-header h1::before {
        content: '';
        display: block;
        height: 35vw;
        border-left: 14vw solid transparent;
        background-image: url('./images/title-bug.png');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStepMobile 1400ms steps(2) infinite;
    }
}

/* Mobile: Show only one bug before title - Personalizer pages */
@media (max-width: 767px) {
    body:has(.back-button) h1,
    body:has(.container) h1 {
        font-size: 2em;
    }
    
    body:has(.back-button) h1::before,
    body:has(.container) h1::before {
        content: '';
        display: block;
        width: 50px;
        height: 50px;
        margin: 0 auto 10px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        animation: rotateStepMobile 1400ms steps(2) infinite;
    }

    body:has(.back-button) .page-header.page-form-header h1::before,
    body:has(.container) .page-header.page-form-header h1::before {
        width: 300px;
        height: 60px;
        background-size: auto 100%;
        animation: rotateStepMobile 1400ms steps(2) infinite;
    }

    body:has(.back-button) h1::after,
    body:has(.container) h1::after {
        display: none;
    }
}

@media (min-width: 501px) and (max-width: 767px) {
    .page-header h1 span{
        height: 105px;
    }

    .page-header h1::before {
        height: 160px;
        border-left: 73px solid transparent;
        animation: rotateStepMobile 1400ms steps(2) infinite;
    }
}

/* Page-specific bug icon styles */

/* Words page */
@media (min-width: 768px) {

    body:has(.back-button) .page-words::before,
    body:has(.container) .page-words::before {
        background-image: url('./images/icon-bug-02.png');
        width: 100px;
        height: 100px;
        left: -35px;
    }
    body:has(.back-button) .page-words::after,
    body:has(.container) .page-words::after {
        background-image: url('./images/icon-bug-03.png'); 
        width: 130px;
        height: 90px;
        right: -95px;
    }
}

@media (max-width: 767px) {
    body:has(.back-button) .page-words::before,
    body:has(.container) .page-words::before {
        background-image: url('./images/icon-bug-03.png');
        border-left: 0 solid transparent;
    }
}

/* Math page */
@media (min-width: 768px) {
    body:has(.back-button) .page-math::before,
    body:has(.container) .page-math::before {
        background-image: url('./images/icon-bug-04.png');
        width: 100px;
        height: 40px;
        left: -45px;
    }
    body:has(.back-button) .page-math::after,
    body:has(.container) .page-math::after {
        background-image: url('./images/icon-bug-05.png');
        width: 130px;
        height: 50px;
        right: -75px;
    }
}

@media (max-width: 767px) {
    body:has(.back-button) .page-math::before,
    body:has(.container) .page-math::before {
        background-image: url('./images/icon-bug-05.png');
        border-left: 0 solid transparent;
    }
}

/* Drawing page */
@media (min-width: 768px) {
    body:has(.back-button) .page-drawing::before,
    body:has(.container) .page-drawing::before {
        background-image: url('./images/icon-bug-06.png');
        width: 70px;
        height: 60px;
        top: 20px;
        left: 85px;
    }
    body:has(.back-button) .page-drawing::after,
    body:has(.container) .page-drawing::after {
        background-image: url('./images/icon-bug-07.png');
        width: 80px;
        height: 70px;
        right: 75px;
        top: 20px;
    }
}

@media (max-width: 767px) {
    body:has(.back-button) .page-drawing::before,
    body:has(.container) .page-drawing::before {
        background-image: url('./images/icon-bug-07.png');
        border-left: 0 solid transparent;
    }
}

/* Puzzles page */
@media (min-width: 768px) {
    body:has(.back-button) .page-puzzles::before,
    body:has(.container) .page-puzzles::before {
        background-image: url('./images/icon-bug-10.png');
        width: 70px;
        height: 70px;
        left: 85px;
        top: 15px;
    }
    body:has(.back-button) .page-puzzles::after,
    body:has(.container) .page-puzzles::after {
        background-image: url('./images/icon-bug-12.png');
        width: 70px;
        height: 70px;
        right: 85px;
        top: 20px;
    }
}

@media (max-width: 767px) {
    body:has(.back-button) .page-puzzles::before,
    body:has(.container) .page-puzzles::before {
        background-image: url('./images/icon-bug-11.png');
        border-left: 0 solid transparent;
    }
}

/* MiniBook page */
@media (min-width: 768px) {
    body:has(.back-button) .page-minibook::before,
    body:has(.container) .page-minibook::before {
        background-image: url('./images/icon-bug-16.png');
        width: 70px;
        height: 70px;
        left: 55px;
        top: 15px;
    }
    body:has(.back-button) .page-minibook::after,
    body:has(.container) .page-minibook::after {
        background-image: url('./images/icon-bug-13.png');
        width: 80px;
        height: 80px;
        right: 55px;
        top: 10px;
    }
}

@media (max-width: 767px) {
    body:has(.back-button) .page-minibook::before,
    body:has(.container) .page-minibook::before {
        background-image: url('./images/icon-bug-13.png');
        border-left: 0 solid transparent;
    }
}

.page-description {
    color: #000;
    font-size: 1.1em;
    margin-top: 10px;
    font-weight: 400;
    font-family: 'Balsamiq Sans', sans-serif;
}

/* Main Content - Buttons Container - Index page */
.links {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: center;
    flex: 1;
    padding: 30px 20px;
}

/* Vertically center links only at desktop size: width > 1200px AND height > 1100px */
@media (min-width: 1201px){
    .links {
        align-items: center;
        flex: 0 0 auto;
        margin: auto;
        gap: 60px;
    }
}

/* Button Container - Now an anchor element */
.tool-link-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 230px;
    text-decoration: none;
}

/* Animated Background Images - Spritesheet approach */
.tool-link-wrapper::before {
    content: '';
    position: absolute;
    transform: translate(-50%, -50%);
    top: 39%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-size: 200% auto;
    background-repeat: no-repeat;
    background-position: 0 0;
    z-index: 0;
    animation: toggleSpritesheet 1400ms infinite;
    will-change: background-position; /* Optimize animation performance */
}

/* Set background images for each button (spritesheet versions) */
.tool-link-wrapper.words::before {
    background-image: url('./images/tool-preview-words.png');
}

.tool-link-wrapper.math::before {
    background-image: url('./images/tool-preview-math.png');
}

.tool-link-wrapper.drawing::before {
    background-image: url('./images/tool-preview-drawing.png');
}

.tool-link-wrapper.puzzles::before {
    background-image: url('./images/tool-preview-puzzles.png');
}

.tool-link-wrapper.books::before {
    background-image: url('./images/tool-preview-books.png');
}

/* Animation keyframes - shift background position every 700ms */
/* Button width is 300px. With background-size: 200% auto, image is 600px wide */
/* Each frame is 300px, so shift by -300px to show second frame */
/* Use 49.999% to ensure clean transition at exactly 50% */
@keyframes toggleSpritesheet {
    0%, 49.999% { background-position: 0 0; }
    50%, 100% { background-position: -300px 0; }
}

/* Button Styles */
.tool-link {
    position: relative;
    z-index: 1;
    display: block;
    padding: 18px 40px;
    width: 300px;
    background: #247674;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 1.5em;
    font-weight: bold;
    box-shadow: 0 4px 16px rgba(59,184,180,0.08);
    transition: background 0.2s, transform 0.2s;
    text-align: center;
}

.tool-link-wrapper:hover .tool-link {
    background: #2d6a6a;
    transform: translateY(-2px);
}

/* Button Description */
.tool-link-wrapper .button-description {
    position: relative;
    z-index: 1;
    margin-top: 10px;
    color: #185251;
    font-size: 1.1em;
    font-weight: 400;
    text-align: center;
    width: 300px;
}

/* Personalizer page styles */
.back-button {
    position: absolute;
    left: 24px;
    top: 24px;
    text-decoration: none;
    color: white;
    font-weight: bold;
    font-size: 1.1em;
    background: #247674;
    padding: 8px 18px;
    border-radius: 3px;
    box-shadow: 0 4px 16px rgba(59,184,180,0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    transition: background 0.2s, transform 0.2s;
}

.back-button:hover {
    background: #2d6a6a;
    transform: translateY(-2px);
}

@media (max-width: 1023px) {
    .back-button {
        position: static;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        width: fit-content;
    }
}

.container {
    background: white;
    border-radius: 3px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    text-align: center;
}

.subtitle {
    color: #3bb8b4;
    font-size: 1em;
    font-weight: 700;
    font-family: 'Balsamiq Sans', sans-serif;
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group {
    margin-bottom: 25px;
    text-align: left;
}

.input-group.hidden {
    display: none;
}

.input-group-with-icon {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    position: relative;
}

.input-group-with-icon label {
    flex: 1;
}

.input-group-icon-wrapper {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group-icon-wrapper .input-group-icon {
    width: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-group-icon {
    width: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-group-icon img {
    width: 40px;
    height: auto;
    object-fit: contain;
}

select {
    width: 100%;
    padding: 15px;
    padding-right: 2.25em; /* room before the native dropdown caret */
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    font-family: 'Balsamiq Sans', sans-serif;
    font-weight: 400;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

label {
    display: block;
    margin-bottom: 8px;
    color: #222;
    font-weight: 700;
    font-size: 1.1em;
    font-family: 'Balsamiq Sans', sans-serif;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f8f9fa;
    font-family: 'Balsamiq Sans', sans-serif;
    font-weight: 400;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.placeholder-text {
    color: #999;
    font-size: 0.9em;
    margin-top: 5px;
    font-family: 'Balsamiq Sans', sans-serif;
    font-weight: 400;
}

.download-btn {
    background: #247674;
    color: white;
    border: none;
    padding: 18px 40px;
    border-radius: 3px;
    font-size: 1.6em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 4px 16px rgba(59,184,180,0.08);
    width: 100%;
    margin-top: 0;
    font-family: 'Balsamiq Sans', sans-serif;
}

.download-btn:hover {
    background: #2d6a6a;
    transform: translateY(-2px);
}

.download-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading {
    display: none;
    margin-top: 20px;
    color: #667eea;
    font-weight: 700;
    font-family: 'Balsamiq Sans', sans-serif;
}

.error {
    color: #e74c3c;
    margin-top: 15px;
    padding: 10px;
    background: #fdf2f2;
    border-radius: 3px;
    display: none;
    font-family: 'Balsamiq Sans', sans-serif;
    font-weight: 400;
}

.success {
    color: #27ae60;
    margin-top: 15px;
    padding: 10px;
    background: #f0f9f4;
    border-radius: 3px;
    display: none;
    font-family: 'Balsamiq Sans', sans-serif;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.success.is-visible {
    opacity: 1;
}

.success .success-check {
    font-weight: 700;
    margin-right: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .success {
        transition: none;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 30px 20px;
    }
    
    body:has(.back-button) h1,
    body:has(.container) h1 {
        font-size: 2em;
    }
}

.input-row {
    display: flex;
    align-items: center; /* character graphic vertically centered with the field */
    gap: 20px;
}

.input-image {
    flex-shrink: 0;
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px; /* 1px more space above the preview name */
}

.placeholder-square {
    width: 60px;
    height: auto;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-square img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

/* Teeny name under fox / turtle / bug while typing */
.char-name-label {
    max-width: 72px;
    font-family: var(--ui-font);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    color: var(--teal-dark, #185251);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.char-name-label.is-placeholder {
    opacity: 0.55;
    font-weight: 500;
}

img#colorIcon {
    max-width: 80%;
    margin-top: 27px;
    height: 56px;
}

img#colorIcon[alt="Black & White"] {
    transform: rotate(7deg);  
}

img#colorIcon[alt="Full Color"] {
    transform: rotate(-7deg);  
}

img#sizeIcon {
    max-width: 60%;
    margin-top: 27px;
    height: 56px;
    transform: rotate(7deg);  
}

img#sizeIcon[alt="A4"] {
    transform: rotate(7deg);  
}

img#sizeIcon[alt="Letter"] {
    transform: rotate(-7deg);  
}

.input-content {
    flex: 1;
    order: 1;
}

.input-content label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #222;
}

.input-content input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.input-content input:focus {
    outline: none;
    border-color: #3bb8b4;
}

.input-content .placeholder-text {
    margin-top: 6px;
    font-size: 14px;
    color: #7f8c8d;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: #2d6a6a;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    font-weight: 400;
}

/* Fixed footer only for index page */
@media (min-width: 1024px) and (min-height: 800px) {
    body:has(.links) footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #62CECC;
    }
    body:has(.links) {
        padding-bottom: 80px; /* Space for fixed footer */
    }
}

@media (max-width: 767px) {
    .links {
        gap: 45px;
    }
}

/* —— Classroom gallery —— */
.pilot-banner {
    max-width: 640px;
    margin: 8px auto 0;
    padding: 0 16px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    font-size: 1.05em;
    color: #185251;
    text-align: center;
}

.mode-switch {
    display: inline-flex;
    margin: 14px auto 0;
    padding: 3px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.55);
    gap: 0;
}

.page-header .mode-switch {
    display: flex;
    width: fit-content;
}

.mode-switch-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: #185251;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    font-size: 1em;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-switch-btn.is-active {
    background: #247674;
    color: #fff;
}

.mode-switch-btn:not(.is-active):hover {
    background: rgba(36, 118, 116, 0.12);
}

.mode-blurb {
    max-width: 520px;
    margin: 10px auto 0;
    padding: 0 16px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    font-size: 1.05em;
    color: #185251;
    text-align: center;
}

.form-mode-blurb {
    max-width: none;
    margin: 18px 0; /* equal space above and below Add… copy */
    padding: 0;
    text-align: left;
    color: #185251;
}

/* Match input size for the Teachers/Parents mode instruction blurb. */
.worksheet-form-fields .form-mode-blurb,
.worksheet-form-fields .mode-blurb,
body.pilot-page .worksheet-form-fields .form-mode-blurb,
body.pilot-page .worksheet-form-fields .mode-blurb {
    font-family: var(--ui-font);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
}

.pilot-footer-note {
    max-width: 520px;
    margin: 0 auto 10px;
    padding: 0 16px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    font-size: 0.95em;
    line-height: 1.35;
    color: #2d6a6a;
}

.pilot-footer-note.pilot-disclaimer {
    font-size: 0.9em;
    margin-bottom: 16px;
}

.gallery-controls {
    width: min(var(--content-max), calc(100% - (var(--content-inline) * 2)));
    max-width: var(--content-max);
    margin: 0 auto 16px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.filter-chips {
    display: contents; /* chips share the gallery-controls wrap line */
}

/* Smooth wiggly pills — soft uneven radii only (no noise, no rotate).
   Curves stay clean; each chip is a slightly different soft bean. */
.chip {
    position: relative;
    z-index: 0;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: #185251;
    font-family: var(--ui-font);
    font-size: var(--chrome-text-size);
    font-weight: 500;
    padding: 5px 11px;
    cursor: pointer;
}

.chip::before {
    content: '';
    position: absolute;
    /* No left overhang — pill left edge matches nav bug / thumb image */
    inset: -1px -2px -1px 0;
    z-index: -1;
    background: rgba(255, 255, 255, 0.55); /* match mode-switch track */
    /* Extra variance after `/` = slightly wigglier top/bottom edges */
    border-radius: 2.6em 1.7em 2.3em 1.9em / 1.45em 2.85em 1.35em 2.7em;
}

.chip:nth-child(6n + 1)::before {
    border-radius: 1.8em 2.5em 1.9em 2.4em / 2.85em 1.4em 2.9em 1.5em;
}
.chip:nth-child(6n + 2)::before {
    border-radius: 2.5em 1.8em 2.4em 1.7em / 1.4em 2.8em 1.5em 2.9em;
}
.chip:nth-child(6n + 3)::before {
    border-radius: 2em 2.3em 1.7em 2.6em / 2.7em 1.45em 2.85em 1.35em;
}
.chip:nth-child(6n + 4)::before {
    border-radius: 2.4em 1.9em 2.5em 1.8em / 1.5em 2.9em 1.4em 2.7em;
}
.chip:nth-child(6n + 5)::before {
    border-radius: 1.7em 2.6em 2em 2.3em / 2.9em 1.45em 2.7em 1.55em;
}
.chip:nth-child(6n + 6)::before {
    border-radius: 2.3em 2em 1.8em 2.5em / 1.55em 2.7em 1.45em 2.85em;
}

.chip-count {
    margin-left: 0.45em;
    font-variant-numeric: tabular-nums;
    opacity: 0.52;
    font-weight: 600;
}

.chip-active,
.chip:hover {
    color: #fff;
}

.chip-active .chip-count,
.chip:hover .chip-count {
    opacity: 0.72;
}

.chip-active::before,
.chip:hover::before {
    background: #247674;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: min(var(--content-max), calc(100% - (var(--content-inline) * 2)));
    max-width: var(--content-max);
    margin: 0 auto 24px;
    padding: 0;
}

@media (min-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .gallery-grid {
        gap: 12px;
    }
}

@media (min-width: 1300px) {
    .gallery-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.worksheet-card {
    /* One even inset for the media (all four sides) and title/skills text,
       so the hover wash + CTA sit symmetrically on every card. */
    --thumb-inset-x: 16px;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: #222;
    background: transparent;
    border-radius: var(--radius);
    overflow: visible;
    border: none;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.worksheet-card:hover,
.worksheet-card:focus-visible {
    background: rgba(255, 255, 255, 0.55);
    outline: none;
    /* Slight lift for thumb + title + tags (not the old scale/poke). */
    transform: translateY(-2px);
}

.worksheet-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 8.5 / 11;
    object-fit: cover;
    background: #fff;
    display: block;
}

.worksheet-card-title {
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
    font-size: 20px; /* match .brand-title-main */
    line-height: 1.2;
    color: #185251;
    padding: 0 var(--thumb-inset-x) 2px;
}

@media (min-width: 768px) {
    .worksheet-card-title {
        font-size: 22px;
    }
}

.worksheet-card-skills {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-family: var(--ui-font);
    font-size: var(--chrome-text-size);
    font-weight: 500;
    color: #247674;
    padding: 0 var(--thumb-inset-x) 10px;
}

.worksheet-card-dl-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}

.worksheet-card-downloads {
    color: #247674;
}

/* Gallery thumbs: drop shadow; even L/R/top inset; tighter bottom so the title
   sits closer to the page. Multi-page back page peeks inside the inset. */
.worksheet-card-media {
    display: block;
    position: relative;
    --page-stack-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
    padding: var(--thumb-inset-x) var(--thumb-inset-x) 8px;
}

/* Download badge left of downloads count — tag teal bg, light-teal icon, no shadow/motion. */
.worksheet-card-downloaded {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--teal-light, #62CECC);
    background: #247674;
    border-radius: 1.9em 1.35em 1.75em 1.45em / 1.25em 1.85em 1.15em 1.7em;
    pointer-events: none;
    transform: rotate(-8deg);
    box-shadow: none;
}

.worksheet-card-downloaded svg {
    width: 14px;
    height: 14px;
    display: block;
}

.worksheet-card-stage {
    display: block;
    position: relative;
    aspect-ratio: 8.5 / 11;
    width: 100%;
}

/* Hover/focus CTA over the thumb — visual only; the card link is the real control.
   Soft white wash (not a dark dim) so the button reads clearly. */
.worksheet-card-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(255, 255, 255, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.worksheet-card-cta {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 4;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--teal-light, #62CECC);
    color: #185251;
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
    font-size: 20px; /* match .worksheet-card-title */
    line-height: 1.2;
    padding: 10px 18px;
    /* Wiggly pill — same language as filter chips */
    border-radius: 2.6em 1.7em 2.3em 1.9em / 1.45em 2.85em 1.35em 2.7em;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease-out, transform 0.22s ease-out;
}

@media (min-width: 768px) {
    .worksheet-card-cta {
        font-size: 22px; /* match .worksheet-card-title */
    }
}

@media (hover: hover) {
    .worksheet-card:hover .worksheet-card-stage::after,
    .worksheet-card:focus-visible .worksheet-card-stage::after {
        opacity: 1;
    }

    /* Collapse the peek so the stack sits inside the front-page wash. */
    .worksheet-card:hover .worksheet-card-media.has-pages img[data-stack="back"],
    .worksheet-card:focus-visible .worksheet-card-media.has-pages img[data-stack="back"] {
        transform: translate(0, 0) rotate(0deg);
    }

    .worksheet-card:hover .worksheet-card-cta,
    .worksheet-card:focus-visible .worksheet-card-cta {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@media (hover: none) {
    .worksheet-card:focus-visible .worksheet-card-stage::after {
        opacity: 1;
    }

    .worksheet-card:focus-visible .worksheet-card-media.has-pages img[data-stack="back"] {
        transform: translate(0, 0) rotate(0deg);
    }

    .worksheet-card:focus-visible .worksheet-card-cta {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .worksheet-card,
    .worksheet-card-stage::after,
    .worksheet-card-cta {
        transition: none;
    }

    .worksheet-card:hover,
    .worksheet-card:focus-visible {
        transform: none;
    }

    /* No scale motion: CTA sits at full size and just appears. */
    .worksheet-card-cta {
        transform: translate(-50%, -50%);
    }
}

.worksheet-card-media:not(.has-pages) img,
.worksheet-card-media.has-pages img.worksheet-card-page {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    box-shadow: var(--page-stack-shadow);
}

.worksheet-card-media.has-pages img.worksheet-card-page {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.worksheet-card-media.has-pages img[data-stack="front"] {
    z-index: 2;
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
}

.worksheet-card-media.has-pages img[data-stack="back"] {
    z-index: 1;
    opacity: 1;
    /* peek behind-left, slight tilt (stays within the 16px card inset) */
    transform: translate(-7px, -5px) rotate(-4deg);
}

.worksheet-card-media.has-pages img[data-stack="hidden"] {
    z-index: 0;
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
}

@media (prefers-reduced-motion: reduce) {
    .worksheet-card-media.has-pages img.worksheet-card-page {
        transition: none;
    }
}

/* Gallery multipage cards: no page dots (auto-cycle only). Page toggle lives on the form. */

.gallery-empty {
    text-align: center;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    color: #185251;
    padding: 40px 16px;
}

.pilot-footer {
    text-align: center;
    padding: 24px 16px 40px;
    color: #2d6a6a;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
}

.pilot-footer a {
    color: #185251;
}

/* Pilot site footer links (every page). */
body.pilot-page .pilot-footer {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 28px var(--content-inline, 20px) 36px;
    text-align: center;
    font-family: var(--ui-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;
    color: var(--ink-soft, #5f6368);
    background: transparent;
}

body.pilot-page .pilot-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0;
}

body.pilot-page .pilot-footer a {
    color: var(--teal-dark, #185251);
    text-decoration: none;
    font-family: inherit;
    font-weight: 500;
}

body.pilot-page .pilot-footer a:hover,
body.pilot-page .pilot-footer a:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.pilot-page .pilot-footer a[aria-current="page"] {
    font-weight: 700;
}

body.pilot-page .pilot-footer-sep {
    margin: 0 0.55em;
    color: inherit;
    user-select: none;
}

.worksheet-title-visible {
    opacity: 1 !important;
    background: none !important;
    color: #222 !important;
    font-size: 1.8em !important;
}

.container.worksheet-form-layout {
    /* Preview sits on page teal; only the form panel is white. */
    max-width: 980px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
    text-align: left;
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: visible;
}

.worksheet-form-fields {
    min-width: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 28px 24px 32px;
    color: #000;
}

/* Form UI copy: black; small supporting text grey. */
.worksheet-form-fields .worksheet-preview-title,
.worksheet-form-fields .input-content label,
.worksheet-form-fields label,
.worksheet-form-fields .mode-switch-btn,
.worksheet-form-fields .mode-switch-btn.is-active,
.worksheet-form-fields select,
.worksheet-form-fields input[type="text"],
.worksheet-form-fields textarea {
    color: #000;
}

.worksheet-form-fields .placeholder-text {
    color: #9a9a9a;
}

.worksheet-form-fields .char-name-label {
    color: #000;
}

/* Form copy is black; only placeholders stay grey. */
.worksheet-form-fields .form-mode-blurb,
.worksheet-form-fields .mode-blurb,
.worksheet-form-fields .worksheet-preview-meta,
.worksheet-form-fields .worksheet-preview-skills,
.worksheet-form-fields .worksheet-preview-downloads,
.worksheet-form-fields .worksheet-preview-meta-sep,
.worksheet-form-fields .field-help,
.worksheet-form-fields .field-help.field-help-emphasis,
.worksheet-form-fields .sheet-react-prompt,
.worksheet-form-fields .sheet-react-step-title,
.worksheet-form-fields .sheet-react-check,
.worksheet-form-fields .sheet-react-thanks-msg {
    color: #000;
}

.worksheet-form-fields .sheet-react-more-ideas,
.worksheet-form-fields .sheet-react-instagram {
    color: #555;
}

.worksheet-form-fields input::placeholder,
.worksheet-form-fields textarea::placeholder {
    color: #9a9a9a;
    opacity: 1;
}

/* Small form copy — shared size. */
.worksheet-form-fields .worksheet-preview-meta,
.worksheet-form-fields .worksheet-preview-skills,
.worksheet-form-fields .worksheet-preview-downloads,
.worksheet-form-fields .field-help {
    font-family: var(--ui-font);
    font-size: var(--chrome-text-size);
    font-weight: 400; /* slightly lighter than previous 500 */
    line-height: 1.35;
}

/* Privacy footnotes (not the instructional emphasis blurb). */
.worksheet-form-fields .field-help:not(.field-help-emphasis) {
    color: #9aa0a6;
}

.worksheet-form-fields .input-content label,
.worksheet-form-fields label:not(.sheet-react-check):not(.teacher-names-label),
body.pilot-page .worksheet-form-fields .input-content label {
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 600;
    line-height: 1.35;
}

.worksheet-form-fields .sheet-react-prompt {
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 400;
    line-height: 1.35;
}

.worksheet-form-fields .sheet-react-step-title {
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 600;
    line-height: 1.35;
}

.worksheet-form-fields .sheet-react-thanks-msg,
body.pilot-page .worksheet-form-fields .sheet-react-thanks-msg {
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-size: 1.35em;
    font-weight: 400;
    line-height: 1.25;
    color: #000;
}

.worksheet-form-fields .worksheet-preview-meta-sep {
    margin: 0 0.55em;
}

.worksheet-form-fields .field-help.field-help-emphasis {
    margin: 0;
}

.worksheet-form-fields .teacher-names-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: start;
}

.worksheet-form-fields .teacher-names-label {
    grid-column: 1;
    grid-row: 1;
    display: block;
    margin: 0;
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 600;
    color: #000;
}

.worksheet-form-fields .teacher-names-optional,
body.pilot-page .worksheet-form-fields .teacher-names-optional {
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 400;
}

.worksheet-form-fields #teacherNamesGroup textarea {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: var(--radius);
    font-size: 16px;
    font-family: var(--ui-font);
    box-sizing: border-box;
    resize: vertical;
    min-height: 140px;
    color: #000;
}

.worksheet-form-fields #teacherNamesGroup textarea:focus {
    outline: none;
    border-color: #3bb8b4;
}

/* Fox sits beside the textarea — ears align with the textarea top edge. */
.worksheet-form-fields .teacher-names-icon {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    justify-content: flex-start;
    margin: 0;
    gap: 3px;
}

/* Parent fox / turtle / bug — nudge down from vertical center. */
.worksheet-form-fields #parentName1Group .input-image,
.worksheet-form-fields #name2Group .input-image,
.worksheet-form-fields #name3Group .input-image {
    position: relative;
    top: 15px;
}

.worksheet-form-fields .input-group-no-icon .input-content {
    width: 100%;
}

.worksheet-form-fields .char-name-label.is-placeholder {
    color: #000;
    opacity: 1;
    font-weight: 600;
}

.worksheet-preview {
    --preview-inset-x: 16px;
    position: relative;
    text-align: left;
    margin: 0;
    width: 100%;
    max-width: 380px;
    justify-self: center;
}

/* Form header: title + tags. */
.form-header {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 4px;
}

.form-header-copy {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

/* ← All Worksheets — mobile above title; desktop in teal preview pane. */
.form-breadcrumb {
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 500;
    line-height: 1.3;
    color: var(--teal-dark, #185251);
    text-decoration: none;
    align-self: flex-start;
}

.form-breadcrumb:hover,
.form-breadcrumb:focus-visible {
    text-decoration: underline;
    color: #000;
}

.form-breadcrumb:focus-visible {
    outline: 2px solid var(--teal-dark, #185251);
    outline-offset: 2px;
}

.form-breadcrumb--desktop {
    display: none;
}

.form-header-copy .worksheet-preview-meta {
    padding-bottom: 0;
    margin-top: -5px; /* pull tags/downloads 5px closer to the title */
}

.worksheet-form-fields > .mode-switch {
    display: flex;
    width: 100%;
    max-width: none;
    margin: 8px 0 0; /* gap below toggle comes from .form-mode-blurb */
    box-sizing: border-box;
}

/* When the Add… blurb is hidden, keep space before the name fields. */
.worksheet-form-fields:has(#modeBlurb[hidden]) > .mode-switch {
    margin-bottom: 18px;
}

.worksheet-preview-panel {
    min-width: 0;
}

.preview-edit-link {
    display: none; /* mobile preview panel only */
}

.preview-download-slot {
    display: none;
}

.preview-download-slot .download-btn.worksheet-customize-btn {
    width: 100%;
    margin-top: 0;
}

/*
 * Mobile form view: form first with header thumb; Preview at form bottom.
 * Live PDF preview (+ Download) reveal below the form after Preview.
 */
@media (max-width: 859px) {
    /* Full white customize page — no teal gutter above/around the form. */
    body.pilot-page:has(.worksheet-form-layout) {
        background: #fff;
    }

    body.pilot-page:has(.worksheet-form-layout) .pilot-main {
        padding: 0;
        background: #fff;
    }

    body.pilot-page .container.worksheet-form-layout {
        width: 100%;
        max-width: none;
        margin: 0;
        gap: 0;
        display: flex;
        flex-direction: column;
    }

    .worksheet-form-fields {
        order: 1;
        position: relative;
        z-index: 2;
        margin: 0;
        width: 100%;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
        /* Match desktop form rail padding. */
        padding: 28px 28px 20px;
        background: #fff;
        box-sizing: border-box;
        min-height: calc(100vh - var(--chrome-height));
        min-height: calc(100dvh - var(--chrome-height));
    }

    .form-header {
        align-items: center;
        gap: 12px;
        margin: 0 0 12px;
    }

    .form-breadcrumb--mobile {
        display: inline-block;
        margin: 0 0 2px;
    }

    .form-breadcrumb--desktop {
        display: none;
    }

    .worksheet-form-fields .form-title-row {
        margin: 0 0 2px;
    }

    .worksheet-form-fields .worksheet-preview-meta {
        padding: 0;
    }

    .worksheet-form-fields > .mode-switch {
        width: 100%;
        max-width: none;
        margin: 4px 0 0;
    }

    .worksheet-form-fields:has(#modeBlurb[hidden]) > .mode-switch {
        margin-bottom: 18px;
    }

    .worksheet-form-fields > .mode-switch .mode-switch-btn {
        flex: 1 1 50%;
        padding: 7px 10px;
    }

    /* Preview only in the form; Download moves under the live preview. */
    .worksheet-form-fields .form-action-row {
        flex-direction: column;
        gap: 0;
        margin-top: 8px;
    }

    .worksheet-form-fields .download-btn.worksheet-preview-btn {
        flex: 1 1 auto;
        width: 100%;
    }

    .worksheet-form-fields .download-btn.worksheet-customize-btn {
        display: none;
    }

    .worksheet-preview-panel {
        order: 2;
        position: relative;
        display: none;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 12px;
        margin: 0;
        width: 100%;
        /* 30px around the stack; leave room at bottom for How was this worksheet? */
        padding: 24px 30px 20px;
        box-sizing: border-box;
        background: var(--teal-light, #62CECC);
        scroll-margin-top: var(--chrome-height);
        min-height: calc(100vh - var(--chrome-height));
        min-height: calc(100dvh - var(--chrome-height));
    }

    .container.worksheet-form-layout.is-mobile-preview-open .worksheet-preview-panel,
    .container.worksheet-form-layout.is-mobile-preview-loading .worksheet-preview-panel {
        display: flex;
        /* Definite height so the letter preview can flex-shrink on short/square screens. */
        height: calc(100vh - var(--chrome-height));
        height: calc(100dvh - var(--chrome-height));
        max-height: calc(100vh - var(--chrome-height));
        max-height: calc(100dvh - var(--chrome-height));
        overflow: hidden;
    }

    /* Edit + preview + download sit higher; feedback anchors to the bottom. */
    .preview-panel-stack {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 20px; /* space from preview image to Edit / Download */
        width: 100%;
        min-height: 0;
        padding-bottom: 8px;
        box-sizing: border-box;
        overflow: hidden;
    }

    .preview-sheet-react-slot {
        flex: 0 0 auto;
        width: 100%;
        /*
          Expanded/collapsing feedback is position:absolute (out of flow).
          Keep the collapsed strip’s height so Edit/preview/Download don’t reflow.
        */
        min-height: 90px;
    }

    .preview-sheet-react-slot:empty {
        display: none;
        min-height: 0;
    }

    .worksheet-preview-panel .sheet-react {
        margin: 0;
        padding: 8px 8px 0;
        background: transparent;
        width: 100%;
    }

    .worksheet-preview-panel .sheet-react-inner {
        max-width: none;
        padding: 2px 0 2px;
    }

    .worksheet-preview-panel .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react-thanks-msg,
    .worksheet-preview-panel .sheet-react-more-ideas,
    .worksheet-preview-panel .sheet-react-step-title,
    .worksheet-preview-panel .sheet-react-check {
        color: var(--teal-dark, #185251);
    }

    /* Expanded steps get a white card over the teal panel. */
    .worksheet-preview-panel .sheet-react.is-expanded,
    .worksheet-preview-panel .sheet-react.is-collapsing {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 28px 24px;
        z-index: 8;
        height: min(480px, 70vh, calc(100% - 16px));
        max-height: min(70vh, calc(100% - 16px));
        overflow: hidden;
        background: #fff;
        box-shadow: 0 -16px 32px rgba(0, 0, 0, 0.2);
        box-sizing: border-box;
    }

    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-step-title,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-check,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-thanks-msg,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-more-ideas {
        color: #000;
    }

    /* Mobile feedback lives on the teal pane — keep the same slide/fade as desktop. */
    .worksheet-preview-panel .sheet-react.is-expanded {
        animation: sheetReactSlideUp 260ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-thanks {
        animation: sheetReactContentIn 240ms ease-out 100ms both;
    }

    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-face.is-selected {
        animation: sheetReactFaceIn 400ms cubic-bezier(0.22, 0.82, 0.28, 1) 40ms both;
    }

    .worksheet-preview-panel .sheet-react.is-collapsing {
        animation: sheetReactSlideDown 180ms ease-out forwards;
        pointer-events: none;
        overflow: hidden;
    }

    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-face.is-selected {
        animation: sheetReactContentOut 100ms ease-out forwards;
    }

    .preview-edit-link {
        position: static;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 2px; /* icon tight to Edit */
        align-self: center;
        width: auto;
        margin: 0;
        padding: 0 0 1px;
        border: none;
        border-bottom: 1px solid currentColor; /* underline spans icon + text */
        background: transparent;
        color: var(--teal-dark, #185251);
        font-family: var(--ui-font);
        font-size: var(--chrome-text-size, 14px);
        font-weight: 500;
        line-height: 1.2;
        cursor: pointer;
        text-decoration: none;
        text-align: center;
    }

    .preview-edit-link:hover,
    .preview-edit-link:focus-visible {
        color: #0f3332;
    }

    .preview-edit-link:focus-visible {
        outline: 2px solid var(--teal-dark, #185251);
        outline-offset: 3px;
    }

    .preview-edit-icon {
        flex: 0 0 auto;
        display: block;
    }

    .worksheet-preview {
        --preview-inset-x: 0;
        /*
          % max-height fails when the parent height is content-sized (square/short phones).
          Cap with dvh (minus chrome, Edit, gaps, Download, feedback) and derive width
          from the letter aspect so the page never overflows the viewport.
        */
        --mobile-preview-max-h: calc(100dvh - var(--chrome-height) - 220px);
        flex: 1 1 auto;
        min-height: 0;
        width: min(72%, calc(var(--mobile-preview-max-h) * 8.5 / 11));
        max-width: 72%;
        max-height: var(--mobile-preview-max-h);
        justify-self: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .worksheet-preview-frame {
        margin: 0 auto;
        width: 100%;
        max-width: 100%;
        max-height: 100%;
        height: auto;
        aspect-ratio: 8.5 / 11;
    }

    .worksheet-preview-stage {
        margin: 0;
        width: 100%;
        height: auto;
        max-height: 100%;
        aspect-ratio: 8.5 / 11;
    }

    .worksheet-preview-stage > img,
    .worksheet-preview-stage .worksheet-preview-page {
        width: 100%;
        height: auto;
        max-height: 100%;
        aspect-ratio: 8.5 / 11;
        object-fit: contain;
    }

    .preview-page-toggle {
        justify-content: center;
        margin: 0;
        width: 100%;
        max-width: none;
    }

    .preview-download-slot {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 80%;
        max-width: none;
        margin-top: 0; /* spacing comes from .preview-panel-stack gap: 20px */
    }

    .preview-download-slot .download-btn.worksheet-customize-btn {
        /* Keep layout space while hidden so the stack doesn’t jump when ready. */
        display: inline-flex;
        width: 100%;
        max-width: 250px;
        flex: none;
        padding: 14px 16px;
        border: none;
        font-family: var(--ui-font);
        font-weight: 600;
        font-size: 17px;
        line-height: 1.2;
        border-radius: var(--radius);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.45s ease, visibility 0.45s ease;
    }

    /* Always reserve one line so show/hide doesn’t shift the stack. */
    .preview-download-slot .success {
        display: block !important;
        width: 100%;
        min-height: 1.35em;
        margin-top: 12px;
        padding: 0;
        box-sizing: border-box;
        text-align: center;
        font-family: var(--ui-font);
        font-size: var(--chrome-text-size, 14px);
        line-height: 1.35;
        color: var(--teal-dark, #185251);
        background: none;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.45s ease, visibility 0.45s ease;
    }

    .preview-download-slot .success.is-visible {
        opacity: 1;
        visibility: visible;
    }

    /* Fade in with the worksheet after live preview is ready. */
    .container.worksheet-form-layout.is-mobile-preview-open .preview-download-slot .download-btn.worksheet-customize-btn {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    @media (prefers-reduced-motion: reduce) {
        .preview-download-slot .download-btn.worksheet-customize-btn {
            transition: none;
        }
    }

    .worksheet-form-fields .sheet-react.is-expanded,
    .worksheet-form-fields .sheet-react.is-collapsing {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 36px;
        z-index: 8;
        height: min(480px, 70vh, calc(100% - 16px));
        max-height: min(70vh, calc(100% - 16px));
        overflow: hidden;
        background: #fff;
        box-shadow: 0 -16px 32px rgba(0, 0, 0, 0.2);
    }

    .worksheet-form-fields .sheet-react.is-expanded {
        animation: sheetReactSlideUp 260ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-thanks {
        animation: sheetReactContentIn 240ms ease-out 100ms both;
    }

    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-face.is-selected {
        animation: sheetReactFaceIn 400ms cubic-bezier(0.22, 0.82, 0.28, 1) 40ms both;
    }

    .worksheet-form-fields .sheet-react.is-collapsing {
        animation: sheetReactSlideDown 180ms ease-out forwards;
        pointer-events: none;
        overflow: hidden;
    }

    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-face.is-selected {
        animation: sheetReactContentOut 100ms ease-out forwards;
    }
}

.form-action-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 10px;
    margin-top: 4px;
}

.worksheet-form-fields .download-btn.worksheet-preview-btn,
.worksheet-form-fields .download-btn.worksheet-customize-btn {
    flex: 1 1 50%;
    width: auto;
    min-width: 0;
    margin-top: 0;
    padding: 14px 16px;
    border: none;
    font-family: var(--ui-font);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.2;
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.worksheet-form-fields .download-btn.worksheet-preview-btn {
    background: #fff;
    color: var(--teal, #247674);
    border: 2px solid var(--teal, #247674);
    box-shadow: none;
}

.worksheet-form-fields .download-btn.worksheet-preview-btn:hover {
    background: #f3fbfb;
    color: var(--teal-dark, #185251);
    border-color: var(--teal-dark, #185251);
    transform: translateY(-2px);
}

.worksheet-form-fields .download-btn.worksheet-customize-btn,
.preview-download-slot .download-btn.worksheet-customize-btn {
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--teal-light, #62CECC);
    color: #000;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn {
    display: inline-flex;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn .download-btn-icon,
.preview-download-slot .download-btn.worksheet-customize-btn .download-btn-icon {
    flex: 0 0 auto;
    display: block;
    width: 1.05em;
    height: 1.05em;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn .download-btn-spinner,
.preview-download-slot .download-btn.worksheet-customize-btn .download-btn-spinner {
    display: none;
    flex: 0 0 auto;
    width: 1.05em;
    height: 1.05em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: previewSpin 0.75s linear infinite;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn.is-downloading .download-btn-icon,
.preview-download-slot .download-btn.worksheet-customize-btn.is-downloading .download-btn-icon {
    display: none;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn.is-downloading .download-btn-spinner,
.preview-download-slot .download-btn.worksheet-customize-btn.is-downloading .download-btn-spinner {
    display: block;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn:hover {
    background: #4ebfbd;
    color: #000;
    transform: translateY(-2px);
}

.worksheet-form-fields .download-btn.worksheet-preview-btn:disabled,
.worksheet-form-fields .download-btn.worksheet-customize-btn:disabled,
.preview-download-slot .download-btn.worksheet-customize-btn:disabled {
    opacity: 0.6;
    transform: none;
    box-shadow: none;
    cursor: wait;
}

.worksheet-form-fields .download-btn.worksheet-preview-btn:disabled {
    background: #fff;
    color: #8a8a8f;
    border-color: #c5d4d3;
    opacity: 1;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn:disabled {
    background: var(--teal-light, #62CECC);
    color: #000;
}

.worksheet-form-fields .download-btn.worksheet-customize-btn.is-downloading,
.preview-download-slot .download-btn.worksheet-customize-btn.is-downloading {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
}

/* Mobile Preview = same plain/hover/disabled as desktop Download PDF!. */
@media (max-width: 859px) {
    .worksheet-form-fields .download-btn.worksheet-preview-btn {
        background: var(--teal-light, #62CECC);
        color: #000;
        border: none;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    }

    .worksheet-form-fields .download-btn.worksheet-preview-btn:hover {
        background: #4ebfbd;
        color: #000;
        border: none;
        transform: translateY(-2px);
    }

    .worksheet-form-fields .download-btn.worksheet-preview-btn:disabled {
        background: #b7e4e3;
        color: #5f7a79;
        border: none;
        box-shadow: none;
        transform: none;
    }

    /* After shared customize-btn rules so dark teal wins over light teal. */
    .preview-download-slot .download-btn.worksheet-customize-btn {
        display: inline-flex;
        background: var(--teal-dark, #185251);
        color: #fff;
        /* Stay invisible until .is-mobile-preview-open (opacity set above). */
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .container.worksheet-form-layout.is-mobile-preview-open .preview-download-slot .download-btn.worksheet-customize-btn {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 0.45s ease, visibility 0.45s ease;
    }

    .container.worksheet-form-layout.is-mobile-preview-open .preview-download-slot .download-btn.worksheet-customize-btn:hover {
        background: #134140;
        color: #fff;
        transform: translateY(-2px);
    }

    .container.worksheet-form-layout.is-mobile-preview-open .preview-download-slot .download-btn.worksheet-customize-btn:disabled,
    .container.worksheet-form-layout.is-mobile-preview-open .preview-download-slot .download-btn.worksheet-customize-btn.is-downloading {
        background: var(--teal-dark, #185251);
        color: #fff;
        opacity: 0.55;
        cursor: wait;
        transform: none;
        box-shadow: none;
        pointer-events: none;
    }
}

.worksheet-preview-frame {
    position: relative;
    display: block;
    width: auto;
    margin: 0 var(--preview-inset-x);
    aspect-ratio: 8.5 / 11;
}

.preview-loader {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--page-stack-shadow, 0 3px 10px rgba(0, 0, 0, 0.22));
    pointer-events: none;
}

.preview-loader[hidden] {
    display: none !important;
}

.preview-spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(36, 118, 116, 0.22);
    border-top-color: var(--teal, #247674);
    border-radius: 50%;
    animation: previewSpin 0.75s linear infinite;
}

.preview-loader-text {
    font-family: var(--ui-font);
    font-size: var(--chrome-text-size, 14px);
    font-weight: 500;
    color: var(--teal-dark, #185251);
}

@keyframes previewSpin {
    to { transform: rotate(360deg); }
}

.worksheet-preview .worksheet-preview-stage,
.worksheet-preview .preview-page-toggle {
    opacity: 1;
    transition: opacity 0.45s ease;
}

.worksheet-preview.is-generating-preview .worksheet-preview-stage,
.worksheet-preview.is-generating-preview .preview-page-toggle {
    /* Fade out/in instead of a visibility blink. */
    opacity: 0;
    pointer-events: none;
}

.worksheet-preview-stage {
    /* Same L/R inset as gallery thumbs so title lines up with the page edge. */
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    aspect-ratio: 8.5 / 11;
}

.worksheet-preview-stage.is-page-clickable {
    cursor: pointer;
}

.worksheet-preview-stage.is-page-clickable:focus-visible {
    outline: 2px solid var(--teal, #247674);
    outline-offset: 3px;
}

.worksheet-preview-stage img.preview-fade-in {
    /* No fill-mode:both — that can lock opacity:1 and block page stacking. */
    animation: previewFadeIn 0.45s ease;
}

@keyframes previewFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .preview-spinner {
        animation: none;
        border-top-color: var(--teal, #247674);
        opacity: 0.85;
    }

    .worksheet-preview .worksheet-preview-stage,
    .worksheet-preview .preview-page-toggle {
        transition: none;
    }

    .worksheet-preview-stage img.preview-fade-in {
        animation: none;
    }
}

.worksheet-preview-stage > img,
.worksheet-preview-stage .worksheet-preview-page {
    width: 100%;
    height: auto;
    aspect-ratio: 8.5 / 11;
    object-fit: contain;
    image-rendering: auto;
    background: #fff;
    border-radius: 0;
    border: none;
    box-shadow: var(--page-stack-shadow, 0 3px 10px rgba(0, 0, 0, 0.22));
    display: block;
}

.worksheet-preview-stage:not(.has-pages) img {
    position: relative;
}

/* White front plate so page fades stay opaque white (tilted peek stays behind/beside). */
.worksheet-preview-stage.has-pages::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    background: #fff;
    box-shadow: var(--page-stack-shadow, 0 3px 10px rgba(0, 0, 0, 0.22));
    pointer-events: none;
}

.worksheet-preview-stage.has-pages .worksheet-preview-page {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translate(0, 0) rotate(0deg);
    /* Keep visibility visible so opacity can crossfade (no hard cut). */
    visibility: visible;
    /* Opacity only — tilted back page stays put; no rotate/slide tween on swap. */
    transition: opacity 0.48s ease-in-out;
    /* Images sit above the white plate; plate carries the shared page shadow. */
    box-shadow: none;
}

.worksheet-preview-stage.has-pages .worksheet-preview-page[data-stack="front"] {
    z-index: 3;
    opacity: 1;
    pointer-events: auto;
    transform: translate(0, 0) rotate(0deg);
}

.worksheet-preview-stage.has-pages .worksheet-preview-page[data-stack="back"] {
    z-index: 1;
    opacity: 1;
    pointer-events: none;
    /* Same peek + tilt as gallery thumbs. */
    transform: translate(-7px, -5px) rotate(-4deg);
    box-shadow: var(--page-stack-shadow, 0 3px 10px rgba(0, 0, 0, 0.22));
}

.worksheet-preview-stage.has-pages .worksheet-preview-page[data-stack="hidden"] {
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transform: translate(0, 0) rotate(0deg);
}

@media (prefers-reduced-motion: reduce) {
    .worksheet-preview-stage.has-pages .worksheet-preview-page {
        transition: none;
    }
}

.preview-page-toggle {
    position: relative;
    z-index: 6; /* above mobile form overlap so page picks stay clickable */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    min-height: 44px;
    pointer-events: auto;
}

.preview-page-toggle[hidden] {
    display: none !important;
}

.preview-page-thumb {
    appearance: none;
    flex: 0 0 auto;
    display: block;
    width: 34px;
    height: auto;
    aspect-ratio: 8.5 / 11;
    padding: 0;
    margin: 0;
    border: 2px solid rgba(36, 118, 116, 0.35);
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    overflow: hidden;
    line-height: 0;
}

.preview-page-thumb img {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: cover;
    display: block;
    pointer-events: none;
    box-shadow: none;
    border: none;
    background: #fff;
}

.preview-page-thumb:hover,
.preview-page-thumb:focus-visible {
    border-color: #247674;
    outline: none;
    transform: translateY(-1px);
}

.preview-page-thumb.is-active {
    border-color: #247674;
    box-shadow: 0 0 0 2px rgba(36, 118, 116, 0.28), 0 1px 4px rgba(0, 0, 0, 0.18);
}

.form-title-row {
    --form-title-size: clamp(22px, 2.4vw + 12px, 28px);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0 0 2px;
}

.form-title-row .worksheet-preview-title {
    margin: 0;
    padding: 0;
    flex: 0 1 auto;
    min-width: 0;
    font-size: var(--form-title-size);
    line-height: 1.2;
}

/* Light-teal burst badge — appears beside the title after a successful download.
   Clickable: re-downloads with whatever settings are currently in the form. */
.form-downloaded-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin: -3px 0 0;
    padding: 0;
    border: none;
    color: var(--teal-dark, #185251);
    background: var(--teal-light, #62CECC);
    /* Rounded burst / wiggly badge */
    border-radius: 1.9em 1.35em 1.75em 1.45em / 1.25em 1.85em 1.15em 1.7em;
    cursor: pointer;
    transform: rotate(-8deg) scale(1);
    transition: transform 180ms ease, filter 180ms ease;
}

.form-downloaded-badge:hover:not(:disabled),
.form-downloaded-badge:focus-visible:not(:disabled) {
    filter: brightness(1.05);
    transform: rotate(10deg) scale(1.14);
}

.form-downloaded-badge:disabled {
    cursor: wait;
    opacity: 0.7;
}

.form-downloaded-badge:focus-visible {
    outline: 2px solid var(--teal-dark, #185251);
    outline-offset: 2px;
}

.form-downloaded-badge[hidden] {
    display: none !important;
}

.form-downloaded-badge svg {
    width: 18px;
    height: 18px;
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .form-downloaded-badge {
        transition: none;
    }

    .form-downloaded-badge:hover:not(:disabled),
    .form-downloaded-badge:focus-visible:not(:disabled) {
        transform: rotate(-8deg) scale(1);
    }
}

.worksheet-preview-title {
    margin: 8px 0 2px;
    padding: 0 var(--preview-inset-x);
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
    font-size: clamp(22px, 2.4vw + 12px, 28px);
    line-height: 1.2;
    color: #185251;
    text-align: left;
}

.worksheet-preview-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0;
    padding: 0 var(--preview-inset-x) 4px;
    font-family: var(--ui-font);
    font-size: var(--chrome-text-size);
    font-weight: 500;
    color: #247674;
    text-align: left;
}

.worksheet-preview-downloads {
    opacity: 1;
}

/* Desktop: full-bleed split pane — teal preview left (centered), form rail right.
   Placed after base preview rules so width/max-width overrides win. */
@media (min-width: 860px) {
    body.pilot-page:has(.worksheet-form-layout) .pilot-main {
        padding: 0;
    }

    body.pilot-page .container.worksheet-form-layout {
        width: 100%;
        max-width: none;
        margin: 0;
        min-height: calc(100vh - var(--chrome-height));
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 450px);
        grid-template-areas: "preview form";
        gap: 0;
        align-items: stretch;
    }

    .preview-edit-link {
        display: none !important;
    }

    .preview-download-slot {
        display: none !important;
    }

    .worksheet-preview-panel {
        --preview-thumbs-h: 56px;
        --preview-react-h: 0px; /* feedback lives in the form sidebar on desktop */
        --preview-area-h: calc(100vh - var(--chrome-height) - 56px - var(--preview-thumbs-h) - var(--preview-react-h));
        grid-area: preview;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        min-width: 0;
        min-height: 0;
        padding: 32px 40px 16px;
        box-sizing: border-box;
        background: transparent;
        position: sticky;
        top: var(--chrome-height);
        height: calc(100vh - var(--chrome-height));
        max-height: calc(100vh - var(--chrome-height));
        overflow: visible;
    }

    .form-breadcrumb--mobile {
        display: none;
    }

    .form-breadcrumb--desktop {
        display: inline-block;
        align-self: flex-start;
        flex: 0 0 auto;
        margin: 0 0 4px;
    }

    .preview-panel-stack {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        min-height: 0;
    }

    .preview-sheet-react-slot {
        display: none !important;
    }

    .worksheet-preview {
        justify-self: stretch;
        align-self: stretch;
        max-width: none;
        width: 100%;
        min-height: 0;
        height: auto;
        max-height: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 0;
        position: static;
        overflow: visible;
        box-sizing: border-box;
    }

    .worksheet-preview-frame {
        /* Cap by width (660) and by 90% of the left-pane area so short windows fit. */
        width: min(660px, 100%, calc(var(--preview-area-h) * 0.9 * 8.5 / 11));
        max-height: calc(var(--preview-area-h) * 0.9);
        height: auto;
        aspect-ratio: 8.5 / 11;
        margin: 0 auto;
        flex: 0 1 auto;
    }

    .worksheet-preview-stage {
        width: 100%;
        height: 100%;
        margin: 0;
        aspect-ratio: auto;
    }

    .worksheet-preview-stage > img,
    .worksheet-preview-stage .worksheet-preview-page {
        width: 100%;
        height: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .preview-page-toggle {
        width: 100%;
        max-width: 660px;
        align-self: center;
        justify-content: center;
        box-sizing: border-box;
        flex: 0 0 auto;
        margin: 0;
    }

    /* How was this worksheet? under the preview in the teal pane. */
    .worksheet-preview-panel .sheet-react {
        width: 100%;
        margin: 0;
        padding: 8px 8px 4px;
        background: transparent;
        border-radius: 0;
    }

    .worksheet-preview-panel .sheet-react-inner {
        max-width: none;
        padding: 4px 0 8px;
    }

    .worksheet-preview-panel .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react-thanks-msg,
    .worksheet-preview-panel .sheet-react-more-ideas,
    .worksheet-preview-panel .sheet-react-step-title,
    .worksheet-preview-panel .sheet-react-check {
        color: var(--teal-dark, #185251);
    }

    .worksheet-preview-panel .sheet-react.is-expanded,
    .worksheet-preview-panel .sheet-react.is-collapsing {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 40px;
        z-index: 8;
        height: min(520px, 72vh, calc(100% - 24px));
        max-height: min(72vh, calc(100% - 24px));
        overflow: hidden;
        background: #fff;
        box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.22);
        box-sizing: border-box;
    }

    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-step-title,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-check,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-thanks-msg,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-more-ideas {
        color: #000;
    }

    .worksheet-form-fields {
        grid-area: form;
        max-width: 450px;
        width: 100%;
        justify-self: stretch;
        border-radius: 0;
        box-shadow: -10px 0 28px rgba(0, 0, 0, 0.12);
        min-height: calc(100vh - var(--chrome-height));
        max-height: calc(100vh - var(--chrome-height));
        position: sticky;
        top: var(--chrome-height);
        overflow-y: auto;
        padding: 28px 28px 20px;
        display: flex;
        flex-direction: column;
    }

    /* Pin How was this worksheet? to the bottom of the sidebar. */
    .worksheet-form-fields > .sheet-react {
        margin-top: auto;
        margin-bottom: 0;
    }

    .worksheet-form-fields > .sheet-react .sheet-react-inner {
        padding-bottom: 4px;
    }

    .worksheet-form-fields .form-title-row {
        margin: 0 0 2px;
    }

    .worksheet-form-fields .worksheet-preview-title {
        font-size: clamp(22px, 2vw + 14px, 28px);
    }

    .worksheet-form-fields .form-header {
        margin: 0 0 14px;
    }

    .worksheet-form-fields .worksheet-preview-meta {
        padding: 0;
    }

    /*
     * Desktop feedback is in the form sidebar (not the teal pane).
     * Expanded overlay + slide/fade must target .worksheet-form-fields.
     */
    .worksheet-form-fields .sheet-react.is-expanded,
    .worksheet-form-fields .sheet-react.is-collapsing {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin: 0;
        padding: 40px;
        z-index: 8;
        height: min(520px, 72vh, calc(100% - 24px));
        max-height: min(72vh, calc(100% - 24px));
        overflow: hidden;
        background: #fff;
        box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.22);
        box-sizing: border-box;
    }

    .worksheet-form-fields .sheet-react.is-expanded,
    .worksheet-preview-panel .sheet-react.is-expanded {
        animation: sheetReactSlideUp 520ms cubic-bezier(0.22, 0.82, 0.28, 1);
    }

    /* Text/UI after the white panel starts coming in (face fades/grows on its own, last). */
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-thanks,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-thanks {
        animation: sheetReactContentIn 340ms ease-out 160ms both;
    }

    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-face.is-selected,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-face.is-selected {
        animation: sheetReactFaceIn 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms both;
    }

    .worksheet-form-fields .sheet-react.is-collapsing,
    .worksheet-preview-panel .sheet-react.is-collapsing {
        /* Duration/distance halved; text and bg leave nearly together. */
        animation: sheetReactSlideDown 220ms ease-out forwards;
        pointer-events: none;
        overflow: hidden;
    }

    /* Brief head start only — keep text→bg gap tight. */
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-face.is-selected,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-face.is-selected {
        animation: sheetReactContentOut 120ms ease-out forwards;
    }
}

@keyframes sheetReactSlideUp {
    from {
        transform: translateY(28px);
        opacity: 0.7;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes sheetReactSlideDown {
    0% {
        transform: translateY(0);
        opacity: 1;
        box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.22);
    }
    /* Keep the drop shadow a beat longer than the start of the slide/fade. */
    45% {
        box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.18);
    }
    100% {
        transform: translateY(48px); /* was 96px — halved */
        opacity: 0;
        box-shadow: 0 -8px 16px rgba(0, 0, 0, 0);
    }
}

@keyframes sheetReactContentIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sheetReactFaceIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes sheetReactContentOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .worksheet-form-fields .sheet-react.is-expanded,
    .worksheet-form-fields .sheet-react.is-collapsing,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-thanks,
    .worksheet-form-fields .sheet-react.is-expanded .sheet-react-face.is-selected,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-form-fields .sheet-react.is-collapsing .sheet-react-face.is-selected,
    .worksheet-preview-panel .sheet-react.is-expanded,
    .worksheet-preview-panel .sheet-react.is-collapsing,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-thanks,
    .worksheet-preview-panel .sheet-react.is-expanded .sheet-react-face.is-selected,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-prompt,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-step,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-bubble,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-close,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-thanks,
    .worksheet-preview-panel .sheet-react.is-collapsing .sheet-react-face.is-selected {
        animation: none;
    }
}

/* Preview sample captions omitted — thumbs speak for themselves. */

.page-description {
    text-align: center;
    color: #222;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    margin-top: 8px;
}

.field-help {
    margin-top: 6px;
    font-size: var(--chrome-text-size, 14px);
    font-weight: 400; /* slightly lighter than previous 500 */
    line-height: 1.35;
}

.input-content textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    font-size: 16px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    box-sizing: border-box;
    resize: vertical;
    min-height: 140px;
}

.input-content textarea:focus {
    outline: none;
    border-color: #3bb8b4;
}

.post-download-note {
    position: relative;
    margin-top: 16px;
    padding: 12px 36px 12px 14px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 3px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
    color: #185251;
    font-size: 0.95em;
}

.note-dismiss {
    position: absolute;
    right: 8px;
    top: 8px;
    border: none;
    background: transparent;
    font-size: 1.4em;
    cursor: pointer;
    color: #185251;
}

.simple-form-page {
    max-width: 480px;
    margin: 40px auto;
    padding: 24px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 3px;
    font-family: 'Balsamiq Sans', Arial, sans-serif;
}

.simple-form-page label {
    display: block;
    margin: 12px 0 4px;
    color: #222;
}

.simple-form-page input,
.simple-form-page textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 16px;
}

.simple-form-page button {
    margin-top: 16px;
    width: 100%;
}

/* ==========================================================================
   Classroom pilot site chrome (nav / footer / UI font)
   Scoped to body.pilot-page so legacy pack pdf-personalizer pages are untouched.
   UI font only — PDF drawing fonts (Balsamiq / Doodlipoop TTFs) live in JS.
   Google Sans is not freely licensed: stack prefers it if installed, then
   Product Sans, then DM Sans (loaded from Google Fonts in each page <head>).
   ========================================================================== */
:root {
    --ui-font: "Google Sans", "Product Sans", "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --chrome-height: 68px;
    --ink: #202124;
    --ink-soft: #5f6368;
    --teal-dark: #185251;
    --teal: #247674;
    --teal-light: #62CECC;
    /* Shared size: filter chips, gallery skill tags, mode toggle, nav links */
    --chrome-text-size: 14px;
    /* Shared content column — nav bug, filters, and thumb images share this left edge */
    --content-max: 1400px;
    --content-inline: 20px;
    /* Radius system: one outer + one nested. Exceptions: wiggly chips/badge,
       round face buttons (50%), form preview pages (0), confetti. */
    --radius: 6px;
    --radius-inner: 4px;
}

body.pilot-page {
    font-family: var(--ui-font);
    background: #62CECC;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Clear fixed nav */
    padding: var(--chrome-height) 0 0;
}

/* One UI font everywhere on pilot pages (nav, gallery chrome, forms, about). */
body.pilot-page,
body.pilot-page * {
    font-family: var(--ui-font);
}

/* Neutralise legacy header bug decorations / hidden-span title trick on pilot pages. */
body.pilot-page h1::before,
body.pilot-page h1::after {
    content: none !important;
    display: none !important;
}

body.pilot-page h1 span {
    opacity: 1;
    height: auto;
    overflow: visible;
    display: inline;
    font-size: inherit;
    line-height: inherit;
}

.pilot-main {
    flex: 1 0 auto;
    width: 100%;
    padding: 28px 0 48px;
}

/* Content / form pages own their inset — don’t double up with .pilot-main. */
body.pilot-page:has(.content-page) .pilot-main,
body.pilot-page:has(.simple-form-page) .pilot-main {
    padding: 0;
}

/* —— Top nav —— */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    flex: 0 0 var(--chrome-height);
    height: var(--chrome-height);
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.site-nav-inner {
    height: 100%;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 var(--content-inline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-sizing: border-box;
}

.site-nav-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    margin-right: auto; /* push mode switch + links to the right */
    color: var(--ink);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.15;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.site-nav-logo-text {
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

/* Display face for brand + titles (overrides pilot * rule — text often lives in a child span). */
body.pilot-page .site-nav-logo-name,
body.pilot-page .site-nav-logo-sub,
body.pilot-page .worksheet-card-title,
body.pilot-page .worksheet-preview-title,
body.pilot-page .worksheet-card-cta,
body.pilot-page .sheet-react-bubble,
body.pilot-page .sheet-react-bubble-label {
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
}

.site-nav-logo-name {
    font-size: 1em;
    line-height: 1.1;
}

/* Pilot badge — light teal wiggly pill, sits to the right of the title. */
.site-nav-logo-sub {
    display: inline-block;
    margin: 0;
    padding: 3px 10px;
    color: var(--teal-dark);
    background: var(--teal-light);
    font-size: 11px; /* desktop — slightly roomier than mobile/tablet */
    letter-spacing: 0.05em;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: nowrap;
    border-radius: 2.4em 1.7em 2.2em 1.8em / 1.35em 2.7em 1.25em 2.55em;
}

/* Header bug mark: purple title-bug.png (bug only), ~10% larger,
   3° two-step wiggle via navBugWiggle (off under prefers-reduced-motion). */
.site-nav-logo-bug {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 50px;
    overflow: visible;
    animation: navBugWiggle 1400ms steps(2) infinite;
}

.site-nav-logo-bug img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: none;
}

@keyframes navBugWiggle {
    0%, 49.99% { transform: rotate(0deg); }
    50%, 100% { transform: rotate(3deg); }
}

@media (prefers-reduced-motion: reduce) {
    .site-nav-logo-bug {
        animation: none;
    }
}

.site-nav-logo:hover .site-nav-logo-name {
    color: var(--teal);
}

/* iOS-style segmented control: grey inset track + sliding white thumb (::before).
   Gallery: in the nav. Worksheet form: top of the white form panel (where mode changes the fields). */
.site-nav .mode-switch,
.worksheet-form-fields .mode-switch {
    --thumb-x: 3px;
    --thumb-w: 0px;
    position: relative;
    flex: 0 0 auto;
    display: inline-flex;
    padding: 3px;
    gap: 0;
    border-radius: var(--radius);
    background: #e3e3e8;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.18),
        inset 0 0 0 0.5px rgba(0, 0, 0, 0.06),
        0 1px 0 rgba(255, 255, 255, 0.9);
}

.site-nav .mode-switch {
    margin: 0 8px 0 0; /* immediately left of Worksheets / About */
}

.worksheet-form-fields .mode-switch {
    display: flex;
    width: 100%;
    margin: 8px 0 0;
}

.site-nav .mode-switch::before,
.worksheet-form-fields .mode-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 0;
    z-index: 0;
    width: var(--thumb-w);
    height: calc(100% - 6px);
    border-radius: var(--radius-inner);
    background: #fff;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.12),
        0 3px 1px rgba(0, 0, 0, 0.04),
        0 0 0 0.5px rgba(0, 0, 0, 0.04);
    transform: translateX(var(--thumb-x));
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.site-nav .mode-switch-btn,
.worksheet-form-fields .mode-switch-btn {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    min-height: 30px;
    padding: 5px 14px;
    border-radius: var(--radius-inner);
    background: transparent;
    color: #3c3c43;
    font-size: var(--chrome-text-size);
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.worksheet-form-fields .mode-switch-btn {
    flex: 1 1 50%;
    min-width: 0;
    min-height: 34px;
    padding: 7px 16px;
    color: #000;
    font-size: 16px; /* match inputs / mode blurb */
}

.site-nav .mode-switch-btn.is-active,
.worksheet-form-fields .mode-switch-btn.is-active {
    background: transparent;
    color: #000;
    font-weight: 600;
    box-shadow: none;
}

.site-nav .mode-switch-btn:not(.is-active):hover,
.worksheet-form-fields .mode-switch-btn:not(.is-active):hover {
    background: rgba(255, 255, 255, 0.45);
}

@media (prefers-reduced-motion: reduce) {
    .site-nav .mode-switch::before,
    .worksheet-form-fields .mode-switch::before {
        transition: none;
    }
}

.site-nav .mode-switch-btn:focus-visible,
.worksheet-form-fields .mode-switch-btn:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

.site-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    list-style: none;
}

.site-nav-link,
.site-nav-dropdown-toggle {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-inner);
    background: transparent;
    color: var(--ink);
    font-size: var(--chrome-text-size);
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.site-nav-link:hover,
.site-nav-dropdown-toggle:hover,
.site-nav-dropdown-toggle[aria-expanded="true"] {
    background: #f1f3f4;
}

.site-nav-link[aria-current="page"],
.site-nav-dropdown-toggle.is-current {
    color: var(--teal);
    font-weight: 700;
}

.site-nav-link:focus-visible,
.site-nav-dropdown-toggle:focus-visible,
.site-nav-menu a:focus-visible,
.site-nav-logo:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.site-nav-dropdown {
    position: relative;
}

/* Hamburger: three bars (no caret). */
.site-nav-hamburger-btn {
    width: 40px;
    min-width: 40px;
    padding: 8px;
    justify-content: center;
}

.site-nav-hamburger-btn::after {
    content: none !important;
    display: none !important;
}

.site-nav-hamburger-bars,
.site-nav-hamburger-bars::before,
.site-nav-hamburger-bars::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.site-nav-hamburger-bars {
    position: relative;
}

.site-nav-hamburger-bars::before,
.site-nav-hamburger-bars::after {
    content: '';
    position: absolute;
    left: 0;
}

.site-nav-hamburger-bars::before {
    top: -6px;
}

.site-nav-hamburger-bars::after {
    top: 6px;
}

.site-nav-hamburger-btn[aria-expanded="true"] .site-nav-hamburger-bars {
    background: transparent;
}

.site-nav-hamburger-btn[aria-expanded="true"] .site-nav-hamburger-bars::before {
    top: 0;
    transform: rotate(45deg);
}

.site-nav-hamburger-btn[aria-expanded="true"] .site-nav-hamburger-bars::after {
    top: 0;
    transform: rotate(-45deg);
}

.site-nav-hamburger-bars,
.site-nav-hamburger-bars::before,
.site-nav-hamburger-bars::after {
    transition: transform 0.18s ease, top 0.18s ease, background 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
    .site-nav-hamburger-bars,
    .site-nav-hamburger-bars::before,
    .site-nav-hamburger-bars::after {
        transition: none;
    }
}

.site-nav-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 230px;
    padding: 6px 0;
    list-style: none;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 60;
}

/* Invisible hover bridge under the hamburger. */
.site-nav-menu::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 10px;
}

.site-nav-menu[hidden] {
    display: none;
}

.site-nav-menu a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 18px;
    color: var(--ink);
    font-size: 1.1em; /* match “How was this worksheet?” / form labels */
    font-weight: 500;
    text-decoration: none;
}

.site-nav-menu a:hover {
    background: #f1f3f4;
}

.site-nav-menu a[aria-current="page"] {
    color: var(--teal);
    font-weight: 700;
}

/* Tablet: slightly smaller title so hamburger still fits; keep badge readable. */
@media (max-width: 900px) {
    .site-nav-logo {
        font-size: 20px;
    }
    .site-nav-logo-sub {
        font-size: 10px;
        letter-spacing: 0.02em;
        padding: 3px 8px;
    }
}

/* Narrow: keep “Cute & Quirky…”, drop the Classroom Pilot badge beneath it. */
@media (max-width: 760px) {
    :root {
        --chrome-height: 74px; /* room for title + badge stack */
    }
    .site-nav-logo {
        flex: 0 1 auto;
        min-width: 0;
        gap: 8px;
    }
    .site-nav-logo-text {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 2px;
        min-width: 0;
    }
    .site-nav-logo-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
    .site-nav-logo-sub {
        /* Keep badge text readable; tighten padding instead of shrinking type. */
        font-size: 10px;
        padding: 1px 6px;
        line-height: 1.2;
    }
}

/* Phone: tighter gallery gutter + short mode labels ("Teachers" / "Parents").
   Content / form pages keep 25px sides (title spacing overrides live after .content-page). */
@media (max-width: 640px) {
    :root {
        --content-inline: 10px;
    }
    body.pilot-page:has(.content-page),
    body.pilot-page:has(.simple-form-page) {
        --content-inline: 25px;
    }
    .site-nav-inner {
        gap: 4px;
    }
    .site-nav-logo {
        flex: 0 0 auto;
        margin-right: auto;
    }
    .site-nav-link,
    .site-nav-dropdown-toggle {
        padding: 8px 6px;
        gap: 4px;
        font-size: var(--chrome-text-size);
    }
    .site-nav .mode-switch {
        margin: 0 4px 0 0;
        padding: 3px;
    }
    .site-nav .mode-switch-btn {
        min-height: 34px;
        padding: 6px;
        font-size: var(--chrome-text-size);
    }
    .site-nav .mode-word {
        display: none;
    }
}

/* Very narrow phones (~320px): tighten further. */
@media (max-width: 360px) {
    .site-nav-link,
    .site-nav-dropdown-toggle {
        padding: 8px 4px;
    }
    .site-nav .mode-switch-btn {
        padding: 6px 5px;
    }
}

/* —— Page intro (gallery + worksheet form), below the nav —— */
.pilot-intro {
    max-width: 720px;
    margin: 0 auto 20px;
    padding: 0 16px;
    text-align: center;
}

.pilot-intro h1 {
    margin: 0;
    padding: 0;
    min-height: 0;
    background: none;
    color: var(--teal-dark);
    font-size: clamp(22px, 2.4vw + 12px, 32px);
    font-weight: 700;
    line-height: 1.2;
    text-wrap: balance;
    overflow-wrap: break-word;
}

.pilot-intro .page-description {
    margin-top: 6px;
    color: var(--teal-dark);
    font-size: 15px;
}

body.pilot-page .worksheet-preview-title {
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
}

body.pilot-page .worksheet-form-fields .worksheet-preview-title {
    color: #000;
}

body.pilot-page .container.worksheet-form-layout {
    width: min(980px, calc(100% - (var(--content-inline) * 2)));
}

/* Mobile customize: full-bleed width (don’t leave a content-inline gap on the right). */
@media (max-width: 859px) {
    body.pilot-page .container.worksheet-form-layout {
        width: 100%;
        max-width: none;
        margin: 0;
    }
}

@media (min-width: 860px) {
    body.pilot-page .container.worksheet-form-layout {
        width: 100%;
    }
}

/* —— Simple pages: feedback, email signup, about, terms —— */
/* Pilot radius: one token for panels/inputs/buttons; nested controls use --radius-inner.
   Keep wiggly chips/badge, round faces, and square form preview pages as exceptions. */
body.pilot-page select,
body.pilot-page input[type="text"],
body.pilot-page input[type="email"],
body.pilot-page .input-content input,
body.pilot-page .input-content textarea,
body.pilot-page #teacherNamesGroup textarea,
body.pilot-page .download-btn,
body.pilot-page .post-download-note,
body.pilot-page .simple-form-page input,
body.pilot-page .simple-form-page textarea,
body.pilot-page .simple-form-page .download-btn,
body.pilot-page .sheet-react-inline-note,
body.pilot-page .sheet-react-submit {
    border-radius: var(--radius);
}

body.pilot-page .worksheet-preview-stage img {
    border-radius: 0;
}

/* Full white page (not a floating card on teal). */
body.pilot-page:has(.content-page),
body.pilot-page:has(.simple-form-page) {
    background: #fff;
}

body.pilot-page .simple-form-page,
.content-page {
    width: 100%;
    margin: 0 auto;
    padding: 72px var(--content-inline) 72px; /* match top/bottom air around letter */
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    color: var(--ink);
    box-sizing: border-box;
}

.content-page,
body.pilot-page .simple-form-page {
    max-width: 800px;
}

.content-page {
    line-height: 1.55;
}

.content-page h1,
body.pilot-page .simple-form-page h1 {
    margin: 0 0 16px;
    color: var(--ink);
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-size: 32px; /* desktop — scaled with 16px body */
    font-weight: 400;
    line-height: 1.15;
    text-align: left;
}

@media (max-width: 900px) {
    .content-page h1,
    body.pilot-page .simple-form-page h1 {
        font-size: 28px; /* midsize */
    }
}

/* About figures: flush with text by default; more air above/below.
   Side bleed only on wide viewports. Height caps at 500px / 72vw. */
#aboutPage .about-inline-figure {
    margin: 2.4em 0 2.6em;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

#aboutPage .about-inline-figure img,
#aboutPage .about-inline-placeholder {
    display: block;
    width: 100%;
    height: min(500px, 72vw);
    object-fit: cover;
}

#aboutPage .about-inline-placeholder {
    background: #d8d8d8;
}

@media (min-width: 1101px) {
    /* Poke 50px past each side of the text column. */
    #aboutPage .about-inline-figure {
        width: calc(100% + 100px);
        margin-left: -50px;
        margin-right: -50px;
    }
}

/* Closing CTAs sit in the wider letter column; signature is Kelli alone. */
#aboutPage #aboutNotes p:nth-last-of-type(1) {
    /* “Kelli” — sit closer under the letter body */
    margin-top: 0.75em;
    margin-bottom: 0;
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-weight: 400;
    font-size: 24px;
    color: #000;
    line-height: 1.15;
}

#aboutPage #aboutNotes a.about-instagram,
body.pilot-page #aboutPage #aboutNotes a.about-instagram {
    color: #000;
    font-family: inherit;
    font-weight: inherit;
    text-decoration: none;
}

#aboutPage #aboutNotes a.about-instagram:hover,
body.pilot-page #aboutPage #aboutNotes a.about-instagram:hover {
    color: var(--teal, #247674);
    text-decoration: none;
}

.content-page h2 {
    margin: 24px 0 8px;
    color: var(--teal-dark);
    font-size: 18px;
    font-weight: 700;
}

.content-page p,
.content-page li {
    font-size: 16px; /* match customize form mode blurb */
}

.content-page p + p {
    margin-top: 0.9em;
}

.content-page ul {
    margin: 0.5em 0 0 1.25em;
}

.content-page a,
body.pilot-page .simple-form-page a {
    color: var(--teal);
    text-decoration: underline;
}

.content-page .content-note {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e1e5e9;
    color: var(--ink-soft);
    font-size: 14px;
}

/* Match customize-form type; even field-block rhythm (24px between blocks, 8px label→control). */
body.pilot-page .simple-form-page > p {
    margin: 0 0 24px;
    font-family: var(--ui-font);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--ink);
}

body.pilot-page .simple-form-page label:not(.feedback-vote-option):not(.feedback-other-label),
body.pilot-page .simple-form-page .feedback-vote legend {
    display: block;
    margin: 0 0 8px;
    font-family: var(--ui-font);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    color: #000;
}

body.pilot-page .simple-form-page input[type="text"],
body.pilot-page .simple-form-page input[type="email"],
body.pilot-page .simple-form-page select,
body.pilot-page .simple-form-page textarea {
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: var(--radius);
    box-sizing: border-box;
    font-family: var(--ui-font);
    font-size: 16px;
    color: #000;
    background: #fff;
}

body.pilot-page .simple-form-page select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23185251' d='M1.4 0.6L6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    padding-right: 40px;
}

body.pilot-page .simple-form-page .feedback-select-group {
    margin: 0 0 24px;
}

body.pilot-page .simple-form-page .feedback-select-group .feedback-other-wrap {
    margin-top: 8px;
}

/* Space after each label+control pair (not inside the pair). */
body.pilot-page .simple-form-page label:not(.feedback-vote-option):not(.feedback-other-label) + input,
body.pilot-page .simple-form-page label:not(.feedback-vote-option):not(.feedback-other-label) + textarea {
    margin-bottom: 24px;
}

body.pilot-page .simple-form-page textarea {
    min-height: 96px;
    resize: vertical;
}

body.pilot-page .simple-form-page input:focus,
body.pilot-page .simple-form-page select:focus,
body.pilot-page .simple-form-page textarea:focus {
    outline: none;
    border-color: #3bb8b4;
}

body.pilot-page .simple-form-page .feedback-vote {
    margin: 0 0 24px;
    padding: 0;
    border: none;
}

/* Match worksheet “Student Names (optional, but more fun!)” — same size/color, lighter weight. */
body.pilot-page .simple-form-page .feedback-vote-hint {
    font-family: var(--ui-font);
    font-size: 16px;
    font-weight: 400;
    color: inherit;
}

body.pilot-page .simple-form-page .feedback-vote-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    align-items: start;
    margin: 0 0 8px;
    font-family: var(--ui-font);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.35;
    color: #000;
    cursor: pointer;
}

body.pilot-page .simple-form-page .feedback-vote > .feedback-vote-option:last-of-type {
    margin-bottom: 0;
}

body.pilot-page .simple-form-page .feedback-vote-option input {
    margin: 3px 0 0;
    width: 16px;
    height: 16px;
    accent-color: var(--teal, #247674);
}

body.pilot-page .simple-form-page .feedback-vote-option span {
    grid-column: 2;
}

body.pilot-page .simple-form-page .feedback-launch-opt-in {
    margin: 0 0 24px;
}

body.pilot-page .simple-form-page .feedback-launch-opt-in[hidden] {
    display: none !important;
}

body.pilot-page .simple-form-page .feedback-other-wrap {
    margin: 8px 0 0 26px;
}

body.pilot-page .simple-form-page .feedback-price-wrap .feedback-other-label {
    margin-bottom: 8px;
}

body.pilot-page .simple-form-page .feedback-price-options {
    display: flex;
    flex-direction: column;
    gap: 0;
}

body.pilot-page .simple-form-page .feedback-other-label {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 400;
    color: var(--ink-soft);
}

body.pilot-page .simple-form-page .feedback-other-wrap input {
    margin: 0;
}

body.pilot-page .simple-form-page .feedback-step-status {
    margin: 0 0 24px;
    font-family: var(--ui-font);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--ink-soft, #5f6368);
}

body.pilot-page .simple-form-page .feedback-step-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

body.pilot-page .simple-form-page .feedback-step-actions .download-btn {
    width: auto;
    min-width: 160px;
    flex: 0 1 auto;
}

body.pilot-page .simple-form-page .feedback-step-back {
    margin: 0;
    padding: 14px 16px;
    border: 2px solid var(--teal, #247674);
    border-radius: var(--radius);
    background: #fff;
    color: var(--teal-dark, #185251);
    font-family: var(--ui-font);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.2;
    cursor: pointer;
}

body.pilot-page .simple-form-page .feedback-step-back:hover {
    background: rgba(36, 118, 116, 0.08);
}

body.pilot-page .simple-form-page .feedback-step-back[hidden],
body.pilot-page .simple-form-page .feedback-step-actions .download-btn[hidden] {
    display: none !important;
}

/* Same fill as worksheet Download PDF; cap width on desktop. */
body.pilot-page .simple-form-page .download-btn {
    width: 100%;
    max-width: 300px;
    margin-top: 0;
    padding: 14px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--teal-light, #62CECC);
    color: #000;
    font-family: var(--ui-font);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.2;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

body.pilot-page .simple-form-page .download-btn:hover {
    background: #4ebfbd;
    color: #000;
    transform: translateY(-2px);
}

/* After base .content-page rules so these win (earlier 640px block was overridden). */
@media (max-width: 640px) {
    body.pilot-page .simple-form-page,
    .content-page {
        padding-top: 28px;
        padding-left: var(--content-inline);
        padding-right: var(--content-inline);
        padding-bottom: 28px;
    }
    .content-page h1,
    body.pilot-page .simple-form-page h1 {
        margin-bottom: 8px;
        font-size: 24px; /* mobile */
    }
}

@media (max-width: 520px) {
    body.pilot-page .simple-form-page .download-btn {
        max-width: none;
    }
    body.pilot-page .simple-form-page .feedback-step-actions {
        flex-direction: column;
        align-items: stretch;
    }
    body.pilot-page .simple-form-page .feedback-step-back,
    body.pilot-page .simple-form-page .feedback-step-actions .download-btn {
        width: 100%;
    }
}

/* —— Worksheet page: quick face feedback (in form panel; shown after download) —— */
.sheet-react {
    width: 100%;
    margin: 24px 0 0;
    text-align: center;
    background: #fff;
    box-sizing: border-box;
    transition: box-shadow 220ms ease;
}

.sheet-react[hidden] {
    display: none !important;
}

.sheet-react-inner {
    position: relative;
    max-width: 420px;
    margin: 0 auto;
    padding: 8px 8px 6px;
}

.sheet-react-close {
    appearance: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--radius-inner, 4px);
    background: transparent;
    color: #9aa0a6;
    cursor: pointer;
}

.sheet-react-close-icon {
    display: block;
    width: 28px;
    height: 28px;
}

.sheet-react-close[hidden] {
    display: none !important;
}

.sheet-react-close:hover {
    background: #f1f3f4;
}

.sheet-react-close:focus-visible {
    outline: 2px solid var(--teal, #247674);
    outline-offset: 2px;
}

.worksheet-form-fields .sheet-react.is-expanded .sheet-react-close,
.worksheet-preview-panel .sheet-react.is-expanded .sheet-react-close {
    top: 10px;
    right: 12px;
}

@keyframes sheetReactIntroIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sheet-react.is-revealing .sheet-react-prompt,
.sheet-react.is-revealing .sheet-react-faces-row {
    animation: sheetReactIntroIn 520ms ease-out both;
}

.sheet-react.is-revealing .sheet-react-faces-row {
    animation-delay: 70ms;
}

@media (prefers-reduced-motion: reduce) {
    .sheet-react.is-revealing .sheet-react-prompt,
    .sheet-react.is-revealing .sheet-react-faces-row {
        animation: none;
    }
}

.sheet-react-prompt {
    margin: 0 0 4px; /* air under “How was this worksheet?” */
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 400;
    color: #000;
}

.sheet-react-step {
    margin-top: 16px;
    text-align: left;
}

.sheet-react-step-title {
    display: block;
    margin: 0 0 10px;
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    font-weight: 600;
    color: #000;
    text-align: left;
}

.sheet-react-checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 14px;
}

/*
 * Expanded feedback shell: fixed height so like→improve doesn’t jump.
 * Title + face stay top; submit stays bottom; gap above the button flexes.
 */
.sheet-react.is-expanded,
.sheet-react.is-collapsing {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.sheet-react.is-expanded .sheet-react-inner,
.sheet-react.is-collapsing .sheet-react-inner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    height: 100%;
}

.sheet-react.is-expanded .sheet-react-ask {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sheet-react.is-expanded .sheet-react-prompt,
.sheet-react.is-expanded .sheet-react-faces-row {
    flex: 0 0 auto;
}

.sheet-react.is-expanded .sheet-react-step {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-top: 16px;
}

.sheet-react.is-expanded .sheet-react-step-title {
    flex: 0 0 auto;
}

.sheet-react.is-expanded .sheet-react-checks {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 0;
    padding-bottom: 4px;
}

.sheet-react.is-expanded .sheet-react-submit {
    flex: 0 0 auto;
    margin-top: auto;
    width: 100%;
}

.sheet-react-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    align-items: start;
    font-family: var(--ui-font);
    font-size: 16px; /* match form inputs */
    font-weight: 400; /* slightly lighter than previous 500 */
    line-height: 1.35;
    color: #000;
    cursor: pointer;
}

.sheet-react-check input[type="checkbox"],
.sheet-react-check input[type="radio"] {
    margin: 3px 0 0;
    width: 16px;
    height: 16px;
    accent-color: var(--teal, #247674);
}

.sheet-react-check span {
    grid-column: 2;
}

.sheet-react-inline-note {
    grid-column: 2;
    width: 100%;
    margin: 2px 0 0;
    padding: 8px 10px;
    border: 2px solid #e1e5e9;
    border-radius: var(--radius);
    font-family: var(--ui-font);
    font-size: 16px; /* match inputs */
    color: #000;
    box-sizing: border-box;
}

.sheet-react-inline-note[hidden] {
    display: none !important;
}

.sheet-react-inline-note:focus {
    outline: none;
    border-color: #3bb8b4;
}

.sheet-react-more-ideas,
.sheet-react-instagram {
    position: relative;
    z-index: 2;
    margin: 0;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    padding: 0 4px;
    font-family: var(--ui-font);
    font-size: 14px; /* secondary; keep under primary 16px */
    font-weight: 400;
    line-height: 1.4;
    color: #555;
    text-align: center;
}

.sheet-react-instagram {
    margin-top: 8px;
}

.sheet-react-more-ideas a,
.sheet-react-instagram a {
    color: inherit;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.sheet-react-more-ideas a:hover,
.sheet-react-instagram a:hover {
    color: inherit;
}

.sheet-react-faces-row {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    /* Reserve hover face size (60px) so the prompt doesn’t jump on hover. */
    min-height: 64px;
    box-sizing: border-box;
}

.sheet-react-faces {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    box-sizing: border-box;
}

.sheet-react-faces.is-locked {
    gap: 0;
}

/* Reserve large-face space + breathing room above/below. */
.sheet-react.is-expanded .sheet-react-faces-row,
.sheet-react.is-collapsing .sheet-react-faces-row {
    height: 118px; /* 86px face + ~16px air above/below */
    min-height: 118px;
    margin: 6px 0 10px;
}

.sheet-react.is-expanded .sheet-react-faces,
.sheet-react.is-collapsing .sheet-react-faces {
    height: 118px;
    min-height: 118px;
}

/*
 * Rating art colors — tweak these to recolor faces / bubble without editing SVGs.
 * Faces + bubble use CSS mask + background-color.
 */
.sheet-react {
    --rating-face-color: #555555; /* dark grey on grey wash */
    --rating-face-color-great: #6B5420; /* dark brown/yellow on yellow wash */
    --rating-face-color-meh: #A85C55; /* muted red on light-red wash */
    --rating-bubble-color: var(--rating-face-wash-hover); /* same yellow as face */
    --rating-bubble-color-meh: var(--rating-face-wash-hover-meh); /* same red as face */
    --rating-bubble-text: var(--rating-face-color-great);
    --rating-face-wash: #e4e4e8;
    --rating-face-wash-hover: #FFF4A3; /* great / :D */
    --rating-face-wash-hover-meh: #FFD6D0; /* meh / :T — light red */
}

.sheet-react:has(.sheet-react-face[data-face="meh"].is-selected) {
    --rating-bubble-color: var(--rating-bubble-color-meh);
    --rating-bubble-text: var(--rating-face-color-meh);
}

/* Offset beside the centered face so the face stays on the midline.
   Starts small + faded; grows/fades in with the selected face on expand. */
.sheet-react-bubble {
    position: absolute;
    left: calc(50% + 41px); /* +3px right */
    top: 50%;
    transform: translateY(calc(-50% - 10px)) scale(0.45);
    margin: 0;
    box-sizing: border-box;
    width: 44px;
    height: 30px;
    padding: 4px 4px 6px 7px; /* clear the left-pointing tail */
    border: none;
    border-radius: 0;
    background-color: var(--rating-bubble-color);
    background-image: none;
    -webkit-mask-image: url('images/rating-bubble.svg');
    mask-image: url('images/rating-bubble.svg');
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.05;
    color: var(--rating-bubble-text);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition:
        width 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        height 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        font-size 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        padding 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        transform 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        opacity 280ms ease 60ms,
        visibility 0s linear 340ms,
        background-color 0.22s ease,
        color 0.22s ease,
        left 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms;
}

.sheet-react-bubble-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Keep in the layout tree so grow/fade can run (UA [hidden] is display:none). */
.sheet-react-bubble[hidden] {
    display: flex !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.sheet-react-face {
    flex: 0 0 auto;
    width: 40px; /* 2× prior 20px */
    height: 40px;
    padding: 0;
    border: none;
    /* Circle + wiggly-pill radii (same family as filter chips / pilot badge). */
    border-radius: 2.6em 1.7em 2.3em 1.9em / 1.45em 2.85em 1.35em 2.7em;
    background: var(--rating-face-wash);
    color: var(--rating-face-color);
    font-family: var(--ui-font);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transform: rotate(-12deg) translateY(0);
    /* Match panel expand/collapse so face grows/floats with the popup. */
    transition:
        width 520ms cubic-bezier(0.22, 0.82, 0.28, 1),
        height 520ms cubic-bezier(0.22, 0.82, 0.28, 1),
        background 0.22s ease,
        color 0.22s ease,
        transform 520ms cubic-bezier(0.22, 0.82, 0.28, 1),
        opacity 280ms ease,
        margin 520ms ease;
}

.sheet-react-face-icon {
    display: block;
    width: 48%; /* smaller glyph inside the circle (was 70%) */
    height: 48%;
    background-color: currentColor;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    pointer-events: none;
    user-select: none;
}

.sheet-react-face[data-face="great"] .sheet-react-face-icon {
    -webkit-mask-image: url('images/rating-great.svg');
    mask-image: url('images/rating-great.svg');
}

.sheet-react-face[data-face="meh"] .sheet-react-face-icon {
    -webkit-mask-image: url('images/rating-meh.svg');
    mask-image: url('images/rating-meh.svg');
}

.sheet-react-face:nth-child(1) {
    border-radius: 2.6em 1.7em 2.3em 1.9em / 1.45em 2.85em 1.35em 2.7em;
    transform: rotate(-12deg);
}

.sheet-react-face:nth-child(2) {
    border-radius: 1.8em 2.5em 1.9em 2.4em / 2.85em 1.4em 2.9em 1.5em;
    transform: rotate(8deg);
}

.sheet-react-face:nth-child(3) {
    border-radius: 2.4em 1.9em 2.5em 1.8em / 1.5em 2.9em 1.4em 2.7em;
    transform: rotate(-7deg);
}

.sheet-react-face:hover {
    /* Grow visually via transform so layout/title stay put; row already reserves 64px. */
    width: 40px;
    height: 40px;
    background: var(--rating-face-wash-hover);
    color: var(--rating-face-color-great);
    transform: rotate(0deg) scale(1.5); /* ~60px visual */
    z-index: 1;
}

/*
 * Park the non-selected face out of flow (opacity only) so the selected face
 * becomes the sole flex child and grows from the horizontal center — not from
 * its left/right resting slot as a sibling width-collapses.
 */
.sheet-react-face.is-hidden {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translate(-50%, -50%);
    /* No width/height tween — avoids pulling the selected face sideways. */
    transition: opacity 200ms ease, background 0.22s ease;
}

.sheet-react-face.is-selected {
    background: var(--rating-face-wash-hover);
    color: var(--rating-face-color-great);
    transform: rotate(0deg) translateY(0);
    /* Sole in-flow child while locked → centered by justify-content. */
    margin-left: auto;
    margin-right: auto;
}

/* Grow inside the reserved 86px slot — size tween won’t change panel height. */
.sheet-react.is-expanded .sheet-react-face.is-selected {
    width: 86px;
    height: 86px;
    background: var(--rating-face-wash-hover);
    color: var(--rating-face-color-great);
    transform: rotate(0deg) translateY(3px);
    transition:
        width 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        height 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        background 0.22s ease,
        color 0.22s ease,
        transform 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms;
}

.sheet-react-face[data-face="meh"]:hover,
.sheet-react-face[data-face="meh"].is-selected,
.sheet-react.is-expanded .sheet-react-face[data-face="meh"].is-selected {
    background: var(--rating-face-wash-hover-meh);
    color: var(--rating-face-color-meh);
}

.sheet-react.is-expanded .sheet-react-bubble:not([hidden]) {
    left: calc(50% + 49px); /* +3px right from prior expanded */
    width: 95px;
    height: 66px;
    padding: 9px 8px 12px 14px;
    font-size: 16px;
    transform: translateY(calc(-50% - 7px)) scale(1);
    opacity: 1;
    visibility: visible;
    transition:
        width 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        height 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        font-size 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        padding 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        transform 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms,
        opacity 280ms ease 60ms,
        visibility 0s linear 0s,
        background-color 0.22s ease,
        color 0.22s ease,
        left 480ms cubic-bezier(0.22, 0.82, 0.28, 1) 60ms;
}

/* While collapsing, leave faces alone — panel fade handles exit. */
.sheet-react.is-collapsing .sheet-react-bubble {
    opacity: 0;
    visibility: hidden;
    transform: translateY(calc(-50% - 7px)) scale(0.55);
    transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
}

/* After collapse: restore resting faces with opacity only (no slide/scale tween). */
.sheet-react-face.is-fade-only {
    transition: opacity 320ms ease, background 0.22s ease !important;
}

/* One-frame settle at center before the grow/float runs. */
.sheet-react-face.is-layout-settle {
    transition: none !important;
}

.sheet-react-face:focus-visible {
    outline: 2px solid #185251;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .sheet-react.is-expanded .sheet-react-face.is-selected,
    .sheet-react.is-expanded .sheet-react-bubble,
    .sheet-react-face.is-fade-only {
        transition: none;
    }
}

.sheet-react-submit {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    border: none;
    background: var(--teal-light, #62CECC);
    color: #000;
    font-family: var(--ui-font);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
    padding: 14px 16px;
    border-radius: var(--radius);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.sheet-react-submit:hover:not(:disabled) {
    background: #4ebfbd;
    color: #000;
    transform: translateY(-2px);
}

.sheet-react-submit:disabled {
    background: #b7e4e3;
    color: #5f7a79;
    opacity: 1;
    box-shadow: none;
    transform: none;
    cursor: not-allowed;
}

.sheet-react-thanks {
    position: relative;
    /* Fill the locked panel height from the prior feedback form step. */
    flex: 1 1 auto;
    min-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    overflow: visible;
    box-sizing: border-box;
    padding: 8px 0;
}

/* Author display:flex must not override the hidden attribute. */
.sheet-react-thanks[hidden],
.sheet-react-ask[hidden],
.sheet-react-step[hidden] {
    display: none !important;
}

.sheet-react-thanks-msg,
body.pilot-page .sheet-react-thanks-msg {
    position: relative;
    z-index: 2;
    margin: 0 0 18px;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
    padding: 0 4px;
    font-family: 'More Sugar', 'DM Sans', system-ui, sans-serif;
    font-size: 1.35em;
    font-weight: 400;
    line-height: 1.25;
    color: #000;
    text-align: center;
}

.sheet-react.is-celebrating .sheet-react-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    max-width: none;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}

.sheet-react-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 4;
}

.sheet-react-confetti {
    position: absolute;
    left: 50%;
    top: 50%;
    opacity: 0;
    animation: sheetReactBurst var(--dur, 1.4s) var(--delay, 0s) ease-out forwards;
}

.sheet-react-confetti.is-pill {
    width: var(--w, 14px);
    height: var(--h, 8px);
    border-radius: var(--rad, 2em);
}

.sheet-react-confetti.is-bug {
    width: 28px;
    height: 28px;
}

.sheet-react-confetti.is-bug img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Sprinkle outward in all directions (not just up). */
@keyframes sheetReactBurst {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
    }
    12% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform:
            translate(
                calc(-50% + var(--x, 0px)),
                calc(-50% + var(--y, 0px))
            )
            scale(1)
            rotate(var(--rot, 40deg));
    }
}

/* Let confetti bleed past the white popup into the teal page. */
.worksheet-form-fields.is-celebrating-react {
    overflow: visible !important;
}

.worksheet-form-fields .sheet-react.is-expanded.is-celebrating,
.worksheet-preview-panel .sheet-react.is-expanded.is-celebrating {
    overflow: visible;
    /* Wider measure so the “more ideas” sentence can sit in ~2 lines. */
    padding-left: 20px;
    padding-right: 20px;
}

/* Message + white panel fade/slide out together. */
.sheet-react.is-dismissing {
    animation: sheetReactDismiss 0.45s ease-out forwards;
    pointer-events: none;
}

.sheet-react.is-dismissing .sheet-react-thanks,
.sheet-react.is-dismissing .sheet-react-thanks-msg,
.sheet-react.is-dismissing .sheet-react-more-ideas,
.sheet-react.is-dismissing .sheet-react-instagram,
.sheet-react.is-dismissing .sheet-react-close {
    /* Stay opaque; parent panel opacity handles the shared fade. */
    animation: none !important;
    opacity: 1;
}

@keyframes sheetReactDismiss {
    0% {
        opacity: 1;
        transform: translateY(0);
        box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.22);
    }
    100% {
        opacity: 0;
        transform: translateY(48px);
        box-shadow: 0 -8px 16px rgba(0, 0, 0, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sheet-react-face {
        transition: none;
    }

    .sheet-react-confetti {
        animation: none;
        display: none;
    }

    .sheet-react.is-dismissing {
        animation: none;
        opacity: 0;
    }
}
