*, *::before, *::after {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8f9fa;
    color: #1a1a2e;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* ========================
   APP SHELL
   ======================== */
.survey-app {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    -webkit-box-shadow: 0 0 40px rgba(0,0,0,.06);
    box-shadow: 0 0 40px rgba(0,0,0,.06);
    overflow: hidden;
}

/* dvh for modern browsers that support it */
@supports (height: 100dvh) {
    .survey-app {
        height: 100dvh;
    }
}

/* ========================
   HEADER
   ======================== */
.survey-header {
    background: #700000;
    background: -webkit-linear-gradient(315deg, #700000 0%, #a31515 100%);
    background: linear-gradient(135deg, #700000 0%, #a31515 100%);
    color: #fff;
    padding: 12px 16px 0;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    z-index: 10;
}

.header-content {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    padding-bottom: 10px;
}

.header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -o-object-fit: cover;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.3);
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    margin-right: 10px;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
}

.progress-bar {
    height: 4px;
    background: rgba(255,255,255,.2);
    border-radius: 2px;
    -webkit-border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -webkit-transition: width .4s ease;
    -o-transition: width .4s ease;
    transition: width .4s ease;
    width: 0%;
}

/* ========================
   MAIN CONTENT AREA
   ======================== */
.survey-main {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.question-slide {
    display: none;
    padding: 24px 20px 32px;
    min-height: 100%;
}

.question-slide.active {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
    -ms-flex-align: start;
    align-items: flex-start;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
}

/* ========================
   QUESTION CARD
   ======================== */
.question-card {
    width: 100%;
    max-width: 480px;
}

.question-number {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #700000;
    background: rgba(112,0,0,.08);
    padding: 4px 10px;
    border-radius: 20px;
    -webkit-border-radius: 20px;
    margin-bottom: 14px;
}

.question-text {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 24px;
    color: #1a1a2e;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ========================
   ANSWER OPTIONS
   ======================== */
.options-list {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
}

.options-list .option-item {
    margin-bottom: 10px;
}

.options-list .option-item:last-child {
    margin-bottom: 0;
}

.option-item {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    min-height: 48px;
    padding: 12px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    -webkit-border-radius: 12px;
    cursor: pointer;
    -webkit-transition: all .2s ease;
    -o-transition: all .2s ease;
    transition: all .2s ease;
    position: relative;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option-item:active {
    border-color: #700000;
    background: rgba(112,0,0,.06);
}

.option-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Selected state — uses JS-applied class for full compat */
.option-item.selected {
    border-color: #700000;
    background: rgba(112,0,0,.06);
}

.option-item.selected .option-label {
    color: #700000;
    font-weight: 600;
}

.option-item.selected .option-check {
    opacity: 1;
    color: #700000;
}

.option-label {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    font-size: 16px;
    line-height: 1.4;
    color: #374151;
    -webkit-transition: color .2s;
    -o-transition: color .2s;
    transition: color .2s;
    margin-right: 10px;
}

.option-check {
    opacity: 0;
    font-size: 20px;
    font-weight: 700;
    color: #700000;
    -webkit-transition: opacity .2s;
    -o-transition: opacity .2s;
    transition: opacity .2s;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    line-height: 1;
}

/* ========================
   TEXTAREA (free-text)
   ======================== */
.textarea-wrap textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    -webkit-border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    -webkit-transition: border-color .2s;
    -o-transition: border-color .2s;
    transition: border-color .2s;
    background: #fafafa;
    color: #1a1a2e;
    max-width: 100%;
    -webkit-appearance: none;
}

.textarea-wrap textarea:focus {
    outline: none;
    border-color: #700000;
    background: #fff;
}

.textarea-wrap textarea::-webkit-input-placeholder { color: #9ca3af; }
.textarea-wrap textarea::-moz-placeholder { color: #9ca3af; }
.textarea-wrap textarea:-ms-input-placeholder { color: #9ca3af; }
.textarea-wrap textarea::placeholder { color: #9ca3af; }

/* ========================
   SUBMIT SLIDE
   ======================== */
.submit-card {
    text-align: center;
    padding-top: 32px;
}

.submit-icon {
    font-size: 52px;
    color: #700000;
    margin-bottom: 14px;
    display: block;
    line-height: 1;
}

.submit-description {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 28px;
    padding: 0 8px;
}

.btn-submit {
    display: inline-block;
    min-height: 50px;
    padding: 14px 48px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: #700000;
    background: -webkit-linear-gradient(315deg, #700000 0%, #a31515 100%);
    background: linear-gradient(135deg, #700000 0%, #a31515 100%);
    border: none;
    border-radius: 12px;
    -webkit-border-radius: 12px;
    cursor: pointer;
    -webkit-transition: opacity .15s;
    -o-transition: opacity .15s;
    transition: opacity .15s;
    -webkit-box-shadow: 0 4px 14px rgba(112,0,0,.3);
    box-shadow: 0 4px 14px rgba(112,0,0,.3);
    -webkit-appearance: none;
    -moz-appearance: none;
    text-decoration: none;
    text-align: center;
    line-height: 1.4;
}

.btn-submit:active {
    opacity: .8;
}

.btn-submit:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ========================
   FOOTER NAV
   ======================== */
.survey-footer {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    padding: 10px 16px 14px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    z-index: 10;
}

/* iOS safe area — only applies on devices that support it */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .survey-footer {
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
}

.nav-btn {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    background: #fff;
    cursor: pointer;
    -webkit-transition: all .2s;
    -o-transition: all .2s;
    transition: all .2s;
    color: #374151;
    -webkit-appearance: none;
    -moz-appearance: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
}

.nav-btn:active:not(:disabled) {
    border-color: #700000;
    color: #700000;
    background: rgba(112,0,0,.06);
}

.nav-btn:disabled {
    opacity: .3;
    cursor: not-allowed;
}

/* ========================
   STEP DOTS
   ======================== */
.step-dots {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    overflow: hidden;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
    padding: 0 8px;
}

.dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    background: #e5e7eb;
    -webkit-transition: all .3s;
    -o-transition: all .3s;
    transition: all .3s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    display: inline-block;
    margin: 0 2px;
}

.dot.active {
    background: #700000;
    width: 22px;
    min-width: 22px;
    border-radius: 4px;
    -webkit-border-radius: 4px;
}

/* Compact dots for many questions */
.step-dots.compact .dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    margin: 0 1px;
}

.step-dots.compact .dot.active {
    width: 18px;
    min-width: 18px;
    height: 6px;
}

/* ========================
   PHONE BREAKPOINTS
   ======================== */

/* Small phones (iPhone SE, Galaxy S4, older 320-375px devices) */
@media screen and (max-width: 375px) {
    .survey-header {
        padding: 10px 12px 0;
    }
    .header-title {
        font-size: 15px;
    }
    .header-avatar {
        width: 34px;
        height: 34px;
    }
    .question-slide {
        padding: 18px 14px 24px;
    }
    .question-text {
        font-size: 18px;
        margin-bottom: 18px;
    }
    .question-number {
        font-size: 10px;
        margin-bottom: 10px;
    }
    .option-item {
        padding: 10px 12px;
    }
    .option-label {
        font-size: 15px;
    }
    .survey-footer {
        padding: 8px 12px 12px;
    }
}

/* Standard phones */
@media screen and (max-width: 480px) {
    .question-slide {
        padding: 22px 16px 28px;
    }
    .question-text {
        font-size: 19px;
    }
    .btn-submit {
        display: block;
        width: 100%;
        padding: 14px 24px;
    }
}

/* Landscape on phones */
@media screen and (max-height: 500px) {
    .survey-header {
        padding: 6px 16px 0;
    }
    .header-content {
        padding-bottom: 6px;
    }
    .header-avatar {
        width: 30px;
        height: 30px;
    }
    .question-slide {
        padding: 12px 20px 16px;
    }
    .question-text {
        font-size: 17px;
        margin-bottom: 14px;
    }
    .question-number {
        margin-bottom: 8px;
    }
    .options-list .option-item {
        margin-bottom: 6px;
    }
    .option-item {
        min-height: 40px;
        padding: 8px 12px;
    }
    .survey-footer {
        padding: 6px 16px 8px;
    }
    .submit-card {
        padding-top: 12px;
    }
    .submit-icon {
        font-size: 36px;
        margin-bottom: 8px;
    }
}

/* Desktop */
@media screen and (min-width: 768px) {
    .survey-app {
        margin-top: 20px;
        margin-bottom: 20px;
        border-radius: 16px;
        -webkit-border-radius: 16px;
        height: calc(100vh - 40px);
    }
    @supports (height: 100dvh) {
        .survey-app {
            height: calc(100dvh - 40px);
        }
    }
}
