:root {
    /* Service Orange & Harmony Blue Theme */
    --app-bg: #fdfbf7;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text-primary: #2d3436;
    --text-secondary: #636e72;

    --service-orange: #e17055;
    --harmony-blue: #74b9ff;
    --success-green: #00b894;
    --error-red: #d63031;

    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.08);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-mono: "JetBrains Mono", monospace;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--app-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('https://images.unsplash.com/photo-1517048676732-d65bc937f952?q=80&w=2670&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    background: rgba(255, 252, 245, 0.96);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.main-header {
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.6);
}

.header-content h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 400;
    color: var(--service-orange);
}

.highlight {
    color: var(--harmony-blue);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.header-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.mode-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
    font-family: var(--font-family);
    font-weight: 600;
}

.nav-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.02);
}

.nav-btn.active {
    opacity: 1;
    background: var(--service-orange);
    color: white;
    box-shadow: 0 2px 8px rgba(225, 112, 85, 0.3);
}

.nav-btn[data-mode="surjective"].active {
    background: var(--harmony-blue);
    box-shadow: 0 2px 8px rgba(116, 185, 255, 0.3);
}

.nav-btn[data-mode="bijective"].active {
    background: #6c5ce7;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.apple-btn {
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.apple-btn:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

/* Main Stage */
.main-stage {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

.mapping-container {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 40px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.set-column {
    width: 250px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 20px;
    z-index: 2;
}

.column-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.column-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.math-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.nodes-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
}

.node-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fdfdfd;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.node-item:hover {
    transform: scale(1.02);
    border-color: var(--service-orange);
    box-shadow: var(--shadow-sm);
}

.node-item.selected {
    border-color: var(--service-orange);
    background: rgba(225, 112, 85, 0.05);
}

.node-item.target-active {
    border-color: var(--harmony-blue);
    background: rgba(116, 185, 255, 0.1);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(116, 185, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(116, 185, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(116, 185, 255, 0);
    }
}

.node-icon {
    font-size: 1.4rem;
}

.node-label {
    font-size: 0.9rem;
    font-weight: 600;
}

.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.connections-svg {
    width: 100%;
    height: 100%;
}

.connection-line {
    fill: none;
    stroke: var(--service-orange);
    stroke-width: 2px;
    opacity: 0.6;
    marker-end: url(#arrow-head);
    transition: all 0.3s;
    cursor: pointer;
    pointer-events: stroke;
}

.connection-line:hover {
    stroke-width: 4px;
    opacity: 1;
}

/* Bottom Panel */
.bottom-panel {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: 120px;
}

.status-bar,
.insight-box {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.status-bar.success .status-icon {
    background: rgba(0, 184, 148, 0.1);
    color: var(--success-green);
}

.status-bar.error .status-icon {
    background: rgba(214, 48, 49, 0.1);
    color: var(--error-red);
}

.status-text h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.status-text p {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.insight-box {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #fffdf5 0%, #fff 100%);
    border: 1px solid rgba(225, 112, 85, 0.1);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-header h4 {
    color: var(--service-orange);
    font-size: 0.95rem;
}

.insight-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Concept Overlay */
.concept-overlay {
    position: absolute;
    top: 100px;
    right: 40px;
    width: 240px;
    background: rgba(255, 255, 255, 0.95);
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--service-orange);
    backdrop-filter: blur(10px);
}

.concept-overlay h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
    text-align: center;
}

.math-def {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 8px;
    text-align: center;
}

.concept-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}