:root {
    --bg: #f7f3ec;
    --surface: #fffdf8;
    --surface-strong: #ffffff;
    --ink: #082c55;
    --text: #24364a;
    --muted: #64748b;
    --line: #dbe4ef;
    --primary: #064885;
    --primary-hover: #073a6a;
    --teal: #0f766e;
    --amber: #b7791f;
    --danger: #c2413a;
    --danger-soft: #fff1ef;
    --success: #237a55;
    --success-soft: #eaf7ef;
    --shadow: 0 18px 45px rgba(8, 44, 85, 0.10);
    --shadow-soft: 0 8px 24px rgba(8, 44, 85, 0.08);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background:
        linear-gradient(180deg, #fbf8f2 0%, #f7f3ec 42%, #eef6f6 100%);
    min-height: 100vh;
}

button,
input,
textarea,
select {
    font: inherit;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 导航栏 */
.navbar {
    background: rgba(255, 253, 248, 0.94);
    border-bottom: 1px solid rgba(219, 228, 239, 0.9);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 76px;
}

.nav-brand h1 {
    color: var(--ink);
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 0;
}

.nav-menu,
#userNav {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: #2e4055;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 700;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: #e7f0f8;
    color: var(--primary);
}

/* 主内容 */
.main-content {
    min-height: calc(100vh - 180px);
    padding: 32px 0 10px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* 首页 */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.88fr);
    gap: 42px;
    align-items: center;
    min-height: 430px;
    padding: 30px 0 36px;
}

.hero-copy {
    max-width: 620px;
}

.hero h2 {
    color: var(--ink);
    font-size: clamp(34px, 4.2vw, 54px);
    line-height: 1.14;
    font-weight: 900;
    letter-spacing: 0;
    margin-bottom: 18px;
}

.hero p {
    max-width: 560px;
    color: #40536a;
    font-size: 18px;
    line-height: 1.75;
    margin-bottom: 22px;
}

.home-search {
    display: flex;
    gap: 12px;
    max-width: 660px;
    margin-bottom: 18px;
}

.home-search input,
.search-box input,
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.home-search input:focus,
.search-box input:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #94b8d8;
    box-shadow: 0 0 0 4px rgba(6, 72, 133, 0.10);
}

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

.hero-visual {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-self: stretch;
    align-content: center;
}

.hero-tile {
    appearance: none;
    text-align: left;
    font: inherit;
    min-height: 136px;
    padding: 22px;
    border: 1px solid #d7e2ee;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background-color 0.2s;
}

.hero-tile:hover {
    transform: translateY(-3px);
    border-color: #b9cce0;
    box-shadow: var(--shadow);
}

.hero-tile span {
    display: block;
    color: var(--primary);
    font-size: 15px;
    font-weight: 950;
    margin-bottom: 14px;
}

.hero-tile strong {
    display: block;
    color: var(--ink);
    font-size: 24px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.hero-tile p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.hero-tile-accent {
    background: var(--primary);
    border-color: var(--primary);
}

.hero-tile-accent span,
.hero-tile-accent strong,
.hero-tile-accent p {
    color: #fff;
}

.home-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
    margin: 0 0 44px;
}

.home-kpis > div {
    border-top: 1px solid #cdd9e6;
    padding-top: 20px;
}

.home-kpis strong {
    display: block;
    color: var(--primary);
    font-size: 25px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.home-kpis span {
    color: var(--muted);
    font-weight: 700;
}

.home-section,
.categories-grid {
    margin-bottom: 52px;
}

.section-header,
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.section-header h3,
.categories-grid h3,
.page-header h2,
#recordsPage > h2 {
    color: var(--ink);
    font-size: 26px;
    line-height: 1.25;
    font-weight: 900;
}

/* 按钮 */
.btn {
    padding: 13px 22px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 850;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, color 0.2s, border-color 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

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

.btn-primary,
.search-box button {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 24px rgba(6, 72, 133, 0.18);
}

.btn-primary:hover,
.search-box button:hover {
    background: var(--primary-hover);
}

.btn-secondary,
.btn-quiet {
    background: #edf4f8;
    color: var(--primary);
    border-color: #cddfed;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border-color: #b9cce0;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    background: var(--amber);
    color: #fff;
}

.btn-sm {
    padding: 8px 13px;
    font-size: 13px;
}

/* 分类 */
.categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.category-card {
    background: rgba(255, 255, 255, 0.82);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
}

.category-card:hover,
.scale-card:hover {
    transform: translateY(-4px);
    border-color: #b9cce0;
    box-shadow: var(--shadow);
}

.category-card h4 {
    color: var(--ink);
    font-size: 19px;
    margin-bottom: 10px;
}

.category-card p {
    color: var(--muted);
    font-size: 14px;
}

/* 量表 */
.scales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.featured-scales-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.scale-card {
    min-height: 220px;
    background: rgba(255, 255, 255, 0.86);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.scale-card .category {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    background: #e8f3f1;
    color: var(--teal);
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 14px;
}

.scale-card h3 {
    color: var(--ink);
    font-size: 21px;
    line-height: 1.35;
    margin-bottom: 12px;
}

.scale-card p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 18px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scale-card .meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #5d7188;
    font-size: 13px;
    font-weight: 800;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid #edf2f7;
}

.featured-scale-card {
    border-top: 5px solid var(--primary);
}

.mbti-promo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 26px;
    border: 1px solid #cddfed;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-soft);
}

.eyebrow {
    display: inline-flex;
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.mbti-promo h3 {
    color: var(--ink);
    font-size: 25px;
    line-height: 1.25;
    margin-bottom: 8px;
}

.mbti-promo p {
    max-width: 700px;
    color: var(--muted);
}

.mbti-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.74fr);
    gap: 36px;
    align-items: center;
    margin-bottom: 34px;
    padding: 18px 0 28px;
}

.mbti-hero h2 {
    color: var(--ink);
    font-size: clamp(34px, 4vw, 50px);
    line-height: 1.12;
    margin-bottom: 16px;
}

.mbti-hero p {
    max-width: 670px;
    color: #40536a;
    font-size: 17px;
    line-height: 1.8;
    margin-bottom: 22px;
}

.mbti-hero-image {
    min-height: 300px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mbti-hero-image div,
.mbti-card-image {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid rgba(8, 44, 85, 0.12);
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.92), transparent 26%),
        linear-gradient(135deg, #e6f1f8 0%, #d8efe9 55%, #fff4dc 100%);
}

.mbti-hero-image div {
    display: flex;
    align-items: end;
    min-height: 138px;
    padding: 18px;
    color: #fff;
    font-size: 26px;
    font-weight: 950;
    text-shadow: 0 2px 14px rgba(8, 44, 85, 0.34);
}

.mbti-hero-image div:nth-child(2) {
    background:
        radial-gradient(circle at 74% 20%, rgba(255, 255, 255, 0.9), transparent 26%),
        linear-gradient(135deg, #f5d8c4 0%, #dcecf9 52%, #d9f0dd 100%);
}

.mbti-hero-image div:nth-child(3) {
    background:
        radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.92), transparent 24%),
        linear-gradient(135deg, #d7e9dd 0%, #edf4f8 50%, #f5e3c4 100%);
}

.mbti-hero-image div:nth-child(4) {
    background:
        radial-gradient(circle at 78% 18%, rgba(255, 255, 255, 0.9), transparent 25%),
        linear-gradient(135deg, #e1d7f0 0%, #d7edf0 50%, #ffe0b7 100%);
}

.mbti-section-header {
    margin-bottom: 18px;
}

.mbti-section-header h3 {
    color: var(--ink);
    font-size: 27px;
    line-height: 1.25;
    margin-bottom: 6px;
}

.mbti-section-header p {
    color: var(--muted);
}

.mbti-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.mbti-type-card {
    min-height: 390px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
}

.mbti-card-image {
    min-height: 150px;
    border-width: 0;
    border-bottom: 1px solid var(--line);
}

.mbti-card-image::before,
.mbti-card-image::after {
    content: "";
    position: absolute;
    inset: auto 22px 20px auto;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.58);
    box-shadow: -64px -18px 0 rgba(255, 255, 255, 0.28);
}

.mbti-card-image::after {
    inset: 28px auto auto 26px;
    width: 54px;
    height: 54px;
    border-radius: 14px;
    transform: rotate(12deg);
    background: rgba(8, 44, 85, 0.13);
    box-shadow: 54px 34px 0 rgba(15, 118, 110, 0.13);
}

.mbti-card-image span {
    position: absolute;
    left: 18px;
    bottom: 14px;
    color: #fff;
    font-size: 30px;
    font-weight: 950;
    line-height: 1;
    text-shadow: 0 2px 16px rgba(8, 44, 85, 0.4);
}

.mbti-image-strategy,
.mbti-image-logic,
.mbti-image-lead,
.mbti-image-idea {
    background: linear-gradient(135deg, #173d67 0%, #5c87a8 58%, #d7e7ee 100%);
}

.mbti-image-vision,
.mbti-image-create,
.mbti-image-mentor,
.mbti-image-spark {
    background: linear-gradient(135deg, #0f766e 0%, #75a99f 56%, #f4dfbd 100%);
}

.mbti-image-order,
.mbti-image-care,
.mbti-image-execute,
.mbti-image-connect {
    background: linear-gradient(135deg, #6d7f54 0%, #aab98a 52%, #f5e7cf 100%);
}

.mbti-image-craft,
.mbti-image-aesthetic,
.mbti-image-action,
.mbti-image-stage {
    background: linear-gradient(135deg, #9a5c2e 0%, #d5945e 50%, #f7d9bb 100%);
}

.mbti-card-body {
    padding: 20px;
}

.mbti-group {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #e8f3f1;
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
}

.mbti-card-body h4 {
    color: var(--ink);
    font-size: 21px;
    line-height: 1.25;
    margin-bottom: 12px;
}

.mbti-card-body p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* 页面头部和筛选 */
.search-box {
    display: flex;
    gap: 10px;
}

.search-box input {
    width: 320px;
}

.search-box button {
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 800;
}

.category-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 9px 15px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #42566e;
    cursor: pointer;
    font-weight: 800;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* 登录表单 */
.auth-form {
    max-width: 430px;
    margin: 62px auto;
    background: rgba(255, 255, 255, 0.9);
    padding: 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-form h2 {
    color: var(--ink);
    font-size: 30px;
    margin-bottom: 24px;
}

.auth-hint {
    margin: -8px 0 20px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.form-message {
    min-height: 20px;
    margin-top: 12px;
    color: #2563eb;
    font-size: 14px;
    line-height: 1.4;
}

.form-message-error {
    color: #dc2626;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #42566e;
    font-size: 14px;
    font-weight: 800;
}

.consent-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 6px 0 18px;
    color: #42566e;
    font-size: 13px;
    line-height: 1.6;
}

.consent-check input {
    width: auto;
    margin-top: 4px;
}

.inline-code-field {
    display: flex;
    gap: 10px;
}

.inline-code-field input {
    flex: 1;
}

.inline-code-field .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.text-center {
    text-align: center;
    margin-top: 20px;
    color: var(--muted);
}

.text-center a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 800;
}

/* 详情、测试、结果 */
.scale-detail .btn-secondary {
    margin-bottom: 20px;
}

.test-form,
.result-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.test-form h2,
.result-card h2,
.result-card h3 {
    color: var(--ink);
}

.test-form > p,
.result-details p,
.result-card p {
    color: var(--text);
}

.question-item {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid #e7edf3;
}

.question-item h4 {
    margin-bottom: 15px;
    color: var(--ink);
    font-size: 18px;
}

.options {
    display: grid;
    gap: 10px;
}

.option-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    background: #fbfcfd;
    border: 1px solid #e4ebf2;
    border-radius: var(--radius);
    padding: 12px 14px;
}

.option-label:hover {
    border-color: #b9cce0;
}

.option-label input {
    margin-top: 5px;
}

.result-header {
    text-align: center;
    margin-bottom: 28px;
}

.score-display {
    font-size: 46px;
    font-weight: 950;
    color: var(--primary);
    margin: 18px 0;
}

.submission-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    margin: 18px 0 10px;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 900;
}

.mbti-result {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 180px;
    margin: 18px 0 10px;
    padding: 18px 24px;
    border-radius: var(--radius);
    background: #e7f0f8;
    color: var(--primary);
}

.mbti-result span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.mbti-result strong {
    color: var(--ink);
    font-size: 44px;
    line-height: 1;
    margin: 8px 0;
}

.mbti-result p {
    margin: 0;
    color: var(--primary);
    font-size: 15px;
    font-weight: 900;
}

.privacy-note {
    color: var(--muted) !important;
    font-size: 13px !important;
}

.score-alert {
    color: var(--danger) !important;
}

.result-details {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid #e7edf3;
}

/* 记录列表 */
#recordsList {
    margin-top: 22px;
}

.record-item {
    background: rgba(255, 255, 255, 0.88);
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 14px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.record-item-alert {
    border-color: #efb3ad;
    background: var(--danger-soft);
}

.record-info h4 {
    color: var(--ink);
    margin-bottom: 7px;
    font-size: 18px;
}

.record-info p {
    color: var(--muted);
    font-size: 14px;
}

.record-alert-badge,
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.record-alert-badge {
    margin-top: 8px;
}

.record-alert-badge-normal,
.badge-normal {
    background: var(--success-soft);
    color: var(--success);
}

.record-alert-badge-danger,
.badge-alert {
    background: #fdecea;
    color: var(--danger);
}

.record-alert-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 6px;
}

.record-score {
    text-align: right;
    min-width: 88px;
}

.record-score .score {
    font-size: 28px;
    line-height: 1.1;
    font-weight: 950;
    color: var(--primary);
}

.record-delete-btn {
    margin-top: 10px;
}

/* 页脚 */
.footer {
    color: #5f7085;
    text-align: center;
    padding: 28px 0 34px;
    margin-top: 36px;
}

/* 状态 */
.loading,
.empty-state {
    text-align: center;
    padding: 44px 20px;
    color: var(--muted);
}

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

.empty-state-text {
    font-size: 18px;
    margin-bottom: 10px;
}

@media (max-width: 980px) {
    .hero,
    .mbti-hero {
        grid-template-columns: 1fr;
        gap: 34px;
        min-height: auto;
        padding-top: 34px;
    }

    .hero-copy {
        max-width: none;
    }

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

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .navbar .container {
        align-items: flex-start;
        gap: 14px;
        padding-top: 14px;
        padding-bottom: 14px;
        flex-direction: column;
    }

    .nav-menu,
    #userNav {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-link {
        padding: 8px 11px;
        font-size: 14px;
    }

    .main-content {
        padding-top: 26px;
    }

    .hero h2 {
        font-size: 34px;
    }

    .hero p {
        font-size: 17px;
    }

    .hero-visual,
    .mbti-hero-image,
    .home-kpis {
        grid-template-columns: 1fr;
    }

    .hero-tile {
        min-height: 130px;
    }

    .home-search,
    .search-box,
    .hero-actions,
    .mbti-promo {
        flex-direction: column;
        width: 100%;
    }

    .mbti-promo {
        align-items: flex-start;
    }

    .search-box input {
        width: 100%;
    }

    .section-header,
    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .categories,
    .scales-grid,
    .mbti-type-grid {
        grid-template-columns: 1fr;
    }

    .test-form,
    .result-card,
    .auth-form {
        padding: 24px;
    }

    .record-item {
        align-items: flex-start;
    }

    .record-score {
        min-width: 74px;
    }
}

@media (max-width: 520px) {
    .hero h2 {
        font-size: 30px;
    }

    .hero-tile strong {
        font-size: 25px;
    }

    .home-kpis strong,
    .section-header h3,
    .categories-grid h3,
    .page-header h2,
    #recordsPage > h2 {
        font-size: 25px;
    }

    .record-item {
        flex-direction: column;
    }

    .record-score {
        text-align: left;
    }
}
