/* ══════════════════════════════════════
   SBTI 人格测试 — 完整样式
   Light / Dark 双主题
   ══════════════════════════════════════ */

/* ── 浅色主题（默认） ── */
:root,
[data-theme="light"] {
    --bg:            #f6faf6;
    --bg-grad-a:     #f8fff8;
    --bg-grad-b:     #f2f7f3;
    --panel:         #ffffff;
    --panel-sub:     #fbfdfb;
    --panel-alt:     #f8fcf9;
    --panel-dim:     #f7fbf8;
    --text:          #1e2a22;
    --text-sub:      #304034;
    --muted:         #6a786f;
    --line:          #dbe8dd;
    --soft:          #edf6ef;
    --accent:        #6c8d71;
    --accent-strong: #4d6a53;
    --accent-hover:  #3a5240;
    --bar-bg:        #edf3ee;
    --bar-from:      #97b59c;
    --bar-to:        #5b7a62;
    --error:         #e07a5f;
    --error-shadow:  rgba(224, 122, 95, 0.18);
    --option-hover-border: #bcd0c1;
    --shimmer:       rgba(255,255,255,0.35);
    --decor:         rgba(127, 165, 134, 0.15);
    --decor-end:     rgba(127, 165, 134, 0.02);
    --img-bg:        rgba(255, 255, 255, 0.75);
    --shadow:        0 16px 40px rgba(47, 73, 55, 0.08);
    --shadow-btn:    0 12px 30px rgba(77, 106, 83, 0.18);
    --shadow-btn-h:  0 14px 36px rgba(77, 106, 83, 0.24);
    --select-ring:   rgba(77, 106, 83, 0.12);
    --radius:        22px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color-scheme: light;
}

/* ── 深色主题 ── */
[data-theme="dark"] {
    --bg:            #0f1612;
    --bg-grad-a:     #0d1410;
    --bg-grad-b:     #131a16;
    --panel:         #1a2420;
    --panel-sub:     #1e2a24;
    --panel-alt:     #1c2822;
    --panel-dim:     #1b2621;
    --text:          #e2ede5;
    --text-sub:      #c0d1c4;
    --muted:         #8a9e8f;
    --line:          #2d3f34;
    --soft:          #22332a;
    --accent:        #7faa86;
    --accent-strong: #8fbf97;
    --accent-hover:  #a8d4b0;
    --bar-bg:        #253028;
    --bar-from:      #5a7f60;
    --bar-to:        #8fbf97;
    --error:         #e07a5f;
    --error-shadow:  rgba(224, 122, 95, 0.22);
    --option-hover-border: #3d5a44;
    --shimmer:       rgba(255,255,255,0.08);
    --decor:         rgba(127, 165, 134, 0.08);
    --decor-end:     rgba(127, 165, 134, 0.01);
    --img-bg:        rgba(0, 0, 0, 0.25);
    --shadow:        0 16px 40px rgba(0, 0, 0, 0.25);
    --shadow-btn:    0 12px 30px rgba(0, 0, 0, 0.3);
    --shadow-btn-h:  0 14px 36px rgba(0, 0, 0, 0.4);
    --select-ring:   rgba(143, 191, 151, 0.18);
    color-scheme: dark;
}

/* ── 重置 & 基础 ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
    transition: background-color 0.3s ease;
}

body {
    font-family: var(--font);
    background: radial-gradient(circle at top left, var(--bg-grad-a) 0%, var(--bg) 36%, var(--bg-grad-b) 100%);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, h3, p { margin: 0; }

.shell {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 16px 56px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(56px, env(safe-area-inset-bottom));
}

/* ── 主题切换按钮 ── */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.16s ease;
    padding: 0;
    line-height: 1;
}

.theme-toggle:hover {
    transform: scale(1.08);
    border-color: var(--accent);
}

/* ── 卡片 ── */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* ── 按钮 ── */
button {
    border: 0;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, background .2s ease, color .2s ease, border-color .2s ease;
    font: inherit;
    touch-action: manipulation;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.btn-primary {
    background: var(--accent-strong);
    color: #fff;
    padding: 14px 20px;
    border-radius: 14px;
    box-shadow: var(--shadow-btn);
    font-weight: 700;
}

[data-theme="dark"] .btn-primary {
    color: #0f1612;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-btn-h);
}

.btn-secondary {
    background: var(--panel);
    color: var(--accent-strong);
    padding: 14px 20px;
    border-radius: 14px;
    border: 1px solid var(--line);
    font-weight: 700;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--soft);
}

/* ── 焦点样式 ── */
:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

/* ══════════════════════════════════════
   屏幕过渡
   ══════════════════════════════════════ */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.screen.active { display: block; }
.screen.visible { opacity: 1; transform: translateY(0); }

/* ══════════════════════════════════════
   首页 Hero
   ══════════════════════════════════════ */
.hero {
    padding: 28px;
    margin-top: 20px;
    overflow: hidden;
    position: relative;
}

.hero::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--decor), var(--decor-end));
    pointer-events: none;
}

.hero h1 {
    font-size: clamp(28px, 5vw, 52px);
    line-height: 1.08;
    letter-spacing: -0.03em;
    max-width: 680px;
}

.hero-minimal {
    min-height: 48vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    padding: 0 20px;
}

.hero-minimal::after { display: none; }
.hero-minimal h1 { max-width: none; margin: 0; }

.hero-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 42px 0 24px;
}

.hero-sub {
    margin-top: 14px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.6;
    max-width: 400px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.hero-actions-single {
    justify-content: center;
    margin-top: 28px;
}

.hero-credit {
    display: block;
    width: 100%;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    text-align: center;
    transition: color 0.2s ease;
}

.hero-credit:hover {
    color: var(--accent-strong);
}

/* ── 恢复提示 ── */
.restore-prompt {
    margin-top: 16px;
    padding: 20px;
    text-align: center;
}

.restore-prompt p {
    color: var(--muted);
    font-size: 15px;
    margin-bottom: 14px;
}

/* ── 历史记录 ── */
.history-section {
    margin-top: 16px;
    padding: 20px;
}

.history-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.history-list { display: grid; gap: 8px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.history-item:hover {
    border-color: var(--accent);
    background: var(--soft);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-header h3 { margin-bottom: 0; }

.btn-text {
    background: none;
    color: var(--muted);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 8px;
}

.btn-text:hover { color: var(--accent-strong); background: var(--soft); }

.history-type { font-weight: 700; font-size: 14px; }

.history-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
}

.history-view-hint {
    color: var(--accent-strong);
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .history-view-hint { opacity: 1; }

/* ══════════════════════════════════════
   测试页
   ══════════════════════════════════════ */
.test-wrap, .result-wrap {
    margin-top: 22px;
    padding: 22px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

/* 进度条 */
.progress {
    flex: 1;
    min-width: 240px;
    height: 10px;
    background: var(--bar-bg);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress > span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--bar-from), var(--bar-to));
    border-radius: inherit;
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.progress > span::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, var(--shimmer) 50%, transparent 100%);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

.progress-text {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

/* 题目列表 */
.question-list { display: grid; gap: 16px; }

.question {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, var(--panel), var(--panel-sub));
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.question.highlight-unanswered {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-shadow);
}

.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--soft);
    border: 1px solid var(--line);
}

.question-title {
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* 选项 */
.options { display: grid; gap: 10px; margin-top: 14px; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color .2s ease, background .2s ease, transform .16s ease, box-shadow .2s ease;
}

.option:hover {
    border-color: var(--option-hover-border);
    background: var(--panel-alt);
}

.option.selected {
    border-color: var(--accent-strong);
    background: var(--soft);
    box-shadow: 0 0 0 2px var(--select-ring);
}

@keyframes option-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.012); }
    100% { transform: scale(1); }
}

.option.just-selected { animation: option-pulse 0.25s ease; }

.option input {
    margin-top: 3px;
    accent-color: var(--accent-strong);
    transform: scale(1.1);
    flex-shrink: 0;
}

.option-code {
    font-weight: 800;
    color: var(--accent-strong);
    min-width: 22px;
}

/* 底部操作 */
.actions-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 6px;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

/* ══════════════════════════════════════
   结果页
   ══════════════════════════════════════ */
.result-layout { display: grid; gap: 18px; }

.result-top {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 18px;
    align-items: stretch;
}

.poster-box, .type-box, .analysis-box, .dim-box, .note-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, var(--panel), var(--panel-sub));
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* 海报 */
.poster-box {
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 280px;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at top right, var(--decor), rgba(127, 165, 134, 0) 40%), linear-gradient(180deg, var(--panel), var(--panel-dim));
}

.poster-box::after {
    content: "";
    position: absolute;
    right: -46px;
    bottom: -46px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--decor), var(--decor-end));
    pointer-events: none;
}

.poster-image {
    width: 100%;
    min-height: 220px;
    max-height: 460px;
    object-fit: contain;
    border-radius: 18px;
    background: var(--img-bg);
    position: relative;
    z-index: 1;
}

.poster-box.no-image .poster-image { display: none; }

.poster-caption {
    margin-top: 14px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.8;
    position: relative;
    z-index: 1;
}

/* 类型信息 */
.type-kicker {
    font-size: 12px;
    color: var(--accent-strong);
    margin-bottom: 8px;
    letter-spacing: .06em;
}

.type-name {
    font-size: clamp(30px, 5vw, 48px);
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.type-subname {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.8;
}

.match {
    margin-top: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 10px 14px;
    background: var(--soft);
    border: 1px solid var(--line);
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 14px;
    line-height: 1.4;
}

/* 解读 */
.analysis-box h3, .dim-box h3, .note-box h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.analysis-box, .note-box {
    position: relative;
    overflow: hidden;
}

.analysis-box::before, .note-box::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 18px 0 0 18px;
}

.analysis-box::before { background: var(--accent-strong); }
.note-box::before { background: var(--bar-from); }

.analysis-box p {
    margin: 0;
    color: var(--text-sub);
    font-size: 15px;
    line-height: 1.9;
    white-space: pre-wrap;
}

/* 维度列表 */
.dim-list { display: grid; gap: 18px; }

.dim-model-group { display: grid; gap: 10px; }

.dim-model-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-strong);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 4px 12px;
    margin-bottom: 2px;
}

.dim-item {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    padding-left: 18px;
    background: var(--panel);
    position: relative;
    overflow: hidden;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.dim-item::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    border-radius: 16px 0 0 16px;
    background: var(--bar-from);
}

.dim-level-H::before { background: #5b7a62; }
.dim-level-M::before { background: #97b59c; }
.dim-level-L::before { background: #c8d8cb; }

[data-theme="dark"] .dim-level-H::before { background: #8fbf97; }
[data-theme="dark"] .dim-level-M::before { background: #5a7f60; }
[data-theme="dark"] .dim-level-L::before { background: #3d5a44; }

.dim-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.dim-item-name { font-size: 14px; font-weight: 700; color: var(--text); }
.dim-item-score { color: var(--accent-strong); font-weight: 800; font-size: 14px; white-space: nowrap; }

/* 维度进度条 */
.dim-bar {
    height: 6px;
    background: var(--bar-bg);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 8px;
}

.dim-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bar-from), var(--bar-to));
    border-radius: inherit;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.dim-item p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

/* 友情提示 */
.note-box p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

/* 作者的话 */
.author-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, var(--panel), var(--panel-alt));
    overflow: hidden;
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.author-box::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent-strong);
    border-radius: 18px 0 0 18px;
}

.author-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px 0;
}

.author-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 1px;
}

[data-theme="dark"] .author-avatar { color: #0f1612; }

.author-name { font-size: 16px; font-weight: 700; color: var(--text); }

.author-content { padding: 6px 22px 22px; }

.author-content p {
    margin: 12px 0 0;
    color: var(--text-sub);
    font-size: 14px;
    line-height: 1.9;
}

.author-content p:first-child { margin-top: 0; }

.author-link {
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 700;
    transition: color 0.2s ease;
}

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

/* 结果操作 */
.result-actions {
    margin-top: 22px;
}

.result-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.result-actions-grid .btn-primary,
.result-actions-grid .btn-secondary {
    width: 100%;
    text-align: center;
    padding: 13px 12px;
    font-size: 14px;
}

/* ══════════════════════════════════════
   响应式
   ══════════════════════════════════════ */
@media (max-width: 860px) {
    .result-top { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .shell { padding: 14px 12px 42px; }
    .hero, .test-wrap, .result-wrap { padding: 16px; }
    .hero h1 { font-size: 32px; }
    .question-title { font-size: 15px; }
    .option { padding: 16px; min-height: 44px; }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--panel);
        margin: -16px -16px 18px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--line);
        border-radius: 18px 18px 0 0;
    }

    .result-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dim-item { padding: 12px; padding-left: 16px; }
    .dim-model-label { font-size: 11px; padding: 3px 10px; }

    .analysis-box, .note-box, .dim-box, .poster-box, .type-box { padding: 16px; }
    .author-header { padding: 16px 16px 0; }
    .author-content { padding: 6px 16px 16px; }

    .theme-toggle { top: 12px; right: 12px; width: 38px; height: 38px; font-size: 16px; }
}

@media (max-width: 380px) {
    .result-actions-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .result-actions-grid .btn-primary,
    .result-actions-grid .btn-secondary {
        font-size: 13px;
        padding: 11px 8px;
    }
}
