/* ── Design tokens ─────────────────────────────────── */
:root {
    --ground:   #120A1E;
    --surface:  rgba(255,255,255,0.045);
    --surface-b:rgba(255,255,255,0.09);
    --text:     #E8ECF4;
    --text-dim: rgba(232,236,244,0.42);
    --accent:   #A855F7;
    --accent-g: rgba(168,85,247,0.22);
    --radius:   18px;
}

[data-theme="light"] {
    --ground:   #F5F0FF;
    --surface:  rgba(255,255,255,0.82);
    --surface-b:rgba(0,0,0,0.07);
    --text:     #1A0A2E;
    --text-dim: rgba(26,10,46,0.42);
    --accent:   #7C3AED;
    --accent-g: rgba(124,58,237,0.14);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ──────────────────────────────────────────── */
body {
    font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic",
                 "Nanum Gothic", "NanumGothic", sans-serif;
    background: var(--ground);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.4s, color 0.3s;
    overflow-x: hidden;
}

/* ── Layout ────────────────────────────────────────── */
.layout {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 24px 72px;
}

/* ── Header ────────────────────────────────────────── */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0 0;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 19px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text);
}
.brand-name span { color: var(--accent); }

#theme-toggle {
    background: var(--surface);
    border: 1px solid var(--surface-b);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: background 0.25s, border-color 0.25s;
}
#theme-toggle:hover { background: var(--surface-b); }
#theme-toggle svg { width: 17px; height: 17px; }

[data-theme="dark"]  .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ── Main nav ──────────────────────────────────────── */
.main-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--surface-b);
    margin-bottom: 8px;
}

.main-nav a {
    padding: 7px 14px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-dim);
    background: var(--surface);
    border: 1.5px solid var(--surface-b);
    transition: all 0.2s;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Hero ──────────────────────────────────────────── */
.hero {
    padding: 60px 0 52px;
    text-align: center;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 22px;
}

h1 {
    font-size: clamp(38px, 9vw, 58px);
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: -0.025em;
    color: var(--text);
    margin-bottom: 16px;
}
h1 em {
    font-style: normal;
    color: var(--accent);
}

.hero-sub {
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: 0.03em;
    margin-bottom: 40px;
}

/* ── MBTI Tool ─────────────────────────────────────── */
.mbti-tool {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
}

.selector-panels {
    display: flex;
    gap: 16px;
}

.selector-panel {
    flex: 1;
    background: var(--surface);
    border: 1.5px solid var(--surface-b);
    border-radius: var(--radius);
    padding: 18px 14px 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.panel-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    margin-bottom: 14px;
    letter-spacing: 0.04em;
}

/* ── Type grid ─────────────────────────────────────── */
.type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

/* ── Type buttons ──────────────────────────────────── */
.type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    border-radius: 12px;
    border: 1.5px solid var(--surface-b);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text);
    font-family: inherit;
}

.type-btn .type-code {
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}

.type-btn .type-name {
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 2px;
    line-height: 1.2;
    text-align: center;
}

.type-btn .type-emoji {
    font-size: 14px;
    margin-top: 1px;
    line-height: 1;
}

.type-btn:hover {
    border-color: var(--accent);
    background: var(--accent-g);
}

/* Group color variants */
.type-btn.nt { --grp: #818CF8; }
.type-btn.nf { --grp: #34D399; }
.type-btn.sj { --grp: #60A5FA; }
.type-btn.sp { --grp: #F97316; }

/* Selected state — default accent */
.type-btn.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.type-btn.selected .type-name {
    color: rgba(255,255,255,0.8);
}

/* Selected state — group color overrides */
.type-btn.selected.nt {
    background: var(--grp, var(--accent));
    border-color: var(--grp, var(--accent));
}
.type-btn.selected.nf {
    background: var(--grp, var(--accent));
    border-color: var(--grp, var(--accent));
}
.type-btn.selected.sj {
    background: var(--grp, var(--accent));
    border-color: var(--grp, var(--accent));
}
.type-btn.selected.sp {
    background: var(--grp, var(--accent));
    border-color: var(--grp, var(--accent));
}

/* ── Result card ───────────────────────────────────── */
.result-card {
    display: none;
    padding: 28px;
    border-radius: var(--radius);
    border: 1.5px solid var(--accent);
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    text-align: center;
    animation: slideUp 0.35s ease forwards;
}

.result-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.result-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 50px;
    background: var(--accent-g);
    border: 1.5px solid var(--accent);
    color: var(--text);
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.result-heart {
    font-size: 22px;
    line-height: 1;
}

.result-score {
    margin-bottom: 8px;
    line-height: 1;
}

.result-score #r-score {
    font-size: clamp(52px, 14vw, 72px);
    font-weight: 900;
    color: var(--accent);
    letter-spacing: -0.03em;
}

.score-unit {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    margin-left: 2px;
}

.star-rating {
    font-size: 22px;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.score-tier {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

.result-desc {
    font-size: 14px;
    line-height: 1.85;
    color: var(--text-dim);
    margin-bottom: 20px;
    text-align: left;
}

.result-tips {
    text-align: left;
    background: var(--surface-b);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.result-tips h4 {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

.result-tips ul li {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-dim);
    padding-left: 16px;
    position: relative;
    margin-bottom: 6px;
}

.result-tips ul li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}

#reset-btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 50px;
    border: 1.5px solid var(--surface-b);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
#reset-btn:hover {
    background: var(--surface-b);
    border-color: var(--accent);
    color: var(--text);
}

/* ── Guide content ─────────────────────────────────── */
.guide-section {
    margin-top: 72px;
    padding-top: 56px;
    border-top: 1px solid var(--surface-b);
}

.guide-article {
    margin-bottom: 56px;
}

.guide-article h2 {
    font-size: 22px;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    letter-spacing: -0.01em;
}

.guide-article h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    margin: 28px 0 10px;
}

.guide-article p {
    font-size: 14px;
    line-height: 1.9;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.guide-article ul,
.guide-article ol {
    font-size: 14px;
    line-height: 1.85;
    color: var(--text-dim);
    padding-left: 20px;
    margin-bottom: 16px;
}

.guide-article li { margin-bottom: 8px; }

.guide-article strong { color: var(--text); font-weight: 700; }

.guide-article code {
    background: var(--surface-b);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
}

/* ── Table ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 16px 0 20px; }

.odds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 480px;
}

.odds-table th,
.odds-table td {
    padding: 10px 14px;
    border: 1px solid var(--surface-b);
    text-align: left;
    line-height: 1.5;
}

.odds-table th {
    background: var(--surface);
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.odds-table td { color: var(--text-dim); }
.odds-table tbody tr:hover { background: var(--surface); }

/* ── FAQ ───────────────────────────────────────────── */
.faq-section { margin-top: 48px; }

.faq-section h2 {
    font-size: 22px;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
}

.faq-item {
    border: 1px solid var(--surface-b);
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 12px;
    background: var(--surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.faq-item h3 {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.5;
}

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

/* ── Footer ────────────────────────────────────────── */
footer {
    text-align: center;
    padding-top: 52px;
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 0.03em;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}
.footer-link:hover { text-decoration: underline; }

/* ── Animations ────────────────────────────────────── */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 480px) {
    .selector-panels {
        flex-direction: column;
    }

    .type-grid {
        gap: 4px;
    }

    .type-btn {
        padding: 8px 2px;
    }

    .type-btn .type-code { font-size: 11px; }
    .type-btn .type-name { font-size: 8px; }
    .type-btn .type-emoji { font-size: 12px; }
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .result-card {
        animation: none;
    }
}
