.booklet-app {
    margin-top: 24px;
}

.booklet-nav {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
}

.booklet-nav li {
    margin-right: 8px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    cursor: pointer;
}

.booklet-nav li.active {
    background: #007bff;
    border-color: #007bff;
}

.booklet-page .form-group {
    margin-bottom: 12px;
}

.booklet-actions {
    margin-top: 12px;
}

.hidden {
    display: none;
}

.page-transition-wrapper {
    position: relative;
}

.page-transition-enter {
    opacity: 0;
}

.page-transition-enter.page-transition-enter-active {
    opacity: 1;
    transition: opacity 300ms ease;
}

.page-transition-leave {
    opacity: 1;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
}

.page-transition-leave.page-transition-leave-active {
    opacity: 0;
    transition: opacity 300ms ease;
}

.booklet-cover {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 12px;
}

.a4-box {
    width: 100%;
    max-width: 900px;
    position: relative;
    height: 0;
    padding-top: 141.4%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    border: 1px solid #eee;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.a4-box .title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    padding: 0 12px;
}

.booklet-cover .booklet-actions {
    margin-top: 16px;
}

.booklet-cover .a4-box .cover-enter-btn {
    position: absolute;
    left: 50%;
    bottom: 12%;
    transform: translateX(-50%);
    min-width: 160px;
}

.booklet-cover .a4-box .cover-enter-btn .booklet-actions {
    margin-top: 0;
    padding-bottom: 0;
    width: auto;
    justify-content: center;
}

.booklet-cover .a4-box .cover-enter-btn .ba-left,
.booklet-cover .a4-box .cover-enter-btn .ba-right {
    display: none;
}

.booklet-cover .a4-box .cover-enter-btn .booklet-btn-next {
    font-size: clamp(18px, 4.2vw, 36px);
    padding: 14px 34px;
    min-width: clamp(180px, 34vw, 360px);
    border-radius: 16px;
}

.a4-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.a4-content .booklet-fields {
    flex: 1;
    overflow: auto;
}

.a4-content .booklet-actions {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
    position: relative;
    z-index: 1;
    width: 100%;
}

.ba-left {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
}
.ba-center {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}
.ba-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.menu-title {
    color: black;
    text-align: center;
    font-size: clamp(28px, 7vw, 64px);
    margin-top: 8px;
}

.menu-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.menu-item {
    color: black;
    font-size: var(--text-size, 36px);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.25);
}

.tasks-grid {
    margin: 5em auto 5em auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 0 12px;
}

.task-item {
    text-align: center;
}

@media (max-width: 768px) {
    :root {
        --task-img: clamp(120px, 28vw, 180px);
    }
    .tasks-grid {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .task-item {
        width: calc(50% - 12px);
    }
}

.booklet-readonly input,
.booklet-readonly select,
.booklet-readonly textarea {
    pointer-events: none !important;
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
    color: #6c757d !important;
}
.booklet-readonly .booklet-radio,
.booklet-readonly .booklet-radio-label {
    pointer-events: none !important;
    opacity: 0.7;
}

@media (max-width: 480px) {
    :root {
        --task-img: clamp(100px, 40vw, 160px);
    }
    .task-item {
        width: calc(50% - 10px);
    }
}
.task-image {
    width: var(--task-img, 200px);
    height: var(--task-img, 200px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(2px);
    border: 2px solid rgba(255, 255, 255, 0.6);
    cursor: pointer;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}

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

.task-label {
    color: black;
    margin-top: 6px;
    font-size: var(--text-size, 36px);
    cursor: pointer;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.booklet-intro {
    color: black;
    text-align: center;
    margin-top: 12px;
    font-size: var(--text-size, 36px);
}
.booklet-section-title {
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    margin-top: 8px;
}

.booklet-inline-input {
    display: inline-block;
    width: 240px;
    max-width: 60%;
    margin-left: 8px;
}

.booklet-paragraphs {
    margin-top: 12px;
    padding: 0 12px;
}
.booklet-paragraphs-loose p {
    margin: 1em;
}

.booklet-paragraphs-tight p {
    margin-top: 0;
    margin-bottom: 8px;
}

.booklet-subsection {
    margin-top: 8px;
    padding: 0 12px;
}

.booklet-subsection p {
    margin-top: 0;
    margin-bottom: 6px;
}

.booklet-list {
    margin-left: 24px;
    list-style: unset;
}

.booklet-list li {
    color: black;
    font-size: var(--text-size, 36px);
    margin-bottom: 6px;
}

.booklet-bottom-note {
    padding: 2em;
    color: black;
    text-align: center;
    font-size: var(--text-size, 36px);
    margin-top: 12px;
}


.a4-content p {
    color: black;
    line-height: 1.4;
    margin: 8px 0;
}


.a4-box .title {
    font-size: 64px;
}

.booklet-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.booklet-table th {
    color: black;
    text-align: center;
    padding: 8px;
    font-size: var(--text-size, 36px);
}

.booklet-table td {
    padding: 6px;
}

.booklet-table .form-control {
    width: 100%;
    background-color: transparent;
}
.booklet-large-textarea {
    min-height: 320px;
}

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

.booklet-name-tip {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.booklet-textarea {
    border-radius: 24px;
    background-color: transparent;
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 45px, rgba(0, 0, 0, 0.1) 45px, rgba(0, 0, 0, 0.1) 46px);
    line-height: 45px;
    background-attachment: local;
    resize: none;
}

.booklet-name-input {
    width: 33.333%;
    flex: 0 0 33.333%;
}

.booklet-main-left {
    width: 66.666%;
    margin-left: 12px;
    margin-top: 33%;
}
.booklet-main-right {
    width: 66.666%;
    margin-left: auto;
    margin-right: 12px;
    margin-top: 33%;
}

.booklet-headline-input {
    display: inline-block;
    background-color: #ffffff;
    background-clip: padding-box;
    line-height: 1.2;
    height: 1.2em;
    padding: 0 16px;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 40px;
    border: none;
    box-shadow: 8px -8px 0 2px rgba(11, 46, 102, 0.65), 3px -3px 0 1px rgba(11, 46, 102, 0.45);
}

.booklet-headline-input:focus,
.booklet-headline-input:active {
    outline: none;
    box-shadow: 8px -8px 0 2px rgba(11, 46, 102, 0.65), 3px -3px 0 1px rgba(11, 46, 102, 0.45) !important;
}

.booklet-center-headline {
    text-align: center;
    margin-top: 25%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.a4-content .booklet-underline-input {
    display: inline-block;
    width: 260px;
    border: none;
    border-bottom: 3px solid rgba(255, 255, 255, 0.85);
    background: transparent;
    text-align: center;
    line-height: 1.2;
    height: 1.2em;
    padding: 0 8px;
    vertical-align: baseline;
    border-radius: 0;
}

.booklet-section-figure {
    flex: 0 0 calc(50% - 6px);
    width: calc(50% - 6px);
    height: 180px;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    border-radius: 16px;
}

.booklet-section-fields {
    flex: 0 0 calc(50% - 6px);
    width: calc(50% - 6px);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.booklet-question {
    position: absolute;
    left: 100px;
    top: -64px;
    z-index: 2;
    font-size: 160px;
    line-height: 1;
    color: rgba(11, 46, 102, 0.85);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.booklet-section-label {
    display: inline-block;
    width: 230px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.booklet-section-input {
    width: 33.333%;
    flex: 0 0 33.333%;
    border: 3px solid #000;
    border-radius: 12px;
    background-color: transparent;
    color: #000;
    font-weight: 600;
    box-sizing: border-box;
}

.booklet-section-line + .booklet-section-line {
    margin-top: 16px;
}

.booklet-dual-section {
    flex: 1 0 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.booklet-section-main {
    width: 100%;
    margin: 0;
}

.booklet-section-content {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.booklet-section-row {
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.booklet-section-desc {
    text-align: center;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.booklet-section .booklet-section-desc {
    padding-left: 200px;
}

.booklet-section-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.booklet-dual-section-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.booklet-single-section-container {
    width: 66.666%;
    margin: 12px auto 0;
}


.a4-content .booklet-underline-input-wide {
    display: inline-block;
    width: 50%;
    border: none;
    border-bottom: 3px solid rgba(255, 255, 255, 0.85);
    background: transparent;
    padding: 4px 8px;
    border-radius: 0;
}

.page-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 0;
    padding-top: 141.4%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
}
.booklet-overlay {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 0;
    padding-top: 141.4%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    z-index: 0;
}

.booklet-top-emoji {
    position: absolute;
    top: 3%;
    left: 58%;
    transform: translateX(-50%);
    font-size: clamp(64px, 17.675vw, 160px);
    line-height: 1;
    font-weight: 900;
    color: #fff;
    -webkit-text-stroke: clamp(2px, 0.35vw, 6px) #000;
    text-shadow:
        0 0 0 #000,
        1px 0 0 #000,
        -1px 0 0 #000,
        0 1px 0 #000,
        0 -1px 0 #000,
        1px 1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        -1px -1px 0 #000;
    z-index: 2;
    pointer-events: none;
}

.booklet-writerapp-loc-img {
    position: absolute;
    right: 4%;
    top: 14%;
    width: 25%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: center;
    z-index: 0;
    pointer-events: none;
}

.booklet-writerapp-form-page .a4-content {
    z-index: 1;
}

.side-strip {
    position: absolute;
    top: 20%;
    left: 70%;
    width: 28%;
    pointer-events: none;
    z-index: 0;
}

.side-strip-img {
    display: block;
    width: 100%;
    height: auto;
}

.side-strip-left {
    left: 3%;
}


.booklet-btn,
.booklet-actions .booklet-btn {
    border-radius: 12px;
    background: linear-gradient(180deg, #f9f9f9 0%, #eaeaea 100%);
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.15);
    padding: 8px 18px;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.75);
    transition: box-shadow 0.15s ease, background 0.2s ease, transform 0.1s;
}

.booklet-btn-nav {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #4A90E2;
    border: none;
    box-shadow: 0 6px 0 #2a5d99, 0 10px 10px rgba(0,0,0,0.3);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.booklet-btn-nav::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 15%;
    width: 30%;
    height: 15%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(-45deg);
}

.booklet-btn-nav:hover {
    background: #5aa0f2;
    box-shadow: 0 6px 0 #2a5d99, 0 12px 14px rgba(0,0,0,0.35);
    transform: translateY(-2px);
}

.booklet-btn-nav:active {
    background: #357abd;
    box-shadow: 0 2px 0 #2a5d99, 0 4px 6px rgba(0,0,0,0.3);
    transform: translateY(4px);
}

.booklet-btn-nav svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: white;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}

.booklet-btn:hover,
.booklet-actions .booklet-btn:hover {
    background: linear-gradient(180deg, #f7f7f7 0%, #e5e5e5 100%);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.booklet-btn:active,
.booklet-actions .booklet-btn:active {
    background: linear-gradient(180deg, #e6e6e6 0%, #dcdcdc 100%);
    box-shadow: inset 0 8px 14px rgba(0, 0, 0, 0.28),
                inset 0 -2px 4px rgba(0, 0, 0, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.85);
    border-color: transparent;
}

.booklet-btn:focus:active,
.booklet-actions .booklet-btn:focus:active {
    outline: none;
    box-shadow: inset 0 8px 14px rgba(0, 0, 0, 0.28),
                inset 0 -2px 4px rgba(0, 0, 0, 0.18),
                inset 0 1px 0 rgba(255, 255, 255, 0.85) !important;
    border-color: transparent !important;
}

.booklet-btn:focus,
.booklet-actions .booklet-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.booklet-btn[disabled],
.booklet-actions .booklet-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.booklet-btn.booklet-btn-return,
.booklet-btn.booklet-btn-submit {
    border-radius: 50px;
}

/* common booklet section container */
.booklet-section {
    width: 80%;
    max-width: 720px;
    margin: 40px auto 0;
    align-self: center;
    background: #a7d8ff;
    border-radius: 40px;
    padding: 12px 16px;
    padding-bottom: 36px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .a4-content .booklet-fields,
    .a4-content label,
    .a4-content .form-control,
    .a4-content p {
        font-size: 26px;
    }
    .a4-box .title {
        font-size: 40px;
    }
    .booklet-headline-input {
        font-size: 40px;
    }
    .booklet-question {
        font-size: 100px;
        left: 60px;
        top: -48px;
    }
    .booklet-section-input {
        height: 56px;
        line-height: 28px;
        padding: 0 12px;
    }
    .booklet-section-label {
        width: 200px;
        font-size: 26px;
    }
    .booklet-name-tip {
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .a4-content .booklet-fields,
    .a4-content label,
    .a4-content .form-control,
    .a4-content p {
        font-size: 22px;
    }
    .a4-box .title {
        font-size: 32px;
    }
    .booklet-headline-input {
        font-size: 32px;
    }
    .booklet-question {
        font-size: 72px;
        left: 40px;
        top: -36px;
    }
    .booklet-section-label {
        width: 160px;
        font-size: 22px;
    }
    .booklet-section-input,
    .booklet-name-input {
        height: 48px;
        line-height: 24px;
        padding: 0 10px;
        width: 50%;
        flex: 0 0 50%;
    }
    .booklet-name-tip {
        font-size: 22px;
    }
}

:root {
    --text-size: clamp(14px, 3.8vw, 32px);
    --headline-size: clamp(20px, 6vw, 56px);
    --question-size: clamp(40px, 10vw, 140px);
    --label-size: clamp(14px, 3.8vw, 32px);
}

.a4-content .booklet-fields,
.a4-content label,
.a4-content .form-control,
.a4-content p {
    font-size: var(--text-size);
}

.booklet-headline-input {
    font-size: var(--headline-size);
}

.booklet-question {
    font-size: var(--question-size);
    left: clamp(40px, 8vw, 100px);
    top: calc(-1 * clamp(32px, 6vw, 64px));
}

.booklet-section-label {
    width: clamp(160px, 24vw, 230px);
    font-size: var(--label-size);
}

.booklet-section-input,
.booklet-name-input {
    height: calc(2 * var(--text-size));
    line-height: var(--text-size);
    padding: 0 clamp(10px, 2.5vw, 16px);
}

.booklet-name-tip {
    font-size: var(--text-size);
}

.booklet-stage-wrapper {
    --text-size: 36px;
    --headline-size: 64px;
    --question-size: 160px;
    --label-size: 36px;
    --task-img: 200px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.booklet-stage-wrapper .menu-title {
    font-size: 64px;
    padding: 1em;
}

/* Teacher mode UI */
.teacher-meta {
    font-size: 12px;
    color: #666;
}
.teacher-pagination {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    justify-content: center;
    align-items: center;
}
.teacher-toolbar {
    margin-bottom: 8px;
}
.teacher-readonly-tip {
    margin-left: 10px;
    font-size: 12px;
    color: #999;
}

/* Form and controls */
.booklet-radio-label-correct {
    color: red;
}
.booklet-radio-label-correct-selected {
    color: #92d051;
}
.booklet-left-align {
    justify-content: flex-start;
    text-align: left;
}
.label-auto {
    width: auto;
}

.booklet-stage-wrapper .booklet-question {
    left: 100px;
    top: -64px;
}

.booklet-stage-wrapper .booklet-section-label {
    width: 230px;
    font-size: 36px;
}

.booklet-stage-wrapper .booklet-section-input,
.booklet-stage-wrapper .booklet-name-input {
    width: 33.333%;
    flex: 0 0 33.333%;
    height: 72px;
    line-height: 36px;
    padding: 0 16px;
}

.booklet-stage-wrapper .tasks-grid {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.booklet-stage-wrapper .task-item {
    flex: 0 0 calc(25% - 12px);
    max-width: calc(25% - 12px);
}

.booklet-stage {
    width: 100%;
}
.booklet-section-line.booklet-radio-group {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.booklet-radio-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 80%;
    white-space: normal;
    overflow-wrap: anywhere;
}
.booklet-radio {
    width: calc(var(--text-size) * 1.5);
    height: calc(var(--text-size) * 1.5);
    accent-color: #000000;
}

.booklet-ambassador-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}

.booklet-ambassador-title {
    font-size: 40px;
    font-weight: bold;
    color: #333;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    margin: 0;
    text-align: center;
    line-height: 1.2;
}

.booklet-ambassador-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.booklet-ambassador-icon.right {
    transform: scaleX(-1);
}

@media (max-width: 768px) {
    .booklet-ambassador-title {
        font-size: 32px;
    }
    .booklet-ambassador-icon {
        width: 40px;
        height: 40px;
    }
}

.booklet-ambassador-container {
    width: 90% !important;
}

.booklet-ambassador-container .booklet-large-textarea {
    min-height: 160px;
}

.booklet-page-num {
    text-align: center;
    font-weight: bold;
    color: #999;
    font-size: 18px;
}
