body:has(#screen-lobby:not(.hidden)) {
    display: block;
    padding: 0;
    background: #fff;
}
#app:has(#screen-lobby:not(.hidden)) { width: 100%; max-width: none; }
#screen-lobby:not(.hidden) { display: flex; }
.survey-welcome {
    --welcome-orange: #f97316;
    min-height: 100dvh;
    flex-direction: column;
    color: #172b4d;
    background: #fff;
}
.survey-welcome-width { width: min(1120px, calc(100% - 96px)); margin-inline: auto; }
.survey-welcome-header { padding: clamp(36px, 7vh, 80px) 0 36px; border-bottom: 1px solid #e8edf3; }
.survey-welcome-heading { display: flex; align-items: center; gap: 24px; }
.survey-welcome #lobby-icon { display: grid; place-items: center; flex-shrink: 0; width: 64px; height: 64px; border-radius: 16px; background: #fff0e5; color: var(--welcome-orange); font-size: 26px; }
.survey-welcome-eyebrow { margin: 0 0 8px; color: #64748b; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.survey-welcome #lobby-title { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.2; font-weight: 700; overflow-wrap: anywhere; }
.survey-welcome #lobby-subtitle { margin: 12px 0 0; font-size: 16px; color: #64748b; }
.survey-welcome #lobby-subtitle:empty { display: none; }
.survey-welcome-sections { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 56px; flex: 1; align-content: center; padding-block: 56px; }
.survey-welcome-author { padding-right: 40px; border-right: 1px solid #e8edf3; }
.survey-welcome-section-icon { display: block; margin-bottom: 20px; color: var(--welcome-orange); font-size: 24px; }
.survey-welcome-sections h2 { margin: 0 0 16px; font-size: 22px; line-height: 1.35; font-weight: 600; }
.survey-welcome #lobby-professor { margin: 0; font-size: 16px; line-height: 1.7; color: #475569; overflow-wrap: anywhere; }
.survey-welcome #lobby-class { margin: 0; max-width: 640px; font-size: 17px; line-height: 1.85; color: #64748b; }
.survey-welcome-footer { border-top: 1px solid #e8edf3; background: #f8fafc; padding: 30px 0; }
.survey-welcome-start { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.survey-welcome-count { display: flex; align-items: center; gap: 20px; }
.survey-welcome #lobby-qcount { font-size: 42px; line-height: 1; font-weight: 700; }
.survey-welcome-count strong { font-size: 16px; font-weight: 600; }
.survey-welcome-count p { margin: 6px 0 0; font-size: 14px; color: #64748b; }
.survey-welcome-button { display: inline-flex; align-items: center; justify-content: center; gap: 24px; flex-shrink: 0; min-height: 54px; padding: 15px 28px; border: 0; border-radius: 12px; background: var(--welcome-orange); color: #fff; font: inherit; font-weight: 600; cursor: pointer; transition: background .15s; }
.survey-welcome-button:hover { background: #ea580c; }
.survey-welcome-button:focus-visible { outline: 3px solid #fdba74; outline-offset: 4px; }
body:has(#screen-survey:not(.hidden)) { display: block; padding: 0; background: #fff; }
#app:has(#screen-survey:not(.hidden)) { width: 100%; max-width: none; }
#screen-survey {
    --accent: #f97316;
    --primary: #f97316;
    --primary-dark: #ea580c;
    min-height: 100dvh;
    width: 100%;
    padding: 32px clamp(20px, 4vw, 80px);
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#screen-survey #question-container { min-height: calc(100dvh - 240px); padding-block: 20px; }
#screen-survey #question-container h2 { line-height: 1.5; margin-bottom: 32px; }
#screen-survey .form-emoji-grid { table-layout: fixed; min-width: 0; }
#screen-survey .form-emoji-grid caption { padding-bottom: 28px; font-size: 24px; }
#screen-survey .form-emoji-grid th:first-child { width: 48%; min-width: 0; text-align: left; }
#screen-survey .form-emoji-grid thead th:not(:first-child) { width: 10.4%; }
#screen-survey .form-emoji-grid thead th:first-child { font-family: inherit; font-size: 16px; line-height: 1.8; font-weight: 500; }
#screen-survey .form-emoji-grid :is(th, td) { padding: 28px 12px; }
#screen-survey .form-emoji-grid tbody th { padding-right: clamp(24px, 4vw, 72px); font-size: 16px; line-height: 1.8; font-weight: 500; overflow-wrap: anywhere; }
#screen-survey .form-emoji-grid small { margin-top: 12px; font-size: 12px; line-height: 1.4; }
#screen-survey .form-emoji-grid .form-grid-face { width: 48px; height: 48px; }
#screen-survey .form-grid-choice { min-height: 64px; max-width: 88px; margin-inline: auto; }
#screen-survey #grid-next { width: auto; min-width: 180px; align-self: flex-end; padding-inline: 32px; margin-top: 28px; background: #f97316; }
#screen-survey #progress-bar { background: #f97316; }
#screen-survey #question-progress-text { color: #f97316; }
@media (max-width: 850px) {
    #screen-survey { padding: 24px 20px; }
    #screen-survey .form-emoji-grid { display: block; }
    #screen-survey .form-emoji-grid caption { display: block; font-size: 21px; }
    #screen-survey .form-emoji-grid thead, #screen-survey .form-emoji-grid tbody { display: block; }
    #screen-survey .form-emoji-grid tr { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
    #screen-survey .form-emoji-grid thead th:first-child { display: none; }
    #screen-survey .form-emoji-grid thead th:not(:first-child) { width: auto; padding: 12px 3px; font-size: 10px; overflow-wrap: anywhere; }
    #screen-survey .form-emoji-grid tbody tr { padding-block: 24px; border-bottom: 1px solid #e5e7eb; row-gap: 18px; }
    #screen-survey .form-emoji-grid tbody th:first-child { grid-column: 1 / -1; width: auto; padding: 0; border: 0; font-size: 16px; line-height: 1.75; }
    #screen-survey .form-emoji-grid td { padding: 0 3px; border: 0; }
    #screen-survey .form-grid-choice { min-height: 56px; padding: 6px; border-radius: 10px; }
    #screen-survey .form-emoji-grid .form-grid-face { width: 32px; height: 32px; }
    #screen-survey #grid-next { width: 100%; }
}
@media (max-width: 700px) {
    .survey-welcome-width { width: calc(100% - 40px); }
    .survey-welcome-header { padding: 28px 0; }
    .survey-welcome-heading { align-items: flex-start; gap: 16px; }
    .survey-welcome #lobby-icon { width: 48px !important; height: 48px !important; font-size: 20px; }
    .survey-welcome-sections { grid-template-columns: 1fr; gap: 28px; padding-block: 32px; }
    .survey-welcome-author { padding: 0 0 28px; border-right: 0; border-bottom: 1px solid #e8edf3; }
    .survey-welcome-section-icon { margin-bottom: 12px; }
    .survey-welcome-start { flex-direction: column; align-items: stretch; gap: 24px; }
    .survey-welcome-footer { padding: 24px 0; }
    .survey-welcome-count { gap: 16px; }
}

/* Navigation remains available while reading long questions. */
#screen-survey { padding-bottom: 110px; }
.survey-navigation { position: fixed; z-index: 40; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; gap: 16px; padding: 16px clamp(20px, 4vw, 80px); padding-bottom: max(16px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e2e8f0; }
.survey-navigation > button { min-height: 44px; padding: 10px 24px; border-radius: 12px; font-weight: 600; }
.survey-navigation .btn-primary { background: #f97316; color: #fff; }
.modal-dialog .modal-card-universal .btn-confirm { background-color: #f97316; color: #fff; }
.modal-dialog .modal-card-universal .btn-confirm:hover { background-color: #ea580c; }
.modal-dialog .modal-card-universal .modal-header-universal .fa-info-circle { color: #f97316; }
.survey-teacher { font-size: clamp(22px, 2vw, 30px); font-weight: 500; line-height: 1.5; margin: 12px 0 32px; color: #172b4d; }
.survey-teacher-name { font-weight: 800; color: #b45309; background: #fff3e6; border-radius: 6px; padding: .08em .25em; box-decoration-break: clone; -webkit-box-decoration-break: clone; overflow-wrap: anywhere; }
#screen-survey .form-emoji-grid caption { font-size: 13px; font-weight: 400; color: #64748b; padding-bottom: 16px; }
#screen-survey #grid-next, #screen-survey #btn-next-text, #screen-survey #global-finish-container, #question-container button[onclick^="nextMultipleSelectQuestion"] { display: none; }

#screen-survey { animation: none; transform: none; }

/* Keep the current teacher visible without shifting the question layout. */
#survey-teacher-sentinel { height: 1px; margin-bottom: -1px; pointer-events: none; }
#survey-teacher-heading { position: sticky; top: 0; z-index: 30; background: #fff; display: flow-root; }
#survey-teacher-heading:empty { display: none; }
#survey-teacher-heading .survey-teacher { margin: 0; padding: 12px 0 24px; transform-origin: left center; transition: transform 180ms ease; }
#survey-teacher-heading.is-stuck { box-shadow: 0 6px 10px -9px #172b4d66; }
#survey-teacher-heading.is-stuck .survey-teacher { transform: scale(.94); }
@media (prefers-reduced-motion: reduce) { #survey-teacher-heading .survey-teacher { transition: none; } }

#screen-survey .survey-question-intro { margin-bottom: 32px; }
#screen-survey #question-container .survey-question-title { margin: 0; font-family: inherit; font-size: var(--form-question-font-size, 20px); line-height: 1.8; font-weight: 500; color: #12284c; overflow-wrap: anywhere; }
#screen-survey .survey-question-requirement { display: block; margin-top: 12px; font-size: 12px; line-height: 1.4; font-weight: 500; color: #64748b; }
@media (max-width: 850px) { #screen-survey #question-container .survey-question-title { line-height: 1.75; } }

#screen-survey #question-container { justify-content: flex-start; }
#screen-survey .survey-question-type { margin: 0 0 28px; font-size: 13px; line-height: 1.4; font-weight: 400; color: #64748b; }
#screen-survey .survey-likert-face { margin: 0 auto 4px; }
@media (max-width: 850px) { #screen-survey .survey-likert-face { width: 40px; height: 40px; } }

.survey-navigation { display: grid; grid-template-columns: 1fr minmax(0, 2fr) 1fr; align-items: center; }
.survey-navigation #btn-prev { justify-self: start; }
.survey-navigation #survey-next { justify-self: end; }
.survey-navigation #stepper { display: flex; align-items: center; justify-content: safe center; gap: 8px; min-width: 0; overflow-x: auto; padding: 6px; }
.survey-navigation #stepper button { flex-shrink: 0; }
#screen-survey #survey-finish { display: inline-block; width: auto; max-width: 100%; margin-top: 8px; padding: 14px 28px; background: #f97316; color: #fff; border-radius: 12px; font-weight: 600; }
#screen-survey #survey-finish:disabled { opacity: .6; cursor: wait; }
@media (max-width: 600px) {
    .survey-navigation { grid-template-columns: 1fr 1fr; gap: 8px 16px; padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
    .survey-navigation #stepper { grid-column: 1 / -1; grid-row: 1; }
    #screen-survey { padding-bottom: 140px; }
}

#survey-chain-notice { margin: 16px clamp(20px, 4vw, 80px); padding: 16px 20px; border: 1px solid #bbf7d0; border-radius: 12px; background: #f0fdf4; color: #166534; }
#survey-chain-notice p { margin: 6px 0 0; }
#survey-chain-retry { margin-top: 12px; padding: 8px 12px; border: 1px solid currentColor; border-radius: 8px; }

.survey-navigation #stepper .survey-step-current { background-color: #f97316; --tw-ring-color: rgb(249 115 22 / 20%); }

#survey-chain-notice { position: relative; padding-right: 56px; }
#survey-chain-close { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #166534; cursor: pointer; }
#survey-chain-close:hover, #survey-chain-close:focus-visible { background: #dcfce7; }

#survey-previous-form { margin: 0 0 24px; color: #64748b; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }

.survey-navigation #btn-prev:disabled { opacity: .45; cursor: not-allowed; }

.survey-submit-loader { display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px; border: 2px solid rgb(255 255 255 / 35%); border-top-color: #fff; border-radius: 50%; animation: survey-submit-loading .7s linear infinite; }
@keyframes survey-submit-loading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .survey-submit-loader { animation-duration: 1.8s; } }

/* Compact Likert options wrap without stretching across the available row. */
#screen-survey .likert-container-mobile { display: flex !important; flex-wrap: wrap; gap: 10px; align-items: stretch; justify-content: center; }
#screen-survey .likert-container-mobile .likert-item-mobile { flex: 0 0 148px; width: 148px !important; max-width: 100%; min-width: 0; min-height: 112px; padding: 14px 10px; }
#screen-survey .likert-item-mobile > span:last-of-type { font-size: 12px; line-height: 1.4; letter-spacing: normal; text-transform: none; white-space: normal; word-break: normal; overflow-wrap: normal; text-wrap: balance; }
@media (max-width: 640px) {
    #screen-survey .likert-container-mobile .likert-item-mobile { flex-basis: calc((100% - 10px) / 2); max-width: 148px; padding: 12px 8px !important; }
    #screen-survey .likert-item-mobile > span:last-of-type { font-size: 12px !important; line-height: 1.4 !important; }
}
