/* ============ 基础重置 ============ */
* {
    box-sizing: border-box;
}

:root {
    --bg: #f7f7f8;
    --surface: #ffffff;
    --surface-alt: #f0f1f3;
    --border: #e2e4e8;
    --border-strong: #cfd3d9;
    --text: #1f2328;
    --text-muted: #5c6470;
    --text-subtle: #8a919c;
    --accent: #3b4cca;
    --accent-hover: #2f3eb0;
    --accent-soft: #eef0fb;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06);
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.65;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

/* ============ 头部导航 ============ */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text);
    letter-spacing: -0.01em;
}

.logo:hover {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}

.nav-links a:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

/* 汉堡菜单 */
.hamburger {
    display: none;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    position: relative;
    background: none;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.hamburger-lines {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text);
    position: relative;
    transition: background-color var(--transition);
}

.hamburger-lines::before,
.hamburger-lines::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 2px;
    background-color: var(--text);
    left: 0;
    transition: transform var(--transition);
}

.hamburger-lines::before { top: -6px; }
.hamburger-lines::after  { bottom: -6px; }

.hamburger.active .hamburger-lines { background-color: transparent; }
.hamburger.active .hamburger-lines::before { transform: rotate(45deg); top: 0; }
.hamburger.active .hamburger-lines::after  { transform: rotate(-45deg); bottom: 0; }

/* ============ 布局 ============ */
.container {
    display: flex;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 24px;
    gap: 24px;
    width: 100%;
    flex-grow: 1;
    align-items: flex-start;
}

.content {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.sidebar {
    flex: 0 0 260px;
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    align-self: flex-start;
}

.sidebar h3 {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li { margin-bottom: 4px; }

.sidebar ul li a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.sidebar ul li a:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ============ 标题与正文 ============ */
h1 {
    margin: 0 0 16px;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

#info { margin-top: 48px; }

#info h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 32px 0 12px;
    color: var(--text);
    letter-spacing: -0.01em;
}

#info h2:first-child { margin-top: 0; }

#info h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 24px 0 8px;
    color: var(--text);
}

#info h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 6px;
    color: var(--text);
}

#info p {
    font-size: 15.5px;
    margin: 0 0 16px;
    color: var(--text-muted);
}

#info ol,
#info ul {
    padding-left: 20px;
    margin: 0 0 16px;
}

#info li {
    color: var(--text-muted);
    margin-bottom: 8px;
    font-size: 15.5px;
}

#info ul li::marker { color: var(--accent); }

#info strong { color: var(--text); font-weight: 600; }
#info a { color: var(--accent); text-decoration: none; }
#info a:hover { text-decoration: underline; }

#info em {
    color: var(--text-subtle);
    font-style: italic;
}

/* ============ 计算器 / 测验容器 ============ */
.calculator-container {
    max-width: 640px;
    margin: 32px auto;
    padding: 32px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.measurement-input { margin-bottom: 20px; }

.measurement-input label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.measurement-input input,
.calculator-container input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.calculator-container input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============ 按钮 ============ */
.calc-btn {
    display: block;
    margin: 20px auto;
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    font-family: inherit;
    width: fit-content;
}

.calc-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.calc-btn:active { transform: translateY(1px); }

/* 性别选择按钮（沿用类名，改为次要按钮样式） */
.gender-selection {
    margin: 24px 0;
    text-align: center;
}

.gender-btn {
    padding: 10px 20px;
    margin: 0 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
    font-family: inherit;
}

.gender-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.gender-btn.selected {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============ 测验 ============ */
.quiz-container {
    display: none;
    max-width: 800px;
    margin: 0 auto;
}

.question {
    margin: 20px 0;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease-out;
}

.question h3 {
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 16px;
}

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

.option {
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    color: var(--text-muted);
    font-size: 15px;
}

.option:hover {
    border-color: var(--border-strong);
    background: var(--surface-alt);
    color: var(--text);
}

.option.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
}

/* ============ 进度条 ============ */
.progress-container {
    width: 100%;
    background: var(--surface-alt);
    border-radius: 999px;
    margin: 16px 0;
    overflow: hidden;
    height: 6px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ============ 结果区 ============ */
#result,
.result-container {
    display: none;
    padding: 32px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-top: 24px;
    animation: fadeIn 0.4s ease-out;
}

#result h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 16px;
}

.type-description { margin-top: 20px; line-height: 1.65; }
.type-description h3 {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    margin: 20px 0 8px;
}

/* 结果中的特质条（原 trait-bar） */
.trait-result {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.trait-result:last-child { border-bottom: none; }

.trait-result h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 10px;
}

.trait-bar {
    height: 6px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0;
}

.trait-bar > div {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.trait-result p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 8px 0 0;
}

/* ============ 表格 ============ */
.table-wrapper { overflow-x: auto; }

table,
.product-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td,
.product-table th,
.product-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14.5px;
}

th,
.product-table th {
    background: var(--surface-alt);
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:last-child td { border-bottom: none; }

.number-cell {
    font-weight: 600;
    color: var(--text);
    width: 50px;
}

.image-cell { width: 170px; }
.button-cell { width: 150px; }

.product-table-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    transition: transform var(--transition);
}

.product-table-image:hover { transform: scale(1.04); }

.table-amazon-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: background var(--transition);
    text-align: center;
}

.table-amazon-button:hover { background: var(--accent-hover); }

.product-title {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    max-height: 2.8em;
    margin-bottom: 8px;
    text-overflow: ellipsis;
}

.product-title:hover { color: var(--accent); }

/* ============ Likert 量表 ============ */
.likert-scale {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    gap: 8px;
}

.likert-option {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
}

.likert-option:hover {
    border-color: var(--border-strong);
    background: var(--surface-alt);
}

.likert-option.selected {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* ============ 单选/复选 ============ */
.conversion-options {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    justify-content: center;
}

.radio-group {
    position: relative;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-group label {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition);
}

.radio-group input[type="radio"]:checked + label {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 600;
}

.radio-group label:hover {
    border-color: var(--border-strong);
    background: var(--surface-alt);
}

.radio-group input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.radio-group input[type="radio"]:disabled + label {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    position: relative;
    background: var(--surface);
    vertical-align: middle;
    transition: all var(--transition);
}

.input-group input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.input-group input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ============ 卡片网格 ============ */
.calculator-cards {
    padding: 20px;
    max-width: 1100px;
    margin: 0 auto;
}

.calculator-cards ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.calculator-cards li {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.calculator-cards li:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.calculator-cards li a {
    display: block;
    padding: 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: color var(--transition);
}

.calculator-cards li a:hover { color: var(--accent); }

/* ============ 页脚 ============ */
.footer {
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    background: var(--surface);
}

.footer p {
    padding: 3px;
    font-size: 13px;
    color: var(--text-subtle);
    margin: 0;
}

.footer p a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0 6px;
    transition: color var(--transition);
}

.footer p a:hover { color: var(--accent); }

/* ============ 动画 ============ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ 响应式 ============ */
@media (max-width: 900px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        right: 16px;
        background: var(--surface);
        width: 200px;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 8px;
    }

    .nav-links.active { display: block; }
    .nav-links a { display: block; }
    .hamburger { display: block; }

    .container {
        flex-direction: column;
        padding: 16px;
        gap: 16px;
        margin: 16px auto;
    }

    .content { padding: 24px; }
    .sidebar {
        flex: 0 0 auto;
        width: 100%;
        margin: 0;
        padding: 20px;
    }

    h1 { font-size: 22px; }
    #info h2 { font-size: 19px; }
    #info h3 { font-size: 16px; }

    label, select, button { font-size: 16px; }
}

@media (max-width: 768px) {
    .likert-scale { flex-direction: column; gap: 8px; }

    .gender-selection {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .gender-btn { margin: 0; width: 100%; padding: 12px; }
    .options { flex-direction: column; }
    .option { padding: 14px; }
    .question { padding: 20px; margin: 16px 0; }
    #result, .result-container { padding: 20px; }
    .calc-btn { width: 100%; padding: 14px; }

    .calculator-cards ul { grid-template-columns: 1fr; }
    .calculator-cards { padding: 0; }

    /* 表格转卡片 */
    .product-table thead { display: none; }
    .product-table,
    .product-table tbody,
    .product-table tr,
    .product-table td {
        display: block;
        width: 100%;
        text-align: center;
    }

    .product-table tr {
        margin-bottom: 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 16px;
        background: var(--surface);
    }

    .product-table td { border: none; padding: 8px; }
    .number-cell { font-size: 14px; color: var(--text); margin-bottom: 8px; }
    .image-cell { margin: 0 auto; }
    .product-table-image { width: 160px; height: 160px; margin: 0 auto; }
    .product-title { font-size: 15px; margin: 12px auto; max-width: 300px; }
    .button-cell { margin-top: 12px; }
    .table-amazon-button { width: 100%; max-width: 200px; margin: 0 auto; padding: 12px 20px; }
    .number-cell::before { content: "#"; }
}

@media (max-width: 480px) {
    .content { padding: 20px; }
    .calculator-container { padding: 20px; }
    .product-table-image { width: 130px; height: 130px; }
    .product-title { font-size: 14px; max-width: 250px; }
    h1 { font-size: 20px; }
    #info p, #info li { font-size: 15px; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
