/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5A4BD1;
    --accent: #00CEC9;
    --accent-light: #81ECEC;
    --danger: #FD79A8;
    --warning: #FDCB6E;
    --bg: #F8F9FE;
    --card: #FFFFFF;
    --text: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --border: #E8ECF4;
    --shadow-sm: 0 2px 8px rgba(108, 92, 231, 0.08);
    --shadow-md: 0 4px 20px rgba(108, 92, 231, 0.12);
    --shadow-lg: 0 8px 40px rgba(108, 92, 231, 0.16);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Container ===== */
.container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

.page {
    min-height: 100vh;
    min-height: 100dvh;
    animation: pageIn 0.35s ease-out;
}

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

/* ===== Home Page ===== */
.home-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    background: linear-gradient(160deg, #6C5CE7 0%, #A29BFE 50%, #81ECEC 100%);
    position: relative;
    overflow: hidden;
}

.home-page::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -40%;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

.home-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -30%;
    width: 400px;
    height: 400px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}

.hero-section {
    position: relative;
    z-index: 1;
}

.logo {
    width: 88px;
    height: 88px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    margin: 0 auto 32px;
    letter-spacing: 1px;
}

.hero-section h1 {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 15px;
    color: rgba(255,255,255,0.85);
    margin-bottom: 48px;
    line-height: 1.7;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.features {
    display: flex;
    gap: 16px;
    margin-bottom: 48px;
    width: 100%;
    max-width: 340px;
}

.feature-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-md);
    padding: 18px 8px;
}

.feature-item .icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.25);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
}

.feature-item span:last-child {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

.btn-primary {
    background: #fff;
    color: var(--primary);
    border: none;
    padding: 16px 64px;
    border-radius: var(--radius-full);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    letter-spacing: 0.5px;
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.tips {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-top: 24px;
}

/* ===== Questionnaire Page ===== */
.questionnaire-page {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--bg);
}

.header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.btn-back {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.btn-back:active {
    background: var(--border);
}

.progress {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-full);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.question-content {
    flex: 1;
    padding: 28px 20px 120px;
}

.question-title {
    font-size: 21px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.5;
    letter-spacing: -0.3px;
}

.question-hint {
    display: inline-block;
    font-size: 12px;
    color: var(--primary);
    background: rgba(108, 92, 231, 0.08);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    margin-bottom: 24px;
    font-weight: 500;
    white-space: pre-line;
}

.section-badge {
    display: inline-block;
    font-size: 12px;
    color: var(--accent);
    background: rgba(0, 206, 201, 0.1);
    padding: 4px 14px;
    border-radius: var(--radius-full);
    margin: 0 24px 8px;
    font-weight: 600;
    letter-spacing: 1px;
}

.input-area {
    padding: 0 4px;
}

.input-field {
    width: 100%;
    padding: 16px 18px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.input-field::placeholder {
    color: var(--text-muted);
    font-size: 14px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 16px 18px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-user-select: none;
    user-select: none;
}

.option-item:active {
    transform: scale(0.98);
}

.option-item.selected {
    background: rgba(108, 92, 231, 0.06);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.option-code {
    width: 30px;
    height: 30px;
    background: var(--bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    margin-right: 14px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.option-item.selected .option-code {
    background: var(--primary);
    color: #fff;
}

.option-text {
    flex: 1;
    font-size: 15px;
    color: var(--text);
    font-weight: 500;
}

.check-icon {
    color: var(--primary);
    font-size: 16px;
    font-weight: bold;
}

/* ===== Footer Buttons ===== */
.footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 430px;
    margin: 0 auto;
    z-index: 10;
}

.btn-prev, .btn-next {
    flex: 1;
    padding: 15px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-prev {
    background: var(--bg);
    color: var(--text-secondary);
    flex: 0 0 auto;
    padding: 15px 24px;
}

.btn-prev:active {
    background: var(--border);
}

.btn-next {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

.btn-next:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
}

.btn-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== Loading Page ===== */
.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    background: var(--bg);
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loader p {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-top: 28px;
}

.loader .sub-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 400;
}

/* ===== Result Page ===== */
.result-page {
    padding: 0 0 calc(20px + var(--safe-bottom));
    background: var(--bg);
}

.result-header {
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 48px 24px 32px;
    text-align: center;
    border-radius: 0 0 32px 32px;
    position: relative;
}

.result-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}

.profile-card {
    margin: -16px 16px 16px;
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 2;
}

.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: linear-gradient(135deg, rgba(108,92,231,0.1), rgba(0,206,201,0.1));
    color: var(--primary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
}

.ai-analysis {
    margin: 0 16px 20px;
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.ai-analysis::before {
    content: '✨';
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 20px;
}

.ai-analysis h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-analysis p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.recommendations {
    padding: 0 16px;
}

.recommendations h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-item {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.product-item:active {
    box-shadow: var(--shadow-md);
}

.product-image {
    display: none;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.product-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.match-score {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.product-brand {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.product-reason {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-price {
    font-size: 18px;
    color: var(--danger);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.btn-buy {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-buy:active {
    transform: scale(0.95);
}

/* ===== Result Footer ===== */
.result-footer {
    display: flex;
    gap: 12px;
    margin: 24px 16px 0;
    padding-top: 20px;
}

.btn-retry, .btn-share {
    flex: 1;
    padding: 15px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-retry {
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--text-secondary);
}

.btn-retry:active {
    background: var(--border);
}

.btn-share {
    background: var(--primary);
    border: none;
    color: #fff;
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

.btn-share:active {
    transform: scale(0.98);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    z-index: 1000;
    animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: calc(100vw - 48px);
    text-align: center;
}

.toast.error {
    background: rgba(253, 121, 168, 0.95);
}

.toast.warning {
    background: rgba(253, 203, 110, 0.95);
    color: #6D4C00;
}

.toast.info {
    background: rgba(108, 92, 231, 0.95);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ===== Disabled Option ===== */
.option-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 32px 24px;
    max-width: 340px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.modal-message {
    font-size: 15px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
}

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

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 0;
    display: none;
}

/* ===== Responsive fine-tuning ===== */
@media (max-width: 380px) {
    .hero-section h1 {
        font-size: 24px;
    }
    .features {
        gap: 10px;
    }
    .feature-item {
        padding: 14px 6px;
    }
    .btn-primary {
        padding: 15px 48px;
        font-size: 16px;
    }
    .question-title {
        font-size: 19px;
    }
}

@media (min-width: 431px) {
    .container {
        padding: 0;
    }
    .home-page {
        border-radius: 0 0 32px 32px;
    }
}
