:root {
    --primary-color: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    /* Pink */
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-radius: 16px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --font-main: 'Outfit', sans-serif;
    --font-serif: 'Playfair Display', serif;
    --border-color: #e2e8f0;
}

body.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary-color: #818cf8;
    --secondary-color: #f472b6;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --border-color: #334155;
}

html {
    background-color: #f0f9ff;
}

html.dark-mode {
    background-color: #0f172a;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background: linear-gradient(135deg, #0f172a 0%, #151e2e 100%);
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    padding-top: 1rem;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    justify-content: center;
}

.back-home-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    text-decoration: none;
    z-index: 1000;
}

.back-home-btn:hover {
    color: var(--primary-color);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .back-home-btn {
    background: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .back-home-btn:hover {
    background-color: var(--card-bg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.theme-toggle {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    color: var(--primary-color);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .theme-toggle {
    background: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .theme-toggle:hover {
    background-color: var(--card-bg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

body.dark-mode .sun-icon {
    display: block;
}

body.dark-mode .moon-icon {
    display: none;
}

header h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    background: -webkit-linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    padding: 0 3rem;
    /* Add padding to prevent overlap with buttons on mobile */
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Views */
.view {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.view.hidden {
    display: none;
    opacity: 0;
}

.hidden {
    display: none !important;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 50px;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    margin-top: 1.5rem;
}

/* System Links in Explore Page */
.system-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.system-links .wiki-link {
    margin-bottom: 0;
    /* Override existing margin */
    align-self: flex-start;
}

.primary-source {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: baseline;
    /* Align text baselines */
    gap: 0.5rem;
    line-height: 1.4;
}

.source-label {
    flex-shrink: 0;
    /* Prevent label from wrapping or shrinking */
}

.source-text {
    color: var(--text-main);
    font-weight: 600;
    font-style: normal;
}

/* Result Source in Results Page */
.result-source {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: inline-block;
}

body.dark-mode .result-source {
    background: #1e293b;
}

.result-source em {
    color: var(--primary-color);
    font-weight: 600;
    font-style: normal;
}

.primary-btn {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.secondary-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Popularity Badge */
.popularity-badge {
    background: #e0e7ff;
    color: var(--primary-color);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    border: 1px solid var(--primary-color);
}

body.dark-mode .popularity-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.pop-icon {
    font-size: 0.9rem;
}

.pop-divider {
    opacity: 0.4;
    font-weight: 300;
    margin: 0 2px;
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    width: auto;
    margin-top: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.text-btn:hover {
    color: var(--primary-color);
    background: #f1f5f9;
    transform: none;
    box-shadow: none;
}

/* Intro Styles */
.intro-card {
    text-align: center;
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
    border: 1px solid var(--border-color);
}

body.dark-mode .intro-card {
    background: linear-gradient(to bottom, #1e293b, #0f172a);
    border-color: var(--border-color);
}

.intro-content {
    padding: 1rem 0;
}

.intro-lead {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--text-main);
    line-height: 1.5;
    margin-bottom: 2rem;
    font-weight: 500;
}

.divider {
    height: 2px;
    width: 60px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    margin: 0 auto 2rem auto;
    border-radius: 2px;
    opacity: 0.5;
}

.intro-text {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
}

/* Homepage CTA Button */
.cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    text-align: center;
    margin-top: 1.5rem;
    font-size: 1.2rem;
    padding: 1.2rem 2.5rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.cta-btn:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.cta-btn svg {
    transition: fill 0.3s ease;
}

.cta-btn:hover svg {
    fill: currentColor;
}

/* Navigation Groups */
.nav-groups {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-group {
    text-align: left;
}

.nav-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover {
    border-color: var(--primary-color);
    background: white;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body.dark-mode .nav-link {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-icon {
    font-size: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

body.dark-mode .nav-icon {
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-link-content {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.nav-link-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1rem;
}

.nav-link-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Tetralemma Diagram */
.tetralemma-diagram {
    color: var(--text-muted);
}

.navigation-controls {
    display: flex;
    justify-content: flex-start;
}

#next-btn {
    margin-left: auto;
}

/* Sort Toggle Styles */
.sort-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-btn:hover {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.sort-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.sort-btn svg {
    flex-shrink: 0;
}

body.dark-mode .sort-toggle {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .sort-btn:hover {
    background: rgba(129, 140, 248, 0.1);
}

body.dark-mode .sort-btn.active {
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.3);
}

/* Mode toggle positioning in quiz */
.mode-toggle {
    width: fit-content;
    margin: 0 auto 1rem auto;
}

.commitment-section .mode-toggle {
    margin: 0 auto 0.5rem auto;
}

@media (max-width: 480px) {
    .sort-toggle {
        padding: 0.2rem;
    }

    .sort-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .sort-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Quiz Styles */
.progress-container {
    width: calc(100% + 4rem);
    /* Full width including card padding */
    height: 12px;
    background-color: rgba(99, 102, 241, 0.1);
    border-radius: 16px 16px 0 0;
    /* Top corners match card */
    margin: -2rem -2rem 1.5rem -2rem;
    /* Negative margin to pull flush with edges, bottom margin for spacing */
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

body.dark-mode .progress-container {
    background-color: rgba(255, 255, 255, 0.05);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    border-radius: 0 50px 50px 0;
    /* Rounded tip only */
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.dimension-label {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.question-card h2 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    margin-bottom: 2rem;
    line-height: 1.3;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f1f5f9;
    border: 2px solid transparent;
    padding: 1.2rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

body.dark-mode .option-card {
    background: #334155;
}

.option-card:hover {
    background: #e2e8f0;
}

body.dark-mode .option-card:hover {
    background: #475569;
}

.option-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

body.dark-mode .option-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Variant Colors for Option Cards */
.option-card.variant-0 {
    background: #eff6ff;
    border-color: #bfdbfe;
}

body.dark-mode .option-card.variant-0 {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.option-card.variant-1 {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

body.dark-mode .option-card.variant-1 {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.option-card.variant-2 {
    background: #fef2f2;
    border-color: #fecaca;
}

body.dark-mode .option-card.variant-2 {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.option-card.variant-3 {
    background: #fffbeb;
    border-color: #fde68a;
}

body.dark-mode .option-card.variant-3 {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.option-card.selected.variant-0 {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px #3b82f6;
}

.option-card.selected.variant-1 {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px #22c55e;
}

.option-card.selected.variant-2 {
    border-color: #ef4444;
    box-shadow: 0 0 0 2px #ef4444;
}

.option-card.selected.variant-3 {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px #f59e0b;
}

.option-card .checkmark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
    margin-left: 1rem;
}

.option-card.variant-0 .checkmark {
    background: #3b82f6;
}

.option-card.variant-1 .checkmark {
    background: #22c55e;
}

.option-card.variant-2 .checkmark {
    background: #ef4444;
}

.option-card.variant-3 .checkmark {
    background: #f59e0b;
}

.option-content {
    flex: 1;
}

.selection-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-text {
    flex: 1;
    margin-right: 1.5rem;
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.4;
}

.option-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.select-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    color: #cbd5e1;
    position: relative;
}

body.dark-mode .select-btn {
    background: #1e293b;
    border-color: #475569;
    color: #475569;
}

.select-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #334155;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 5px;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

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

/* Agree - Green */
.select-btn.agree:hover {
    border-color: #10b981;
    color: #10b981;
}

.select-btn.agree.selected {
    border-color: #10b981;
    background: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Neutral - Gray */
.select-btn.neutral:hover {
    border-color: #94a3b8;
    color: #94a3b8;
}

.select-btn.neutral.selected {
    border-color: #94a3b8;
    background: #94a3b8;
    color: white;
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.3);
}

/* Disagree - Red */
.select-btn.disagree:hover {
    border-color: #ef4444;
    color: #ef4444;
}

.select-btn.disagree.selected {
    border-color: #ef4444;
    background: #ef4444;
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Results Styles */
.result-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.pre-title {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

#result-name {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    color: var(--primary-color);
}

.result-toggle-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.toggle-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.result-description {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.wiki-link {
    display: inline-block;
    margin-bottom: 2rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
}

.wiki-link:hover {
    border-color: var(--primary-color);
}

.breakdown-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.breakdown-list {
    list-style: none;
}

.breakdown-list li {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    background: white;
    transition: all 0.2s;
}

body.dark-mode .breakdown-list li {
    background: #1e293b;
}

.breakdown-list li:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Match Types */
.breakdown-list li.match-most {
    border-color: #10b981;
    background: #f0fdf4;
}

body.dark-mode .breakdown-list li.match-most {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.breakdown-list li.match-least {
    border-color: #ef4444;
    background: #fef2f2;
}

body.dark-mode .breakdown-list li.match-least {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.breakdown-list li.match-neutral {
    border-color: var(--border-color);
    background: #f8fafc;
}

body.dark-mode .breakdown-list li.match-neutral {
    background: #1e293b;
}

.dim-name {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 0.5rem;
}

.comparison-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.system-stance {
    margin-bottom: 0.5rem;
}

.system-stance .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.2rem;
    display: block;
}

.system-stance .value {
    font-size: 1.2rem;
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.system-stance .description {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.3rem;
    line-height: 1.4;
}

.user-alignment {
    font-size: 0.9rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.user-alignment strong {
    font-weight: 600;
}

.match-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-badge.success {
    background: #dcfce7;
    color: #15803d;
}

.match-badge.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.match-badge.neutral {
    background: #f1f5f9;
    color: #64748b;
}

footer {
    text-align: center;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-top: 2rem;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    .app-container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }
}

/* Ranking UI Styles */
.ranking-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    position: relative;
}

.rank-card {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    cursor: grab;
    position: relative;
    user-select: none;
}

body.dark-mode .rank-card {
    background: #1e293b;
}

.rank-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px) scale(1.01);
    z-index: 10;
}

.rank-card.dragging {
    opacity: 0.5;
    background: #f8fafc;
    border: 2px dashed var(--primary-color);
    cursor: grabbing;
}

body.dark-mode .rank-card.dragging {
    background: #0f172a;
}

.rank-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

body.dark-mode .rank-indicator {
    background: #334155;
    color: #94a3b8;
}

/* Variant Colors for Cards */
.rank-card.variant-0 {
    background: #eff6ff;
    /* Blue-ish */
    border-color: #bfdbfe;
}

body.dark-mode .rank-card.variant-0 {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.rank-card.variant-1 {
    background: #f0fdf4;
    /* Green-ish */
    border-color: #bbf7d0;
}

body.dark-mode .rank-card.variant-1 {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.rank-card.variant-2 {
    background: #fef2f2;
    /* Red-ish */
    border-color: #fecaca;
}

body.dark-mode .rank-card.variant-2 {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.rank-card.variant-3 {
    background: #fffbeb;
    /* Yellow-ish */
    border-color: #fde68a;
}

body.dark-mode .rank-card.variant-3 {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.rank-card.variant-4 {
    background: #fdf4ff;
    /* Purple-ish */
    border-color: #e879f9;
}

body.dark-mode .rank-card.variant-4 {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
}

.rank-card.variant-5 {
    background: #ecfeff;
    /* Cyan-ish */
    border-color: #a5f3fc;
}

body.dark-mode .rank-card.variant-5 {
    background: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.3);
}

.rank-card.variant-6 {
    background: #faf5ff;
    /* Indigo-ish */
    border-color: #c7d2fe;
}

body.dark-mode .rank-card.variant-6 {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Stated Commitment Styles */
.stated-commitment-card {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

body.dark-mode .stated-commitment-card {
    background: rgba(14, 165, 233, 0.1);
    border-color: rgba(14, 165, 233, 0.3);
}

.sc-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0ea5e9;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

body.dark-mode .sc-icon {
    background: #0f172a;
    color: #38bdf8;
}

.sc-content {
    display: flex;
    flex-direction: column;
}

.sc-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.sc-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: var(--font-serif);
}

.sc-explanation {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.5;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed rgba(14, 165, 233, 0.3);
}

/* LLM Preferences Page Styles */
.llm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding-bottom: 2rem;
}

.llm-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.llm-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.1);
}

.llm-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.llm-name {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    color: var(--text-main);
    margin: 0;
}

.model-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.model-link:hover {
    color: var(--primary-color);
}

.run-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

body.dark-mode .run-count {
    background: #334155;
}

.preference-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preference-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pref-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}

.pref-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.pref-bar-container {
    height: 12px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    margin-top: 0.2rem;
}

body.dark-mode .pref-bar-container {
    background: #334155;
}

.pref-bar {
    height: 100%;
    border-radius: 6px;
    position: relative;
    z-index: 1;
    /* Default gradient - will be enhanced with mask for fade effect */
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    /* Use mask to create fade effect at the end based on data attributes */
    -webkit-mask-image: linear-gradient(90deg,
            black 0%,
            black calc(var(--fade-start, 80%) - 5%),
            rgba(0, 0, 0, 0.3) var(--fade-start, 80%),
            rgba(0, 0, 0, 0.1) 100%);
    mask-image: linear-gradient(90deg,
            black 0%,
            black calc(var(--fade-start, 80%) - 5%),
            rgba(0, 0, 0, 0.3) var(--fade-start, 80%),
            rgba(0, 0, 0, 0.1) 100%);
}

.pref-bar-mean {
    position: absolute;
    top: -2px;
    width: 3px;
    height: calc(100% + 4px);
    background: var(--text-main);
    border-radius: 2px;
    z-index: 2;
    transform: translateX(-50%);
    opacity: 0.7;
}

body.dark-mode .pref-bar-mean {
    background: #f8fafc;
}

.pref-percent {
    position: absolute;
    right: 0;
    top: -1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.top-choice .pref-value {
    color: var(--primary-color);
}

.runner-up .pref-value {
    color: var(--secondary-color);
}

.runner-up .pref-bar {
    background: linear-gradient(90deg, var(--secondary-color), #f472b6);
    opacity: 0.8;
}

.worst-match .pref-value {
    color: #ef4444;
}

.worst-match .pref-bar {
    background: linear-gradient(90deg, #ef4444, #f87171);
    opacity: 0.8;
}

.rank-card.variant-1 {
    background: #f0fdf4;
    /* Green-ish */
    border-color: #bbf7d0;
}

body.dark-mode .rank-card.variant-1 {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.rank-card.variant-2 {
    background: #faf5ff;
    /* Purple-ish */
    border-color: #e9d5ff;
}

body.dark-mode .rank-card.variant-2 {
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.3);
}

.rank-card.variant-3 {
    background: #fff7ed;
    /* Orange-ish */
    border-color: #fed7aa;
}

body.dark-mode .rank-card.variant-3 {
    background: rgba(249, 115, 22, 0.1);
    border-color: rgba(249, 115, 22, 0.3);
}

.rank-content {
    flex: 1;
    margin-right: 1rem;
}

.rank-label {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
}

.rank-text {
    font-size: 1.0rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.rank-controls {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.rank-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

body.dark-mode .rank-btn {
    border-color: #475569;
}

.rank-btn:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

body.dark-mode .rank-btn:hover {
    background: #334155;
}

.drag-handle {
    color: #cbd5e1;
    margin-right: 0.8rem;
    cursor: grab;
    display: flex;
    align-items: center;
}

body.dark-mode .drag-handle {
    color: #475569;
}

.drag-handle svg {
    width: 20px;
    height: 20px;
}

/* Hide original option controls */
.option-controls {
    display: none;
}

.instruction-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 0.5rem;
    font-family: var(--font-main);
}

.result-score {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--secondary-color);
    margin-top: 0.5rem;
    font-family: var(--font-main);
}

.result-popularity {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
}

/* Alphabet Navigation */
.alpha-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.4rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    z-index: 100;
    /* Left position set by JS */
}

.alpha-btn {
    width: 24px;
    height: 20px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.alpha-btn:hover:not(.disabled) {
    background: var(--primary-color);
    color: white;
}

.alpha-btn.active {
    background: var(--primary-color);
    color: white;
}

.alpha-btn.disabled {
    color: var(--text-muted);
    opacity: 0.3;
    cursor: default;
}

body.dark-mode .alpha-nav {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* Mobile: horizontal bar at top */
@media (max-width: 900px) {
    .alpha-nav {
        position: sticky;
        top: 0;
        left: 0 !important;
        transform: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.15rem;
        padding: 0.5rem;
        margin-bottom: 1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .alpha-btn {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
    }
}

/* Explore Page Styles */
.systems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding-bottom: 2rem;
}

.system-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    scroll-margin-top: 100px;
}

.system-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

body.dark-mode .system-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.system-card h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.system-description {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.system-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 0;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    /* Push meta to bottom if we want, or just let it flow */
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.meta-item .value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.meta-item a.dimension-link {
    text-decoration: none;
    color: var(--text-main);
    transition: color 0.2s;
}

.meta-item a.dimension-link:hover {
    color: var(--primary-color);
}

.system-card .wiki-link {
    margin-bottom: 1rem;
    align-self: flex-start;
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    text-align: left;
    padding: 1rem;
    font-size: 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 300px;
    z-index: 100;
    font-family: var(--font-main);
}

.tooltip h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    font-family: var(--font-serif);
}

.tooltip p {
    margin: 0;
    color: var(--text-main);
    line-height: 1.4;
}

/* System Link Styles */
.system-link {
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
}

.system-link:hover {
    color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.05);
}

/* Toggle Switch */
.mode-toggle-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.commitment-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.commitment-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.commitment-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.commitment-section .mode-toggle-container {
    justify-content: flex-start;
    margin-bottom: 0.5rem;
}

.section-explanation {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.commitment-section .select-group {
    margin-top: 1rem;
}

.commitment-section .select-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
}

/* Toggle label active states */
.toggle-label {
    transition: color 0.2s ease, opacity 0.2s ease;
    opacity: 0.6;
}

.toggle-label.active {
    color: var(--primary-color);
    opacity: 1;
}

.commitment-nav {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.commitment-nav .btn {
    width: 140px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

body.dark-mode .slider {
    background-color: #475569;
}

/* Share Section Styles */
.share-section {
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.share-section h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

.share-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 12px;
    /* Slightly less rounded for grid look */
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    color: white;
    width: 100%;
    /* Fill grid cell */
    box-sizing: border-box;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.share-btn:active {
    transform: translateY(0);
}

.share-btn svg {
    flex-shrink: 0;
}

/* Platform-specific colors */
.share-btn.twitter {
    background-color: #000000;
}

.share-btn.twitter:hover {
    background-color: #333333;
}

.share-btn.bluesky {
    background-color: #0560ff;
}

.share-btn.bluesky:hover {
    background-color: #0045c4;
}

.share-btn.facebook {
    background-color: #1877f2;
}

.share-btn.facebook:hover {
    background-color: #0d65d9;
}

.share-btn.facebook.copied {
    background-color: #10b981;
}

.share-btn.threads {
    background-color: #1a1a1a;
}

.share-btn.threads:hover {
    background-color: #333333;
}

.share-btn.linkedin {
    background-color: #0a66c2;
}

.share-btn.linkedin:hover {
    background-color: #004182;
}

.share-btn.reddit {
    background-color: #ff4500;
}

.share-btn.reddit:hover {
    background-color: #e03d00;
}

.share-btn.download {
    background-color: #64748b;
}

.share-btn.download:hover {
    background-color: #475569;
}

.share-btn.copy-link {
    background-color: var(--primary-color);
}

.share-btn.copy-link:hover {
    background-color: var(--primary-hover);
}

.share-btn.copy-link.copied {
    background-color: #10b981;
}

/* Mobile responsiveness for share buttons */
@media (max-width: 480px) {
    .share-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .share-btn {
        justify-content: center;
    }
}

/* Share Banner Styles */
.share-banner {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1080px;
    height: 1080px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 80px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
    color: #1e293b;
    border: none;
}

.banner-content {
    background: white;
    border-radius: 40px;
    padding: 60px;
    /* Removed box-shadow and border to prevent html2canvas artifacts */
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    position: relative;
}

.banner-header {
    text-align: center;
    margin-bottom: 2rem;
}

.banner-subtitle {
    text-transform: uppercase;
    letter-spacing: 4px;
    font-weight: 800;
    color: #64748b;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    display: block;
}

.banner-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 6rem;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.1;
}

.banner-score {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--secondary-color);
    margin-top: 1rem;
}

.banner-body {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 40px;
}

#banner-description {
    font-size: 2.2rem;
    /* Increased size since source is gone */
    line-height: 1.5;
    color: #334155;
    margin-bottom: 0;
    max-width: 95%;
}

/* Removed .banner-source styles */

.banner-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 3px solid #e2e8f0;
    padding-top: 30px;
    margin-top: 40px;
}

.banner-url {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.5rem;
}

.banner-tagline {
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1.2rem;
}

/* Similarity Score in LLM Results */
.sc-similarity {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.similarity-percent {
    font-weight: 700;
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

body.dark-mode .similarity-percent {
    background: rgba(129, 140, 248, 0.2);
    color: var(--primary-color);
}